From 551e5329c53acede500628b41beb3d8f2cff69ad Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 19 Jan 2017 16:16:26 +0100 Subject: [PATCH] enhance http messages at some bad input schemat Change-Id: I737984fc401636c32aaa5895f7ea217ff40af0bc Signed-off-by: tierno --- httpserver.py | 34 ++++++++++++++--------------- openmanod.py | 2 +- vnfs/examples/linux-cloud-init.yaml | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/httpserver.py b/httpserver.py index 789e0224..8cd482f9 100644 --- a/httpserver.py +++ b/httpserver.py @@ -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']), @@ -1126,15 +1126,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 +1225,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) diff --git a/openmanod.py b/openmanod.py index a5f0be0d..2eddb20e 100755 --- a/openmanod.py +++ b/openmanod.py @@ -33,7 +33,7 @@ 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.5.6-r516" +__version__="0.5.7-r517" version_date="Jan 2017" database_version="0.19" #expected database schema version diff --git a/vnfs/examples/linux-cloud-init.yaml b/vnfs/examples/linux-cloud-init.yaml index ce8c5de1..92e14fb2 100644 --- a/vnfs/examples/linux-cloud-init.yaml +++ b/vnfs/examples/linux-cloud-init.yaml @@ -26,7 +26,7 @@ vnf: description: Single-VM VNF with a traditional cloud VM based on generic Linux OS external-connections: - name: eth0 - type: bridge + type: mgmt description: General purpose interface VNFC: linux-VM local_iface_name: eth0 -- 2.17.1