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 Dec 12, 2018
2 parents d649701 + d2e0223 commit 4b72021
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .pep8speaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pycodestyle:
max-line-length: 100 # Default is 79 in PEP8
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ source NameOfRcFile.sh
~~~

#### Configuration
You can configure your client either by placing the config.yml in the VirtualMachineService/config folder or by providing the --config parameter when the client starts.
You can view all existing parameters in the [yaml file](VirtualMachineService/config/config.yml).
Also you need to provide the path to your config file as the first param when starting a server.


##### Gateway

Expand Down Expand Up @@ -58,7 +59,7 @@ pip install git+https://github.com/deNBI/cloud-portal-client.git
If you set your configuration you can start the portal-client:

~~~BASH
portal_client_start_server --config=path/to/config.yml
portal_client_start_server path/to/config.yml
~~~

### Using Docker
Expand Down
8 changes: 3 additions & 5 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def create_connection(self):
self.logger.info("Connected to Openstack")
return conn

def __init__(self):
def __init__(self,config):
"""
Initialize the handler.
Expand Down Expand Up @@ -102,8 +102,6 @@ def __init__(self):
self.AUTH_URL = os.environ['OS_AUTH_URL']
self.SSH_PORT = 22

fileDir = os.path.dirname(os.path.abspath(__file__))
config = os.path.join(fileDir, 'config/config.yml')
with open(config, 'r') as ymlfile:
cfg = yaml.load(ymlfile)
self.USE_GATEWAY = cfg['openstack_connection']['use_gateway']
Expand Down Expand Up @@ -581,7 +579,7 @@ def check_server_status(self, openstack_id, diskspace, volume_id):
host = self.get_server(openstack_id).floating_ip
port = self.SSH_PORT

if self.USE_G:
if self.USE_GATEWAY:
serv_cop = self.get_server(openstack_id)
server_base = serv_cop.fixed_ip.split(".")[-1]
host = str(self.GATEWAY_IP)
Expand Down Expand Up @@ -630,7 +628,7 @@ def get_IP_PORT(self, openstack_id):
server = self.get_server(openstack_id)
server_base = server.fixed_ip.split(".")[-1]
port = int(self.GATEWAY_BASE) + int(server_base) * 3
return {'IP': str(self.GATEWAY_IPs), 'PORT': str(port)}
return {'IP': str(self.GATEWAY_IP), 'PORT': str(port)}

else:
floating_ip = self.get_server(openstack_id).floating_ip
Expand Down
14 changes: 4 additions & 10 deletions VirtualMachineService/VirtualMachineServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@
import yaml
import click

DEFAULT_CONFIG = 'config/config.yml'
@click.command()
@click.option('--config', default=DEFAULT_CONFIG,help= 'path to the config file')
@click.argument('config')
def startServer(config):
click.echo("Start Cloud-Client-Portal Server")
if config == DEFAULT_CONFIG:
CONFIG_FILE = os.path.join(
os.path.dirname(
os.path.abspath(__file__)),
config)
else:
CONFIG_FILE=config

CONFIG_FILE=config

with open(CONFIG_FILE, 'r') as ymlfile:
cfg = yaml.load(ymlfile)
HOST = cfg['openstack_connection']['host']
PORT = cfg['openstack_connection']['port']
CERTFILE = cfg['openstack_connection']['certfile']
handler = VirtualMachineHandler()
handler = VirtualMachineHandler(CONFIG_FILE)
processor = Processor(handler)
transport = TSSLSocket.TSSLServerSocket(
host=HOST, port=PORT, certfile=CERTFILE)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ services:
volumes:
- ./VirtualMachineService/config/config.yml:/code/VirtualMachineService/config.yml
- ./VirtualMachineService/keys/localhost/server.pem:/code/VirtualMachineService/keys/server.pem
command: python3 VirtualMachineServer.py --config=/code/VirtualMachineService/config.yml
command: python3 VirtualMachineServer.py /code/VirtualMachineService/config.yml

0 comments on commit 4b72021

Please sign in to comment.