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

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

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

ovirt-engine cannot cope with empty bridge (bridge without interfaces
assigned).

Network team does not wish to fix engine.

We will have to drag workarounds for it.

This reverts commit 817103dfd95f00d894e54730b3789aa8a9cf1e63.

Change-Id: If4a575a6e48a33ca346b911b99243177de6c46a9
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M ChangeLog
M src/plugins/ovirt-host-deploy/vdsm/bridge.py
2 files changed, 57 insertions(+), 18 deletions(-)


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

diff --git a/ChangeLog b/ChangeLog
index ae160de..0f1cbd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,9 +4,6 @@
 
 Alon Bar-Lev <[email protected]>
 
- * 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 a2e9e48..845c899 100644
--- a/src/plugins/ovirt-host-deploy/vdsm/bridge.py
+++ b/src/plugins/ovirt-host-deploy/vdsm/bridge.py
@@ -58,6 +58,33 @@
     """
 
     """
+    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
@@ -310,6 +337,33 @@
         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
@@ -473,9 +527,6 @@
                 self._interfacesOfBonding(name=interface)
             )
 
-        if interface == self._INTERFACE_LOOPBACK:
-            interface = ''
-
         parameters = parameters[:] + ['blockingdhcp=true']
         self.execute(
             (
@@ -617,7 +668,7 @@
             ] = engineAddress
 
             install = True
-            interface = self._getInterfaceForDestination(
+            interface = self._getInterfaceToInstallBasedOnDestination(
                 address=engineAddress
             )
             if self._interfaceIsBridge(name=interface):
@@ -693,19 +744,10 @@
                 self.services.state('messagebus', True)
             self.services.state('libvirtd', True)
 
-        interface = self._getInterfaceForDestination(
+        interface = self._getInterfaceToInstallBasedOnDestination(
             address=self.environment[odeploycons.VdsmEnv.ENGINE_ADDRESS]
         )
-        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
-            )
+        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/10580
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4a575a6e48a33ca346b911b99243177de6c46a9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-host-deploy
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to