From bddcd93f1fc8eb00607d62c7f688f6d000f24419 Mon Sep 17 00:00:00 2001 From: ashoksingh Date: Tue, 21 Feb 2017 17:04:57 +0530 Subject: [PATCH] Vm project UUID should be optional for Port Add requests. Currently the REST interface of contrail-vrouter-agent for Port Adds, makes it mandatory for vm-project-uuid to be specified when the port type is NovaVMPort. In case of thrift interface this was not mandatory. To ensure backward compatibility, vm-project-uuid should be optional even in REST interface. Also change the default value for port-type in vrouter_api.py to NameSpacePort to ensure backward compatibility. Closes-Bug: #1664819 (cherry picked from commit de72bafd363f96048ece41785b0b6f55e64f3a0d) Change-Id: Iacad9fc68acd6affcf9f8c3908644924407e8077 --- src/vnsw/agent/port_ipc/port_ipc_handler.cc | 7 +------ .../contrail_vrouter_api/vrouter_api.py | 9 ++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/vnsw/agent/port_ipc/port_ipc_handler.cc b/src/vnsw/agent/port_ipc/port_ipc_handler.cc index 1a3c2b39624..402a196f74c 100644 --- a/src/vnsw/agent/port_ipc/port_ipc_handler.cc +++ b/src/vnsw/agent/port_ipc/port_ipc_handler.cc @@ -190,7 +190,7 @@ bool PortIpcHandler::AddPort(const PortIpcHandler::AddPortParams &r, if (r.vn_id.length() != 0) { vn_uuid = StringToUuid(r.vn_id); } - /* VM Project UUID is optional for CfgIntNameSpacePort */ + /* VM Project UUID is optional */ uuid vm_project_uuid = nil_uuid(); if (r.vm_project_id.length() != 0) { vm_project_uuid = StringToUuid(r.vm_project_id); @@ -226,11 +226,6 @@ bool PortIpcHandler::AddPort(const PortIpcHandler::AddPortParams &r, resp_str += "invalid VN uuid, "; err = true; } - if ((intf_type == CfgIntEntry::CfgIntVMPort) && - (vm_project_uuid == nil_uuid())) { - resp_str += "invalid VM project uuid, "; - err = true; - } if (!ValidateMac(r.mac_address)) { resp_str += "Invalid MAC, Use xx:xx:xx:xx:xx:xx format"; err = true; diff --git a/src/vnsw/contrail-vrouter-api/contrail_vrouter_api/vrouter_api.py b/src/vnsw/contrail-vrouter-api/contrail_vrouter_api/vrouter_api.py index 86810b538fa..00076551baa 100644 --- a/src/vnsw/contrail-vrouter-api/contrail_vrouter_api/vrouter_api.py +++ b/src/vnsw/contrail-vrouter-api/contrail_vrouter_api/vrouter_api.py @@ -52,16 +52,15 @@ def add_port(self, vm_uuid_str, vif_uuid_str, interface_name, mac_address, if 'vm_project_id' in kwargs: vm_project_id = kwargs['vm_project_id'] - if ('port_type' in kwargs and - kwargs['port_type'] in [0,1]): + if ('port_type' in kwargs): if (kwargs['port_type'] == 0): port_type = "NovaVMPort" elif (kwargs['port_type'] == 1): port_type = "NameSpacePort" - elif (kwargs['port_type'] == 'NameSpacePort'): - port_type = "NameSpacePort" - else: + elif (kwargs['port_type'] == 'NovaVMPort'): port_type = "NovaVMPort" + else: + port_type = "NameSpacePort" else: port_type = "NameSpacePort"