X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=httpserver.py;h=a0216e12f2f209853703f77e240bf54565b57291;hb=06e6c396413630640cafae3488442a0869f1642d;hp=9dd537f201a8d6a9cdefe35630b63e41d2ad35be;hpb=6ecca189895532ec01cf302a43afa29492f6d207;p=osm%2FRO.git diff --git a/httpserver.py b/httpserver.py index 9dd537f2..a0216e12 100644 --- a/httpserver.py +++ b/httpserver.py @@ -975,9 +975,9 @@ def http_post_scenarios(tenant_id): if used_schema == nsd_schema_v01: scenario_id = nfvo.new_scenario(mydb, tenant_id, http_content) elif used_schema == nsd_schema_v02: - scenario_id = nfvo.new_scenario_v02(mydb, tenant_id, http_content) + scenario_id = nfvo.new_scenario_v02(mydb, tenant_id, http_content, "0.2") elif used_schema == nsd_schema_v03: - scenario_id = nfvo.new_scenario_v03(mydb, tenant_id, http_content) + scenario_id = nfvo.new_scenario_v02(mydb, tenant_id, http_content, "0.3") else: logger.warning('Unexpected schema_version: %s', http_content.get("schema_version")) bottle.abort(HTTP_Bad_Request, "Invalid schema version") @@ -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 @@ def http_get_scenario_id(tenant_id, scenario_id): @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 @@ def http_put_scenario_id(tenant_id, scenario_id): 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 @@ def http_delete_instance_id(tenant_id, instance_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)