Change in vdsm[master]: Memory Hotplug
by vdelima@redhat.com
Vitor de Lima has uploaded a new change for review.
Change subject: Memory Hotplug
......................................................................
Memory Hotplug
Introduces a new method to increase the amount of memory of a guest
and exposes it in the XML-RPC and JSON-RPC.
Change-Id: I82bb7d1f7eaaca67b0ceebb4e782ea36541c81c0
Signed-off-by: Vitor de Lima <vdelima(a)redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/Bridge.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/vm.py
6 files changed, 61 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/35080/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 9091644..2022391 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -306,6 +306,9 @@
params = {'vmId': args[0], 'drive': drive}
return self.ExecAndExit(self.s.hotunplugDisk(params))
+ def setAmountOfMemory(self, args):
+ return self.ExecAndExit(self.s.setAmountOfMemory(args[0], args[1]))
+
def setNumberOfCpus(self, args):
return self.ExecAndExit(self.s.setNumberOfCpus(args[0], args[1]))
@@ -2696,6 +2699,11 @@
'<vmId> <spUUID> <sdUUID> <imgUUID> <volUUID> <newSize>',
'Extends the virtual size of a disk'
)),
+ 'setAmountOfMemory': (
+ serv.setAmountOfMemory, (
+ '<vmId> <amountOfMemory>',
+ 'set the amount of memory for a running VM'
+ )),
'setNumberOfCpus': (
serv.setNumberOfCpus, (
'<vmId> <numberOfCpus>',
diff --git a/vdsm/API.py b/vdsm/API.py
index 1ef4b00..3fd81fa 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -467,6 +467,23 @@
return curVm.hotunplugDisk(params)
+ def setAmountOfMemory(self, amountOfMemory):
+
+ if self._UUID is None or amountOfMemory is None:
+ self.log.error('Missing one of required parameters: \
+ vmId: (%s), amountOfMemory: (%s)', self._UUID, amountOfMemory)
+ return {'status': {'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing one of required '
+ 'parameters: vmId, amountOfMemory'}}
+
+ try:
+ curVm = self._cif.vmContainer[self._UUID]
+ except KeyError:
+ self.log.warning("vm %s doesn't exist", self._UUID)
+ return errCode['noVM']
+
+ return curVm.setAmountOfMemory(int(amountOfMemory))
+
def setNumberOfCpus(self, numberOfCpus):
if self._UUID is None or numberOfCpus is None:
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 0164691..25f35e6 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -427,6 +427,10 @@
vm = API.VM(vmId)
return vm.updateDevice(params)
+ def vmSetAmountOfMemory(self, vmId, amountOfMemory):
+ vm = API.VM(vmId)
+ return vm.setAmountOfMemory(amountOfMemory)
+
def vmSetNumberOfCpus(self, vmId, numberOfCpus):
vm = API.VM(vmId)
return vm.setNumberOfCpus(numberOfCpus)
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index f894758..465a3ac 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -451,6 +451,7 @@
'VM_hotunplugNic': {'ret': 'vmList'},
'VM_mergeStatus': {'ret': 'mergeStatus'},
'VM_migrationCreate': {'ret': VM_migrationCreate_Ret},
+ 'VM_setAmountOfMemory': {'ret': 'vmList'},
'VM_setNumberOfCpus': {'ret': 'vmList'},
'VM_getIoTunePolicy': {'ret': 'ioTunePolicyList'},
'VM_updateDevice': {'ret': 'vmList'},
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 624b686..8169c76 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -7772,6 +7772,24 @@
'legality': 'VolumeLegality'}}
##
+# @VM.setAmountOfMemory:
+#
+# Set the amount of memory for a VM
+#
+# @vmID: The UUID of the VM
+#
+# @amountOfMemory: The new amount of memory
+#
+# Returns:
+# The VM definition, as updated
+#
+# Since: ?
+##
+{'command': {'class': 'VM', 'name': 'setAmountOfMemory'},
+ 'data': {'vmID': 'UUID', 'amountOfMemory': 'int'},
+ 'returns': 'VmDefinition'}
+
+##
# @VM.setNumberOfCpus:
#
# Set the number CPUs for a VM
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index eaa609c..5c3b3f1 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3071,6 +3071,19 @@
params=nic.custom)
return {'status': doneCode, 'vmList': self.status()}
+ def setAmountOfMemory(self, amountOfMemory):
+
+ if self.isMigrating():
+ return errCode['migInProgress']
+
+ self.log.debug("Setting amount of memory to : %s", amountOfMemory)
+
+ # FIXME call libvirt to set the amount of memory
+
+ self.saveState()
+
+ return {'status': doneCode, 'vmList': self.status()}
+
def setNumberOfCpus(self, numberOfCpus):
if self.isMigrating():
--
To view, visit http://gerrit.ovirt.org/35080
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I82bb7d1f7eaaca67b0ceebb4e782ea36541c81c0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vitor de Lima <vdelima(a)redhat.com>
9 years, 6 months
Change in vdsm[ovirt-3.5]: vdsm-reg: Fix closed log file descriptors
by ybronhei@redhat.com
Hello Dima Kuznetsov, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/35120
to review the following change.
Change subject: vdsm-reg: Fix closed log file descriptors
......................................................................
vdsm-reg: Fix closed log file descriptors
When calling createDaemon(), all file descriptors are closed, including
the file descriptors held by log handlers. This patch moves logging
configuration below the daemonization to make sure the file descriptors
stay open.
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1150238
Change-Id: Ida11e61aea18fbb2990176889423d2c4b6292a09
Signed-off-by: Dima Kuznetsov <dkuznets(a)redhat.com>
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
Reviewed-on: http://gerrit.ovirt.org/34981
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm_reg/vdsm-reg-setup.in
1 file changed, 9 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/35120/1
diff --git a/vdsm_reg/vdsm-reg-setup.in b/vdsm_reg/vdsm-reg-setup.in
index 804183f..7fc8943 100644
--- a/vdsm_reg/vdsm-reg-setup.in
+++ b/vdsm_reg/vdsm-reg-setup.in
@@ -352,19 +352,21 @@
pidfile = config.get('vars', 'pidfile')
sleepTime = float(config.get('vars', 'reg_req_interval'))
- loggerConf = config.get('vars', 'logger_conf')
- logging.config.fileConfig(loggerConf, disable_existing_loggers=False)
- log = logging.getLogger('')
-
- _createUpgradeDir(os.path.dirname(config.get('vars', 'upgrade_iso_file')))
-
try:
if daemonize:
createDaemon.createDaemon()
+
+ loggerConf = config.get('vars', 'logger_conf')
+ logging.config.fileConfig(loggerConf, disable_existing_loggers=False)
+ log = logging.getLogger('')
+
if daemonize:
log = logging.getLogger('vdsRegistrator')
if not daemonize:
log.handlers.append(logging.StreamHandler())
+
+ _createUpgradeDir(
+ os.path.dirname(config.get('vars', 'upgrade_iso_file')))
log.info("After daemonize - My pid is %d", os.getpid())
file(pidfile, 'w').write(str(os.getpid()) + "\n")
@@ -396,10 +398,10 @@
itr,
sleepTime+nRandom
)
+ log.info("Exiting ....")
finally:
if pidfile and os.path.exists(pidfile):
os.unlink(pidfile)
- log.info("Exiting ....")
def usage():
--
To view, visit http://gerrit.ovirt.org/35120
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida11e61aea18fbb2990176889423d2c4b6292a09
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Dima Kuznetsov <dkuznets(a)redhat.com>
9 years, 6 months
Change in vdsm[master]: vm: state change missing return value
by fromani@redhat.com
Francesco Romani has posted comments on this change.
Change subject: vm: state change missing return value
......................................................................
Patch Set 1: Code-Review+1 Verified+1
I don't know a better way to fix this, and this solves my reproducer:
VDSM:
Thread-100::DEBUG::2014-11-13 13:05:38,935::__init__::502::jsonrpc.JsonRpcServer::(_serveRequest) Return 'VM.cont' in bridge with {'vmList': {}}
Thread-100::DEBUG::2014-11-13 13:05:38,935::__init__::143::root::(encode) sending back: {"jsonrpc": "2.0", "id": "4a653b70-05ca-4c4d-a70f-92ded559e43f", "result": {"vmList": {}}}
Thread-100::DEBUG::2014-11-13 13:05:38,935::stompReactor::163::yajsonrpc.StompServer::(send) Sending response
libvirtEventLoop::DEBUG::2014-11-13 13:05:39,010::vm::5381::vm.Vm::(_logGuestCpuStatus) vmId=`2ba1a9eb-5843-466a-a5e5-530a9c06447b`::CPU running: onResume
libvirtEventLoop::DEBUG::2014-11-13 13:05:39,010::vm::4919::vm.Vm::(_onLibvirtLifecycleEvent) vmId=`2ba1a9eb-5843-466a-a5e5-530a9c06447b`::event Resumed detail 0 opaque None
libvirtEventLoop::DEBUG::2014-11-13 13:05:39,011::vm::5381::vm.Vm::(_logGuestCpuStatus) vmId=`2ba1a9eb-5843-466a-a5e5-530a9c06447b`::CPU running: onResume
JsonRpc (StompReactor)::DEBUG::2014-11-13 13:05:39,208::stompReactor::98::Broker.StompAdapter::(handle_frame) Handling message <StompFrame command='SEND'>
JsonRpcServer::DEBUG::2014-11-13 13:05:39,209::__init__::508::jsonrpc.JsonRpcServer::(serve_requests) Waiting for request
Engine:
2014-11-13 13:05:38,194 INFO [org.ovirt.engine.core.bll.RunVmCommand] (http--0.0.0.0-8080-4) [668a01e3] Lock Acquired to object 'EngineLock [exclusiveLocks= key: 2ba1a9eb-5843-466a-a5e5-530a9c06447b value: VM
, sharedLocks= ]'
2014-11-13 13:05:38,318 INFO [org.ovirt.engine.core.bll.RunVmCommand] (org.ovirt.thread.pool-8-thread-37) [668a01e3] Running command: RunVmCommand internal: false. Entities affected : ID: 2ba1a9eb-5843-466a-a5e5-530a9c06447b Type: VMAction group VM_BASIC_OPERATIONS with role type USER
2014-11-13 13:05:38,324 INFO [org.ovirt.engine.core.vdsbroker.ResumeVDSCommand] (org.ovirt.thread.pool-8-thread-37) [668a01e3] START, ResumeVDSCommand(HostName = toji, HostId = 4afae575-0864-4583-93a7-e67d4e4de4ba, vmId=2ba1a9eb-5843-466a-a5e5-530a9c06447b), log id: 64a8a0af
2014-11-13 13:05:38,330 INFO [org.ovirt.engine.core.vdsbroker.vdsbroker.ResumeBrokerVDSCommand] (org.ovirt.thread.pool-8-thread-37) [668a01e3] START, ResumeBrokerVDSCommand(HostName = toji, HostId = 4afae575-0864-4583-93a7-e67d4e4de4ba, vmId=2ba1a9eb-5843-466a-a5e5-530a9c06447b), log id: 17d5fe23
2014-11-13 13:05:38,408 INFO [org.ovirt.engine.core.vdsbroker.vdsbroker.ResumeBrokerVDSCommand] (org.ovirt.thread.pool-8-thread-37) [668a01e3] FINISH, ResumeBrokerVDSCommand, log id: 17d5fe23
2014-11-13 13:05:38,410 INFO [org.ovirt.engine.core.vdsbroker.ResumeVDSCommand] (org.ovirt.thread.pool-8-thread-37) [668a01e3] FINISH, ResumeVDSCommand, return: PoweringUp, log id: 64a8a0af
2014-11-13 13:05:38,412 INFO [org.ovirt.engine.core.bll.RunVmCommand] (org.ovirt.thread.pool-8-thread-37) [668a01e3] Lock freed to object 'EngineLock [exclusiveLocks= key: 2ba1a9eb-5843-466a-a5e5-530a9c06447b value: VM
, sharedLocks= ]'
2014-11-13 13:05:38,459 INFO [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (org.ovirt.thread.pool-8-thread-37) [668a01e3] Correlation ID: 668a01e3, Job ID: dcdb5701-e484-4482-a3a6-0672a2dab68f, Call Stack: null, Custom Event ID: -1, Message: VM NS_C001 was resumed by admin (Host: toji).
2014-11-13 13:05:38,685 INFO [org.ovirt.engine.core.vdsbroker.VdsUpdateRunTimeInfo] (DefaultQuartzScheduler_Worker-99) [] VM NS_C001 2ba1a9eb-5843-466a-a5e5-530a9c06447b moved from Paused --> PoweringUp
2014-11-13 13:06:16,483 INFO [org.ovirt.engine.core.bll.SetVmTicketCommand] (http--0.0.0.0-8080-4) [2310d22d] Running command: SetVmTicketCommand internal: false. Entities affected : ID: 2ba1a9eb-5843-466a-a5e5-530a9c06447b Type: VMAction group CONNECT_TO_VM with role type USER
2014-11-13 13:06:16,503 INFO [org.ovirt.engine.core.vdsbroker.vdsbroker.SetVmTicketVDSCommand] (http--0.0.0.0-8080-4) [2310d22d] START, SetVmTicketVDSCommand(HostName = toji, HostId = 4afae575-0864-4583-93a7-e67d4e4de4ba, vmId=2ba1a9eb-5843-466a-a5e5-530a9c06447b, ticket=3eaYsvnA+JSb, validTime=120,m userName=admin, userId=fdfc627c-d875-11e0-90f0-83df133b58cc), log id: 13bb8a5
2014-11-13 13:06:16,544 INFO [org.ovirt.engine.core.vdsbroker.vdsbroker.SetVmTicketVDSCommand] (http--0.0.0.0-8080-4) [2310d22d] FINISH, SetVmTicketVDSCommand, log id: 13bb8a5
2014-11-13 13:06:16,587 INFO [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (http--0.0.0.0-8080-4) [2310d22d] Correlation ID: 2310d22d, Call Stack: null, Custom Event ID: -1, Message: user admin initiated console session for VM NS_C001
2014-11-13 13:06:19,501 INFO [org.ovirt.engine.core.vdsbroker.VdsUpdateRunTimeInfo] (DefaultQuartzScheduler_Worker-40) [] VM NS_C001 2ba1a9eb-5843-466a-a5e5-530a9c06447b moved from PoweringUp --> Up
2014-11-13 13:06:19,595 INFO [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (DefaultQuartzScheduler_Worker-40) [] Correlation ID: 668a01e3, Job ID: dcdb5701-e484-4482-a3a6-0672a2dab68f, Call Stack: null, Custom Event ID: -1, Message: VM NS_C001 started on Host toji
2014-11-13 13:06:22,763 INFO [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (DefaultQuartzScheduler_Worker-49) [] Correlation ID: null, Call Stack: null, Custom Event ID: -1, Message: User admin is connected to VM NS_C001.
2014-11-13 13:08:21,119 INFO [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (DefaultQuartzScheduler_Worker-29) [] Correlation ID: null, Call Stack: null, Custom Event ID: -1, Message: User admin got disconnected from VM NS_C001.
2014-11-13 13:08:21,768 INFO [org.ovirt.engine.core.bll.HibernateVmCommand] (http--0.0.0.0-8080-4) [1b325763] Lock Acquired to object 'EngineLock [exclusiveLocks= key: 2ba1a9eb-5843-466a-a5e5-530a9c06447b value: VM
--
To view, visit http://gerrit.ovirt.org/35105
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: If0737403dcfa0ccd0a3c2813b215b4d5fa958eca
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
9 years, 6 months
Change in vdsm[ovirt-3.5.0]: vdsm-reg: Fix closed log file descriptors
by ybronhei@redhat.com
Hello Dima Kuznetsov, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/35121
to review the following change.
Change subject: vdsm-reg: Fix closed log file descriptors
......................................................................
vdsm-reg: Fix closed log file descriptors
When calling createDaemon(), all file descriptors are closed, including
the file descriptors held by log handlers. This patch moves logging
configuration below the daemonization to make sure the file descriptors
stay open.
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1150238
Change-Id: Ida11e61aea18fbb2990176889423d2c4b6292a09
Signed-off-by: Dima Kuznetsov <dkuznets(a)redhat.com>
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
Reviewed-on: http://gerrit.ovirt.org/34981
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm_reg/vdsm-reg-setup.in
1 file changed, 9 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/35121/1
diff --git a/vdsm_reg/vdsm-reg-setup.in b/vdsm_reg/vdsm-reg-setup.in
index 804183f..7fc8943 100644
--- a/vdsm_reg/vdsm-reg-setup.in
+++ b/vdsm_reg/vdsm-reg-setup.in
@@ -352,19 +352,21 @@
pidfile = config.get('vars', 'pidfile')
sleepTime = float(config.get('vars', 'reg_req_interval'))
- loggerConf = config.get('vars', 'logger_conf')
- logging.config.fileConfig(loggerConf, disable_existing_loggers=False)
- log = logging.getLogger('')
-
- _createUpgradeDir(os.path.dirname(config.get('vars', 'upgrade_iso_file')))
-
try:
if daemonize:
createDaemon.createDaemon()
+
+ loggerConf = config.get('vars', 'logger_conf')
+ logging.config.fileConfig(loggerConf, disable_existing_loggers=False)
+ log = logging.getLogger('')
+
if daemonize:
log = logging.getLogger('vdsRegistrator')
if not daemonize:
log.handlers.append(logging.StreamHandler())
+
+ _createUpgradeDir(
+ os.path.dirname(config.get('vars', 'upgrade_iso_file')))
log.info("After daemonize - My pid is %d", os.getpid())
file(pidfile, 'w').write(str(os.getpid()) + "\n")
@@ -396,10 +398,10 @@
itr,
sleepTime+nRandom
)
+ log.info("Exiting ....")
finally:
if pidfile and os.path.exists(pidfile):
os.unlink(pidfile)
- log.info("Exiting ....")
def usage():
--
To view, visit http://gerrit.ovirt.org/35121
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida11e61aea18fbb2990176889423d2c4b6292a09
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5.0
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Dima Kuznetsov <dkuznets(a)redhat.com>
9 years, 6 months
Change in vdsm[master]: context manager for dhclient in functional tests
by ibarkan@redhat.com
Ido Barkan has uploaded a new change for review.
Change subject: context manager for dhclient in functional tests
......................................................................
context manager for dhclient in functional tests
the context manager kills dhclient process that
outlive the functional test
Change-Id: I458aa38415c697d3863e173444ff921d759166a2
Signed-off-by: ibarkan <ibarkan(a)redhat.com>
---
M tests/functional/dhcp.py
M tests/functional/networkTests.py
M tests/tcTests.py
3 files changed, 80 insertions(+), 41 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/34366/1
diff --git a/tests/functional/dhcp.py b/tests/functional/dhcp.py
index 28d1220..9895827 100644
--- a/tests/functional/dhcp.py
+++ b/tests/functional/dhcp.py
@@ -16,9 +16,11 @@
#
# Refer to the README and COPYING files for full details of the license
#
+from contextlib import contextmanager
import logging
import os
+from signal import SIGKILL
from time import sleep
from nose.plugins.skip import SkipTest
@@ -65,29 +67,54 @@
logging.debug(''.join(self.proc.stderr))
-def runDhclient(interface, tmpDir, dateFormat):
+class _DhclientRunner(object):
"""On the interface, dhclient is run to obtain a DHCP lease.
- In the working directory (tmpDir), which is managed by the caller,
- a lease file is created and a path to it is returned.
- dhclient accepts the following dateFormats: 'default' and 'local'.
+ In the working directory (tmp_dir), which is managed by the caller.
+ dhclient accepts the following date_formats: 'default' and 'local'.
"""
- confFile = os.path.join(tmpDir, 'test.conf')
- pidFile = os.path.join(tmpDir, 'test.pid')
- leaseFile = os.path.join(tmpDir, 'test.lease')
+ def __init__(self, interface, tmp_dir, date_format):
+ self._interface = interface
+ self._date_format = date_format
+ self._conf_file = os.path.join(tmp_dir, 'test.conf')
+ self._pid_file = os.path.join(tmp_dir, 'test.pid')
+ self.pid = None
+ self.lease_file = os.path.join(tmp_dir, 'test.lease')
+ self._create_conf()
- with open(confFile, 'w') as f:
- f.write('db-time-format {0};'.format(dateFormat))
+ def _create_conf(self):
+ with open(self._conf_file, 'w') as f:
+ f.write('db-time-format {0};'.format(self._date_format))
- rc, out, err = execCmd([_DHCLIENT_BINARY.cmd, '-lf', leaseFile,
- '-pf', pidFile, '-timeout', str(_DHCLIENT_TIMEOUT),
- '-1', '-cf', confFile, interface])
+ def run(self):
+ rc, out, err = execCmd([_DHCLIENT_BINARY.cmd, '-v', '-lf',
+ self.lease_file, '-pf', self._pid_file,
+ '-timeout', str(_DHCLIENT_TIMEOUT), '-1',
+ '-cf', self._conf_file, self._interface])
- if rc: # == 2
- logging.debug(''.join(err))
- raise DhcpError('dhclient failed to obtain a lease: %d', rc)
+ if rc: # == 2
+ logging.debug(''.join(err))
+ raise DhcpError('dhclient failed to obtain a lease: %d', rc)
- return leaseFile
+ with open(self._pid_file) as pid_fd:
+ self.pid = int(pid_fd.read())
+
+ def kill(self):
+ if self.pid:
+ try:
+ os.kill(self.pid, SIGKILL)
+ except OSError:
+ pass # No such process
+
+
+@contextmanager
+def dhclient(interface, tmpDir, dateFormat):
+ dhclient_runner = _DhclientRunner(interface, tmpDir, dateFormat)
+ try:
+ dhclient_runner.run()
+ yield dhclient_runner
+ finally:
+ dhclient_runner.kill()
def addNMplaceholderConnection(interface, connection):
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 34741ab..d1fa007 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -1991,9 +1991,9 @@
with dnsmasqDhcp(server):
with namedTemporaryDir(dir='/var/lib/dhclient') as dir:
- leaseFile = dhcp.runDhclient(client, dir, dateFormat)
-
- dhcp4 = getDhclientIfaces([leaseFile])
+ with dhcp.dhclient(client, dir, dateFormat) as \
+ _dh_client:
+ dhcp4 = getDhclientIfaces([_dh_client.lease_file])
self.assertIn(client, dhcp4, 'Test iface not found in a lease file.')
@@ -2259,6 +2259,11 @@
"""When asked to setupNetwork on top of an interface with a running
dhclient process, Vdsm is expected to stop that dhclient and start
owning the interface. BZ#1100264"""
+ def _get_dhclient_ifaces():
+ pids = pgrep('dhclient')
+ return [open('/proc/%s/cmdline' % pid).read().strip('\0')
+ .split('\0')[-1] for pid in pids]
+
with vethIf() as (server, client):
with avoidAnotherDhclient(client):
veth.setIP(server, IP_ADDRESS, IP_CIDR)
@@ -2267,27 +2272,34 @@
with namedTemporaryDir(dir='/var/lib/dhclient') as dhdir:
# Start a non-vdsm owned dhclient for the 'client'
# iface
- dhcp.runDhclient(client, dhdir, 'default')
- # Set up a network over it and wait for dhcp success
- status, msg = self.vdsm_net.setupNetworks(
- {NETWORK_NAME: {'nic': client, 'bridged': False,
- 'bootproto': 'dhcp', 'blockingdhcp': True}}, {},
- NOCHK)
- self.assertEquals(status, SUCCESS, msg)
- self.assertNetworkExists(NETWORK_NAME)
+ dhcp._runDhclient(client, dhdir, 'default')
+ with dhcp.dhclient(client, dhdir, 'default'):
+ # Set up a network over it and wait for dhcp
+ # success
+ status, msg = self.vdsm_net.setupNetworks(
+ {
+ NETWORK_NAME: {
+ 'nic': client, 'bridged': False,
+ 'bootproto': 'dhcp',
+ 'blockingdhcp': True
+ }
+ },
+ {},
+ NOCHK)
+ self.assertEquals(status, SUCCESS, msg)
+ self.assertNetworkExists(NETWORK_NAME)
- # Verify that dhclient is running for the device
- pids = pgrep('dhclient')
- ifaces = [open('/proc/%s/cmdline' % pid).read().
- strip('\0').split('\0')[-1] for pid in pids]
- vdsm_dhclient = [iface for iface in ifaces if
- iface == client]
- self.assertEqual(len(vdsm_dhclient), 1,
- 'There should be one and only one '
- 'running dhclient for the device')
+ # Verify that dhclient is running for the device
+ ifaces = _get_dhclient_ifaces()
+ vdsm_dhclient = [iface for iface in ifaces if
+ iface == client]
+ self.assertEqual(len(vdsm_dhclient), 1,
+ 'There should be one and only '
+ 'one running dhclient for the '
+ 'device')
# cleanup
- status, msg = self.vdsm_net.setupNetworks(
+ self.vdsm_net.setupNetworks(
{NETWORK_NAME: {'remove': True}}, {}, NOCHK)
@cleanupNet
diff --git a/tests/tcTests.py b/tests/tcTests.py
index 45ae29a..67a9db0 100644
--- a/tests/tcTests.py
+++ b/tests/tcTests.py
@@ -354,11 +354,11 @@
when it is attached to an active device.
"""
- ####[ Ethernet ]###
+ # ###[ Ethernet ]###
# dst = 00:1c:c0:d0:44:dc
# src = 00:21:5c:4d:42:75
# type = IPv4
- ####[ IP ]###
+ # ###[ IP ]###
# version = 4L
# ihl = 5L
# tos = 0x0
@@ -372,13 +372,13 @@
# src = 192.168.0.52
# dst = 192.168.0.3
# \options \
- ####[ ICMP ]###
+ # ###[ ICMP ]###
# type = echo-request
# code = 0
# chksum = 0x2875
# id = 0x0
# seq = 0x0
- ####[ Raw ]###
+ # ###[ Raw ]###
# load = '\x01#Eg\x89'
_ICMP = unhexlify(
'001cc0d044dc''00215c4d4275''0800' # Ethernet
--
To view, visit http://gerrit.ovirt.org/34366
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I458aa38415c697d3863e173444ff921d759166a2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan(a)redhat.com>
9 years, 6 months
Change in vdsm[master]: tests: Avoid printing objects that reference None
by dkuznets@redhat.com
Dima Kuznetsov has uploaded a new change for review.
Change subject: tests: Avoid printing objects that reference None
......................................................................
tests: Avoid printing objects that reference None
One of the current ioprocess tests checks who holds reference to the
ioprocess object, but since only a weak reference is stored, if the
object is freed, we check who holds reference to None, and apparently
quite a lot things do.
Change-Id: I9770873d70ec962837574fe32e8b4cb613e7c696
Signed-off-by: Dima Kuznetsov <dkuznets(a)redhat.com>
---
M tests/outOfProcessTests.py
1 file changed, 5 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/78/34978/1
diff --git a/tests/outOfProcessTests.py b/tests/outOfProcessTests.py
index 974e2e1..f905282 100644
--- a/tests/outOfProcessTests.py
+++ b/tests/outOfProcessTests.py
@@ -76,10 +76,11 @@
gc.collect()
time.sleep(1)
gc.collect()
- logging.info("GARBAGE: %s", gc.garbage)
- refs = gc.get_referrers(ioproc())
- logging.info(refs)
- logging.info(gc.get_referrers(*refs))
+ if ioproc() is not None:
+ logging.info("GARBAGE: %s", gc.garbage)
+ refs = gc.get_referrers(ioproc())
+ logging.info(refs)
+ logging.info(gc.get_referrers(*refs))
self.assertEquals(ioproc(), None)
finally:
oop.IOPROC_IDLE_TIME = idle
--
To view, visit http://gerrit.ovirt.org/34978
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9770873d70ec962837574fe32e8b4cb613e7c696
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuznets(a)redhat.com>
9 years, 6 months
Change in vdsm[master]: vdsm-reg: Fix closed log file descriptors
by dkuznets@redhat.com
Dima Kuznetsov has uploaded a new change for review.
Change subject: vdsm-reg: Fix closed log file descriptors
......................................................................
vdsm-reg: Fix closed log file descriptors
When calling createDaemon(), all file descriptors are closed, including
the file descriptors held by log handlers. This patch moves logging
configuration below the daemonization to make sure the file descriptors
stay open.
Change-Id: Ida11e61aea18fbb2990176889423d2c4b6292a09
Signed-off-by: Dima Kuznetsov <dkuznets(a)redhat.com>
---
M vdsm_reg/vdsm-reg-setup.in
1 file changed, 9 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/34981/1
diff --git a/vdsm_reg/vdsm-reg-setup.in b/vdsm_reg/vdsm-reg-setup.in
index 5a4cd1b..84f137d 100644
--- a/vdsm_reg/vdsm-reg-setup.in
+++ b/vdsm_reg/vdsm-reg-setup.in
@@ -371,19 +371,22 @@
pidfile = config.get('vars', 'pidfile')
sleepTime = float(config.get('vars', 'reg_req_interval'))
- loggerConf = config.get('vars', 'logger_conf')
- logging.config.fileConfig(loggerConf, disable_existing_loggers=False)
- log = logging.getLogger('')
-
- _createUpgradeDir(os.path.dirname(config.get('vars', 'upgrade_iso_file')))
-
try:
if daemonize:
createDaemon.createDaemon()
+
+ loggerConf = config.get('vars', 'logger_conf')
+ logging.config.fileConfig(loggerConf, disable_existing_loggers=False)
+ log = logging.getLogger('')
+
+ if daemonize:
log = logging.getLogger('vdsRegistrator')
else:
log.handlers.append(logging.StreamHandler())
+ _createUpgradeDir(
+ os.path.dirname(config.get('vars', 'upgrade_iso_file')))
+
log.info("After daemonize - My pid is %d", os.getpid())
with open(pidfile, 'w') as f:
f.write(str(os.getpid()) + "\n")
--
To view, visit http://gerrit.ovirt.org/34981
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida11e61aea18fbb2990176889423d2c4b6292a09
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuznets(a)redhat.com>
9 years, 6 months
Change in vdsm[master]: fixing pyflakes errors
by ybronhei@redhat.com
Yaniv Bronhaim has uploaded a new change for review.
Change subject: fixing pyflakes errors
......................................................................
fixing pyflakes errors
Change-Id: I54dad2edc73c3922bdb8c97e6fa036a3dfcf683b
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M contrib/profile-stats
M vdsm/vdsm
M vdsm/vdsmDebugPlugin.py
3 files changed, 2 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/35026/1
diff --git a/contrib/profile-stats b/contrib/profile-stats
index 0666eac..4b02cd9 100755
--- a/contrib/profile-stats
+++ b/contrib/profile-stats
@@ -56,7 +56,6 @@
import optparse
import pstats
-import sys
op = optparse.OptionParser(usage='%prog [options] file')
op.add_option('-s', '--sort', dest='sort',
diff --git a/vdsm/vdsm b/vdsm/vdsm
index 9004c8c..5c1ab71 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -111,6 +111,7 @@
# vdsmDebugPlugin.py should not exists
try:
import vdsmDebugPlugin
+ vdsmDebugPlugin.turnOnDebugPlugin()
except ImportError:
# This is OK, it just means the file isn't
# there and we are not running in debug mode.
diff --git a/vdsm/vdsmDebugPlugin.py b/vdsm/vdsmDebugPlugin.py
index 3f4e7b7..af06dbe 100644
--- a/vdsm/vdsmDebugPlugin.py
+++ b/vdsm/vdsmDebugPlugin.py
@@ -36,7 +36,7 @@
exec(code)
-def __turnOnDebugPlugin():
+def turnOnDebugPlugin():
log.warn("Starting Debug Interpreter. Tread lightly!")
try:
if os.path.exists(ADDRESS):
@@ -50,5 +50,3 @@
servThread.start()
except:
log.error("Could not start debug plugin", exc_info=True)
-
-__turnOnDebugPlugin()
--
To view, visit http://gerrit.ovirt.org/35026
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I54dad2edc73c3922bdb8c97e6fa036a3dfcf683b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
9 years, 6 months