echo "4/4 Try to start"
-/usr/bin/openmanod -c /etc/osm/openmanod.cfg --log-file=/var/log/osm/openmano.log
+/usr/bin/openmanod -c /etc/osm/openmanod.cfg --log-file=/var/log/osm/openmano.log --create-tenant=osm
__author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.5.56-r566"
+__version__ = "0.5.57-r567"
version_date = "Mar 2018"
database_version = 28 # expected database schema version
print(" --log-socket-host HOST: send logs to this host")
print(" --log-socket-port PORT: send logs using this port (default: 9022)")
print(" --log-file FILE: send logs to this file")
+ print(" --create-tenant NAME: Try to creates this tenant name before starting, ignoring any errors as e.g. conflict")
return
# Read parameters and configuration file
httpthread = None
try:
- #load parameters and configuration
- opts, args = getopt.getopt(sys.argv[1:], "hvc:V:p:P:", ["config=", "help", "version", "port=", "vnf-repository=", "adminport=", "log-socket-host=", "log-socket-port=", "log-file="])
+ # load parameters and configuration
+ opts, args = getopt.getopt(sys.argv[1:], "hvc:V:p:P:",
+ ["config=", "help", "version", "port=", "vnf-repository=", "adminport=",
+ "log-socket-host=", "log-socket-port=", "log-file=", "create-tenant="])
port=None
port_admin = None
config_file = 'osm_ro/openmanod.cfg'
log_file = None
log_socket_host = None
log_socket_port = None
+ create_tenant = None
for o, a in opts:
if o in ("-v", "--version"):
log_socket_host = a
elif o == "--log-file":
log_file = a
+ elif o == "--create-tenant":
+ create_tenant = a
else:
assert False, "Unhandled option"
if log_file:
exit(-1)
nfvo.global_config=global_config
+ if create_tenant:
+ try:
+ nfvo.new_tenant(mydb, {"name": create_tenant})
+ except Exception as e:
+ if isinstance(e, nfvo.NfvoException) and e.http_code == 409:
+ pass # if tenant exist (NfvoException error 409), ignore
+ else: # otherwise print and error and continue
+ logger.error("Cannot create tenant '{}': {}".format(create_tenant, e))
nfvo.start_service(mydb)
httpthread = httpserver.httpserver(mydb, False, global_config['http_host'], global_config['http_port'])
tenant_dict['encrypted_RO_priv_key'] = priv_key
mydb.new_row("nfvo_tenants", tenant_dict, confidential_data=True)
except db_base_Exception as e:
- raise NfvoException("Error creating the new tenant: {} ".format(tenant_dict['name']) + str(e), HTTP_Internal_Server_Error)
+ raise NfvoException("Error creating the new tenant: {} ".format(tenant_dict['name']) + str(e), e.http_code)
return tenant_uuid
def delete_tenant(mydb, tenant):
result = mydb.get_rows(SELECT=('sdn_net_id',), FROM='instance_nets', WHERE=search_dict)
except db_base_Exception as e:
raise NfvoException("db_base_Exception obtaining SDN network to associated to vim network {}".format(
- network_id) + str(e), HTTP_Internal_Server_Error)
+ network_id) + str(e), e.http_code)
sdn_net_counter = 0
for net in result:
sdn_network_id, network_id) + str(e), HTTP_Internal_Server_Error)
except db_base_Exception as e:
raise NfvoException("db_base_Exception attaching SDN network to vim network {}".format(
- network_id) + str(e), HTTP_Internal_Server_Error)
+ network_id) + str(e), e.http_code)
return 'Port uuid: '+ result
mydb.delete_row(FROM='instance_nets', WHERE={'instance_scenario_id': None, 'sdn_net_id': sdn_network_id, 'vim_net_id': item_id})
except db_base_Exception as e:
raise NfvoException("Error deleting correspondence for VIM/SDN dataplane networks{}: ".format(correspondence) +
- str(e), HTTP_Internal_Server_Error)
+ str(e), e.http_code)
#Delete the SDN network
try:
mydb.new_row('instance_nets', correspondence, add_uuid=True)
except db_base_Exception as e:
raise NfvoException("Error saving correspondence for VIM/SDN dataplane networks{}: {}".format(
- correspondence, e), HTTP_Internal_Server_Error)
+ correspondence, e), e.http_code)
elif item=="tenants":
tenant = descriptor["tenant"]
content = myvim.new_tenant(tenant["name"], tenant.get("description"))
break
elif task_dependency["status"] == "FAILED":
raise VimThreadException(
- "Cannot {} {}, (task {}.{}) because depends on failed {} {}, (task{}.{})".format(
+ "Cannot {} {}, (task {}.{}) because depends on failed {}.{}, (task{}.{}): {}".format(
task["action"], task["item"],
task["instance_action_id"], task["task_index"],
task_dependency["instance_action_id"], task_dependency["task_index"],
- task_dependency["action"], task_dependency["item"]))
+ task_dependency["action"], task_dependency["item"], task_dependency.get("error_msg")))
if dependency_not_completed:
# Move this task to the end.
task["extra"]["tries"] = task["extra"].get("tries", 0) + 1
error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
#TODO insert exception vimconn.HTTP_Unauthorized
#if reaching here is because an exception
- if self.debug:
- self.logger.debug("new_user " + error_text)
+ self.logger.debug("new_user " + error_text)
return error_value, error_text
def delete_user(self, user_id):
error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
#TODO insert exception vimconn.HTTP_Unauthorized
#if reaching here is because an exception
- if self.debug:
- print("delete_tenant " + error_text)
+ self.logger.debug("delete_tenant " + error_text)
return error_value, error_text
def get_hosts_info(self):
error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
#TODO insert exception vimconn.HTTP_Unauthorized
#if reaching here is because an exception
- if self.debug:
- print("get_hosts_info " + error_text)
+ self.logger.debug("get_hosts_info " + error_text)
return error_value, error_text
def get_hosts(self, vim_tenant):
error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
#TODO insert exception vimconn.HTTP_Unauthorized
#if reaching here is because an exception
- if self.debug:
- print("get_hosts " + error_text)
+ self.logger.debug("get_hosts " + error_text)
return error_value, error_text
def new_classification(self, name, ctype, definition):
try:
new_sf = None
self._reload_connection()
- correlation = None
- if sfc_encap:
- correlation = 'nsh'
+ # correlation = None
+ # if sfc_encap:
+ # correlation = 'nsh'
for instance in sfis:
sfi = self.get_sfi(instance)
if sfi.get('sfc_encap') != sfc_encap: