Change in vdsm[master]: BZ#846004 - IP on nic/bond should be preserved when VLAN add...

ilvovsky at redhat.com ilvovsky at redhat.com
Thu Aug 16 11:31:00 UTC 2012


Igor Lvovsky has uploaded a new change for review.

Change subject: BZ#846004 - IP on nic/bond should be preserved when VLAN added
......................................................................

BZ#846004 - IP on nic/bond should be preserved when VLAN added

Change-Id: I5a6481c64c285b8a9bd6f6cc49c1c84507c91603
Signed-off-by: Igor Lvovsky <ilvovsky at redhat.com>
---
M vdsm/configNetwork.py
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/7259/1

diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 6faeb9d..7e3379e 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -367,9 +367,16 @@
     def _createConfFile(self, conf, name, ipaddr=None, netmask=None,
                 gateway=None, bootproto=None, mtu=None, onboot='yes', **kwargs):
         """ Create ifcfg-* file with proper fields per device """
+        cf = self.NET_CONF_PREF + name
         cfg = """DEVICE=%s\nONBOOT=%s\n""" % (pipes.quote(name),
                                               pipes.quote(onboot))
         cfg += conf
+        # Check whether we need to preserve prev ip/mask/gateway
+        if not ipaddr and os.path.exists(cf):
+            ipaddr = self._getConfigValue(cf, 'IPADDR')
+            netmask = self._getConfigValue(cf, 'NETMASK')
+            gateway = self._getConfigValue(cf, 'GATEWAY')
+
         if ipaddr:
             cfg = cfg + 'IPADDR=%s\nNETMASK=%s\n' % (pipes.quote(ipaddr),
                                                      pipes.quote(netmask))
@@ -381,6 +388,7 @@
         else:
             if bootproto:
                 cfg = cfg + 'BOOTPROTO=%s\n' % pipes.quote(bootproto)
+
         if mtu:
             cfg = cfg + 'MTU=%d\n' % mtu
         cfg += 'NM_CONTROLLED=no\n'
@@ -394,7 +402,7 @@
             else:
                 logging.debug('ignoring variable %s', k)
 
-        self.writeConfFile(self.NET_CONF_PREF + name, cfg)
+        self.writeConfFile(cf, cfg)
 
     def addBridge(self, name, ipaddr=None, netmask=None, mtu=None,
             gateway=None, bootproto=None, delay='0', onboot='yes', **kwargs):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a6481c64c285b8a9bd6f6cc49c1c84507c91603
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Igor Lvovsky <ilvovsky at redhat.com>


More information about the vdsm-patches mailing list