Change in vdsm[master]: netconf: Improve unified persistence's rollback in memory.
by wudxw@linux.vnet.ibm.com
Mark Wu has uploaded a new change for review.
Change subject: netconf: Improve unified persistence's rollback in memory.
......................................................................
netconf: Improve unified persistence's rollback in memory.
This patch removes the dependency on ifcfg's code for the unified
persistence's rollback in memory. It also move transaction management
implementaion from ifcfg to its base class Configurator. With this
change, the rollback function be reused for the iproute2 configuration.
This patch also adds a functional test for live rollback. It passes with
ifcfg persistence and unified persistence.
Change-Id: I7436976d8bacbfaa1c4b059c71c4abb46192f99a
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
M lib/vdsm/constants.py.in
M tests/functional/networkTests.py
M vdsm/netconf/__init__.py
M vdsm/netconf/ifcfg.py
M vdsm/vdsm-restore-net-config
5 files changed, 95 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/20032/1
diff --git a/lib/vdsm/constants.py.in b/lib/vdsm/constants.py.in
index 1fb729b..a1a0dd6 100644
--- a/lib/vdsm/constants.py.in
+++ b/lib/vdsm/constants.py.in
@@ -139,6 +139,7 @@
EXT_UNPERSIST = '@UNPERSIST_PATH@'
EXT_VDSM_STORE_NET_CONFIG = '@VDSMDIR@/vdsm-store-net-config'
+EXT_VDSM_RESTORE_NET_CONFIG = '@VDSMDIR@/vdsm-restore-net-config'
EXT_WGET = '@WGET_PATH@'
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index b6c747f..d1f2329 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -1425,3 +1425,36 @@
status, msg = self.vdsm_net.setupNetworks(delete_networks,
{}, {})
self.assertEqual(status, SUCCESS, msg)
+
+ @cleanupNet
+ @permutations([[True], [False]])
+ @RequireDummyMod
+ @ValidateRunningAsRoot
+ def testSetupNetworksRollback(self, bridged):
+ with dummyIf(1) as nics:
+ with self.vdsm_net.pinger():
+ nic, = nics
+ tags = (10, 11, 12000)
+ networks = [NETWORK_NAME + str(tag) for tag in tags]
+ attrs = [dict(vlan=tag, nic=nic, bridged=bridged)
+ for tag in tags]
+ status, msg = self.vdsm_net.setupNetworks({networks[0]:
+ attrs[0]}, {}, {})
+
+ self.assertEqual(status, SUCCESS, msg)
+ self.assertTrue(self.vdsm_net.networkExists(networks[0]))
+
+ status, msg = self.vdsm_net.setupNetworks({networks[0]:
+ dict(remove=True),
+ networks[1]:
+ attrs[1],
+ networks[2]:
+ attrs[2]}, {}, {})
+ self.assertFalse(self.vdsm_net.networkExists(networks[1]))
+ self.assertFalse(self.vdsm_net.networkExists(networks[2]))
+ self.assertTrue(self.vdsm_net.networkExists(networks[0]))
+
+ status, msg = self.vdsm_net.setupNetworks({networks[0]:
+ dict(remove=True)},
+ {}, {})
+ self.assertEqual(status, SUCCESS, msg)
diff --git a/vdsm/netconf/__init__.py b/vdsm/netconf/__init__.py
index c0e3ee9..9dc0f70 100644
--- a/vdsm/netconf/__init__.py
+++ b/vdsm/netconf/__init__.py
@@ -18,13 +18,16 @@
#
import logging
+import pickle
from netmodels import Bond, Bridge
from sourceRoute import DynamicSourceRoute
from sourceRoute import StaticSourceRoute
+from vdsm import constants
from vdsm import netinfo
from vdsm.config import config
from vdsm.netconfpersistence import RunningConfig
+from vdsm.utils import execCmd
class Configurator(object):
@@ -46,6 +49,28 @@
else:
self.rollback()
+ def begin(self, configApplierClass):
+ if self.configApplier is None:
+ self.configApplier = configApplierClass()
+ if self.unifiedPersistence and self.runningConfig is None:
+ self.runningConfig = RunningConfig()
+
+ def rollback(self):
+ if self.unifiedPersistence:
+ liveConfig = pickle.dumps(self.runningConfig)
+ execCmd([constants.EXT_VDSM_RESTORE_NET_CONFIG, '--memory',
+ liveConfig])
+ self.runningConfig = None
+ else:
+ self.configApplier.restoreBackups()
+ self.configApplier = None
+
+ def commit(self):
+ self.configApplier = None
+ if self.unifiedPersistence:
+ self.runningConfig.save()
+ self.runningConfig = None
+
def configureBridge(self, bridge, **opts):
raise NotImplementedError
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index 0747b04..e0705d7 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -36,7 +36,6 @@
from vdsm import constants
from vdsm import netinfo
from vdsm import utils
-from vdsm.netconfpersistence import RunningConfig
import dsaversion
import libvirtCfg
import neterrors as ne
@@ -48,22 +47,7 @@
super(Ifcfg, self).__init__(ConfigWriter())
def begin(self):
- if self.configApplier is None:
- self.configApplier = ConfigWriter()
- if self.unifiedPersistence and self.runningConfig is None:
- self.runningConfig = RunningConfig()
-
- def rollback(self):
- self.configApplier.restoreBackups()
- self.configApplier = None
- if self.unifiedPersistence:
- self.runningConfig = None
-
- def commit(self):
- self.configApplier = None
- if self.unifiedPersistence:
- self.runningConfig.save()
- self.runningConfig = None
+ super(Ifcfg, self).begin(ConfigWriter)
def configureBridge(self, bridge, **opts):
self.configApplier.addBridge(bridge, **opts)
@@ -286,8 +270,8 @@
"(until next 'set safe config')", backup)
def _networkBackup(self, network):
- self._atomicNetworkBackup(network)
if config.get('vars', 'persistence') != 'unified':
+ self._atomicNetworkBackup(network)
self._persistentNetworkBackup(network)
def _atomicNetworkBackup(self, network):
@@ -328,8 +312,8 @@
logging.info('Restored %s', network)
def _backup(self, filename):
- self._atomicBackup(filename)
if config.get('vars', 'persistence') != 'unified':
+ self._atomicBackup(filename)
self._persistentBackup(filename)
def _atomicBackup(self, filename):
diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index 374387f..451d560 100755
--- a/vdsm/vdsm-restore-net-config
+++ b/vdsm/vdsm-restore-net-config
@@ -19,6 +19,9 @@
# Refer to the README and COPYING files for full details of the license
#
+import getopt
+import pickle
+import sys
import logging
import logging.config
@@ -64,6 +67,28 @@
ifcfg_restoration()
+def restore_from_memory(liveConfig):
+ assert config.get('vars', 'persistence') == 'unified'
+ lastConfig = RunningConfig() # snapshot of running config on disk
+
+ def get_restore_configs(liveConfig, lastConfig):
+ restoreConfigs = {}
+ for name in liveConfig:
+ if name not in lastConfig:
+ restoreConfigs[name] = {'remove': True}
+
+ for name, attr in lastConfig.iteritems():
+ if name not in liveConfig or attr != lastConfig[name]:
+ restoreConfigs[name] = lastConfig[name]
+ return restoreConfigs
+
+ nets = get_restore_configs(liveConfig.networks, lastConfig.networks)
+ bonds = get_restore_configs(liveConfig.bonds, lastConfig.bonds)
+ logging.debug("Calling setupNetworks with networks: %s, bondings: %s" %
+ (nets, bonds))
+ setupNetworks(nets, bonds, connectivityCheck=False)
+
+
if __name__ == '__main__':
try:
logging.config.fileConfig("/etc/vdsm/svdsm.logger.conf")
@@ -72,4 +97,12 @@
level=logging.DEBUG)
logging.error("Could not init proper logging", exc_info=True)
+ opts, args = getopt.getopt(sys.argv[1:], "m:", ["memory="])
+ for opt, arg in opts:
+ if opt in ('-m', '--memory'):
+ restore_from_memory(pickle.loads(arg))
+ sys.exit(0)
+ else:
+ assert False, "Unhandled option"
+
restore()
--
To view, visit http://gerrit.ovirt.org/20032
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7436976d8bacbfaa1c4b059c71c4abb46192f99a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw(a)linux.vnet.ibm.com>
9 years, 3 months
Change in vdsm[master]: Revert "Introducing configurator package in vdsm-tool"
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: Revert "Introducing configurator package in vdsm-tool"
......................................................................
Revert "Introducing configurator package in vdsm-tool"
This reverts commit 89d70a90288ba233eb760e78e2e59a96bdfb985f.
Change-Id: I8bd71a1e9a62ce5e76b2131a9cec55f02bfa8de1
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M debian/vdsm-python.install
M init/systemd/systemd-vdsmd.in
M init/sysvinit/vdsmd.init.in
M init/vdsmd_init_common.sh.in
M lib/vdsm/tool/Makefile.am
D lib/vdsm/tool/configurator.py
A lib/vdsm/tool/libvirt_configure.py
M lib/vdsm/tool/libvirt_configure.sh.in
A lib/vdsm/tool/sanlock.py
M vdsm.spec.in
10 files changed, 218 insertions(+), 316 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/21849/1
diff --git a/debian/vdsm-python.install b/debian/vdsm-python.install
index 5901152..7b695f3 100644
--- a/debian/vdsm-python.install
+++ b/debian/vdsm-python.install
@@ -13,11 +13,12 @@
./usr/lib/python2.7/dist-packages/vdsm/qemuImg.py
./usr/lib/python2.7/dist-packages/vdsm/tool/__init__.py
./usr/lib/python2.7/dist-packages/vdsm/tool/dummybr.py
-./usr/lib/python2.7/dist-packages/vdsm/tool/configurator.py
+./usr/lib/python2.7/dist-packages/vdsm/tool/libvirt_configure.py
./usr/lib/python2.7/dist-packages/vdsm/tool/load_needed_modules.py
./usr/lib/python2.7/dist-packages/vdsm/tool/nwfilter.py
./usr/lib/python2.7/dist-packages/vdsm/tool/passwd.py
./usr/lib/python2.7/dist-packages/vdsm/tool/restore_nets.py
+./usr/lib/python2.7/dist-packages/vdsm/tool/sanlock.py
./usr/lib/python2.7/dist-packages/vdsm/tool/seboolsetup.py
./usr/lib/python2.7/dist-packages/vdsm/tool/service.py
./usr/lib/python2.7/dist-packages/vdsm/tool/transient.py
diff --git a/init/systemd/systemd-vdsmd.in b/init/systemd/systemd-vdsmd.in
index a502b62..692e5eb 100644
--- a/init/systemd/systemd-vdsmd.in
+++ b/init/systemd/systemd-vdsmd.in
@@ -26,6 +26,5 @@
[ "$1" != "reconfigure" ] && usage_exit
[ -n "$2" -a "$2" != "force" ] && usage_exit
-if [ "$2" = "force" ] || ! "@BINDIR@/vdsm-tool" is-configured; then
- "@BINDIR@/vdsm-tool" configure --force
-fi
+"@BINDIR@/vdsm-tool" libvirt-configure ${2:+--force} &&
+ "@BINDIR@/vdsm-tool" libvirt-configure-services-restart
diff --git a/init/sysvinit/vdsmd.init.in b/init/sysvinit/vdsmd.init.in
index ea1ea85..4a4fc7d 100755
--- a/init/sysvinit/vdsmd.init.in
+++ b/init/sysvinit/vdsmd.init.in
@@ -108,10 +108,11 @@
return 1
}
-reconfigure() {
- if [ "${1}" = "force" ] || ! "$VDSM_TOOL" is-configured; then
- "$VDSM_TOOL" configure "--force"
- fi
+reconfigure_libvirt() {
+ local force
+ [ "${1}" = "force" ] && force="--force"
+ "$VDSM_TOOL" libvirt-configure ${force} &&
+ "$VDSM_TOOL" libvirt-configure-services-restart
}
start() {
@@ -205,11 +206,11 @@
reconfigure)
# Jump over 'reconfigure'
shift 1
- reconfigure "$@"
+ reconfigure_libvirt "$@"
RETVAL=$?
;;
*)
- echo "Usage: $0 {start|stop|status|restart|force-reload|try-restart|condrestart}"
+ echo "Usage: $0 {start|stop|status|restart|force-reload|try-restart}"
RETVAL=2
esac
diff --git a/init/vdsmd_init_common.sh.in b/init/vdsmd_init_common.sh.in
index dde9a71..9d9a5ba 100644
--- a/init/vdsmd_init_common.sh.in
+++ b/init/vdsmd_init_common.sh.in
@@ -46,8 +46,29 @@
}
-task_check_is_configured() {
- "$VDSM_TOOL" is-configured
+task_reconfigure_sanlock() {
+ _reconfigure_sanlock
+}
+
+_reconfigure_sanlock() {
+ # If sanlock was started before the *first* installation of vdsm
+ # then it is probably missing the supplementary groups.
+ # Here we attempt to restart the service (when needed) to refresh
+ # the groups.
+ "$VDSM_TOOL" sanlock-check-service
+ if [ $? != 0 ]; then
+ echo -n "Attempting to restart sanlock service:"
+ "$VDSM_TOOL" service-restart sanlock || return 1
+ fi
+}
+
+
+task_check_libvirt_configure() {
+ if ! "$VDSM_TOOL" libvirt-is-configured; then
+ echo "Perform 'vdsm-tool libvirt-configure' before starting vdsmd"
+ return 1
+ fi
+ return 0
}
@@ -166,8 +187,8 @@
}
-task_validate_configuration(){
- "$VDSM_TOOL" validate-config
+task_test_conflicting_conf(){
+ "$VDSM_TOOL" libvirt-test-conflicts
}
task_restore_nets(){
@@ -213,9 +234,9 @@
configure_coredump \
run_init_hooks \
gencerts \
- check_is_configured \
- validate_configuration \
+ check_libvirt_configure \
prepare_transient_repository \
+ reconfigure_sanlock \
syslog_available \
nwfilter \
dummybr \
@@ -223,6 +244,7 @@
tune_system \
test_space \
test_lo \
+ test_conflicting_conf \
restore_nets \
"
;;
diff --git a/lib/vdsm/tool/Makefile.am b/lib/vdsm/tool/Makefile.am
index f448a67..5112141 100644
--- a/lib/vdsm/tool/Makefile.am
+++ b/lib/vdsm/tool/Makefile.am
@@ -38,9 +38,10 @@
__init__.py \
dummybr.py \
nwfilter.py \
- configurator.py \
+ libvirt_configure.py \
passwd.py \
restore_nets.py \
+ sanlock.py \
seboolsetup.py \
service.py \
transient.py \
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
deleted file mode 100644
index 9e866b4..0000000
--- a/lib/vdsm/tool/configurator.py
+++ /dev/null
@@ -1,287 +0,0 @@
-# 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
-#
-
-import os
-import sys
-import grp
-import argparse
-
-from .. import utils
-from . import service, expose
-from ..constants import P_VDSM_EXEC, DISKIMAGE_GROUP
-
-
-class _ModuleConfigure(object):
- def __init__(self):
- pass
-
- def getName(self):
- return None
-
- def getServices(self):
- return []
-
- def validate(self):
- return True
-
- def configure(self):
- pass
-
- def isconfigured(self):
- return True
-
-
-class LibvirtModuleConfigure(_ModuleConfigure):
- def __init__(self):
- super(LibvirtModuleConfigure, self).__init__()
-
- def getName(self):
- return 'libvirt'
-
- def getServices(self):
- return ["supervdsmd", "vdsmd", "libvirtd"]
-
- def _exec_libvirt_configure(self, action):
- """
- Invoke libvirt_configure.sh script
- """
- if os.getuid() != 0:
- raise UserWarning("Must run as root")
-
- rc, out, err = utils.execCmd(
- (
- os.path.join(
- P_VDSM_EXEC,
- 'libvirt_configure.sh'
- ),
- action,
- ),
- raw=True,
- )
- sys.stdout.write(out)
- sys.stderr.write(err)
- if rc != 0:
- raise RuntimeError("Failed to perform libvirt action.")
-
- def configure(self):
- self._exec_libvirt_configure("reconfigure")
-
- def validate(self):
- """
- Validate conflict in configured files
- """
- try:
- self._exec_libvirt_configure("test_conflict_configurations")
- return True
- except RuntimeError:
- return False
-
- def isconfigured(self):
- """
- Check if libvirt is already configured for vdsm
- """
- try:
- self._exec_libvirt_configure("check_if_configured")
- return True
- except RuntimeError:
- return False
-
-
-class SanlockModuleConfigure(_ModuleConfigure):
- def __init__(self):
- super(SanlockModuleConfigure, self).__init__()
-
- def getName(self):
- return 'sanlock'
-
- def getServices(self):
- return ['sanlock']
-
- def configure(self):
- """
- Configure sanlock process groups
- """
- if os.getuid() != 0:
- raise UserWarning("Must run as root")
-
- rc, out, err = utils.execCmd(
- (
- '/usr/sbin/usermod',
- '-a',
- '-G',
- 'qemu,kvm',
- 'sanlock'
- ),
- raw=True,
- )
- sys.stdout.write(out)
- sys.stderr.write(err)
- if rc != 0:
- raise RuntimeError("Failed to perform sanlock config.")
-
- def isconfigured(self, *args):
- """
- Return 0 if sanlock service requires a restart to reload the relevant
- supplementary groups.
- """
- proc_status_group_prefix = "Groups:\t"
- try:
- with open("/var/run/sanlock/sanlock.pid", "r") as f:
- sanlock_pid = f.readline().strip()
- with open(os.path.join('/proc', sanlock_pid, 'status'),
- "r") as sanlock_status:
- for status_line in sanlock_status:
- if status_line.startswith(proc_status_group_prefix):
- groups = [int(x) for x in
- status_line[len(proc_status_group_prefix):].
- strip().split(" ")]
- break
- else:
- raise RuntimeError("Unable to find sanlock service groups")
-
- except IOError as e:
- if e.errno == os.errno.ENOENT:
- raise RuntimeError("sanlock service is not running")
- raise
-
- diskimage_gid = grp.getgrnam(DISKIMAGE_GROUP)[2]
- if diskimage_gid not in groups:
- raise RuntimeError("sanlock service requires restart")
-
- sys.stdout.write("sanlock service is already configured\n")
- return True
-
-
-__configurers = (
- LibvirtModuleConfigure(),
- SanlockModuleConfigure(),
-)
-
-
-@expose("configure")
-def configure(*args):
- """
- Configure external services for vdsm
- """
- args = _parse_args("configure")
- configurer_to_trigger = []
- for c in __configurers:
- if c.getName() in args.modules:
- if not c.validate():
- raise RuntimeError(
- "Configuration of %s is invalid" % c.getName()
- )
- if args.force or not c.isconfigured():
- configurer_to_trigger.append(c)
-
- services = []
- for c in configurer_to_trigger:
- for s in c.getServices():
- if service.service_status(s) == 0:
- if not args.force:
- raise RuntimeError(
- "Cannot configure while %s is running" % s
- )
- services.append(s)
-
- for s in services:
- service.service_stop(s)
-
- for c in configurer_to_trigger:
- c.configure()
-
- for s in reversed(services):
- service.service_start(s)
-
-
-@expose("is-configured")
-def isconfigured(*args):
- """
- Determine if module is configured
- """
- ret = True
- args = _parse_args('is-configured')
-
- m = [
- c.getName() for c in __configurers
- if c.getName() in args.modules and not c.isconfigured()
- ]
-
- if m:
- sys.stdout.write(
- "Modules %s are not configured\n " % ','.join(m),
- )
- ret = False
-
- if not ret:
- raise RuntimeError("Not configured. Try 'vdsm-tool configure'")
-
-
-@expose("validate-config")
-def validate_config(*args):
- """
- Determine if configuration is valid
- """
- ret = True
- args = _parse_args('validate-config')
-
- m = [
- c.getName() for c in __configurers
- if c.getName() in args.modules and not c.validate()
- ]
-
- if m:
- sys.stdout.write(
- "Modules %s contains invalid configuration\n " % ','.join(m),
- )
- ret = False
-
- if not ret:
- raise RuntimeError("Config is not valid. Check conf files")
-
-
-def _parse_args(action):
- parser = argparse.ArgumentParser('vdsm-tool %s' % (action))
- allModules = [n.getName() for n in __configurers]
- parser.add_argument(
- '--module',
- dest='modules',
- choices=allModules,
- default=[],
- metavar='STRING',
- action='append',
- help=(
- 'Specify the module to run the action on '
- '(e.g %(choices)s).\n'
- 'If non is specified, operation will run for '
- 'all related modules.'
- ),
- )
- if action == "configure":
- parser.add_argument(
- '--force',
- dest='force',
- default=False,
- action='store_true',
- help='Force configuration, trigger services restart',
- )
- args = parser.parse_args(sys.argv[2:])
- if not args.modules:
- args.modules = allModules
- return args
diff --git a/lib/vdsm/tool/libvirt_configure.py b/lib/vdsm/tool/libvirt_configure.py
new file mode 100644
index 0000000..0ecaa55
--- /dev/null
+++ b/lib/vdsm/tool/libvirt_configure.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
+#
+
+import os
+import sys
+
+from .. import utils
+from . import expose
+from . import service
+from ..constants import P_VDSM_EXEC
+
+
+def exec_libvirt_configure(action, *args):
+ """
+ Invoke libvirt_configure.sh script
+ """
+ if os.getuid() != 0:
+ raise RuntimeError("Must run as root")
+
+ rc, out, err = utils.execCmd([os.path.join(
+ P_VDSM_EXEC,
+ 'libvirt_configure.sh'), action] +
+ list(args),
+ raw=True)
+
+ sys.stdout.write(out)
+ sys.stderr.write(err)
+ return rc
+
+
+@expose("libvirt-configure")
+def configure_libvirt(*args):
+ """
+ libvirt configuration (--force for reconfigure)
+ """
+ rc = exec_libvirt_configure("reconfigure", *args)
+ if rc != 0:
+ raise RuntimeError("Failed to configure libvirt")
+
+ return 0
+
+
+@expose("libvirt-test-conflicts")
+def test_conflict_configurations(*args):
+ """
+ Validate conflict in configured files
+ """
+ return exec_libvirt_configure("test_conflict_configurations", *args)
+
+
+@expose("libvirt-configure-services-restart")
+def libvirt_configure_services_restart(*args):
+ """
+ Managing restart of related services
+ """
+ service.service_stop("supervdsmd")
+ service.service_stop("libvirtd")
+ service.service_start("libvirtd")
+ service.service_start("supervdsmd")
+ return 0
+
+
+@expose("libvirt-is-configured")
+def libvirt_is_configured(*args):
+ """
+ Check if libvirt is already configured for vdsm
+ """
+ return exec_libvirt_configure("check_if_configured", *args)
diff --git a/lib/vdsm/tool/libvirt_configure.sh.in b/lib/vdsm/tool/libvirt_configure.sh.in
index 950c11f..b6fc2e7 100755
--- a/lib/vdsm/tool/libvirt_configure.sh.in
+++ b/lib/vdsm/tool/libvirt_configure.sh.in
@@ -104,12 +104,14 @@
return 0
fi
- # Shutoff libvirt SysV service before configure upstart
+ # Stop libvirt SysV service before configure upstart
if [ ! -f "${target}" ]; then
"@CHKCONFIG_PATH@" libvirtd off
+ "@SERVICE_PATH@" libvirtd stop
fi
- if ! diff -q "${packaged}" "${target}" >/dev/null 2>&1; then
+ if ! diff -q "${packaged}" "${target}" >/dev/null 2>&1;
+ then
/bin/cp -p "${packaged}" "${target}" || return 1
/sbin/initctl reload-configuration
fi
@@ -173,6 +175,7 @@
local qconf="$2"
local ldconf="$3"
local qlconf="$4"
+ local force_reconfigure="$5"
local by_vdsm="by vdsm"
local start_conf_section="## beginning of configuration section ${by_vdsm}"
local end_conf_section="## end of configuration section ${by_vdsm}"
@@ -191,6 +194,20 @@
return 6
fi
/usr/bin/vdsm-tool validate-ovirt-certs
+ fi
+
+ #
+ # reconfigure if:
+ # - force specified or
+ # - we have the FORCE_RECONFIGURE trigger file
+ # - not configured
+ #
+ if [ "${force_reconfigure}" != "--force" ] && \
+ ! [ -f "${FORCE_RECONFIGURE}" ] && \
+ is_already_configured "${lconf}" "${qconf}" "${ldconf}" "${qlconf}";
+ then
+ echo "Not forcing reconfigure"
+ return 0
fi
# Remove a previous configuration (if present)
@@ -297,6 +314,14 @@
fi
echo "Reconfiguration of libvirt is done."
+ echo
+ cat << __EOF__
+To start working with the new configuration, execute:
+'vdsm-tool libvirt-configure-services-restart'
+This will manage restarting of the following services:
+libvirtd, supervdsmd
+__EOF__
+ echo
#
# finished reconfiguration, do not trigger
@@ -321,7 +346,7 @@
RETVAL=$?
;;
*)
- echo "Usage: $0 {reconfigure|test_conflict_configurations|check_if_configured}"
+ echo "Usage: $0 {reconfigure *conf-files [--force] | test_conflict_configurations *conf-files | check_if_configured}"
RETVAL=2
esac
diff --git a/lib/vdsm/tool/sanlock.py b/lib/vdsm/tool/sanlock.py
new file mode 100644
index 0000000..ba59a73
--- /dev/null
+++ b/lib/vdsm/tool/sanlock.py
@@ -0,0 +1,58 @@
+# 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
+#
+
+import os
+import grp
+
+from .. import constants
+from . import expose
+
+
+SANLOCK_PID = "/var/run/sanlock/sanlock.pid"
+
+PROC_STATUS_PATH = "/proc/%s/status"
+PROC_STATUS_GROUPS = "Groups:\t"
+PROC_STATUS_GROUPS_LEN = len(PROC_STATUS_GROUPS)
+
+
+@expose("sanlock-check-service")
+def sanlock_check_service(*args):
+ """
+ Check if sanlock service requires a restart to reload the relevant
+ supplementary groups.
+ """
+
+ try:
+ sanlock_pid = open(SANLOCK_PID, "r").readline().strip()
+ sanlock_status = open(PROC_STATUS_PATH % sanlock_pid, "r")
+ except IOError as e:
+ if e.errno == os.errno.ENOENT:
+ return 0 # service is not running, returning
+ raise
+
+ for status_line in sanlock_status:
+ if status_line.startswith(PROC_STATUS_GROUPS):
+ groups = [int(x) for x in
+ status_line[PROC_STATUS_GROUPS_LEN:].strip().split(" ")]
+ break
+ else:
+ raise RuntimeError("Unable to find sanlock service groups")
+
+ diskimage_gid = grp.getgrnam(constants.DISKIMAGE_GROUP)[2]
+ return 0 if diskimage_gid in groups else 1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 43e47ea..b72e1da 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -641,6 +641,7 @@
/usr/sbin/useradd -r -u 36 -g %{vdsm_group} -d /var/lib/vdsm \
-s /sbin/nologin -c "Node Virtualization Manager" %{vdsm_user}
/usr/sbin/usermod -a -G %{qemu_group},%{snlk_group} %{vdsm_user}
+/usr/sbin/usermod -a -G %{qemu_group},%{vdsm_group} %{snlk_user}
%post
%{_bindir}/vdsm-tool sebool-config || :
@@ -736,9 +737,6 @@
if [ "$1" -ge 1 ]; then
supervdsmd_start_required='no'
vdsmd_start_required='no'
-
- # Both vdsm and supervdsm should be managed here and must be restarted if
- # ran before (code might changed)
if %{_bindir}/vdsm-tool service-status vdsmd >/dev/null 2>&1; then
%{_bindir}/vdsm-tool service-stop vdsmd >/dev/null 2>&1
vdsmd_start_required='yes'
@@ -747,12 +745,11 @@
%{_bindir}/vdsm-tool service-stop supervdsmd >/dev/null 2>&1
supervdsmd_start_required='yes'
fi
-
- if ! %{_bindir}/vdsm-tool is-configured --module libvirt >/dev/null 2>&1;
- then
- %{_bindir}/vdsm-tool configure --module libvirt --force >/dev/null 2>&1
+ if %{_bindir}/vdsm-tool libvirt-configure | grep -q 'is done.'; then
+ if %{_bindir}/vdsm-tool service-status libvirtd >/dev/null 2>&1; then
+ %{_bindir}/vdsm-tool service-restart libvirtd >/dev/null 2>&1
+ fi
fi
-
if [ "${supervdsmd_start_required}" = 'yes' ]; then
%{_bindir}/vdsm-tool service-start supervdsmd >/dev/null 2>&1
fi
@@ -1065,10 +1062,11 @@
%endif
%{python_sitearch}/%{vdsm_name}/tool/dummybr.py*
%{python_sitearch}/%{vdsm_name}/tool/nwfilter.py*
-%{python_sitearch}/%{vdsm_name}/tool/configurator.py*
+%{python_sitearch}/%{vdsm_name}/tool/libvirt_configure.py*
%{_libexecdir}/%{vdsm_name}/libvirt_configure.sh
%{python_sitearch}/%{vdsm_name}/tool/passwd.py*
%{python_sitearch}/%{vdsm_name}/tool/restore_nets.py*
+%{python_sitearch}/%{vdsm_name}/tool/sanlock.py*
%{python_sitearch}/%{vdsm_name}/tool/seboolsetup.py*
%{python_sitearch}/%{vdsm_name}/tool/service.py*
%{python_sitearch}/%{vdsm_name}/tool/transient.py*
--
To view, visit http://gerrit.ovirt.org/21849
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8bd71a1e9a62ce5e76b2131a9cec55f02bfa8de1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 3 months
Change in vdsm[master]: vdsm: Handling topology for ppc64
by ybronhei@redhat.com
Yaniv Bronhaim has posted comments on this change.
Change subject: vdsm: Handling topology for ppc64
......................................................................
Patch Set 6: Code-Review-1
(3 comments)
....................................................
File vdsm/ppc64HardwareInfo.py
Line 54:
Line 55: def getLsCpu():
Line 56: p = CPopen(['lscpu'])
Line 57: p.wait()
Line 58: return p.stdout.read()
can be in utils.py. move it there please
Line 59:
Line 60:
Line 61: @utils.memoized
Line 62: def getCpuTopology(capabilities):
Line 79: threadsPC = int(value)
Line 80: elif key == 'Core(s) per socket':
Line 81: corePS = int(value)
Line 82:
Line 83: if (corePS is not None
just make also socket = None, and if all None raise the RuntimeError
Line 84: and threadsPC is not None
Line 85: and 'sockets' in topology):
Line 86: topology['cores'] = corePS * topology['sockets']
Line 87: topology['threads'] = threadsPC * corePS * topology['sockets']
Line 88:
Line 89: keys = ['sockets', 'threads', 'cores']
Line 90:
Line 91: if not all(x in topology for x in keys):
Line 92: raise RuntimeError('Undefined topology')
you can use utils.validateMinimalKeySet I think. but I don't think you need this part at all ^
Line 93:
--
To view, visit http://gerrit.ovirt.org/19875
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I048d4a6c083392d63fbcff76453e682b9d6f03fc
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Leonardo Bianconi <leonardo.bianconi(a)eldorado.org.br>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Gustavo Frederico Temple Pedrosa <gustavo.pedrosa(a)eldorado.org.br>
Gerrit-Reviewer: Leonardo Bianconi <leonardo.bianconi(a)eldorado.org.br>
Gerrit-Reviewer: Vitor de Lima <vitor.lima(a)eldorado.org.br>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
9 years, 3 months