Don't use root_helper when it's not needed
LinuxBridge agent doesn't need to use root_helper when checking if a device exists. Root priviledges are required to perform operations inside a namespace and it's not the case here. Change-Id: I12e0cde2f4dd3b3f8e7f5ed9e90e2805a4466aaa Closes-bug: #1305800
This commit is contained in:
parent
043f04c159
commit
31f6bbbbe8
|
@ -132,7 +132,7 @@ class LinuxBridgeManager:
|
|||
return neutron_bridge_list
|
||||
|
||||
def get_interfaces_on_bridge(self, bridge_name):
|
||||
if ip_lib.device_exists(bridge_name, root_helper=self.root_helper):
|
||||
if ip_lib.device_exists(bridge_name):
|
||||
bridge_interface_path = BRIDGE_INTERFACES_FS.replace(
|
||||
BRIDGE_NAME_PLACEHOLDER, bridge_name)
|
||||
return os.listdir(bridge_interface_path)
|
||||
|
@ -214,7 +214,7 @@ class LinuxBridgeManager:
|
|||
def ensure_vlan(self, physical_interface, vlan_id):
|
||||
"""Create a vlan unless it already exists."""
|
||||
interface = self.get_subinterface_name(physical_interface, vlan_id)
|
||||
if not ip_lib.device_exists(interface, root_helper=self.root_helper):
|
||||
if not ip_lib.device_exists(interface):
|
||||
LOG.debug(_("Creating subinterface %(interface)s for "
|
||||
"VLAN %(vlan_id)s on interface "
|
||||
"%(physical_interface)s"),
|
||||
|
@ -234,7 +234,7 @@ class LinuxBridgeManager:
|
|||
def ensure_vxlan(self, segmentation_id):
|
||||
"""Create a vxlan unless it already exists."""
|
||||
interface = self.get_vxlan_device_name(segmentation_id)
|
||||
if not ip_lib.device_exists(interface, root_helper=self.root_helper):
|
||||
if not ip_lib.device_exists(interface):
|
||||
LOG.debug(_("Creating vxlan interface %(interface)s for "
|
||||
"VNI %(segmentation_id)s"),
|
||||
{'interface': interface,
|
||||
|
@ -380,8 +380,7 @@ class LinuxBridgeManager:
|
|||
If a VIF has been plugged into a network, this function will
|
||||
add the corresponding tap device to the relevant bridge.
|
||||
"""
|
||||
if not ip_lib.device_exists(tap_device_name,
|
||||
root_helper=self.root_helper):
|
||||
if not ip_lib.device_exists(tap_device_name):
|
||||
LOG.debug(_("Tap device: %s does not exist on "
|
||||
"this host, skipped"), tap_device_name)
|
||||
return False
|
||||
|
@ -425,7 +424,7 @@ class LinuxBridgeManager:
|
|||
tap_device_name)
|
||||
|
||||
def delete_vlan_bridge(self, bridge_name):
|
||||
if ip_lib.device_exists(bridge_name, root_helper=self.root_helper):
|
||||
if ip_lib.device_exists(bridge_name):
|
||||
interfaces_on_bridge = self.get_interfaces_on_bridge(bridge_name)
|
||||
for interface in interfaces_on_bridge:
|
||||
self.remove_interface(bridge_name, interface)
|
||||
|
@ -468,7 +467,7 @@ class LinuxBridgeManager:
|
|||
del self.network_map[network_id]
|
||||
|
||||
def remove_interface(self, bridge_name, interface_name):
|
||||
if ip_lib.device_exists(bridge_name, root_helper=self.root_helper):
|
||||
if ip_lib.device_exists(bridge_name):
|
||||
if not self.is_device_on_bridge(interface_name):
|
||||
return True
|
||||
LOG.debug(_("Removing device %(interface_name)s from bridge "
|
||||
|
@ -491,7 +490,7 @@ class LinuxBridgeManager:
|
|||
return False
|
||||
|
||||
def delete_vlan(self, interface):
|
||||
if ip_lib.device_exists(interface, root_helper=self.root_helper):
|
||||
if ip_lib.device_exists(interface):
|
||||
LOG.debug(_("Deleting subinterface %s for vlan"), interface)
|
||||
if utils.execute(['ip', 'link', 'set', interface, 'down'],
|
||||
root_helper=self.root_helper):
|
||||
|
@ -502,7 +501,7 @@ class LinuxBridgeManager:
|
|||
LOG.debug(_("Done deleting subinterface %s"), interface)
|
||||
|
||||
def delete_vxlan(self, interface):
|
||||
if ip_lib.device_exists(interface, root_helper=self.root_helper):
|
||||
if ip_lib.device_exists(interface):
|
||||
LOG.debug(_("Deleting vxlan interface %s for vlan"),
|
||||
interface)
|
||||
int_vxlan = self.ip.device(interface)
|
||||
|
@ -540,8 +539,7 @@ class LinuxBridgeManager:
|
|||
return False
|
||||
for segmentation_id in range(1, constants.MAX_VXLAN_VNI + 1):
|
||||
if not ip_lib.device_exists(
|
||||
self.get_vxlan_device_name(segmentation_id),
|
||||
root_helper=self.root_helper):
|
||||
self.get_vxlan_device_name(segmentation_id)):
|
||||
break
|
||||
else:
|
||||
LOG.error(_('No valid Segmentation ID to perform UCAST test.'))
|
||||
|
|
Loading…
Reference in New Issue