Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add support for rx_vlan_id and ESXiPort port type
In vrouter-port-control and vrouter_api, add a new port type.
In vrouter_api make specifying rx_vlan_id possible

Closes-Bug: #1765013
Depends-On: Iba1fea552c7778a48cce3bd7695e07d487272a45
Change-Id: Icdf6c3ba94f766c5989278fdfd131a07aba7db9c
  • Loading branch information
aszc-dev committed May 22, 2018
1 parent c685b45 commit 177c527
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/vnsw/agent/port_ipc/vrouter-port-control
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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)
Expand Down
52 changes: 39 additions & 13 deletions src/vnsw/contrail-vrouter-api/contrail_vrouter_api/vrouter_api.py
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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()
Expand Down

0 comments on commit 177c527

Please sign in to comment.