Linux bridge agents did not work with common linus utils
bug 1014286 Change-Id: I66327f5414d7f08dd13208707f12291ce202e47f
This commit is contained in:
parent
8cca7ca6c9
commit
b1bfe1ae13
@ -67,7 +67,7 @@ class LinuxBridge:
|
|||||||
def device_exists(self, device):
|
def device_exists(self, device):
|
||||||
"""Check if ethernet device exists."""
|
"""Check if ethernet device exists."""
|
||||||
retval = utils.execute(['ip', 'link', 'show',
|
retval = utils.execute(['ip', 'link', 'show',
|
||||||
'dev', device], root_wrapper=self.root_helper)
|
'dev', device], root_helper=self.root_helper)
|
||||||
if retval:
|
if retval:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@ -110,7 +110,7 @@ class LinuxBridge:
|
|||||||
|
|
||||||
def _get_prefixed_ip_link_devices(self, prefix):
|
def _get_prefixed_ip_link_devices(self, prefix):
|
||||||
prefixed_devices = []
|
prefixed_devices = []
|
||||||
retval = utils.execute(['ip', 'link'], root_wrapper=self.root_helper)
|
retval = utils.execute(['ip', 'link'], root_helper=self.root_helper)
|
||||||
rows = retval.split('\n')
|
rows = retval.split('\n')
|
||||||
for row in rows:
|
for row in rows:
|
||||||
values = row.split(':')
|
values = row.split(':')
|
||||||
@ -122,7 +122,7 @@ class LinuxBridge:
|
|||||||
|
|
||||||
def _get_prefixed_tap_devices(self, prefix):
|
def _get_prefixed_tap_devices(self, prefix):
|
||||||
prefixed_devices = []
|
prefixed_devices = []
|
||||||
retval = utils.execute(['ip', 'tuntap'], root_wrapper=self.root_helper)
|
retval = utils.execute(['ip', 'tuntap'], root_helper=self.root_helper)
|
||||||
rows = retval.split('\n')
|
rows = retval.split('\n')
|
||||||
for row in rows:
|
for row in rows:
|
||||||
split_row = row.split(':')
|
split_row = row.split(':')
|
||||||
@ -175,10 +175,10 @@ class LinuxBridge:
|
|||||||
if utils.execute(['ip', 'link', 'add', 'link',
|
if utils.execute(['ip', 'link', 'add', 'link',
|
||||||
self.physical_interface,
|
self.physical_interface,
|
||||||
'name', interface, 'type', 'vlan', 'id',
|
'name', interface, 'type', 'vlan', 'id',
|
||||||
vlan_id], root_wrapper=self.root_helper):
|
vlan_id], root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['ip', 'link', 'set',
|
if utils.execute(['ip', 'link', 'set',
|
||||||
interface, 'up'], root_wrapper=self.root_helper):
|
interface, 'up'], root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
LOG.debug("Done creating subinterface %s" % interface)
|
LOG.debug("Done creating subinterface %s" % interface)
|
||||||
return interface
|
return interface
|
||||||
@ -191,22 +191,22 @@ class LinuxBridge:
|
|||||||
LOG.debug("Starting bridge %s for subinterface %s" % (bridge_name,
|
LOG.debug("Starting bridge %s for subinterface %s" % (bridge_name,
|
||||||
interface))
|
interface))
|
||||||
if utils.execute(['brctl', 'addbr', bridge_name],
|
if utils.execute(['brctl', 'addbr', bridge_name],
|
||||||
root_wrapper=self.root_helper):
|
root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['brctl', 'setfd', bridge_name,
|
if utils.execute(['brctl', 'setfd', bridge_name,
|
||||||
str(0)], root_wrapper=self.root_helper):
|
str(0)], root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['brctl', 'stp', bridge_name,
|
if utils.execute(['brctl', 'stp', bridge_name,
|
||||||
'off'], root_wrapper=self.root_helper):
|
'off'], root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['ip', 'link', 'set', bridge_name,
|
if utils.execute(['ip', 'link', 'set', bridge_name,
|
||||||
'up'], root_wrapper=self.root_helper):
|
'up'], root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
LOG.debug("Done starting bridge %s for subinterface %s" %
|
LOG.debug("Done starting bridge %s for subinterface %s" %
|
||||||
(bridge_name, interface))
|
(bridge_name, interface))
|
||||||
|
|
||||||
utils.execute(['brctl', 'addif', bridge_name, interface],
|
utils.execute(['brctl', 'addif', bridge_name, interface],
|
||||||
root_wrapper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
|
|
||||||
def add_tap_interface(self, network_id, vlan_id, tap_device_name):
|
def add_tap_interface(self, network_id, vlan_id, tap_device_name):
|
||||||
"""
|
"""
|
||||||
@ -229,12 +229,12 @@ class LinuxBridge:
|
|||||||
bridge_name))
|
bridge_name))
|
||||||
if current_bridge_name:
|
if current_bridge_name:
|
||||||
if utils.execute(['brctl', 'delif', current_bridge_name,
|
if utils.execute(['brctl', 'delif', current_bridge_name,
|
||||||
tap_device_name], root_wrapper=self.root_helper):
|
tap_device_name], root_helper=self.root_helper):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.ensure_vlan_bridge(network_id, vlan_id)
|
self.ensure_vlan_bridge(network_id, vlan_id)
|
||||||
if utils.execute(['brctl', 'addif', bridge_name, tap_device_name],
|
if utils.execute(['brctl', 'addif', bridge_name, tap_device_name],
|
||||||
root_wrapper=self.root_helper):
|
root_helper=self.root_helper):
|
||||||
return False
|
return False
|
||||||
LOG.debug("Done adding device %s to bridge %s" % (tap_device_name,
|
LOG.debug("Done adding device %s to bridge %s" % (tap_device_name,
|
||||||
bridge_name))
|
bridge_name))
|
||||||
@ -263,10 +263,10 @@ class LinuxBridge:
|
|||||||
|
|
||||||
LOG.debug("Deleting bridge %s" % bridge_name)
|
LOG.debug("Deleting bridge %s" % bridge_name)
|
||||||
if utils.execute(['ip', 'link', 'set', bridge_name, 'down'],
|
if utils.execute(['ip', 'link', 'set', bridge_name, 'down'],
|
||||||
root_wrapper=self.root_helper):
|
root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['brctl', 'delbr', bridge_name],
|
if utils.execute(['brctl', 'delbr', bridge_name],
|
||||||
root_wrapper=self.root_helper):
|
root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
LOG.debug("Done deleting bridge %s" % bridge_name)
|
LOG.debug("Done deleting bridge %s" % bridge_name)
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ class LinuxBridge:
|
|||||||
LOG.debug("Removing device %s from bridge %s" %
|
LOG.debug("Removing device %s from bridge %s" %
|
||||||
(interface_name, bridge_name))
|
(interface_name, bridge_name))
|
||||||
if utils.execute(['brctl', 'delif', bridge_name, interface_name],
|
if utils.execute(['brctl', 'delif', bridge_name, interface_name],
|
||||||
root_wrapper=self.root_helper):
|
root_helper=self.root_helper):
|
||||||
return False
|
return False
|
||||||
LOG.debug("Done removing device %s from bridge %s" %
|
LOG.debug("Done removing device %s from bridge %s" %
|
||||||
(interface_name, bridge_name))
|
(interface_name, bridge_name))
|
||||||
@ -294,10 +294,10 @@ class LinuxBridge:
|
|||||||
if self.device_exists(interface):
|
if self.device_exists(interface):
|
||||||
LOG.debug("Deleting subinterface %s for vlan" % interface)
|
LOG.debug("Deleting subinterface %s for vlan" % interface)
|
||||||
if utils.execute(['ip', 'link', 'set', interface, 'down'],
|
if utils.execute(['ip', 'link', 'set', interface, 'down'],
|
||||||
root_wrapper=self.root_helper):
|
root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['ip', 'link', 'delete', interface],
|
if utils.execute(['ip', 'link', 'delete', interface],
|
||||||
root_wrapper=self.root_helper):
|
root_helper=self.root_helper):
|
||||||
return
|
return
|
||||||
LOG.debug("Done deleting subinterface %s" % interface)
|
LOG.debug("Done deleting subinterface %s" % interface)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user