Change in vdsm[master]: Packaging: libvirt configuration detection should skip /dev/...
by zhshzhou@linux.vnet.ibm.com
Zhou Zheng Sheng has uploaded a new change for review.
Change subject: Packaging: libvirt configuration detection should skip /dev/null
......................................................................
Packaging: libvirt configuration detection should skip /dev/null
We disabled libvirt-sanlock in Ubuntu, so QLCONF is set to /dev/null,
and later we need to grep "${BY_VDSM_VERS}" from QLCONF to confirm
libvirt is configured. grep returns 1 for /dev/null but actually libvirt
is configured. This patch skip /dev/null when grep libvirt .conf files.
Change-Id: Ia0d8a976c023709068ca2f3691fab5cd59ae02ff
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
M lib/vdsm/tool/libvirt_configure.sh.in
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/60/20260/1
diff --git a/lib/vdsm/tool/libvirt_configure.sh.in b/lib/vdsm/tool/libvirt_configure.sh.in
index ed8a466..f9ac757 100755
--- a/lib/vdsm/tool/libvirt_configure.sh.in
+++ b/lib/vdsm/tool/libvirt_configure.sh.in
@@ -152,6 +152,10 @@
is_already_configured() {
local rc=0
while [ -n "$1" ]; do
+ if [ "$1" = "/dev/null" ];then
+ shift
+ continue
+ fi
if ! /bin/grep -q "${BY_VDSM_VERS}" "$1" >/dev/null 2>&1; then
rc=1
echo "libvirt is not configured for vdsm yet"
--
To view, visit http://gerrit.ovirt.org/20260
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0d8a976c023709068ca2f3691fab5cd59ae02ff
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
10 years, 7 months
Change in vdsm[master]: Packaging: fix libvirt configuration
by zhshzhou@linux.vnet.ibm.com
Zhou Zheng Sheng has uploaded a new change for review.
Change subject: Packaging: fix libvirt configuration
......................................................................
Packaging: fix libvirt configuration
The help string "=FILE" is incorrectly added to the name of the
configure option --with-libvirt-service-default. So This patch moves
"=FILE" to help string.
Another problem is we disabled libvirt-sanlock in Ubuntu, so QLCONF is
set to "/dev/null", but later we need to grep "${BY_VDSM_VERS}" from
QLCONF to confirm libvirt is configured. grep returns 1 for QLCONF but
actually libvirt is configured. This patch does not set QLCONF to
"/dev/null", this is harmless because when libvirt-sanlock is not
enabled, no one reads and cares QLCONF actually.
Change-Id: I34fa3764b999e71186171931664b0481b2ef3a15
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
M configure.ac
M lib/vdsm/tool/libvirt_configure.sh.in
2 files changed, 2 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/20168/1
diff --git a/configure.ac b/configure.ac
index a1a5465..04e5d2d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,9 +100,9 @@
AC_SUBST([QEMUGROUP], ["${with_qemu_group}"])
AC_ARG_WITH(
- [libvirt-service-default=FILE],
+ [libvirt-service-default],
[AS_HELP_STRING(
- [--with-libvirt-service-default],
+ [--with-libvirt-service-default=FILE],
[configure full path of libvirt service environment file.
@<:@SYSCONFDIR/sysconfig/libvirtd@:>@]
)],
diff --git a/lib/vdsm/tool/libvirt_configure.sh.in b/lib/vdsm/tool/libvirt_configure.sh.in
index ed8a466..467ef27 100755
--- a/lib/vdsm/tool/libvirt_configure.sh.in
+++ b/lib/vdsm/tool/libvirt_configure.sh.in
@@ -39,8 +39,6 @@
# continue to use this string.
BY_VDSM_VERS="4.10.3"
-[ "${ENABLE_LIBVIRT_SANLOCK}" = "yes" ] || QLCONF="/dev/null"
-
# trigger for reconfiguration
FORCE_RECONFIGURE="@VDSMLIBDIR@/reconfigure"
--
To view, visit http://gerrit.ovirt.org/20168
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I34fa3764b999e71186171931664b0481b2ef3a15
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
10 years, 7 months
Change in vdsm[master]: Adding [start|stop]MonitoringDomain().
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Adding [start|stop]MonitoringDomain().
......................................................................
Adding [start|stop]MonitoringDomain().
startMonitoringDomain() is added for monitoring a storage domain
without being connected to the pool and geting and ID for such
SD lockspace.
stopMonitoringDomain() stops the monitoring and releases the ID.
Monitoring results are gathered with repoStats().
Caveat Emptor:
SDs added to the monitor using startMonitoringDomain() should not
be part of the pool! i.e. the pool domain set and the added SDs set
should be disjoint.
Making repoStats pool independent.
Change-Id: I983d49b0a42cc06428ec75b7795d23abaa6ab84c
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
M vdsm_api/vdsmapi-schema.json
6 files changed, 105 insertions(+), 32 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/19762/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 590b1e7..6aba25e 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1692,6 +1692,16 @@
print 'Domain %s %s' % (d, str(stats[d]))
return 0, ''
+ def startMonitoringDomain(self, args):
+ sdUUID, hostID = args
+ self.s.startMonitoringDomain(sdUUID, hostID)
+ return 0, ''
+
+ def stopMonitoringDomain(self, args):
+ sdUUID, = args
+ self.s.stopMonitoringDomain(sdUUID)
+ return 0, ''
+
def snapshot(self, args):
vmUUID, sdUUID, imgUUID, baseVolUUID, volUUID = args
@@ -2466,8 +2476,16 @@
)),
'repoStats': (serv.repoStats,
('',
- 'Get the the health status of the active domains'
+ 'Get the health status of the monitored domains'
)),
+ 'startMonitoringDomain': (serv.startMonitoringDomain,
+ ('<sdUUID> <hostID>',
+ 'Start SD: sdUUID monitoring with hostID'
+ )),
+ 'stopMonitoringDomain': (serv.stopMonitoringDomain,
+ ('<sdUUID>',
+ 'Stop monitoring SD: sdUUID'
+ )),
'snapshot': (serv.snapshot,
('<vmId> <sdUUID> <imgUUID> <baseVolUUID> <volUUID>',
'Take a live snapshot'
diff --git a/vdsm/API.py b/vdsm/API.py
index 37bb908..fa9a3ab 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1396,6 +1396,12 @@
def getStorageRepoStats(self):
return self._irs.repoStats()
+ def startMonitoringDomain(self, sdUUID, hostID):
+ return self._irs.startMonitoringDomain(sdUUID, hostID)
+
+ def stopMonitoringDomain(self, sdUUID):
+ return self._irs.stopMonitoringDomain(sdUUID)
+
def getLVMVolumeGroups(self, storageType=None):
return self._irs.getVGList(storageType)
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index fb65ad4..5dd747a 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -787,6 +787,14 @@
api = API.Global()
return api.getStorageRepoStats()
+ def startMonitoringDomain(self, sdUUID, hostID, options=None):
+ api = API.Global()
+ return api.startMonitoringDomain(sdUUID, hostID)
+
+ def stopMonitoringDomain(self, sdUUID, options=None):
+ api = API.Global()
+ return api.stopMonitoringDomain(sdUUID)
+
def vgsGetList(self, storageType=None, options=None):
api = API.Global()
return api.getLVMVolumeGroups(storageType)
@@ -937,6 +945,8 @@
(self.domainsGetList, 'getStorageDomainsList'),
(self.poolsGetConnectedList, 'getConnectedStoragePoolsList'),
(self.storageRepoGetStats, 'repoStats'),
+ (self.startMonitoringDomain, 'startMonitoringDomain'),
+ (self.stopMonitoringDomain, 'stopMonitoringDomain'),
(self.vgsGetList, 'getVGList'),
(self.devicesGetList, 'getDeviceList'),
(self.devicesGetVisibility, 'getDevicesVisibility'),
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 4ea68ea..5f14468 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -40,6 +40,7 @@
from vdsm.config import config
import sp
+import domainMonitor
import sd
import blockSD
import nfsSD
@@ -93,6 +94,8 @@
STORAGE_CONNECTION_DIR = os.path.join(constants.P_VDSM_LIB, "connections/")
QEMU_READABLE_TIMEOUT = 30
+
+HSM_DOM_MON_LOCK = "HsmDomainMonitorLock"
def public(f=None, **kwargs):
@@ -398,6 +401,9 @@
name="storageRefresh")
storageRefreshThread.daemon = True
storageRefreshThread.start()
+
+ monitorInterval = config.getint('irs', 'sd_health_check_delay')
+ self.domainMonitor = domainMonitor.DomainMonitor(monitorInterval)
@public
def registerDomainStateChangeCallback(self, callbackFunc):
@@ -971,9 +977,8 @@
for dom in sorted(domList):
vars.task.getExclusiveLock(STORAGE, dom)
- return sp.StoragePool(
- spUUID, self.taskMng).create(poolName, masterDom, domList,
- masterVersion, leaseParams)
+ return sp.StoragePool(spUUID, self.domainMonitor, self.taskMng).create(
+ poolName, masterDom, domList, masterVersion, leaseParams)
@public
def connectStoragePool(self, spUUID, hostID, scsiKey,
@@ -1003,8 +1008,10 @@
"spUUID=%s, msdUUID=%s, masterVersion=%s, hostID=%s, "
"scsiKey=%s" % (spUUID, msdUUID, masterVersion,
hostID, scsiKey)))
- return self._connectStoragePool(spUUID, hostID, scsiKey, msdUUID,
- masterVersion, options)
+ with rmanager.acquireResource(STORAGE, HSM_DOM_MON_LOCK,
+ rm.LockType.exclusive):
+ return self._connectStoragePool(spUUID, hostID, scsiKey, msdUUID,
+ masterVersion, options)
def _connectStoragePool(self, spUUID, hostID, scsiKey, msdUUID,
masterVersion, options=None):
@@ -1048,7 +1055,7 @@
masterVersion=masterVersion)
return
- pool = sp.StoragePool(spUUID, self.taskMng)
+ pool = sp.StoragePool(spUUID, self.domainMonitor, self.taskMng)
if not hostID or not scsiKey or not msdUUID or not masterVersion:
hostID, scsiKey, msdUUID, masterVersion = pool.getPoolParams()
res = pool.connect(hostID, scsiKey, msdUUID, masterVersion)
@@ -1103,8 +1110,10 @@
def _disconnectPool(self, pool, hostID, scsiKey, remove):
self.validateNotSPM(pool.spUUID)
- res = pool.disconnect()
- del self.pools[pool.spUUID]
+ with rmanager.acquireResource(STORAGE, HSM_DOM_MON_LOCK,
+ rm.LockType.exclusive):
+ res = pool.disconnect()
+ del self.pools[pool.spUUID]
return res
@public
@@ -1854,7 +1863,7 @@
try:
pool = self.getPool(spUUID)
except se.StoragePoolUnknown:
- pool = sp.StoragePool(spUUID, self.taskMng)
+ pool = sp.StoragePool(spUUID, self.domainMonitor, self.taskMng)
else:
raise se.StoragePoolConnected(spUUID)
@@ -3494,14 +3503,12 @@
if self.pools[spUUID].hsmMailer:
self.pools[spUUID].hsmMailer.stop()
- # Stop repoStat threads
- for pool in self.pools.values():
- try:
- pool.stopMonitoringDomains()
- except Exception:
- self.log.warning("Failed to stop RepoStats thread",
- exc_info=True)
- continue
+ # Stop repoStat threads
+ try:
+ self.domainMonitor.close()
+ except Exception:
+ self.log.warning("Failed to stop RepoStats thread",
+ exc_info=True)
self.taskMng.prepareForShutdown()
except:
@@ -3667,10 +3674,23 @@
"""
result = {}
- for p in self.pools.values():
- repo_stats = self._getRepoStats(p.domainMonitor)
+ repo_stats = self._getRepoStats(self.domainMonitor)
- for d in repo_stats:
- result[d] = repo_stats[d]['result']
+ for d in repo_stats:
+ result[d] = repo_stats[d]['result']
return result
+
+ @deprecated
+ @public
+ def startMonitoringDomain(self, sdUUID, hostID, options=None):
+ with rmanager.acquireResource(STORAGE, HSM_DOM_MON_LOCK,
+ rm.LockType.exclusive):
+ self.domainMonitor.startMonitoring(sdUUID, int(hostID))
+
+ @deprecated
+ @public
+ def stopMonitoringDomain(self, sdUUID, options=None):
+ with rmanager.acquireResource(STORAGE, HSM_DOM_MON_LOCK,
+ rm.LockType.exclusive):
+ self.domainMonitor.stopMonitoring(sdUUID)
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index e0559bd..cae84b3 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -51,7 +51,6 @@
import resourceManager as rm
import volume
import mount
-from domainMonitor import DomainMonitor
POOL_MASTER_DOMAIN = 'mastersd'
@@ -112,9 +111,8 @@
storage_repository = config.get('irs', 'repository')
_poolsTmpDir = config.get('irs', 'pools_data_dir')
lvExtendPolicy = config.get('irs', 'vol_extend_policy')
- monitorInterval = config.getint('irs', 'sd_health_check_delay')
- def __init__(self, spUUID, taskManager):
+ def __init__(self, spUUID, domainMonitor, taskManager):
Securable.__init__(self)
self._formatConverter = DefaultFormatConverter()
@@ -131,7 +129,7 @@
self.spmMailer = None
self.masterDomain = None
self.spmRole = SPM_FREE
- self.domainMonitor = DomainMonitor(self.monitorInterval)
+ self.domainMonitor = domainMonitor
self._upgradeCallback = partial(StoragePool._upgradePoolDomain,
proxy(self))
@@ -702,7 +700,8 @@
@unsecured
def stopMonitoringDomains(self):
- self.domainMonitor.close()
+ for sdUUID in self.getDomains():
+ self.domainMonitor.stopMonitoring(sdUUID)
return True
@unsecured
@@ -1542,13 +1541,15 @@
@unsecured
@misc.samplingmethod
def updateMonitoringThreads(self):
- # domain list it's list of sdUUID:status
- # sdUUID1:status1,sdUUID2:status2,...
+ # getDomains() returns a dict of {sdUUID:status}
+ # {sdUUID1: status1, sdUUID2: status2, ...}
self.invalidateMetadata()
- activeDomains = self.getDomains(activeOnly=True)
+ poolDoms = self.getDomains()
+ activeDomains = tuple(sdUUID for sdUUID in poolDoms
+ if poolDoms[sdUUID] == sd.DOM_ACTIVE_STATUS)
monitoredDomains = self.domainMonitor.monitoredDomains
- for sdUUID in monitoredDomains:
+ for sdUUID in poolDoms:
if sdUUID not in activeDomains:
try:
self.domainMonitor.stopMonitoring(sdUUID)
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 27c12c1..66de033 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -1712,7 +1712,7 @@
##
# @Host.getStorageRepoStats:
#
-# Get statistics and liveness of currently attached Storage Domains.
+# Get statistics and liveness of currently monitored Storage Domains.
#
# Returns:
# Statistics for all storage domains
@@ -1723,6 +1723,24 @@
'returns': 'StorageDomainVitalsMap'}
##
+# @Host.startMonitorDomain:
+#
+# Start SD monitoring with hostID
+#
+# @SdUUID: The Storage Domain UUID
+#
+# @HostID: A host ID number in the Storage Domain Lockspace
+#
+# Returns:
+# None
+#
+# Since: 4.12.2
+##
+{'command': {'class': 'Host', 'name': 'startMonitorDomain'},
+ 'data': {'SdUUID': 'UUID', 'HostID': 'int' }
+ 'returns': ''}
+
+##
# @VmStatus:
#
# An enumeration of possible virtual machine statuses.
--
To view, visit http://gerrit.ovirt.org/19762
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I983d49b0a42cc06428ec75b7795d23abaa6ab84c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
10 years, 7 months
Change in vdsm[master]: Packaging: make the auto build scripts suitable for running ...
by zhshzhou@linux.vnet.ibm.com
Zhou Zheng Sheng has uploaded a new change for review.
Change subject: Packaging: make the auto build scripts suitable for running in Jenkins
......................................................................
Packaging: make the auto build scripts suitable for running in Jenkins
1. Add a "--local" option to autobuild.sh to generate rpms in the
./rpmbuild . When runs in Jenkins, it's better to do everything under
the current working dir.
2. When checking pep8, ignore .py files generated from .py.in, because
this kind of files may contain generated long lines. When built in
Jenkins, the working path can be very long, so generated files under
./builder may contain constants for a long path.
Change-Id: I470a7eca71d6d28ef76521a2759b485b5a5cab6f
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
M .gitignore
M Makefile.am
M autobuild.sh
3 files changed, 27 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/11238/1
diff --git a/.gitignore b/.gitignore
index d36ed82..b8eb409 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,10 +15,12 @@
build-aux/install-sh
build-aux/missing
build-aux/py-compile
+builder
config.log
config.status
configure
results.log
+rpmbuild
tests/run_tests.sh
tests/run_tests_local.sh
vdsm-*.tar.gz
diff --git a/Makefile.am b/Makefile.am
index 48bdc5e..ba6df2a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,19 +61,27 @@
vdsm_reg \
$(NULL)
-PEP8_BLACKLIST = config.py,constants.py
+PEP8_BLACKLIST =
check-local:
find . -path './.git' -prune -type f -o \
-name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES)
- $(PEP8) --exclude="$(PEP8_BLACKLIST)" --filename '*.py,*.py.in' \
- $(PEP8_WHITELIST)
- @if test -f .gitignore; then \
+ PEP8_EXCLUDE="$(PEP8_BLACKLIST)" ; \
+ if test -f .gitignore; then \
for i in `git ls-files \*.in`; do \
if ! grep -q -x $${i%%.in} .gitignore; then \
echo "Missing $${i%%.in} in .gitignore"; exit 1; fi; \
done; \
- fi;
+ PEP8_EXCLUDE+=`find . -path './.git' -prune -type f -o -name "*.py" | \
+ while read PYFILE; do \
+ if [ -f "$$PYFILE.in" ]; then \
+ printf ,\`basename "$$PYFILE"\`; \
+ fi; \
+ done`; \
+ fi; \
+ PEP8_EXCLUDE=$${PEP8_EXCLUDE#,} ; \
+ $(PEP8) --exclude="$$PEP8_EXCLUDE" --filename '*.py,*.py.in' \
+ $(PEP8_WHITELIST)
all-local: \
vdsm.spec
diff --git a/autobuild.sh b/autobuild.sh
index c7a592c..cb74f86 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -3,6 +3,16 @@
set -e
set -v
+if [ "$1" == "--local" ]; then
+ # --prefix needs absolute directory name
+ BUILDERDIR="$(pwd)/builder"
+ RPMTOPDIR="$(pwd)/rpmbuild"
+ shift
+else
+ BUILDERDIR="$HOME/builder"
+ RPMTOPDIR="$HOME/rpmbuild"
+fi
+
# Make things clean.
test -n "$1" && RESULTS=$1 || RESULTS=results.log
@@ -10,7 +20,7 @@
test -f Makefile && make -k distclean || :
-./autogen.sh --prefix="$AUTOBUILD_INSTALL_ROOT"
+./autogen.sh --prefix="$BUILDERDIR"
# If the MAKEFLAGS envvar does not yet include a -j option,
# add -jN where N depends on the number of processors.
@@ -50,5 +60,6 @@
NOSE_EXCLUDE=.* rpmbuild --nodeps \
--define "extra_release $EXTRA_RELEASE" \
--define "_sourcedir `pwd`" \
+ --define "_topdir $RPMTOPDIR" \
-ba --clean vdsm.spec
fi
--
To view, visit http://gerrit.ovirt.org/11238
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I470a7eca71d6d28ef76521a2759b485b5a5cab6f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
10 years, 7 months
Change in vdsm[master]: WIP: sd.py: Remove sds from sdCache when connecting
by Allon Mureinik
Allon Mureinik has uploaded a new change for review.
Change subject: WIP: sd.py: Remove sds from sdCache when connecting
......................................................................
WIP: sd.py: Remove sds from sdCache when connecting
When connecting to a storage server, pre-existing domains should be
removed, since we have no way of knowing what happened to these
domains in the meanwhile.
Change-Id: Ic0e0d0e970ce55acf92f7e39ec9cf2170e948274
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=950055
Signed-off-by: Allon Mureinik <amureini(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/19995/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index d46ef50..8fae844 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -2371,6 +2371,11 @@
self.log.debug("prefetch failed: %s",
sdCache.knownSDs, exc_info=True)
else:
+ # Any pre-existing domains in sdCache stand the chance of
+ # being invalid, since there is no way to know what happens
+ # to them while the storage is disconnected.
+ for sdUUID in doms.iterkeys():
+ sdCache.manuallyRemoveDomain(sdUUID)
sdCache.knownSDs.update(doms)
self.log.debug("knownSDs: {%s}", ", ".join("%s: %s.%s" %
--
To view, visit http://gerrit.ovirt.org/19995
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0e0d0e970ce55acf92f7e39ec9cf2170e948274
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amureini(a)redhat.com>
10 years, 7 months
Change in vdsm[master]: tests: Add monkey patching class decorator
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: tests: Add monkey patching class decorator
......................................................................
tests: Add monkey patching class decorator
Using the new MonkeyClass decorator, you can do monkey patching during
all test methods in a test case class, without implementing setUp() or
tearDown().
Change-Id: Ice429b01afaf00730ff59dcdf866ab5eeae6b926
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/monkeypatch.py
M tests/monkeypatchTests.py
2 files changed, 89 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/20175/1
diff --git a/tests/monkeypatch.py b/tests/monkeypatch.py
index f851f82..b51f097 100644
--- a/tests/monkeypatch.py
+++ b/tests/monkeypatch.py
@@ -21,8 +21,9 @@
from contextlib import contextmanager
from functools import wraps
+
#
-# Monkey patch
+# Monkey patch.
#
# Usage:
# ---
@@ -49,8 +50,6 @@
# # using patched functions
# ---
#
-
-
class Patch(object):
def __init__(self, what):
@@ -75,7 +74,7 @@
#
# Usage:
# ---
-# from monkeypatch import MonkeyPatch
+# from monkeypatch import MonkeyPatchScope
#
# def test():
# with MonkeyPatchScope([
@@ -96,7 +95,7 @@
#
-# Monkey patch decoration.
+# Monkey patch function decorator.
#
# Usage:
# ---
@@ -116,3 +115,50 @@
return f(*args, **kw)
return wrapper
return decorator
+
+
+#
+# Monkey patch class decorator.
+#
+# Usage:
+# ---
+# from monkeypatch import MonkeyClass
+#
+# @MonkeyClass(subprocess, 'Popen', lambda x: None)
+# @MonkeyClass(os, 'chown', lambda *x: 0)
+# class TestSomething():
+#
+# def testThis(self):
+# # using patched functions
+#
+# def testThat(self):
+# # using patched functions
+# ---
+#
+def MonkeyClass(module, name, that):
+
+ def setup_decorator(func):
+ @wraps(func)
+ def setup(self, *a, **kw):
+ if not hasattr(self, '__monkeystack__'):
+ self.__monkeystack__ = []
+ patch = Patch([(module, name, that)])
+ self.__monkeystack__.append(patch)
+ patch.apply()
+ return func(self, *a, **kw)
+ return setup
+
+ def teardown_decorator(func):
+ @wraps(func)
+ def teardown(self, *a, **kw):
+ patch = self.__monkeystack__.pop()
+ patch.revert()
+ return func(self, *a, **kw)
+ return teardown
+
+ def wrapper(cls):
+ cls.setUp = setup_decorator(cls.setUp)
+ cls.tearDown = teardown_decorator(cls.tearDown)
+ return cls
+
+ return wrapper
diff --git a/tests/monkeypatchTests.py b/tests/monkeypatchTests.py
index b1b9359..2c52b4f 100644
--- a/tests/monkeypatchTests.py
+++ b/tests/monkeypatchTests.py
@@ -20,7 +20,7 @@
from testrunner import VdsmTestCase
-import monkeypatch
+from monkeypatch import Patch, MonkeyPatch, MonkeyClass
class FakeModule:
@@ -49,7 +49,7 @@
pass
-class TestMonkeyPatchDecorator(VdsmTestCase):
+class TestMonkeyPatch(VdsmTestCase):
module = FakeModule()
@@ -66,18 +66,46 @@
# This method patches module in one way
- @monkeypatch.MonkeyPatch(module, 'a', patched)
+ @MonkeyPatch(module, 'a', patched)
def testPatchOne(self):
self.assertEqual(self.module.a, patched)
self.assertNotEqual(self.module.b, patched)
# This method patches module in another way
- @monkeypatch.MonkeyPatch(module, 'a', patched)
- @monkeypatch.MonkeyPatch(module, 'b', patched)
+ @MonkeyPatch(module, 'a', patched)
+ @MonkeyPatch(module, 'b', patched)
def testPatchBoth(self):
self.assertEqual(self.module.a, patched)
self.assertEqual(self.module.b, patched)
+
+
+module = FakeModule()
+
+
+@MonkeyClass(module, 'a', patched)
+class TestMonkeyClass(VdsmTestCase):
+
+ def tearDown(self):
+ self.assertTrue(module.isClean())
+
+ def testPatched(self):
+ self.assertEqual(module.a, patched)
+ self.assertNotEqual(module.b, patched)
+ self.assertNotEqual(module.c, patched)
+
+
+@MonkeyClass(module, 'a', patched)
+@MonkeyClass(module, 'b', patched)
+class TestMonkeyClassChain(VdsmTestCase):
+
+ def tearDown(self):
+ self.assertTrue(module.isClean())
+
+ def testPatched(self):
+ self.assertEqual(module.a, patched)
+ self.assertEqual(module.b, patched)
+ self.assertNotEqual(module.c, patched)
class TestMonkeyPatchFixture(VdsmTestCase):
@@ -85,7 +113,7 @@
def __init__(self, *a, **kw):
super(VdsmTestCase, self).__init__(*a, **kw)
self.module = FakeModule()
- self.patch = monkeypatch.Patch([
+ self.patch = Patch([
(self.module, 'a', patched),
(self.module, 'b', patched),
])
@@ -106,19 +134,19 @@
self.assertNotEqual(self.module.c, patched)
-class TestMonkeyPatchAssertions(VdsmTestCase):
+class TestMonkeyPatchFixtureAssertions(VdsmTestCase):
def testAlreadyApplied(self):
- patch = monkeypatch.Patch([(FakeModule(), 'a', patched)])
+ patch = Patch([(FakeModule(), 'a', patched)])
patch.apply()
self.assertRaises(AssertionError, patch.apply)
def testNotApplied(self):
- patch = monkeypatch.Patch([(FakeModule(), 'a', patched)])
+ patch = Patch([(FakeModule(), 'a', patched)])
self.assertRaises(AssertionError, patch.revert)
def testAlreadyReverted(self):
- patch = monkeypatch.Patch([(FakeModule(), 'a', patched)])
+ patch = Patch([(FakeModule(), 'a', patched)])
patch.apply()
patch.revert()
self.assertRaises(AssertionError, patch.revert)
--
To view, visit http://gerrit.ovirt.org/20175
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice429b01afaf00730ff59dcdf866ab5eeae6b926
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
10 years, 7 months
Change in vdsm[master]: Adding dependency on cpopen formal package
by ybronhei@redhat.com
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Adding dependency on cpopen formal package
......................................................................
Adding dependency on cpopen formal package
Removing cpopen code from vdsm and using formal package instead
Change-Id: I6dfc943cbf7ac1e4c575069afca9c7df0624372f
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=903246
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M Makefile.am
M configure.ac
M debian/control
D debian/vdsm-python-cpopen.docs
D debian/vdsm-python-cpopen.install
M lib/Makefile.am
D lib/cpopen/.gitignore
D lib/cpopen/Makefile.am
D lib/cpopen/__init__.py
D lib/cpopen/cpopen.c
D lib/cpopen/setup.py
D lib/cpopen/tests.py
M vdsm.spec.in
13 files changed, 9 insertions(+), 755 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/42/20142/1
diff --git a/Makefile.am b/Makefile.am
index 195688f..84e5e6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,7 +56,6 @@
# checkd from now on
PEP8_WHITELIST = \
client \
- lib/cpopen/*.py \
lib/vdsm/*.py \
lib/vdsm/*.py.in \
tests \
diff --git a/configure.ac b/configure.ac
index 93b6b96..a1a5465 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,7 +252,6 @@
init/sysvinit/Makefile
init/upstart/Makefile
lib/Makefile
- lib/cpopen/Makefile
lib/vdsm/Makefile
lib/vdsm/tool/Makefile
lib/yajsonrpc/Makefile
diff --git a/debian/control b/debian/control
index da030ad..820bc26 100644
--- a/debian/control
+++ b/debian/control
@@ -31,13 +31,6 @@
Vcs-Git: git://gerrit.ovirt.org/vdsm
Vcs-Browser: http://gerrit.ovirt.org/gitweb?p=vdsm.git
-Package: vdsm-python-cpopen
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python (>=2.7.3)
-Description: Creates a sub-process in simpler safer manner
- Python package for creating sub-process in simpler and safer manner by using
- C code.
-
Package: vdsm-yajsonrpc
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, python (>=2.7.3),
@@ -54,7 +47,7 @@
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends},
python (>=2.7.3),
- vdsm-python-cpopen (>= ${source:Version}),
+ python-cpopen,
vdsm-python (= ${source:Version})
Description: VDSM command line interface
Call VDSM commands from the command line. Used for testing and debugging.
@@ -93,7 +86,7 @@
policycoreutils (>= 2.1.10),
psmisc (>= 22.6),
python (>= 2.7.3),
- vdsm-python-cpopen (= ${binary:Version}),
+ python-cpopen,
python-dmidecode,
python-ethtool (>= 0.8),
python-ethtool (>= 0.8),
diff --git a/debian/vdsm-python-cpopen.docs b/debian/vdsm-python-cpopen.docs
deleted file mode 100644
index 5ecd9c6..0000000
--- a/debian/vdsm-python-cpopen.docs
+++ /dev/null
@@ -1 +0,0 @@
-COPYING
diff --git a/debian/vdsm-python-cpopen.install b/debian/vdsm-python-cpopen.install
deleted file mode 100644
index d38a40e..0000000
--- a/debian/vdsm-python-cpopen.install
+++ /dev/null
@@ -1,2 +0,0 @@
-./usr/lib/python2.7/dist-packages/cpopen/__init__.py
-./usr/lib/python2.7/dist-packages/cpopen/cpopen.so
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b1a1a12..ff46328 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -19,4 +19,4 @@
#
include $(top_srcdir)/build-aux/Makefile.subs
-SUBDIRS = vdsm cpopen yajsonrpc
+SUBDIRS = vdsm yajsonrpc
diff --git a/lib/cpopen/.gitignore b/lib/cpopen/.gitignore
deleted file mode 100644
index d23b815..0000000
--- a/lib/cpopen/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build
-*.so
diff --git a/lib/cpopen/Makefile.am b/lib/cpopen/Makefile.am
deleted file mode 100644
index c39ca24..0000000
--- a/lib/cpopen/Makefile.am
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright 2012 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
-#
-
-cpopendir = $(pyexecdir)/cpopen
-
-dist_cpopen_PYTHON = \
- __init__.py \
- $(NULL)
-
-cpopen.so: cpopen.c setup.py
- (cd $(srcdir); $(PYTHON) setup.py build \
- --build-temp $(abs_builddir) --build-lib $(abs_builddir))
-
-all-local: cpopen.so
-
-install-data-local:
- $(MKDIR_P) $(DESTDIR)$(cpopendir)
- $(INSTALL_PROGRAM) cpopen.so \
- $(DESTDIR)$(cpopendir)/cpopen.so
-
-check-local: tests.py
- nosetests tests.py
-
-EXTRA_DIST = \
- cpopen.c \
- tests.py \
- setup.py
-
-CLEANFILES = \
- cpopen.o \
- cpopen.so
diff --git a/lib/cpopen/__init__.py b/lib/cpopen/__init__.py
deleted file mode 100644
index d671355..0000000
--- a/lib/cpopen/__init__.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# Copyright 2012 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
-#
-
-"""
-Python's implementation of Popen forks back to python before execing.
-Forking a python proc is a very complex and volatile process.
-
-This is a simpler method of execing that doesn't go back to python after
-forking. This allows for faster safer exec.
-"""
-
-import os
-from subprocess import Popen, PIPE
-
-from cpopen import createProcess
-
-
-class CPopen(Popen):
- def __init__(self, args, close_fds=False, cwd=None, env=None,
- deathSignal=0):
- if not isinstance(args, list):
- args = list(args)
-
- if env is not None and not isinstance(env, list):
- env = list(("=".join(item) for item in env.iteritems()))
-
- self._deathSignal = int(deathSignal)
- Popen.__init__(self, args,
- close_fds=close_fds, cwd=cwd, env=env,
- stdin=PIPE, stdout=PIPE,
- stderr=PIPE)
-
- def _execute_child(self, args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
- startupinfo, creationflags, shell,
- p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite):
-
- try:
- pid, stdin, stdout, stderr = \
- createProcess(args, close_fds, p2cread, p2cwrite,
- c2pread, c2pwrite, errread, errwrite,
- cwd, env, self._deathSignal)
-
- self.pid = pid
- self._closed = False
- self._returncode = None
- except:
- os.close(p2cwrite)
- os.close(errread)
- os.close(c2pread)
- raise
- finally:
- os.close(p2cread)
- os.close(errwrite)
- os.close(c2pwrite)
diff --git a/lib/cpopen/cpopen.c b/lib/cpopen/cpopen.c
deleted file mode 100644
index 7b9ddce..0000000
--- a/lib/cpopen/cpopen.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
-* Copyright 2012 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
-*/
-
-#include <Python.h>
-
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/prctl.h>
-
-static PyObject *createProcess(PyObject *self, PyObject *args);
-static PyMethodDef CreateProcessMethods[];
-static void closeFDs(int errnofd);
-
-/* Python boilerplate */
-static PyMethodDef
-CreateProcessMethods[] = {
- {"createProcess", createProcess, METH_VARARGS,
- "Execute a command."},
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-
-PyMODINIT_FUNC
-initcpopen(void)
-{
- PyObject *m;
-
- m = Py_InitModule("cpopen", CreateProcessMethods);
-
- /* In the future put other init code after this condition. */
- if (m == NULL)
- return;
-}
-
-/* Just like close() but retries on interrupt */
-static int
-safeClose(int fd) {
- int rv;
-
-retry:
- rv = close(fd);
- if ((rv < 0) && (errno == EINTR)) {
- goto retry;
- }
-
- return rv;
-}
-
-/* Just like read() but retries on interrupt and tries to fill the buffer */
-static int
-safeRead(int fd, void *buff, size_t count) {
- size_t bread = 0;
- char* cbuff = buff;
- int rv = 0;
- while (bread < count) {
- rv = read(fd, cbuff + bread, count - bread);
- if (rv == 0) { /* EOF */
- return bread;
- } else if (rv < 0) { /* ERROR */
- switch (errno) {
- case EINTR:
- case EAGAIN:
- break;
- default:
- return rv;
- }
- } else { /* Success */
- bread += rv;
- }
- }
-
- return bread;
-}
-
-static int
-setCloseOnExec(int fd) {
- int flags;
-
- flags = fcntl(fd, F_GETFD);
- if (flags == -1) {
- return -1;
- }
-
- if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
- return -1;
- }
-
- return 0;
-}
-
-/* Closes all open FDs except for stdin, stdout and stderr */
-static void
-closeFDs(int errnofd) {
- DIR *dp;
- int dfd;
- struct dirent *ep;
- int fdNum = -1;
-
- dfd = open("/proc/self/fd/", O_RDONLY);
- dp = fdopendir(dfd);
- while ((ep = readdir(dp))) {
- if(sscanf(ep->d_name, "%d", &fdNum) < 1) {
- continue;
- }
-
- if (fdNum < 3) {
- continue;
- }
-
- if (fdNum == dfd) {
- continue;
- }
-
- if (fdNum == errnofd) {
- continue;
- }
-
- safeClose(fdNum);
- }
-
- closedir(dp);
- safeClose(dfd);
-}
-
-static void
-freeStringArray(char** arr) {
- char** item;
- for (item = arr; *item != NULL; item++) {
- PyMem_Free(*item);
- }
-
- free(arr);
-}
-
-/* Copies the strings from a python list to a null terminated array.
- * The strings are shallow copied and are owned by python.
- * Don't keep this array after the call.
- *
- * Returns a NULL terminated array of null strings. On error returns NULL and
- * sets the python error accordingly
- */
-static char**
-pyListToArray(PyObject* list, int checkIfEmpty) {
- int argn;
- int i;
- char** argv;
-
- if (!PyList_Check(list)) {
- PyErr_SetString(PyExc_TypeError, "Argument must be a python list");
- return NULL;
- }
-
- argn = PyList_Size(list);
- if ((checkIfEmpty) && (argn < 1)) {
- PyErr_SetString(PyExc_ValueError, "List must not be empty");
- return NULL;
- }
-
- argv = calloc(argn + 1, sizeof(char*));
- if (!argv) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- for (i = 0; i < argn; i++) {
- if (!PyArg_Parse(PyList_GetItem(list, i),
- "et;",
- Py_FileSystemDefaultEncoding,
- &argv[i])) {
- PyErr_SetString(PyExc_TypeError,
- "createProcess() arg 2 must contain only strings");
- goto fail;
- }
- }
-
- return argv;
-
-fail:
- freeStringArray(argv);
- return NULL;
-}
-
-/* Python's implementation of Popen forks back to python before execing.
- * Forking a python proc is a very complex and volatile process.
- *
- * This is a simpler method of execing that doesn't go back to python after
- * forking. This allows for faster safer exec.
- *
- * return NULL on error and sets the python error accordingly.
- */
-static PyObject *
-createProcess(PyObject *self, PyObject *args)
-{
- int cpid;
- int deathSignal = 0;
- int rv;
-
- int outfd[2] = {-1, -1};
- int in1fd[2] = {-1, -1};
- int in2fd[2] = {-1, -1};
-
- int errnofd[2] = {-1, -1};
- int childErrno = 0;
-
- PyObject* pyArgList;
- PyObject* pyEnvList;
- const char* cwd;
- int close_fds = 0;
-
- char** argv = NULL;
- char** envp = NULL;
-
- if (!PyArg_ParseTuple(args, "O!iiiiiiizOi:createProcess;",
- &PyList_Type, &pyArgList, &close_fds,
- &outfd[0], &outfd[1],
- &in1fd[0], &in1fd[1],
- &in2fd[0], &in2fd[1],
- &cwd, &pyEnvList, &deathSignal)) {
- return NULL;
- }
-
- argv = pyListToArray(pyArgList, 1);
- if (!argv) {
- goto fail;
- }
-
- if (PyList_Check(pyEnvList)) {
- envp = pyListToArray(pyEnvList, 0);
- if (!envp) {
- goto fail;
- }
- }
-
- if(pipe(errnofd) < 0) {
- PyErr_SetFromErrno(PyExc_OSError);
- goto fail;
- }
-
-try_fork:
- cpid = fork();
- if (cpid < 0) {
- if (errno == EAGAIN ||
- errno == EINTR ) {
- goto try_fork;
- }
-
- PyErr_SetFromErrno(PyExc_OSError);
- goto fail;
- }
-
- if (!cpid) {
- safeClose(0);
- safeClose(1);
- safeClose(2);
-
- dup2(outfd[0], 0);
- dup2(in1fd[1], 1);
- dup2(in2fd[1], 2);
-
- safeClose(outfd[0]);
- safeClose(outfd[1]);
- safeClose(in1fd[0]);
- safeClose(in1fd[1]);
- safeClose(in2fd[0]);
- safeClose(in2fd[1]);
- safeClose(errnofd[0]);
-
- if (deathSignal) {
- childErrno = prctl(PR_SET_PDEATHSIG, deathSignal);
- if (childErrno < 0) {
- childErrno = errno;
- }
- /* Check that parent did not already die between fork and us
- * setting the death signal */
- if (write(errnofd[1], &childErrno, sizeof(int)) < sizeof(int)) {
- exit(-1);
- }
-
- if (childErrno != 0) {
- exit(-1);
- }
- }
-
- if (setCloseOnExec(errnofd[1]) < 0) {
- goto sendErrno;
- }
-
- if (close_fds) {
- closeFDs(errnofd[1]);
- }
-
- if (cwd) {
- if (chdir(cwd) < 0) {
- goto sendErrno;
- }
- setenv("PWD", cwd, 1);
- }
-exec:
- if (envp) {
- execvpe(argv[0], argv, envp);
- } else {
- execvp(argv[0], argv);
- }
-
- if (errno == EINTR ||
- errno == EAGAIN )
- {
- goto exec;
- }
-sendErrno:
- if (write(errnofd[1], &errno, sizeof(int)) < 0) {
- exit(errno);
- }
- exit(-1);
- }
-
- safeClose(errnofd[1]);
- errnofd[1] = -1;
-
- if (deathSignal) {
- /* death signal sync point */
- rv = safeRead(errnofd[0], &childErrno, sizeof(int));
- if (rv != sizeof(int)) {
- PyErr_SetFromErrno(PyExc_OSError);
- goto fail;
- } else if (childErrno != 0) {
- PyErr_SetString(PyExc_OSError, strerror(childErrno));
- goto fail;
- }
- }
-
- /* error sync point */
- rv = safeRead(errnofd[0], &childErrno, sizeof(int));
- if (rv == sizeof(int)) {
- PyErr_SetString(PyExc_OSError, strerror(childErrno));
- goto fail;
- } else if (rv < 0) {
- PyErr_SetFromErrno(PyExc_OSError);
- goto fail;
- }
-
- safeClose(errnofd[0]);
- errnofd[0] = -1;
-
- /* From this point errors shouldn't occur, if they do something is very
- * very very wrong */
-
- freeStringArray(argv);
-
- if (envp) {
- freeStringArray(envp);
- }
-
- return Py_BuildValue("(iiii)", cpid, outfd[1], in1fd[0], in2fd[0]);
-
-fail:
- if (argv) {
- freeStringArray(argv);
- }
-
- if (envp) {
- freeStringArray(envp);
- }
-
- if (errnofd[0] >= 0) {
- safeClose(errnofd[0]);
- }
-
- if (errnofd[1] >= 0) {
- safeClose(errnofd[1]);
- }
-
- return NULL;
-}
diff --git a/lib/cpopen/setup.py b/lib/cpopen/setup.py
deleted file mode 100644
index 66fc157..0000000
--- a/lib/cpopen/setup.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from distutils.core import setup, Extension
-
-module1 = Extension('cpopen',
- sources=['cpopen.c'])
-
-setup(name='cpopen',
- version='1.2.1',
- description='Creates a subprocess in simpler safer manner',
- py_modules=['__init__'],
- author='Yaniv Bronhaim',
- author_email='ybronhei(a)redhat.com',
- url='redhat.com',
- ext_modules=[module1])
diff --git a/lib/cpopen/tests.py b/lib/cpopen/tests.py
deleted file mode 100644
index 9dd1906..0000000
--- a/lib/cpopen/tests.py
+++ /dev/null
@@ -1,196 +0,0 @@
-#
-# Copyright 2012 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 subprocess
-from nose.plugins.skip import SkipTest
-import signal
-import threading
-import time
-
-from unittest import TestCase
-
-EXT_ECHO = "/bin/echo"
-
-if __name__ != "__main__":
- # This will not be available when we use this module as a subprocess
- import glob
- for p in glob.glob("build/*/"):
- sys.path.append(p)
-
- from . import CPopen
-
-
-class TestCPopen(TestCase):
- def testEcho(self):
- data = "Hello"
- p = CPopen([EXT_ECHO, "-n", data])
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- self.assertEquals(p.stdout.read(), data)
-
- def testCat(self):
- path = "/etc/passwd"
- p = CPopen(["cat", path])
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- with open(path, "r") as f:
- self.assertEquals(p.stdout.read(), f.read())
-
- def _subTest(self, name, params, *args, **kwargs):
- p = CPopen(["python", __file__, name] + params,
- *args, **kwargs)
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- self.assertEquals(p.stdout.read().strip(), "True")
-
- def testCloseFDs(self):
- fds = os.pipe()
- try:
- self._subTest("fds", [str(fds[1])], close_fds=True)
- finally:
- os.close(fds[0])
- os.close(fds[1])
-
- def testNoCloseFds(self):
- fds = os.pipe()
- try:
- self._subTest("nofds", [str(fds[1])], close_fds=False)
- finally:
- os.close(fds[0])
- os.close(fds[1])
-
- def testEnv(self):
- env = os.environ.copy()
- env["TEST"] = "True"
- self._subTest("env", [], env=env)
-
- def testCwd(self):
- cwd = "/proc"
- p = CPopen(["python", "-c", "import os; print os.getcwd()"],
- cwd=cwd)
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- self.assertEquals(p.stdout.read().strip(), cwd)
-
- def testRunNonExecutable(self):
- self.assertRaises(OSError, CPopen, ["/tmp"])
-
- def testBadCwd(self):
- self.assertRaises(OSError, CPopen, ["echo", "hello"],
- cwd="/~~~~~dasdas~~~~")
-
- def testUnicodeArg(self):
- data = u'hello'
- cmd = [EXT_ECHO, "-n", data]
-
- p = CPopen(cmd)
- p.wait()
- p2 = subprocess.Popen(cmd, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p2.wait()
- self.assertEquals(p.stdout.read(), p2.stdout.read())
-
- def testNonASCIIUnicodeArg(self):
- data = u'\u05e9\u05dc\u05d5\u05dd'
- # If the default encoding is not utf-8 the test *should* fail as non
- # ascii conversion shouldn't work
- if sys.getfilesystemencoding() != "UTF-8":
- raise SkipTest("The default encoding isn't unicode")
-
- cmd = [EXT_ECHO, "-n", data]
-
- p = CPopen(cmd)
- p.wait()
- p2 = subprocess.Popen(cmd, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p2.wait()
- self.assertEquals(p.stdout.read(), p2.stdout.read())
-
- def testStdin(self):
- data = "Hello World"
- p = CPopen(["cat"])
- p.stdin.write(data)
- p.stdin.flush()
- p.stdin.close()
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
-
- self.assertEquals(p.stdout.read(), data)
-
- def testStdinEpoll(self):
- import select
-
- data = "Hello World"
- p = CPopen(["cat"])
- ep = select.epoll()
- ep.register(p.stdin, select.EPOLLOUT)
- fd, ev = ep.poll(1)[0]
- ep.close()
- os.write(fd, data)
- p.stdin.close()
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
-
- self.assertEquals(p.stdout.read(), data)
-
- def testDeathSignal(self):
- # This is done because assignment in python doesn't cross scopes
- procPtr = [None]
-
- def spawn():
- procPtr[0] = CPopen(["sleep", "10"],
- deathSignal=signal.SIGKILL)
-
- t = threading.Thread(target=spawn)
- t.start()
- t.join()
- start = time.time()
- procPtr[0].wait()
- self.assertTrue(time.time() - start < 1)
-
-
-if __name__ == "__main__":
- cmd = sys.argv[1]
- if cmd == "fds":
- try:
- os.close(int(sys.argv[2]))
- print "False"
- except:
- print "True"
-
- elif cmd == "nofds":
- try:
- os.close(int(sys.argv[2]))
- print "True"
- except:
- print "False"
-
- elif cmd == "env":
- try:
- print os.environ.get("TEST", "False")
- except:
- print "False"
diff --git a/vdsm.spec.in b/vdsm.spec.in
index f996bd8..203069f 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -237,7 +237,7 @@
Requires: %{name}-python = %{version}-%{release}
Requires: %{name}-xmlrpc = %{version}-%{release}
-Requires: %{name}-python-cpopen
+Requires: python-cpopen
%description cli
Call VDSM commands from the command line. Used for testing and debugging.
@@ -247,7 +247,7 @@
BuildArch: noarch
Requires: %{name}-python = %{version}-%{release}
-Requires: %{name}-python-cpopen
+Requires: python-cpopen
%description xmlrpc
@@ -302,15 +302,6 @@
%description reg
VDSM registration package. Used to register a Linux host to a Virtualization
Manager.
-
-%package python-cpopen
-Summary: Creates a sub-process in simpler safer manner.
-
-BuildRequires: python2-devel
-
-%description python-cpopen
-Python package for creating sub-process in simpler and safer manner by using C
-code.
%package python
Summary: VDSM python libraries
@@ -1300,11 +1291,11 @@
%{_datadir}/%{vdsm_name}/gluster/tasks.py*
%endif
-%files python-cpopen
-%{python_sitearch}/cpopen/__init__.py*
-%attr(755, root, root) %{python_sitearch}/cpopen/cpopen.so*
-
%changelog
+* Sun Oct 13 2013 Yaniv Bronhaim <ybronhei(a)redhat.com> - 4.13.0
+- Removing vdsm-python-cpopen from the spec
+- Adding dependency on formal cpopen package
+
* Sun Apr 07 2013 Yaniv Bronhaim <ybronhei(a)redhat.com> - 4.9.0-1
- Adding cpopen package
--
To view, visit http://gerrit.ovirt.org/20142
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6dfc943cbf7ac1e4c575069afca9c7df0624372f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
10 years, 7 months
Change in vdsm[master]: Drop evil exception swallowing form removeNic
by asegurap@redhat.com
Antoni Segura Puimedon has uploaded a new change for review.
Change subject: Drop evil exception swallowing form removeNic
......................................................................
Drop evil exception swallowing form removeNic
Change-Id: Ib7e2ef5e75a4637110843e205753cef1110de8ea
Signed-off-by: Antoni S. Puimedon <asegurap(a)redhat.com>
---
M vdsm/netconf/ifcfg.py
1 file changed, 6 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/79/20179/1
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index 6c8af10..49106cd 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -605,15 +605,12 @@
def removeNic(self, nic):
cf = netinfo.NET_CONF_PREF + nic
self._backup(cf)
- try:
- hwlines = [line for line in open(cf).readlines()
- if line.startswith('HWADDR=')]
- l = ['DEVICE=%s\n' % nic, 'ONBOOT=yes\n',
- 'MTU=%s\n' % netinfo.DEFAULT_MTU] + hwlines
- with open(cf, 'w') as nicFile:
- nicFile.writelines(l)
- except IOError:
- pass
+ with open(cf)as nicFile:
+ hwlines = [line for line in nicFile if line.startswith('HWADDR=')]
+ l = ['DEVICE=%s\n' % nic, 'ONBOOT=yes\n', 'MTU=%s\n' %
+ netinfo.DEFAULT_MTU] + hwlines
+ with open(cf, 'w') as nicFile:
+ nicFile.writelines(l)
def removeVlan(self, vlan):
self._backup(netinfo.NET_CONF_PREF + vlan)
--
To view, visit http://gerrit.ovirt.org/20179
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7e2ef5e75a4637110843e205753cef1110de8ea
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap(a)redhat.com>
10 years, 7 months
Change in vdsm[master]: Testing my sanity
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: Testing my sanity
......................................................................
Testing my sanity
Change-Id: I8e2054ca3695bcf50cf77e99d7285b6460332e75
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/cpopen/tests.py
1 file changed, 2 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/20176/1
diff --git a/lib/cpopen/tests.py b/lib/cpopen/tests.py
index 9dd1906..039770b 100644
--- a/lib/cpopen/tests.py
+++ b/lib/cpopen/tests.py
@@ -27,6 +27,8 @@
from unittest import TestCase
+# No change yet
+
EXT_ECHO = "/bin/echo"
if __name__ != "__main__":
--
To view, visit http://gerrit.ovirt.org/20176
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e2054ca3695bcf50cf77e99d7285b6460332e75
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
10 years, 7 months
Change in vdsm[master]: fix [start|stop]MonitoringDomain introduction version
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: fix [start|stop]MonitoringDomain introduction version
......................................................................
fix [start|stop]MonitoringDomain introduction version
vdsm-4.13.0 was released without this new verb, which should be
available only in vdsm-4.14.
Change-Id: I2e559192c6960fafb32f887f6812e3f7aead6d9a
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm_api/vdsmapi-schema.json
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/20171/1
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 8448498..73889d1 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -1738,7 +1738,7 @@
# Returns:
# None
#
-# Since: 4.12.2
+# Since: 4.14.0
##
{'command': {'class': 'Host', 'name': 'startMonitoringDomain'},
'data': {'SdUUID': 'UUID', 'HostID': 'int' }
@@ -1754,7 +1754,7 @@
# Returns:
# None
#
-# Since: 4.12.2
+# Since: 4.14.0
##
{'command': {'class': 'Host', 'name': 'stopMonitoringDomain'},
'data': {'SdUUID': 'UUID' }
--
To view, visit http://gerrit.ovirt.org/20171
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e559192c6960fafb32f887f6812e3f7aead6d9a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
10 years, 7 months