From: tierno Date: Fri, 19 Aug 2016 15:02:35 +0000 (+0200) Subject: v0.4.45 Action over a Instance to obtian VM console. Allow both with or without proxy... X-Git-Tag: v1.0.0~55 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=20fc2a23c457b0206e6361a1652232d58c488b3c;p=osm%2FRO.git v0.4.45 Action over a Instance to obtian VM console. Allow both with or without proxy depending on the configuration Change-Id: I17e8993af8e524e9a04e0b2a81ff92f8d019c173 Signed-off-by: tierno --- diff --git a/nfvo.py b/nfvo.py index b358ea84..25a484bf 100644 --- a/nfvo.py +++ b/nfvo.py @@ -1771,23 +1771,39 @@ def instance_action(mydb,nfvo_tenant,instance_id, action_dict): try: data = myvim.action_vminstance(vm['vim_vm_id'], action_dict) if "console" in action_dict: - if data["server"]=="127.0.0.1" or data["server"]=="localhost": + if not global_config["http_console_proxy"]: + vm_result[ vm['uuid'] ] = {"vim_result": 200, + "description": "{protocol}//{ip}:{port}/{suffix}".format( + protocol=data["protocol"], + ip = data["server"], + port = data["port"], + suffix = data["suffix"]), + "name":vm['name'] + } + vm_ok +=1 + elif data["server"]=="127.0.0.1" or data["server"]=="localhost": vm_result[ vm['uuid'] ] = {"vim_result": -HTTP_Unauthorized, "description": "this console is only reachable by local interface", "name":vm['name'] } vm_error+=1 - continue + else: #print "console data", data - try: - console_thread = create_or_use_console_proxy_thread(data["server"], data["port"]) - vm_result[ vm['uuid'] ] = {"vim_result": 200, - "description": "%s//%s:%d/%s" %(data["protocol"], console_thread.host, console_thread.port, data["suffix"]), - "name":vm['name'] - } - vm_ok +=1 - except NfvoException as e: - vm_result[ vm['uuid'] ] = {"vim_result": e.http_code, "name":vm['name'], "description": str(e)} + try: + console_thread = create_or_use_console_proxy_thread(data["server"], data["port"]) + vm_result[ vm['uuid'] ] = {"vim_result": 200, + "description": "{protocol}//{ip}:{port}/{suffix}".format( + protocol=data["protocol"], + ip = global_config["http_console_host"], + port = console_thread.port, + suffix = data["suffix"]), + "name":vm['name'] + } + vm_ok +=1 + except NfvoException as e: + vm_result[ vm['uuid'] ] = {"vim_result": e.http_code, "name":vm['name'], "description": str(e)} + vm_error+=1 + else: vm_result[ vm['uuid'] ] = {"vim_result": 200, "description": "ok", "name":vm['name']} vm_ok +=1 @@ -1808,7 +1824,7 @@ def create_or_use_console_proxy_thread(console_server, console_port): return global_config["console_thread"][console_thread_key] for port in global_config["console_port_iterator"](): - print "create_or_use_console_proxy_thread() port:", port + #print "create_or_use_console_proxy_thread() port:", port if port in global_config["console_ports"]: continue try: diff --git a/openmano_schemas.py b/openmano_schemas.py index e9b33d6e..63587f11 100644 --- a/openmano_schemas.py +++ b/openmano_schemas.py @@ -88,6 +88,8 @@ config_schema = { "vim_tenant_name": nameshort_schema, "mano_tenant_name": nameshort_schema, "mano_tenant_id": id_schema, + "http_console_proxy": {"type":"boolean"}, + "http_console_host": nameshort_schema, "http_console_ports": { "type": "array", "items": {"OneOf" : [ diff --git a/openmanod.cfg b/openmanod.cfg index 6328bdfd..e4dc4e1d 100644 --- a/openmanod.cfg +++ b/openmanod.cfg @@ -28,6 +28,12 @@ http_port: 9090 # General port (by default, 9090) #http_admin_port: 9095 # Admin port where openmano is listening (when missing, no administration server is launched) # Not used in current version! +#Parameters for a VIM console access. Can be directly the VIM URL or a proxy to offer the openmano IP address +#http_console_proxy: False #by default True. If False proxy is not implemented and VIM URL is offered. It is + #assumed then, that client can access directly to the VIMs +#http_console_host: #by default the same as 'http_host'. However is openmano server is behind a NAT/proxy + #you should specify the public IP used to access the server. Also when 'http_host' is + #0.0.0.0 you should specify the concrete IP address (or name) the server is accessed # Ports to be used. Comma separated list. Can contain a {"from":, "to":} entry #e.g. from 9000 to 9005: [{"from":9000, "to":9005}], or also [9000,9001,9002,9003,9004,9005] #e.g. from 9000 to 9100 apart from 9050,9053: [{"from":9000, "to":9049},9051,9052,{"from":9054, "to":9099}] diff --git a/openmanod.py b/openmanod.py index dbd7737e..3422a7cc 100755 --- a/openmanod.py +++ b/openmanod.py @@ -33,8 +33,8 @@ It loads the configuration file and launches the http_server thread that will li ''' __author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes" __date__ ="$26-aug-2014 11:09:29$" -__version__="0.4.44-r482" -version_date="Jul 2016" +__version__="0.4.45-r484" +version_date="Aug 2016" database_version="0.11" #expected database schema version import httpserver @@ -59,6 +59,8 @@ class LoadConfigurationException(Exception): def load_configuration(configuration_file): default_tokens ={'http_port':9090, 'http_host':'localhost', + 'http_console_proxy': True, + 'http_console_host': None, 'log_level': 'DEBUG', 'log_level_db': 'ERROR', 'log_level_vimconn': 'DEBUG', @@ -211,6 +213,10 @@ if __name__=="__main__": global_config["console_port_iterator"] = console_port_iterator global_config["console_thread"]={} global_config["console_ports"]={} + if not global_config["http_console_host"]: + global_config["http_console_host"] = global_config["http_host"] + if global_config["http_host"]=="0.0.0.0": + global_config["http_console_host"] = socket.gethostname() #Configure logging STEP 2 if "log_host" in global_config: