Alon Bar-Lev has uploaded a new change for review.

Change subject: vdsm: bridge: handle engine at loopback (all-in-one)
......................................................................

vdsm: bridge: handle engine at loopback (all-in-one)

When engine is at loopback we cannot create the bridge normally, as lo
cannot be added to a bridge.

As a workaround we create an empty bridge with loopback address of
127.0.0.2.

Change-Id: Ie96d40c41c2d72921407bfb7d132bdfccb1b84ac
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M ChangeLog
M src/plugins/ovirt-host-deploy/vdsm/bridge.py
2 files changed, 18 insertions(+), 57 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-host-deploy 
refs/changes/22/10222/1

diff --git a/ChangeLog b/ChangeLog
index 0f1cbd9..ae160de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
 
 Alon Bar-Lev <alo...@redhat.com>
 
+ * When engine address is local, create empty bridge with loopback address,
+   useful for all-in-one configuration.
+
  * support vdsm hooks by copying hooks from engine machine to host or by
    specifying a list of packages to be installed at host, refer to README for
    farther information.
diff --git a/src/plugins/ovirt-host-deploy/vdsm/bridge.py 
b/src/plugins/ovirt-host-deploy/vdsm/bridge.py
index fa2834b..224492c 100644
--- a/src/plugins/ovirt-host-deploy/vdsm/bridge.py
+++ b/src/plugins/ovirt-host-deploy/vdsm/bridge.py
@@ -58,33 +58,6 @@
     """
 
     """
-    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP...
-        link/ether 00:0e:bf:44:0d:1f brd ff:ff:ff:ff:ff:ff
-            inet 192.168.0.104/24 brd 192.168.0.255 scope global wlan0
-    """
-    _RE_IPROUTE_ADDR_SHOW = re.compile(
-        flags=re.VERBOSE,
-        pattern=r"""
-            ^
-            \s+
-            (inet|inet6)
-            \s+
-            ([0-9a-f.:]+)/[0-9]+
-            .*
-            scope
-            \s+
-            global
-            \s+
-            (\S+)
-        """
-    )
-    (
-        _RE_IPROUTE_ADDR_SHOW_TYPE,
-        _RE_IPROUTE_ADDR_SHOW_ADDRESS,
-        _RE_IPROUTE_ADDR_SHOW_INTERFACE
-    ) = range(1, 4)
-
-    """
     Remote:
         192.168.1.1 via 192.168.0.1 dev wlan0  src 192.168.0.104
             cache
@@ -337,33 +310,6 @@
         self.logger.debug('interface for %s is %s', address, interface)
         return interface
 
-    def _getInterfaceToInstallBasedOnDestination(self, address):
-        interface = self._getInterfaceForDestination(
-            address=address
-        )
-
-        # this is required for all-in-one
-        # we need to guess which interface to
-        # bridge
-        if interface == self._INTERFACE_LOOPBACK:
-            rc, stdout, stderr = self.execute(
-                (
-                    self.command.get('ip'),
-                    'addr', 'show',
-                ),
-            )
-            for line in stdout:
-                m = self._RE_IPROUTE_ADDR_SHOW.match(line)
-                if (
-                    m is not None and
-                    m.group(self._RE_IPROUTE_ADDR_SHOW_ADDRESS) == address
-                ):
-                    interface = m.group(
-                        self._RE_IPROUTE_ADDR_SHOW_INTERFACE
-                    )
-
-        return interface
-
     def _getVlanMasterDevice(self, name):
         interface = None
         vlanid = None
@@ -527,6 +473,9 @@
                 self._interfacesOfBonding(name=interface)
             )
 
+        if interface == self._INTERFACE_LOOPBACK:
+            interface = ''
+
         parameters = parameters[:] + ['blockingdhcp=true']
         self.execute(
             (
@@ -677,7 +626,7 @@
             ] = engineAddress
 
             install = True
-            interface = self._getInterfaceToInstallBasedOnDestination(
+            interface = self._getInterfaceForDestination(
                 address=engineAddress
             )
             if self._interfaceIsBridge(name=interface):
@@ -753,10 +702,19 @@
                 self.services.state('messagebus', True)
             self.services.state('libvirtd', True)
 
-        interface = self._getInterfaceToInstallBasedOnDestination(
+        interface = self._getInterfaceForDestination(
             address=self.environment[odeploycons.VdsmEnv.ENGINE_ADDRESS]
         )
-        parameters = self._rhel_getInterfaceConfigParameters(name=interface)
+        if interface == self._INTERFACE_LOOPBACK:
+            parameters = [
+                'IPADDR=127.0.0.2',
+                'NETMASK=255.0.0.0',
+                'ONBOOT=yes',
+            ]
+        else:
+            parameters = self._rhel_getInterfaceConfigParameters(
+                name=interface
+            )
 
         # The followin can be executed
         # only at node as we won't reach here


--
To view, visit http://gerrit.ovirt.org/10222
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie96d40c41c2d72921407bfb7d132bdfccb1b84ac
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-host-deploy
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to