From: rossella Date: Mon, 16 Jun 2014 10:52:38 +0000 (+0000) Subject: Don't use root_helper when it's not needed X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=31f6bbbbe8f9909af922dc4146afc50b7bbb0eac;p=openstack-build%2Fneutron-build.git 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 --- diff --git a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py index 5d215791a..90dbd451b 100755 --- a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -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.'))