From: tierno Date: Tue, 7 Feb 2017 09:30:32 +0000 (+0100) Subject: Merge branch 'v1.1' X-Git-Tag: v2.0.0~45^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=0a3fc475690c26c63fb61269315dc17e05584b55;hp=-c;p=osm%2FRO.git Merge branch 'v1.1' --- 0a3fc475690c26c63fb61269315dc17e05584b55 diff --combined httpserver.py index 9dd537f2,65d7ede1..64eddfa5 --- a/httpserver.py +++ b/httpserver.py @@@ -483,14 -483,14 +483,14 @@@ def http_get_datacenter_id(tenant_id, d try: config_dict = yaml.load(vim_tenant['config']) vim_tenant['config'] = config_dict - except Exception, e: + except Exception as e: logger.error("Exception '%s' while trying to load config information", str(e)) if datacenter['config'] != None: try: config_dict = yaml.load(datacenter['config']) datacenter['config'] = config_dict - except Exception, e: + except Exception as e: logger.error("Exception '%s' while trying to load config information", str(e)) #change_keys_http2db(content, http2db_datacenter, reverse=True) convert_datetime2str(datacenter) @@@ -996,14 -996,14 +996,14 @@@ def http_post_scenarios(tenant_id) def http_post_scenario_action(tenant_id, scenario_id): '''take an action over a scenario''' logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) - #check valid tenant_id + # parse input data + http_content, _ = format_in(scenario_action_schema) + r = utils.remove_extra_items(http_content, scenario_action_schema) + if r: + logger.debug("Remove received extra items %s", str(r)) try: - nfvo.check_tenant(mydb, tenant_id) - #parse input data - http_content,_ = format_in( scenario_action_schema ) - r = utils.remove_extra_items(http_content, scenario_action_schema) - if r: - logger.debug("Remove received extra items %s", str(r)) + # check valid tenant_id + nfvo.check_tenant(mydb, tenant_id) if "start" in http_content: data = nfvo.start_scenario(mydb, tenant_id, scenario_id, http_content['start']['instance_name'], \ http_content['start'].get('description',http_content['start']['instance_name']), @@@ -1086,10 -1086,11 +1086,11 @@@ def http_get_scenario_id(tenant_id, sce @bottle.route(url_base + '//scenarios/', method='DELETE') def http_delete_scenario_id(tenant_id, scenario_id): '''delete a scenario from database, can use both uuid or name''' + logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) try: #check valid tenant_id if tenant_id != "any": - nfvo.check_tenant(mydb, tenant_id) + nfvo.check_tenant(mydb, tenant_id) #obtain data data = mydb.delete_scenario(scenario_id, tenant_id) #print json.dumps(data, indent=4) @@@ -1126,15 -1127,15 +1127,15 @@@ def http_put_scenario_id(tenant_id, sce def http_post_instances(tenant_id): '''create an instance-scenario''' logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) + # parse input data + http_content, used_schema = format_in(instance_scenario_create_schema_v01) + r = utils.remove_extra_items(http_content, used_schema) + if r is not None: + logger.warning("http_post_instances: Warning: remove extra items %s", str(r)) try: #check valid tenant_id if tenant_id != "any": nfvo.check_tenant(mydb, tenant_id) - #parse input data - http_content,used_schema = format_in( instance_scenario_create_schema_v01) - r = utils.remove_extra_items(http_content, used_schema) - if r is not None: - logger.warning("http_post_instances: Warning: remove extra items %s", str(r)) data = nfvo.create_instance(mydb, tenant_id, http_content["instance"]) return format_out(data) except (nfvo.NfvoException, db_base_Exception) as e: @@@ -1225,16 -1226,16 +1226,16 @@@ def http_delete_instance_id(tenant_id, def http_post_instance_scenario_action(tenant_id, instance_id): '''take an action over a scenario instance''' logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) + # parse input data + http_content, _ = format_in(instance_scenario_action_schema) + r = utils.remove_extra_items(http_content, instance_scenario_action_schema) + if r: + logger.debug("Remove received extra items %s", str(r)) try: #check valid tenant_id if tenant_id != "any": nfvo.check_tenant(mydb, tenant_id) - #parse input data - http_content,_ = format_in( instance_scenario_action_schema ) - r = utils.remove_extra_items(http_content, instance_scenario_action_schema) - if r: - logger.debug("Remove received extra items %s", str(r)) #print "http_post_instance_scenario_action input: ", http_content #obtain data instance = mydb.get_instance_scenario(instance_id, tenant_id) diff --combined vimconn_openvim.py index bd963c7d,4a0843b5..fb59eccc --- a/vimconn_openvim.py +++ b/vimconn_openvim.py @@@ -377,7 -377,7 +377,7 @@@ class vimconnector(vimconn.vimconnector js_v(client_data, schema) #print "Input data: ", str(client_data) return True, client_data - except js_e.ValidationError, exc: + except js_e.ValidationError as exc: print "validate_in error, jsonschema exception ", exc.message, "at", exc.path return False, ("validate_in error, jsonschema exception ", exc.message, "at", exc.path) @@@ -753,7 -753,7 +753,7 @@@ payload_req = vm_data try: vim_response = requests.post(self.url+'/'+self.tenant+'/servers', headers = self.headers_req, data=payload_req) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: print "new_vminstancefromJSON Exception: ", e.args return -vimconn.HTTP_Not_Found, str(e.args[0]) print vim_response @@@ -795,6 -795,7 +795,7 @@@ #TODO ip, security groups Returns the instance identifier ''' + self.logger.debug("new_vminstance input: image='%s' flavor='%s' nics='%s'", image_id, flavor_id, str(net_list)) try: self._get_my_tenant() # net_list = [] @@@ -1079,7 -1080,7 +1080,7 @@@ url=self.url+'/hosts' try: vim_response = requests.get(url) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: print "get_hosts_info Exception: ", e.args return -vimconn.HTTP_Not_Found, str(e.args[0]) print "vim get", url, "response:", vim_response.status_code, vim_response.json() @@@ -1101,7 -1102,7 +1102,7 @@@ url=self.url+'/hosts/'+host['id'] try: vim_response = requests.get(url) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: print "get_hosts_info Exception: ", e.args return -vimconn.HTTP_Not_Found, str(e.args[0]) print "vim get", url, "response:", vim_response.status_code, vim_response.json() @@@ -1123,7 -1124,7 +1124,7 @@@ url=self.url+'/hosts' try: vim_response = requests.get(url) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: print "get_hosts Exception: ", e.args return -vimconn.HTTP_Not_Found, str(e.args[0]) print "vim get", url, "response:", vim_response.status_code, vim_response.json() @@@ -1144,7 -1145,7 +1145,7 @@@ url=self.url+'/' + vim_tenant + '/servers?hostId='+host['id'] try: vim_response = requests.get(url) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: print "get_hosts Exception: ", e.args return -vimconn.HTTP_Not_Found, str(e.args[0]) print "vim get", url, "response:", vim_response.status_code, vim_response.json() @@@ -1164,7 -1165,7 +1165,7 @@@ url=self.url+'/processor_ranking' try: vim_response = requests.get(url) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: print "get_processor_rankings Exception: ", e.args return -vimconn.HTTP_Not_Found, str(e.args[0]) print "vim get", url, "response:", vim_response.status_code, vim_response.json() @@@ -1207,7 -1208,7 +1208,7 @@@ payload_req = port_data try: vim_response = requests.post(self.url_admin+'/ports', headers = self.headers_req, data=payload_req) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: self.logger.error("new_external_port Exception: ", str(e)) return -vimconn.HTTP_Not_Found, str(e.args[0]) print vim_response @@@ -1241,7 -1242,7 +1242,7 @@@ payload_req = '{"network":{"name": "' + net_name + '","shared":true,"type": "' + net_type + '"}}' try: vim_response = requests.post(self.url+'/networks', headers = self.headers_req, data=payload_req) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: self.logger.error( "new_external_network Exception: ", e.args) return -vimconn.HTTP_Not_Found, str(e.args[0]) print vim_response @@@ -1281,7 -1282,7 +1282,7 @@@ url= self.url try: vim_response = requests.put(url +'/ports/'+port_id, headers = self.headers_req, data=payload_req) - except requests.exceptions.RequestException, e: + except requests.exceptions.RequestException as e: print "connect_port_network Exception: ", e.args return -vimconn.HTTP_Not_Found, str(e.args[0]) print vim_response