Change in vdsm[master]: always teardown snapshot's memory volume
by ahadas@redhat.com
Arik Hadas has uploaded a new change for review.
Change subject: always teardown snapshot's memory volume
......................................................................
always teardown snapshot's memory volume
Change-Id: If59047f7d5ba6cfa942b593683f6f9987619a7ea
Signed-off-by: Arik Hadas <ahadas(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/44/26544/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index b8ce533..3982116 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3680,6 +3680,7 @@
# with size that is not multiple of block size correctly.
if memoryParams:
_padMemoryVolume(memoryVolPath, memoryVol['domainID'])
+ # Teardown should happen anyway (also in case of exceptions).
self.cif.teardownVolumePath(memoryVol)
for drive in newDrives.values(): # Update the drive information
--
To view, visit http://gerrit.ovirt.org/26544
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If59047f7d5ba6cfa942b593683f6f9987619a7ea
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <ahadas(a)redhat.com>
10 years
Change in vdsm[master]: volume: use qemuimg and remove custom qemuRebase
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: volume: use qemuimg and remove custom qemuRebase
......................................................................
volume: use qemuimg and remove custom qemuRebase
Change-Id: Icd05300bb31dae68a67ea8c2a3252b28a8d7978c
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M lib/vdsm/qemuimg.py
M vdsm/storage/volume.py
2 files changed, 40 insertions(+), 38 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/26901/1
diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py
index 80addc8..e68313c 100644
--- a/lib/vdsm/qemuimg.py
+++ b/lib/vdsm/qemuimg.py
@@ -172,3 +172,22 @@
if rc != 0:
raise QImgError(rc, out, err)
+
+
+def rebase(image, backing, format=None, backingFormat=None, unsafe=False,
+ stop=None):
+ cmd = [_qemuimg.cmd, "rebase", "-t", "none"]
+
+ if format:
+ cmd.extend(("-f", format))
+
+ if backingFormat:
+ cmd.extend(("-F", backingFormat))
+
+ cmd.extend(("-b", backing))
+
+ rc, out, err = utils.watchCmd(
+ cmd, stop=stop, nice=utils.NICENESS.HIGH, ioclass=utils.IOCLASS.IDLE)
+
+ if rc != 0:
+ raise QImgError(rc, out, err)
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index cf9b8f1..5d6cac2 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -201,17 +201,20 @@
vol = sdCache.produce(sdUUID).produceVolume(srcImg, srcVol)
vol.prepare(rw=True, chainrw=True, setrw=True)
- try:
- (rc, out, err) = qemuRebase(
- vol.getVolumePath(), vol.getFormat(),
- os.path.join('..', srcImg, srcParent),
- int(dstFormat), misc.parseBool(unsafe),
- vars.task.aborting)
- if rc:
- raise se.MergeVolumeRollbackError(srcVol)
+ volumePath = vol.getVolumePath()
+ parentBackingPath = os.path.join('..', srcImg, srcParent)
+ try:
+ qemuimg.rebase(volumePath, parentBackingPath,
+ fmt2str(vol.getFormat()),
+ fmt2str(int(dstFormat)),
+ misc.parseBool(unsafe), vars.task.aborting)
vol.setParent(srcParent)
vol.recheckIfLeaf()
+ except qemuimg.QImgError:
+ cls.log.exception('cannot rollback rebase for volume %s on '
+ '%s', volumePath, parentBackingPath)
+ raise se.MergeVolumeRollbackError(srcVol)
finally:
vol.teardown(sdUUID, srcVol)
@@ -235,11 +238,17 @@
self.volUUID, str(pvol.getFormat()),
pvol.volUUID, str(True)]))
- (rc, out, err) = qemuRebase(self.getVolumePath(), self.getFormat(),
- backingVolPath, backingFormat, unsafe,
- vars.task.aborting)
- if rc:
+ volumePath = self.getVolumePath()
+
+ try:
+ qemuimg.rebase(volumePath, backingVolPath,
+ fmt2str(self.getFormat()), fmt2str(backingFormat),
+ unsafe, vars.task.aborting)
+ except qemuimg.QImgError:
+ self.log.exception('cannot rebase volume %s on %s', volumePath,
+ backingVolPath)
raise se.MergeSnapshotsError(self.volUUID)
+
self.setParent(backingVol)
self.recheckIfLeaf()
@@ -974,32 +983,6 @@
by reducing the lv to minimal size required
"""
pass
-
-
-def qemuRebase(src, srcFormat, backingFile, backingFormat, unsafe, stop):
- """
- Rebase the 'src' volume on top of the new 'backingFile'
- with new 'backingFormat'
- """
- backingFormat = fmt2str(backingFormat)
- srcFormat = fmt2str(srcFormat)
- cwd = os.path.dirname(src)
- log.debug('(qemuRebase): REBASE %s (fmt=%s) on top of %s (%s) START' %
- (src, srcFormat, backingFile, backingFormat))
-
- cmd = [constants.EXT_QEMUIMG, "rebase",
- "-t", "none", "-f", srcFormat,
- "-b", backingFile, "-F", backingFormat]
- if unsafe:
- cmd += ["-u"]
- cmd += [src]
-
- (rc, out, err) = misc.watchCmd(cmd, stop=stop, cwd=cwd,
- ioclass=utils.IOCLASS.IDLE,
- nice=utils.NICENESS.HIGH)
-
- log.debug('(qemuRebase): REBASE %s DONE' % (src))
- return (rc, out, err)
def qemuConvert(src, dst, src_fmt, dst_fmt, stop, size, dstvolType):
--
To view, visit http://gerrit.ovirt.org/26901
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd05300bb31dae68a67ea8c2a3252b28a8d7978c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
10 years
Change in vdsm[master]: virt: graphdev: support multiple graphics devices
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: graphdev: support multiple graphics devices
......................................................................
virt: graphdev: support multiple graphics devices
This patch allows a Vm to have more than one Graphics Devices.
Change-Id: I5be348b342359d42c878937dca27454fe206a35a
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
M vdsm_api/vdsmapi-schema.json
2 files changed, 37 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/27215/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6563f68..c5c8daa 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1816,8 +1816,16 @@
if len(devices[device]) > 1:
raise ValueError("only a single %s device is "
"supported" % device)
- if len(devices[GRAPHICS_DEVICES]) != 1:
- raise ValueError("graphics device is required")
+ graphDevs = set()
+ for dev in devices[GRAPHICS_DEVICES]:
+ if dev.device not in graphDevs:
+ graphDevs.add(dev.device)
+ else:
+ raise ValueError("only a single graphic device "
+ "per type is supported")
+ if not graphDevs:
+ raise ValueError("at least one graphics device is required")
+
def getConfController(self):
"""
@@ -2576,7 +2584,10 @@
stats['displayType'] = 'qxl'
return stats
+ # backward compatibility
stats.update(getInfo(self.getConfGraphics()[0]))
+ stats['graphicDevices'] = [getInfo(dev, legacy=False)
+ for dev in self.getConfGraphics()]
def isMigrating(self):
return self._migrationSourceThread.isAlive()
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 5836f1d..57a78e1 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -5825,6 +5825,25 @@
'balloon_target': 'str'}}
##
+# @GraphicsDeviceInfo:
+#
+# Graphics Device information.
+#
+# @displayPort: The port in use for unencrypted display data
+#
+# @displaySecurePort: The port in use for encrypted display data
+#
+# @displayType: The type of display in use
+#
+# @displayIp: The IP address to use for accessing the VM display
+#
+# Since: 4.15.0
+##
+{'type': 'GraphicsDeviceInfo',
+ 'data': {'displayPort': 'uint', 'displaySecurePort': 'uint',
+ 'displayType': 'VmGraphicsDeviceType', 'displayIp': 'str'}}
+
+##
# @GuestMountInfo:
#
# Information about a mounted filesystem as reported by the guest agent.
@@ -6001,6 +6020,9 @@
# @guestCPUCount: The number of CPU cores are visible as online on the
# guest OS. This value is -1 if not supported to report
#
+# @graphicDevices: Graphics device informations.
+# (new in version 4.15.0)
+#
# Since: 4.10.0
##
{'type': 'RunningVmStats',
@@ -6020,7 +6042,8 @@
'disksUsage': ['GuestMountInfo'],
'netIfaces': ['GuestNetworkDeviceInfo'],
'*watchdogEvent': 'WatchdogEvent', 'guestFQDN': 'str',
- '*migrationProgress': 'uint', 'guestCPUCount': 'int'}}
+ '*migrationProgress': 'uint', 'guestCPUCount': 'int',
+ 'graphicDevices': ['GraphicsDeviceInfo']}}
##
# @VmStats:
--
To view, visit http://gerrit.ovirt.org/27215
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5be348b342359d42c878937dca27454fe206a35a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
10 years
Change in vdsm[master]: task: prevent tasks with the same id to be queued
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: task: prevent tasks with the same id to be queued
......................................................................
task: prevent tasks with the same id to be queued
Change-Id: I0b9980de08d10203a75071dae9b16c9b850a91f5
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/task.py
M vdsm/storage/taskManager.py
2 files changed, 13 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/26808/1
diff --git a/vdsm/storage/task.py b/vdsm/storage/task.py
index 222cb2e..d8ca3a6 100644
--- a/vdsm/storage/task.py
+++ b/vdsm/storage/task.py
@@ -537,6 +537,7 @@
except Exception as e:
self._setError(e)
self.stop()
+ raise
def __state_running(self, fromState):
self._runJobs()
diff --git a/vdsm/storage/taskManager.py b/vdsm/storage/taskManager.py
index 4a7a04f..aeae9d5 100644
--- a/vdsm/storage/taskManager.py
+++ b/vdsm/storage/taskManager.py
@@ -20,6 +20,7 @@
import os
import logging
+import threading
from vdsm.config import config
import storage_exception as se
@@ -38,6 +39,7 @@
self.tp = ThreadPool(tpSize, waitTimeout, maxTasks)
self._tasks = {}
self._unqueuedTasks = []
+ self._tasksLock = threading.Lock()
def queue(self, task):
return self._queueTask(task, task.commit)
@@ -46,17 +48,24 @@
return self._queueTask(task, task.recover)
def _queueTask(self, task, method):
- try:
+ with self._tasksLock:
+ if task.id in self._tasks:
+ raise se.AddTaskError(
+ 'Task id already in use: {0}'.format(task.id))
+
self.log.debug("queuing task: %s", task.id)
self._tasks[task.id] = task
+
+ try:
if not self.tp.queueTask(task.id, method):
self.log.error("unable to queue task: %s", task.dumpTask())
del self._tasks[task.id]
raise se.AddTaskError()
self.log.debug("task queued: %s", task.id)
- except Exception as ex:
- self.log.error("Could not queue task, encountered: %s", str(ex))
+ except Exception:
+ self.log.exception('could not queue task %s', task.id)
raise
+
return task.id
def scheduleJob(self, type, store, task, jobName, func, *args):
--
To view, visit http://gerrit.ovirt.org/26808
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b9980de08d10203a75071dae9b16c9b850a91f5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
10 years
Change in vdsm[master]: virt: migration: always run migration monitor
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: migration: always run migration monitor
......................................................................
virt: migration: always run migration monitor
The migration monitor thread was run conditionally
if the migration monitor was specified.
This patch let the migration monitor always run.
If the migration monitor interval is disabled (= set to zero)
then the monitor thread will just sit idle.
This patch is a necessary step toward the unification
of MigrationMonitor and MigrationDowntime threads.
Change-Id: Ib4953ddda5a5c6c0ecd7ea0f95377309e18f771a
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/migration.py
1 file changed, 17 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/25975/1
diff --git a/vdsm/migration.py b/vdsm/migration.py
index a684499..3699ca5 100644
--- a/vdsm/migration.py
+++ b/vdsm/migration.py
@@ -295,10 +295,9 @@
t = MigrationDowntimeThread(self._vm, int(self._downtime))
- if MigrationMonitorThread._MIGRATION_MONITOR_INTERVAL:
- self._monitorThread = MigrationMonitorThread(self._vm,
- startTime)
- self._monitorThread.start()
+ self._monitorThread = MigrationMonitorThread(self._vm,
+ startTime)
+ self._monitorThread.start()
try:
if ('qxl' in self._vm.conf['display'] and
@@ -327,8 +326,7 @@
finally:
t.cancel()
- if MigrationMonitorThread._MIGRATION_MONITOR_INTERVAL:
- self._monitorThread.stop()
+ self._monitorThread.stop()
def stop(self):
# if its locks we are before the migrateToURI2()
@@ -389,7 +387,17 @@
self.daemon = True
self.progress = 0
+ @property
+ def enabled(self):
+ return MigrationMonitorThread._MIGRATION_MONITOR_INTERVAL > 0
+
def run(self):
+ if self.enabled:
+ self.monitor_migration()
+ else:
+ self.idle()
+
+ def monitor_migration(self):
def calculateProgress(remaining, total):
if remaining == 0:
return 100
@@ -455,6 +463,9 @@
' data processed' %
(timeElapsed / 1000, self.progress))
+ def idle(self):
+ self._stop.wait(1.0)
+
def stop(self):
self._vm.log.debug('stopping migration monitor thread')
self._stop.set()
--
To view, visit http://gerrit.ovirt.org/25975
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4953ddda5a5c6c0ecd7ea0f95377309e18f771a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
10 years
Change in vdsm[master]: vdsm: Add force and timeout options to VM.shutdown
by mbetak@redhat.com
Martin Betak has uploaded a new change for review.
Change subject: vdsm: Add force and timeout options to VM.shutdown
......................................................................
vdsm: Add force and timeout options to VM.shutdown
Added optional boolean parameters 'timeout' and 'force' to
shutdown in vdsm and vdsClient.
Timeout represents number of seconds to wait before falling back to next
alternative method of shutdown/reboot.
If 'force' is True and all graceful methods fail, we reset/destroy the VM.
Change-Id: I30180f9906eb45fa485aa7d773a436e62bd3c815
Signed-off-by: Martin Betak <mbetak(a)redhat.com>
---
M client/vdsClient.py
M lib/vdsm/config.py.in
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/virt/vm.py
M vdsm/virt/vmpowerdown.py
M vdsm_api/vdsmapi-schema.json
7 files changed, 55 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/27054/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index e67f330..1583b22 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -352,7 +352,13 @@
vmId, timeout, message = args[:3]
if len(args) > 3:
reboot = utils.tobool(args[3])
- response = self.s.shutdown(vmId, timeout, message, reboot)
+ if len(args) > 4:
+ timeout = args[4]
+ force = utils.tobool(args[5] if len(args) > 5 else False)
+ response = self.s.shutdown(vmId, timeout, message, reboot,
+ timeout, force)
+ else:
+ response = self.s.shutdown(vmId, timeout, message, reboot)
else:
response = self.s.shutdown(vmId, timeout, message)
print response['status']['message']
@@ -1953,7 +1959,11 @@
'Stops the emulation and graceful shutdown the virtual'
' machine.',
'o reboot: if specified, reboot instead of shutdown'
- ' (default False)'
+ ' (default False)',
+ 'o timeout: number of seconds to wait before proceeding '
+ 'to next shutdown/reboot method',
+ 'o force: if specified, forcefuly reboot/shutdown'
+ ' after all graceful methods fail (default False)'
)),
'list': (serv.do_list,
('[view] [vms:vmId1,vmId2]',
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 591f268..cee0f6b 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -125,7 +125,7 @@
('max_outgoing_migrations', '3',
'Maximum concurrent outgoing migrations'),
- ('sys_shutdown_timeout', '10',
+ ('sys_shutdown_timeout', '120',
'Destroy and shutdown timeouts (in sec) before completing the '
'action.'),
diff --git a/vdsm/API.py b/vdsm/API.py
index 94b39b6..ebfc5f4 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -620,7 +620,8 @@
return errCode['noVM']
return v.setTicket(password, ttl, existingConnAction, params)
- def shutdown(self, delay=None, message=None, reboot=False):
+ def shutdown(self, delay=None, message=None, reboot=False, timeout=None,
+ force=False):
"""
Shut a VM down politely.
@@ -629,6 +630,10 @@
:param delay: grace period (seconds) to let guest user close his
applications.
:param reboot: True if reboot is desired, False for shutdown
+ :param timeout: number of seconds to wait before trying next
+ shutdown/reboot method
+ :param force: True if shutdown/reboot desired by any means necessary
+ (forceful reboot/shutdown if all graceful methods fail)
"""
try:
v = self._cif.vmContainer[self._UUID]
@@ -638,7 +643,9 @@
delay = config.get('vars', 'user_shutdown_timeout')
if not message:
message = USER_SHUTDOWN_MESSAGE
- return v.shutdown(delay, message, reboot)
+ if not timeout:
+ timeout = config.get('vars', 'sys_shutdown_timeout')
+ return v.shutdown(delay, message, reboot, timeout, force)
def _createSysprepFloppyFromInf(self, infFileBinary, floppyImage):
try:
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 76251f5..874d8c6 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -302,9 +302,10 @@
vm = API.VM(vmId)
return vm.reset()
- def vmShutdown(self, vmId, delay=None, message=None, reboot=False):
+ def vmShutdown(self, vmId, delay=None, message=None, reboot=False,
+ timeout=None, force=False):
vm = API.VM(vmId)
- return vm.shutdown(delay, message, reboot)
+ return vm.shutdown(delay, message, reboot, timeout, force)
def vmSetTicket(self, vmId, password, ttl,
existingConnAction='disconnect', params={}):
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 79ff40b..7703544 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2297,21 +2297,21 @@
if not guestCpuLocked:
self._guestCpuLock.release()
- def shutdown(self, delay, message, reboot):
+ def shutdown(self, delay, message, reboot, timeout, force):
if self.lastStatus == vmstatus.DOWN:
return errCode['noVM']
delay = int(delay)
- timeout = int(config.get('vars', 'sys_shutdown_timeout'))
+ timeout = int(timeout)
self._guestEventTime = time.time()
if reboot:
self._guestEvent = vmstatus.REBOOT_IN_PROGRESS
- powerDown = VmReboot(self, delay, message, timeout,
+ powerDown = VmReboot(self, delay, message, timeout, force,
self._powerDownEvent)
else:
self._guestEvent = vmstatus.POWERING_DOWN
- powerDown = VmShutdown(self, delay, message, timeout,
+ powerDown = VmShutdown(self, delay, message, timeout, force,
self._powerDownEvent)
return powerDown.start()
diff --git a/vdsm/virt/vmpowerdown.py b/vdsm/virt/vmpowerdown.py
index 219e4ca..d66f9a1 100644
--- a/vdsm/virt/vmpowerdown.py
+++ b/vdsm/virt/vmpowerdown.py
@@ -29,7 +29,7 @@
Derived classes must provide the guestAgentCallback and acpiCallback
methods and returnMsg property.
"""
- def __init__(self, vm, delay, message, timeout, event):
+ def __init__(self, vm, delay, message, timeout, force, event):
"""
:param vm: Vm undergoing power-down action
:param delay: Graceful timeout for the user to close his applications
@@ -38,6 +38,7 @@
:param timeout: Timeout for each power-down method (guestAgent, acpi)
until it is considered unsuccessful and the callback
chain should try another alternative.
+ :param force: Use forceful power-down if all graceful methods fail?
:param event: Event object used to detect successful power-down.
"""
self.vm = vm
@@ -54,6 +55,9 @@
# then acpi if enabled
if utils.tobool(vm.conf.get('acpiEnable', 'true')):
self.chain.addCallback(self.acpiCallback)
+
+ if force:
+ self.chain.addCallback(self.forceCallback)
def start(self):
# are there any available methods for power-down?
@@ -87,6 +91,15 @@
self.vm._dom.shutdownFlags(libvirt.VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN)
return self.event.wait(self.timeout)
+ def forceCallback(self):
+ # acquire vmContainerLock to safely perform deleteVm() which is called
+ # by destroy()
+ with self.vm.cif.vmContainerLock:
+ self.vm.log.info("vmContainerLock acquired by PowerDown of vm %s",
+ self.vm.conf['vmId'])
+ self.vm.destroy()
+ return self.event.wait(self.timeout)
+
class VmReboot(VmPowerDown):
returnMsg = 'Machine rebooting'
@@ -98,3 +111,7 @@
def acpiCallback(self):
self.vm._dom.reboot(libvirt.VIR_DOMAIN_REBOOT_ACPI_POWER_BTN)
return self.event.wait(self.timeout)
+
+ def forceCallback(self):
+ self.vm._dom.reset(0)
+ return self.event.wait(self.timeout)
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 6765536..978da2e 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -6420,10 +6420,17 @@
#
# @reboot: #optional True if reboot is desired, False for shutdown
#
+# @timeout: #optional Number of seconds to wait before trying next
+# shutdown/reboot method.
+#
+# @force: #optional True if shutdown/reboot desired by any means necessary
+# (forceful reboot/shutdown if all graceful methods fail)
+# Default is False (i.e. graceful only).
# Since: 4.10.0
##
{'command': {'class': 'VM', 'name': 'shutdown'},
- 'data': {'vmID': 'UUID', '*delay': 'int', '*message': 'str', '*reboot': 'bool'}}
+ 'data': {'vmID': 'UUID', '*delay': 'int', '*message': 'str', '*reboot': 'bool',
+ '*timeout': 'int', '*force': 'bool'}}
##
# @SnapshotVolumeDriveInfo:
--
To view, visit http://gerrit.ovirt.org/27054
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I30180f9906eb45fa485aa7d773a436e62bd3c815
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Betak <mbetak(a)redhat.com>
10 years
Change in vdsm[master]: vdsm-tool: Add command name to args for command
by dkuznets@redhat.com
Dima Kuznetsov has uploaded a new change for review.
Change subject: vdsm-tool: Add command name to args for command
......................................................................
vdsm-tool: Add command name to args for command
Each command now receives its own copy of 'sys.argv'-like argument list,
starting with command name and all its arguments.
Added exception each command can throw in case wrong params were passed.
Exception handler for this exception prints the doc string for the
command.
Some command functions were split because they're called both from vdsm
code and vdsm-tool code, so the vdsm-tool expose goes to a wrapper
function first and ensures the parameters are there, then passes to the
actual function.
Change-Id: I831bde947f451805e086e25f1c0b9943b17e7bd8
Signed-off-by: Dima Kuznetsov <dkuznets(a)redhat.com>
---
M lib/vdsm/tool/__init__.py
M lib/vdsm/tool/configurator.py
M lib/vdsm/tool/dummybr.py
M lib/vdsm/tool/load_needed_modules.py.in
M lib/vdsm/tool/nwfilter.py
M lib/vdsm/tool/passwd.py
M lib/vdsm/tool/restore_nets.py
M lib/vdsm/tool/seboolsetup.py
M lib/vdsm/tool/service.py
M lib/vdsm/tool/transient.py
M lib/vdsm/tool/validate_ovirt_certs.py.in
M lib/vdsm/tool/vdsm-id.py
M vdsm-tool/vdsm-tool
13 files changed, 180 insertions(+), 49 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/26575/1
diff --git a/lib/vdsm/tool/__init__.py b/lib/vdsm/tool/__init__.py
index 863ad51..9323835 100644
--- a/lib/vdsm/tool/__init__.py
+++ b/lib/vdsm/tool/__init__.py
@@ -34,3 +34,9 @@
class VdsmToolNotRootError(VdsmToolRuntimeError):
def __init__(self):
VdsmToolRuntimeError.__init__(self, "Must run as root")
+
+
+class VdsmToolWrongArgsError(VdsmToolRuntimeError):
+ def __init__(self):
+ VdsmToolRuntimeError.__init__(self,
+ "Wrong parameters passed to command")
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index 601288f..7561cf6 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -213,7 +213,7 @@
"""
Configure external services for vdsm
"""
- args = _parse_args("configure")
+ args = _parse_args(*args)
configurer_to_trigger = []
sys.stdout.write("\nChecking configuration status...\n\n")
@@ -257,7 +257,7 @@
Determine if module is configured
"""
ret = True
- args = _parse_args('is-configured')
+ args = _parse_args(*args)
m = [
c.getName() for c in __configurers
@@ -292,7 +292,7 @@
Determine if configuration is valid
"""
ret = True
- args = _parse_args('validate-config')
+ args = _parse_args(*args)
m = [
c.getName() for c in __configurers
@@ -309,7 +309,7 @@
raise VdsmToolRuntimeError("Config is not valid. Check conf files")
-def _parse_args(action):
+def _parse_args(action, *args):
parser = argparse.ArgumentParser('vdsm-tool %s' % (action))
allModules = [n.getName() for n in __configurers]
parser.add_argument(
@@ -334,7 +334,7 @@
action='store_true',
help='Force configuration, trigger services restart',
)
- args = parser.parse_args(sys.argv[2:])
+ args = parser.parse_args(args)
if not args.modules:
args.modules = allModules
return args
diff --git a/lib/vdsm/tool/dummybr.py b/lib/vdsm/tool/dummybr.py
index 59a43d2..9daafe6 100644
--- a/lib/vdsm/tool/dummybr.py
+++ b/lib/vdsm/tool/dummybr.py
@@ -23,7 +23,7 @@
from ..netinfo import DUMMY_BRIDGE
from .. import libvirtconnection, utils, constants
-from . import expose, VdsmToolRuntimeError
+from . import expose, VdsmToolRuntimeError, VdsmToolWrongArgsError
def createEphemeralBridge(bridgeName):
@@ -43,10 +43,15 @@
@expose('dummybr')
-def main():
+def main(*args):
"""
+ dummybr
Defines dummy bridge on libvirt network.
"""
+
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
if not os.path.exists('/sys/class/net/%s' % DUMMY_BRIDGE):
createEphemeralBridge(DUMMY_BRIDGE)
addBridgeToLibvirt(DUMMY_BRIDGE)
diff --git a/lib/vdsm/tool/load_needed_modules.py.in b/lib/vdsm/tool/load_needed_modules.py.in
index 8ebb1be..f65b5f5 100644
--- a/lib/vdsm/tool/load_needed_modules.py.in
+++ b/lib/vdsm/tool/load_needed_modules.py.in
@@ -21,7 +21,7 @@
import os.path
from .. import netinfo
-from . import expose, VdsmToolRuntimeError
+from . import expose, VdsmToolRuntimeError, VdsmToolWrongArgsError
from ..utils import execCmd
@@ -54,11 +54,15 @@
@expose('load-needed-modules')
-def load_needed_modules():
+def load_needed_modules(*args):
"""
+ load-needed-modules
Load needed modules
"""
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
for mod in ['bridge', 'tun', 'bonding', '8021q']:
_exec_command([EX_MODPROBE, mod])
_enable_bond_dev()
diff --git a/lib/vdsm/tool/nwfilter.py b/lib/vdsm/tool/nwfilter.py
index 25febc0..951061f 100755
--- a/lib/vdsm/tool/nwfilter.py
+++ b/lib/vdsm/tool/nwfilter.py
@@ -22,14 +22,18 @@
import logging
from .. import libvirtconnection
-from . import expose
+from . import expose, VdsmToolWrongArgsError
@expose('nwfilter')
-def main():
+def main(*args):
"""
+ nwfilter
Defines network filters on libvirt
"""
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
conn = libvirtconnection.get(None, False)
NoMacSpoofingFilter().defineNwFilter(conn)
conn.close()
diff --git a/lib/vdsm/tool/passwd.py b/lib/vdsm/tool/passwd.py
index 654d81d..ccd0ac8 100644
--- a/lib/vdsm/tool/passwd.py
+++ b/lib/vdsm/tool/passwd.py
@@ -20,14 +20,19 @@
import errno
import subprocess
from .. import constants
-from . import expose, VdsmToolRuntimeError
+from . import expose, VdsmToolRuntimeError, VdsmToolWrongArgsError
@expose("set-saslpasswd")
-def set_saslpasswd():
+def set_saslpasswd(*args):
"""
+ set-saslpasswd
Set vdsm password for libvirt connection
"""
+
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
script = ['/usr/sbin/saslpasswd2', '-p', '-a', 'libvirt',
constants.SASL_USERNAME]
diff --git a/lib/vdsm/tool/restore_nets.py b/lib/vdsm/tool/restore_nets.py
index 8ffe5d7..ddd6c2a 100644
--- a/lib/vdsm/tool/restore_nets.py
+++ b/lib/vdsm/tool/restore_nets.py
@@ -21,20 +21,27 @@
import sys
from .. import utils
-from . import expose, VdsmToolRuntimeError
+from . import expose, VdsmToolRuntimeError, VdsmToolWrongArgsError
from ..constants import P_VDSM
@expose('restore-nets')
-def restore(*args, **kwargs):
+def restore_command(*args):
"""
+ restore-nets
Restores the networks to what was previously persisted via vdsm.
"""
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+ restore(raiseType=VdsmToolRuntimeError)
+
+
+def restore(raiseType=RuntimeError):
rc, out, err = utils.execCmd([os.path.join(
P_VDSM, 'vdsm-restore-net-config')], raw=True)
sys.stdout.write(out)
sys.stderr.write(err)
if rc != 0:
- raise VdsmToolRuntimeError(
+ raise raiseType(
'Failed to restore the persisted networks'
)
diff --git a/lib/vdsm/tool/seboolsetup.py b/lib/vdsm/tool/seboolsetup.py
index f664ecd..c942f5d 100644
--- a/lib/vdsm/tool/seboolsetup.py
+++ b/lib/vdsm/tool/seboolsetup.py
@@ -18,7 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
-from . import expose
+from . import expose, VdsmToolWrongArgsError
SEBOOL_ENABLED = "on"
SEBOOL_DISABLED = "off"
@@ -54,12 +54,24 @@
@expose("sebool-config")
-def sebool_config():
- """Enable the required selinux booleans"""
+def sebool_config(*args):
+ """
+ sebool-config
+ Enable the required selinux booleans
+ """
+
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
setup_booleans(True)
@expose("sebool-unconfig")
-def sebool_unconfig():
- """Disable the required selinux booleans"""
+def sebool_unconfig(*args):
+ """
+ sebool-unconfig
+ Disable the required selinux booleans
+ """
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
setup_booleans(False)
diff --git a/lib/vdsm/tool/service.py b/lib/vdsm/tool/service.py
index 9c6f19c..d104cd9 100644
--- a/lib/vdsm/tool/service.py
+++ b/lib/vdsm/tool/service.py
@@ -27,7 +27,7 @@
import sys
from collections import defaultdict
-from . import expose, VdsmToolRuntimeError
+from . import expose, VdsmToolRuntimeError, VdsmToolWrongArgsError
from ..utils import CommandPath
from ..utils import execCmd as _execCmd
@@ -355,26 +355,56 @@
@expose("service-start")
+def service_start_command(cmdName, *args):
+ """
+ service-start service-name
+ Start a system service.
+
+ Parameters:
+ service-start - service to start
+ """
+ if len(args) != 1:
+ raise VdsmToolWrongArgsError()
+ return service_start(args[0])
+
+
def service_start(srvName):
- """
- Start a system service
- """
return _runAlts(_srvStartAlts, srvName)
@expose("service-stop")
+def service_stop_command(cmdName, *args):
+ """
+ service-stop service-name
+ Stop a system service.
+
+ Parameters:
+ service-name - service to stop
+ """
+ if len(args) != 1:
+ raise VdsmToolWrongArgsError()
+ return service_stop(args[0])
+
+
def service_stop(srvName):
- """
- Stop a system service
- """
return _runAlts(_srvStopAlts, srvName)
@expose("service-status")
+def service_status_command(cmdName, *args):
+ """
+ service-status service-name
+ Get status of a system service.
+
+ Parameters:
+ service-name - service to query
+ """
+ if len(args) != 1:
+ raise VdsmToolWrongArgsError()
+ return service_status(args[0])
+
+
def service_status(srvName, verbose=True):
- """
- Get status of a system service
- """
try:
return _runAlts(_srvStatusAlts, srvName)
except ServiceError as e:
@@ -384,34 +414,74 @@
@expose("service-restart")
+def service_restart_command(cmdName, *args):
+ """
+ service-restart service-name
+ Restart a system service.
+
+ Parameters:
+ service-name - service to restart
+ """
+ if len(args) != 1:
+ raise VdsmToolWrongArgsError()
+ return service_restart(args[0])
+
+
def service_restart(srvName):
- """
- Restart a system service
- """
return _runAlts(_srvRestartAlts, srvName)
@expose("service-reload")
+def service_reload_command(cmdName, *args):
+ """
+ service-reload service-name
+ Notify a system service to reload configurations.
+
+ Parameters:
+ service-name - service to notify
+ """
+ if len(args) != 1:
+ raise VdsmToolWrongArgsError()
+ return service_reload(args[0])
+
+
def service_reload(srvName):
- """
- Notify a system service to reload configurations
- """
return _runAlts(_srvReloadAlts, srvName)
@expose("service-disable")
+def service_disable_command(cmdName, *args):
+ """
+ service-disable service-name
+ Disable a system service.
+
+ Parameters:
+ service-name - service to disable
+ """
+ if len(args) != 1:
+ raise VdsmToolWrongArgsError()
+ return service_disable(args[0])
+
+
def service_disable(srvName):
- """
- Disable a system service
- """
return _runAlts(_srvDisableAlts, srvName)
@expose("service-is-managed")
+def service_is_managed_command(cmdName, *args):
+ """
+ service-is-managed service-name
+ Check the existence of a service.
+
+ Parameters:
+ service-name - service to query
+ """
+ if len(args) != 1:
+ raise VdsmToolWrongArgsError()
+ return service_is_managed(args[0])
+
+
def service_is_managed(srvName):
- """
- Check the existence of a service
- """
try:
return _runAlts(_srvIsManagedAlts, srvName)
except ServiceError as e:
diff --git a/lib/vdsm/tool/transient.py b/lib/vdsm/tool/transient.py
index d58e9fb..36190da 100644
--- a/lib/vdsm/tool/transient.py
+++ b/lib/vdsm/tool/transient.py
@@ -24,7 +24,7 @@
from .. import constants
from ..config import config
-from . import expose
+from . import expose, VdsmToolWrongArgsError
from ..utils import execCmd, CommandPath
@@ -40,8 +40,12 @@
@expose("setup-transient-repository")
def setup_transient_repository(*args):
"""
+ setup-transient-repository
Prepare the transient disks repository
"""
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
_, _, vdsm_uid, vdsm_gid, _, _, _ = pwd.getpwnam(constants.VDSM_USER)
try:
@@ -58,10 +62,14 @@
@expose("cleanup-transient-repository")
def cleanup_transient_repository(*args):
"""
+ cleanup-transient-repository
Cleanup the unused transient disks present in the repository.
(NOTE: it is recommended to NOT execute this command when the vdsm
daemon is running)
"""
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
transient_images = set(glob.glob(os.path.join(TRANSIENT_DISKS_REPO, "*")))
if len(transient_images) == 0:
diff --git a/lib/vdsm/tool/validate_ovirt_certs.py.in b/lib/vdsm/tool/validate_ovirt_certs.py.in
index 6a8c13f..4693f4a 100644
--- a/lib/vdsm/tool/validate_ovirt_certs.py.in
+++ b/lib/vdsm/tool/validate_ovirt_certs.py.in
@@ -21,7 +21,7 @@
import pwd
import shutil
-from . import expose
+from . import expose, VdsmToolWrongArgsError
from ..utils import execCmd
try:
@@ -44,12 +44,16 @@
@expose('validate-ovirt-certs')
-def validate_ovirt_certs():
+def validate_ovirt_certs(*args):
"""
+ validate-ovirt-certs
Validate vdsmcert.pem against cacert.pem.
If current cacert.pem is invalidate, it will find a validate certificate
file and replace the old cacert.pem with it. And then persist it.
"""
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
+
print "checking certs.."
uid, gid = pwd.getpwnam('vdsm')[2:4]
if not is_our_cafile(PATH_CACERT):
diff --git a/lib/vdsm/tool/vdsm-id.py b/lib/vdsm/tool/vdsm-id.py
index 2113621..8ea4abc 100644
--- a/lib/vdsm/tool/vdsm-id.py
+++ b/lib/vdsm/tool/vdsm-id.py
@@ -18,15 +18,18 @@
#
from ..utils import getHostUUID
-from . import expose, VdsmToolRuntimeError
+from . import expose, VdsmToolRuntimeError, VdsmToolWrongArgsError
import sys
@expose("vdsm-id")
-def getUUID():
+def getUUID(*args):
"""
+ vdsm-id
Printing host uuid
"""
+ if len(args) > 1:
+ raise VdsmToolWrongArgsError()
hostUUID = getHostUUID(False)
if hostUUID is None:
raise VdsmToolRuntimeError('Cannot retrieve host UUID')
diff --git a/vdsm-tool/vdsm-tool b/vdsm-tool/vdsm-tool
index 8eb4e52..d1ba58f 100755
--- a/vdsm-tool/vdsm-tool
+++ b/vdsm-tool/vdsm-tool
@@ -148,7 +148,10 @@
usage_and_exit(1)
try:
- return tool_command[cmd]["command"](*args[1:])
+ return tool_command[cmd]["command"](*args)
+ except vdsm.tool.VdsmToolWrongArgsError as e:
+ print >> sys.stderr, 'usage:', sys.argv[0], '[options]', \
+ tool_command[cmd]["command"].__doc__.lstrip()
except vdsm.tool.VdsmToolRuntimeError as e:
print >> sys.stderr, 'Error:', e
except Exception:
--
To view, visit http://gerrit.ovirt.org/26575
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I831bde947f451805e086e25f1c0b9943b17e7bd8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuznets(a)redhat.com>
10 years
Change in vdsm[master]: vdsm-tool: Change exception reporting
by dkuznets@redhat.com
Dima Kuznetsov has uploaded a new change for review.
Change subject: vdsm-tool: Change exception reporting
......................................................................
vdsm-tool: Change exception reporting
Introduced VdsmToolRuntimeError as the root class for all the errors
that vdsm-tool expects to encounter and wants to present to the user.
Those errors are just printed to the screen preceded by "Error:" and do
not generate a stack trace.
Change-Id: I467d1e5ef7503312cde6e013aacb68dc2d46dd37
Signed-off-by: Dima Kuznetsov <dkuznets(a)redhat.com>
---
M lib/vdsm/tool/__init__.py
M lib/vdsm/tool/configurator.py
M lib/vdsm/tool/dummybr.py
M lib/vdsm/tool/load_needed_modules.py.in
M lib/vdsm/tool/passwd.py
M lib/vdsm/tool/restore_nets.py
M lib/vdsm/tool/service.py
M lib/vdsm/tool/vdsm-id.py
M vdsm-tool/vdsm-tool
9 files changed, 48 insertions(+), 25 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/26565/1
diff --git a/lib/vdsm/tool/__init__.py b/lib/vdsm/tool/__init__.py
index 49f3767..863ad51 100644
--- a/lib/vdsm/tool/__init__.py
+++ b/lib/vdsm/tool/__init__.py
@@ -25,3 +25,12 @@
def __call__(self, fun):
fun._vdsm_tool = {"name": self.name}
return fun
+
+
+class VdsmToolRuntimeError(Exception):
+ pass
+
+
+class VdsmToolNotRootError(VdsmToolRuntimeError):
+ def __init__(self):
+ VdsmToolRuntimeError.__init__(self, "Must run as root")
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index f0944f3..601288f 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -23,7 +23,7 @@
import argparse
from .. import utils
-from . import service, expose
+from . import service, expose, VdsmToolRuntimeError, VdsmToolNotRootError
from ..constants import P_VDSM_EXEC, QEMU_PROCESS_GROUP, \
SANLOCK_USER, VDSM_GROUP
@@ -70,7 +70,7 @@
Invoke libvirt_configure.sh script
"""
if os.getuid() != 0:
- raise UserWarning("Must run as root")
+ raise VdsmToolNotRootError()
env = os.environ.copy()
for k, v in self.env_override.items():
@@ -88,7 +88,7 @@
sys.stdout.write(out)
sys.stderr.write(err)
if rc != 0:
- raise RuntimeError("Failed to perform libvirt action.")
+ raise VdsmToolRuntimeError("Failed to perform libvirt action.")
def _get_libvirt_exec(self):
return (os.path.join(P_VDSM_EXEC, 'libvirt_configure.sh'), )
@@ -103,7 +103,7 @@
try:
self._exec_libvirt_configure("test_conflict_configurations")
return True
- except RuntimeError:
+ except VdsmToolRuntimeError:
return False
def isconfigured(self):
@@ -113,7 +113,7 @@
try:
self._exec_libvirt_configure("check_if_configured")
return True
- except RuntimeError:
+ except VdsmToolRuntimeError:
return False
@@ -135,7 +135,7 @@
Configure sanlock process groups
"""
if os.getuid() != 0:
- raise UserWarning("Must run as root")
+ raise VdsmToolNotRootError()
rc, out, err = utils.execCmd(
(
@@ -150,7 +150,7 @@
sys.stdout.write(out)
sys.stderr.write(err)
if rc != 0:
- raise RuntimeError("Failed to perform sanlock config.")
+ raise VdsmToolRuntimeError("Failed to perform sanlock config.")
def isconfigured(self):
"""
@@ -171,7 +171,9 @@
strip().split(" ")]
break
else:
- raise RuntimeError("Unable to find sanlock service groups")
+ raise VdsmToolRuntimeError(
+ "Unable to find sanlock service groups"
+ )
is_sanlock_groups_set = True
for g in self.SANLOCK_GROUPS:
@@ -219,7 +221,7 @@
if c.getName() in args.modules:
override = args.force and c.reconfigureOnForce()
if not override and not c.validate():
- raise RuntimeError(
+ raise VdsmToolRuntimeError(
"Configuration of %s is invalid" % c.getName()
)
if override or not c.isconfigured():
@@ -230,7 +232,7 @@
for s in c.getServices():
if service.service_status(s, False) == 0:
if not args.force:
- raise RuntimeError(
+ raise VdsmToolRuntimeError(
"\n\nCannot configure while service '%s' is "
"running.\n Stop the service manually or use the "
"--force flag.\n" % s
@@ -281,7 +283,7 @@
(The force flag will stop the module's service and start it
afterwards automatically to load the new configuration.)
"""
- raise RuntimeError(msg)
+ raise VdsmToolRuntimeError(msg)
@expose("validate-config")
@@ -304,7 +306,7 @@
ret = False
if not ret:
- raise RuntimeError("Config is not valid. Check conf files")
+ raise VdsmToolRuntimeError("Config is not valid. Check conf files")
def _parse_args(action):
diff --git a/lib/vdsm/tool/dummybr.py b/lib/vdsm/tool/dummybr.py
index d5825f2..59a43d2 100644
--- a/lib/vdsm/tool/dummybr.py
+++ b/lib/vdsm/tool/dummybr.py
@@ -23,14 +23,15 @@
from ..netinfo import DUMMY_BRIDGE
from .. import libvirtconnection, utils, constants
-from . import expose
+from . import expose, VdsmToolRuntimeError
def createEphemeralBridge(bridgeName):
rc, out, err = utils.execCmd([constants.EXT_BRCTL, 'addbr', bridgeName])
if rc != 0:
- raise Exception('Failed to create ephemeral dummy bridge. Err: %s' %
- err)
+ raise VdsmToolRuntimeError(
+ 'Failed to create ephemeral dummy bridge. Err: %s' % err
+ )
def addBridgeToLibvirt(bridgeName):
diff --git a/lib/vdsm/tool/load_needed_modules.py.in b/lib/vdsm/tool/load_needed_modules.py.in
index 1be9448..8ebb1be 100644
--- a/lib/vdsm/tool/load_needed_modules.py.in
+++ b/lib/vdsm/tool/load_needed_modules.py.in
@@ -21,7 +21,7 @@
import os.path
from .. import netinfo
-from . import expose
+from . import expose, VdsmToolRuntimeError
from ..utils import execCmd
@@ -34,7 +34,9 @@
"""
rc, out, err = execCmd(argv, raw=True)
if rc != 0:
- raise Exception("Execute command %s failed: %s" % (argv, err))
+ raise VdsmToolRuntimeError(
+ "Execute command %s failed: %s" % (argv, err)
+ )
def _enable_bond_dev():
diff --git a/lib/vdsm/tool/passwd.py b/lib/vdsm/tool/passwd.py
index 71e6c1c..654d81d 100644
--- a/lib/vdsm/tool/passwd.py
+++ b/lib/vdsm/tool/passwd.py
@@ -20,7 +20,7 @@
import errno
import subprocess
from .. import constants
-from . import expose
+from . import expose, VdsmToolRuntimeError
@expose("set-saslpasswd")
@@ -43,4 +43,4 @@
stderr=subprocess.PIPE, close_fds=True)
output, err = p.communicate()
if p.returncode != 0:
- raise RuntimeError("Set password failed: %s" % (err,))
+ raise VdsmToolRuntimeError("Set password failed: %s" % (err,))
diff --git a/lib/vdsm/tool/restore_nets.py b/lib/vdsm/tool/restore_nets.py
index c2a0dcc..8ffe5d7 100644
--- a/lib/vdsm/tool/restore_nets.py
+++ b/lib/vdsm/tool/restore_nets.py
@@ -21,7 +21,7 @@
import sys
from .. import utils
-from . import expose
+from . import expose, VdsmToolRuntimeError
from ..constants import P_VDSM
@@ -35,4 +35,6 @@
sys.stdout.write(out)
sys.stderr.write(err)
if rc != 0:
- raise Exception('Failed to restore the persisted networks')
+ raise VdsmToolRuntimeError(
+ 'Failed to restore the persisted networks'
+ )
diff --git a/lib/vdsm/tool/service.py b/lib/vdsm/tool/service.py
index 444ef80..9c6f19c 100644
--- a/lib/vdsm/tool/service.py
+++ b/lib/vdsm/tool/service.py
@@ -27,7 +27,7 @@
import sys
from collections import defaultdict
-from . import expose
+from . import expose, VdsmToolRuntimeError
from ..utils import CommandPath
from ..utils import execCmd as _execCmd
@@ -75,7 +75,7 @@
_srvIsManagedAlts = []
-class ServiceError(RuntimeError):
+class ServiceError(VdsmToolRuntimeError):
def __init__(self, message, out=None, err=None):
self.out = out
self.err = err
diff --git a/lib/vdsm/tool/vdsm-id.py b/lib/vdsm/tool/vdsm-id.py
index ac5faae..2113621 100644
--- a/lib/vdsm/tool/vdsm-id.py
+++ b/lib/vdsm/tool/vdsm-id.py
@@ -18,7 +18,7 @@
#
from ..utils import getHostUUID
-from . import expose
+from . import expose, VdsmToolRuntimeError
import sys
@@ -29,6 +29,6 @@
"""
hostUUID = getHostUUID(False)
if hostUUID is None:
- raise RuntimeError('Cannot retrieve host UUID')
+ raise VdsmToolRuntimeError('Cannot retrieve host UUID')
sys.stdout.write(hostUUID)
return 0
diff --git a/vdsm-tool/vdsm-tool b/vdsm-tool/vdsm-tool
index 8bdf1bc..8eb4e52 100755
--- a/vdsm-tool/vdsm-tool
+++ b/vdsm-tool/vdsm-tool
@@ -149,9 +149,16 @@
try:
return tool_command[cmd]["command"](*args[1:])
+ except vdsm.tool.VdsmToolRuntimeError as e:
+ print >> sys.stderr, 'Error:', e
except Exception:
traceback.print_exc(file=sys.stderr)
return 1
+ except KeyboardInterrupt:
+ print "Interrupted"
+ return 1
+ except SystemExit:
+ return 1
if __name__ == "__main__":
sys.exit(main())
--
To view, visit http://gerrit.ovirt.org/26565
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I467d1e5ef7503312cde6e013aacb68dc2d46dd37
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuznets(a)redhat.com>
10 years
Change in vdsm[master]: agent: Only forward desktopLogin when the agent is responsive
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: agent: Only forward desktopLogin when the agent is responsive
......................................................................
agent: Only forward desktopLogin when the agent is responsive
Change-Id: Ie1c65304319df949795ec0906df1343a43129641
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M vdsm/virt/guestagent.py
1 file changed, 13 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/27147/1
diff --git a/vdsm/virt/guestagent.py b/vdsm/virt/guestagent.py
index 5098da1..5e78b36 100644
--- a/vdsm/virt/guestagent.py
+++ b/vdsm/virt/guestagent.py
@@ -353,16 +353,19 @@
self.log.error("desktopLock failed", exc_info=True)
def desktopLogin(self, domain, user, password):
- try:
- self.log.debug("desktopLogin called")
- if domain != '':
- username = user + '@' + domain
- else:
- username = user
- self._forward('login', {'username': username,
- "password": password})
- except:
- self.log.error("desktopLogin failed", exc_info=True)
+ if self.isResponsive():
+ try:
+ self.log.debug("desktopLogin called")
+ if domain != '':
+ username = user + '@' + domain
+ else:
+ username = user
+ self._forward('login', {'username': username,
+ "password": password})
+ except:
+ self.log.error("desktopLogin failed", exc_info=True)
+ else:
+ self.log.info("desktopLogin called but guest agent not responsive")
def desktopLogoff(self, force):
try:
--
To view, visit http://gerrit.ovirt.org/27147
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1c65304319df949795ec0906df1343a43129641
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
10 years
Change in vdsm[master]: tests: fix read not blocksize aligned
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: tests: fix read not blocksize aligned
......................................................................
tests: fix read not blocksize aligned
starting with linux 3.14.1-200.fc20.x86_64 and dd (coreutils) 8.21
the direct I/O read started to fail with (message trimmed for breviry)
Storage.Misc.excCmd: DEBUG: FAILED: <err> = "/usr/bin/dd: error reading
'/tmp/tmp53guul': Invalid argument\n0+1 records in\n0+1 records out\n131
bytes (131 B) copied, 0.0020193 s, 64.9 kB/s\n"; <rc> = 1
Evidence suggests this is due by the fact the data to be read is not
a multiple of the block size (dd default block size is 512b; ext4 is
4k). Unfortunately. I still haven't found any document which confirm
this, either from the kernel or from the coreutils camp.
This patch fixes this issue locally.
Please note this patch addresses only tests, since I run my VDSM
on older kernels.
Change-Id: I7a77133e8dfa719195958228b4fc69314bab4354
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/miscTests.py
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/27/27127/1
diff --git a/tests/miscTests.py b/tests/miscTests.py
index 69cf690..44cb2b2 100644
--- a/tests/miscTests.py
+++ b/tests/miscTests.py
@@ -50,6 +50,8 @@
SUDO_USER = "root"
SUDO_GROUP = "root"
+BLOCK_SIZE = 512 # bytes
+
def watchCmd(cmd, stop, cwd=None, data=None, recoveryCallback=None):
ret, out, err = utils.watchCmd(cmd, stop, cwd=cwd, data=data,
@@ -856,7 +858,8 @@
# create
writeData = ("Trust me, I know what self-loathing is,"
"but to kill myself? That would put a damper on my "
- "search for answers. Not at all productive.")
+ "search for answers. Not at all "
+ "productive.".zfill(BLOCK_SIZE))
# (C) Jhonen Vasquez - Johnny the Homicidal Maniac
with temporaryPath(data=writeData) as path:
# read
--
To view, visit http://gerrit.ovirt.org/27127
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a77133e8dfa719195958228b4fc69314bab4354
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
10 years