Assaf Muller has uploaded a new change for review.
Change subject: Unified network persistence [4/4] - Upgrade updates running conf
......................................................................
Unified network persistence [4/4] - Upgrade updates running conf
Run a VDSM upgrade that gathers net info and updates the running
config of the unified network persistence.
Change-Id: I051b0f168b6357e60184409845ea410c5891b083
Signed-off-by: Assaf Muller <amuller(a)redhat.com>
---
M vdsm.spec.in
M vdsm/Makefile.am
M vdsm/upgrade/Makefile.am
A vdsm/upgrade/__init__.py
A vdsm/upgrade/unifiedPersistence.py
A vdsm/vdsm-unified-network-persistence
M vdsm/vdsmd.init.in
7 files changed, 140 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/25/18425/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 73fde5b..4e03b4f 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -832,6 +832,7 @@
%{_datadir}/%{vdsm_name}/vdsm
%{_datadir}/%{vdsm_name}/vdsm-restore-net-config
%{_datadir}/%{vdsm_name}/vdsm-store-net-config
+%{_datadir}/%{vdsm_name}/vdsm-unified-network-persistence
%{_datadir}/%{vdsm_name}/vm.py*
%{_datadir}/%{vdsm_name}/zombieReaper.py*
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/logger.conf
@@ -973,6 +974,7 @@
%{_datadir}/%{vdsm_name}/set-conf-item
%dir %{_datadir}/%{vdsm_name}/upgrade
%{_datadir}/%{vdsm_name}/upgrade/upgrade.py*
+%{_datadir}/%{vdsm_name}/upgrade/unifiedPersistence.py*
%if 0%{?with_gluster}
%dir %{_datadir}/%{vdsm_name}/gluster
%{_datadir}/%{vdsm_name}/gluster/__init__.py*
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 4c5f02a..2712c4e 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -93,6 +93,7 @@
set-conf-item \
vdsm \
vdsm-restore-net-config \
+ vdsm-unified-network-persistence \
$(NULL)
nodist_man8_MANS = \
diff --git a/vdsm/upgrade/Makefile.am b/vdsm/upgrade/Makefile.am
index 014864a..558a19a 100644
--- a/vdsm/upgrade/Makefile.am
+++ b/vdsm/upgrade/Makefile.am
@@ -23,4 +23,6 @@
upgradedir = $(vdsmdir)/upgrade
dist_upgrade_PYTHON = \
- upgrade.py
+ upgrade.py \
+ unifiedPersistence.py
+
diff --git a/vdsm/upgrade/__init__.py b/vdsm/upgrade/__init__.py
new file mode 100644
index 0000000..8e88115
--- /dev/null
+++ b/vdsm/upgrade/__init__.py
@@ -0,0 +1,18 @@
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
diff --git a/vdsm/upgrade/unifiedPersistence.py b/vdsm/upgrade/unifiedPersistence.py
new file mode 100644
index 0000000..7db6646
--- /dev/null
+++ b/vdsm/upgrade/unifiedPersistence.py
@@ -0,0 +1,84 @@
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+from upgrade import Upgrade
+from vdsm import netinfo
+
+
+class UnifiedPersistence(Upgrade):
+ def run(self):
+ networks, bondings = self._getNetInfo()
+ self._persist(networks, bondings)
+
+ def _getNetInfo(self):
+ _netinfo = netinfo.NetInfo()
+ networks = {}
+ bondings = {}
+ whitelist = ['bridged', 'vlan', 'mtu',
'qosInbound', 'qosOutbound',
+ 'stp']
+
+ """
+ bridged="True | False"
+ vlan=<id>
+ bonding="<name>" | nic="<name>"
+ ipaddr="<ip>"
+ netmask="<ip>"
+ gateway="<ip>"
+ bootproto="dhcp | none"
+ delay="..."
+ onboot="yes | no"
+ """
+
+ for network, netParams in _netinfo.networks.iteritems():
+ networks[network] = {}
+ for k, v in netParams.iteritems():
+ if k in whitelist:
+ networks[network][k] = v
+ if netParams.get('ports'):
+ device = "".join(netParams['ports'])
+ else:
+ device = netParams['interface']
+ topLevelDevice = \
+ netParams['iface'] if netParams['bridged'] else device
+ bootproto = netinfo.getBootProtocol(topLevelDevice)
+ networks[network]['bootproto'] = bootproto
+ if bootproto != 'dhcp':
+ networks[network]['ipaddr'] = netParams['addr']
+ networks[network]['netmask'] = netParams['netmask']
+ networks[network]['gateway'] = netParams['gateway']
+ if device in _netinfo.bondings:
+ bondings[device] = \
+ {'nics': _netinfo.bondings[device]['slaves']}
+ networks[network]['bonding'] = device
+ else:
+ networks[network]['nic'] = device
+
+ return networks, bondings
+
+ def _persist(self, networks, bondings):
+ self.log.debug("networks: %s, bondings: %s" % (networks, bondings))
+ print("networks: %s, bondings: %s" % (networks, bondings))
+
+
+def main():
+ UnifiedPersistence().runIfNeeded()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/vdsm/vdsm-unified-network-persistence
b/vdsm/vdsm-unified-network-persistence
new file mode 100755
index 0000000..64a4db9
--- /dev/null
+++ b/vdsm/vdsm-unified-network-persistence
@@ -0,0 +1,30 @@
+#! /usr/bin/python
+#
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+from upgrade.unifiedPersistence import UnifiedPersistence
+
+
+def main():
+ UnifiedPersistence().runIfNeeded()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/vdsm/vdsmd.init.in b/vdsm/vdsmd.init.in
index 1bdb911..215b0ff 100755
--- a/vdsm/vdsmd.init.in
+++ b/vdsm/vdsmd.init.in
@@ -261,6 +261,8 @@
return 1
fi
+ "@VDSMDIR@/vdsm-unified-network-persistence"
+
echo $"Starting up vdsm daemon: "
local vdsm_nice="$("${GETCONFITEM}" "${CONF_FILE}" vars
vdsm_nice -5)"
--
To view, visit
http://gerrit.ovirt.org/18425
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I051b0f168b6357e60184409845ea410c5891b083
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Assaf Muller <amuller(a)redhat.com>