diff --git a/src/vnsw/agent/port_ipc/vrouter-port-control b/src/vnsw/agent/port_ipc/vrouter-port-control index 974fb9ec8cc..23a3053878d 100755 --- a/src/vnsw/agent/port_ipc/vrouter-port-control +++ b/src/vnsw/agent/port_ipc/vrouter-port-control @@ -49,6 +49,8 @@ class VrouterPortControl(object): port_type_value = 0 elif self._args.port_type == "NameSpacePort": port_type_value = 1 + elif self._args.port_type == "ESXiPort": + port_type_value = 2 u = self._args.vm_project_uuid project_id = "" @@ -207,7 +209,7 @@ class VrouterPortControl(object): sys.exit(1) if self._args.oper == "add": - port_type_list = ['NovaVMPort', 'NameSpacePort'] + port_type_list = ['NovaVMPort', 'NameSpacePort', 'ESXiPort'] if self._args.port_type not in port_type_list: print "Invalid argument for port_type %s" % (self._args.port_type) sys.exit(1) 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 c378110ae01..d23a32d52ab 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 @@ -48,15 +48,18 @@ def add_port(self, vm_uuid_str, vif_uuid_str, interface_name, mac_address, display_name='' if 'display_name' in kwargs: display_name = kwargs['display_name'] - vm_project_id='' + vm_project_id='' if 'vm_project_id' in kwargs: vm_project_id = kwargs['vm_project_id'] + 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'] == 2): + port_type = "ESXiPort" elif (kwargs['port_type'] == 'NovaVMPort'): port_type = "NovaVMPort" else: @@ -72,16 +75,39 @@ def add_port(self, vm_uuid_str, vif_uuid_str, interface_name, mac_address, if 'vlan' in kwargs: tx_vlan_id = kwargs['vlan'] - cmd_args = ("vrouter-port-control --oper=\"add\" --uuid=\"%s\" " - "--instance_uuid=\"%s\" --vn_uuid=\"%s\" " - "--vm_project_uuid=\"%s\" --ip_address=\"%s\" " - "--ipv6_address=\"%s\" --vm_name=\"%s\" --mac=\"%s\" " - "--tap_name=\"%s\" --port_type=\"%s\" " - "--vif_type=\"Vrouter\" --tx_vlan_id=\"%d\" " - "--rx_vlan_id=\"%d\"" %(vif_uuid_str, vm_uuid_str, - network_uuid, vm_project_id, ip_address, ip6_address, - display_name, mac_address, interface_name, port_type, - tx_vlan_id, -1)) + rx_vlan_id = -1 + if 'rx_vlan' in kwargs: + rx_vlan_id = kwargs['rx_vlan'] + + cmd_args = ( + "vrouter-port-control --oper=\"add\" " + "--uuid=\"%s\" " + "--instance_uuid=\"%s\" " + "--vn_uuid=\"%s\" " + "--vm_project_uuid=\"%s\" " + "--ip_address=\"%s\" " + "--ipv6_address=\"%s\" " + "--vm_name=\"%s\" " + "--mac=\"%s\" " + "--tap_name=\"%s\" " + "--port_type=\"%s\" " + "--vif_type=\"Vrouter\" " + "--tx_vlan_id=\"%d\" " + "--rx_vlan_id=\"%d\" " % ( + vif_uuid_str, + vm_uuid_str, + network_uuid, + vm_project_id, + ip_address, + ip6_address, + display_name, + mac_address, + interface_name, + port_type, + tx_vlan_id, + rx_vlan_id, + ) + ) cmd = cmd_args.split() ret_code = subprocess.call(cmd) @@ -118,7 +144,7 @@ def delete_port(self, vif_uuid_str): finally: if self._semaphore: self._semaphore.release() - + def enable_port(self, vif_uuid_str): """ Enable a port in the agent. @@ -135,7 +161,7 @@ def enable_port(self, vif_uuid_str): if ret_code != 0: return False return True - + finally: if self._semaphore: self._semaphore.release()