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
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:
"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" : [
#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: <ip> #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":<port>, "to":<port>} 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}]
'''
__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
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',
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: