Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed May 28, 2019
2 parents baf3bf7 + 9e8bd56 commit 5c53fed
Show file tree
Hide file tree
Showing 10 changed files with 1,624 additions and 827 deletions.
711 changes: 440 additions & 271 deletions VirtualMachineService/VirtualMachineHandler.py

Large diffs are not rendered by default.

45 changes: 36 additions & 9 deletions VirtualMachineService/VirtualMachineServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

try:
from VirtualMachineService import Client, Processor
from VirtualMachineHandler import VirtualMachineHandler
except Exception as e:
except Exception:
from .VirtualMachineService import Client, Processor

try:
from VirtualMachineHandler import VirtualMachineHandler
except Exception:
from .VirtualMachineHandler import VirtualMachineHandler

from thrift.transport import TSSLSocket
Expand All @@ -14,15 +17,32 @@
from thrift.server import TServer
import yaml
import click
import socket
from contextlib import closing

USERNAME = 'OS_USERNAME'
PASSWORD = 'OS_PASSWORD'
PROJECT_NAME = 'OS_PROJECT_NAME'
PROJECT_ID = 'OS_PROJECT_ID'
USER_DOMAIN_ID = 'OS_USER_DOMAIN_NAME'
AUTH_URL = 'OS_AUTH_URL'
PROJECT_DOMAIN_ID="OS_PROJECT_DOMAIN_ID"

environment_variables = [
USERNAME,
PASSWORD,
PROJECT_NAME,
PROJECT_ID,
USER_DOMAIN_ID,
AUTH_URL,
PROJECT_DOMAIN_ID
]


@click.command()
@click.argument('config')
def startServer(config):
click.echo("Start Cloud-Client-Portal Server")

CONFIG_FILE=config
CONFIG_FILE = config

with open(CONFIG_FILE, 'r') as ymlfile:
cfg = yaml.load(ymlfile)
Expand All @@ -41,9 +61,16 @@ def startServer(config):
server.serve()


def check_environment_variables(envs):
def check_env(var):
if var not in os.environ:
click.echo("ERROR: There is no {} set in environment.".format(var))
click.echo("Please make sure you have sourced your OpenStack rc file")
sys.exit()

list(map(lambda var: check_env(var), envs))


if __name__ == '__main__':
with closing(
socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
r = sock.connect_ex(('129.70.51.6', 30072))
print(r)
check_environment_variables(environment_variables)
startServer()
17 changes: 12 additions & 5 deletions VirtualMachineService/VirtualMachineService-remote
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Autogenerated by Thrift Compiler (0.10.0)
# Autogenerated by Thrift Compiler (0.12.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
Expand All @@ -27,7 +27,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' bool check_Version(double version)')
print(' string get_client_version()')
print(' string import_keypair(string keyname, string public_key)')
print(' get_IP_PORT(string openstack_id)')
print(' get_ip_ports(string openstack_id)')
print(' get_Flavors()')
print(' get_Images()')
print(' Image get_Image_with_Tag(string openstack_id)')
Expand All @@ -37,6 +37,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' string add_floating_ip_to_server(string openstack_id, string network)')
print(' bool create_connection(string username, string password, string auth_url, string user_domain_name, string project_domain_name)')
print(' start_server(string flavor, string image, string public_key, string servername, string elixir_id, string diskspace, string volumename)')
print(' bool add_security_group_to_server(bool http, bool https, bool udp, string server_id)')
print(' VM get_server(string openstack_id)')
print(' bool stop_server(string openstack_id)')
print(' string create_snapshot(string openstack_id, string name, string elixir_id, string base_tag)')
Expand Down Expand Up @@ -147,11 +148,11 @@ elif cmd == 'import_keypair':
sys.exit(1)
pp.pprint(client.import_keypair(args[0], args[1],))

elif cmd == 'get_IP_PORT':
elif cmd == 'get_ip_ports':
if len(args) != 1:
print('get_IP_PORT requires 1 args')
print('get_ip_ports requires 1 args')
sys.exit(1)
pp.pprint(client.get_IP_PORT(args[0],))
pp.pprint(client.get_ip_ports(args[0],))

elif cmd == 'get_Flavors':
if len(args) != 0:
Expand Down Expand Up @@ -207,6 +208,12 @@ elif cmd == 'start_server':
sys.exit(1)
pp.pprint(client.start_server(args[0], args[1], args[2], args[3], args[4], args[5], args[6],))

elif cmd == 'add_security_group_to_server':
if len(args) != 4:
print('add_security_group_to_server requires 4 args')
sys.exit(1)
pp.pprint(client.add_security_group_to_server(eval(args[0]), eval(args[1]), eval(args[2]), args[3],))

elif cmd == 'get_server':
if len(args) != 1:
print('get_server requires 1 args')
Expand Down
Loading

0 comments on commit 5c53fed

Please sign in to comment.