Change in vdsm[master]: sampling: remove HostStatsThread.get()
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: sampling: remove HostStatsThread.get()
......................................................................
sampling: remove HostStatsThread.get()
Remove the get() operation of HostStatsThread,
decouple sample storage and stats production,
Change-Id: I80d919b0adb48a40d41f387543f14be265610405
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/samplingTests.py
M vdsm/API.py
M vdsm/clientIF.py
M vdsm/virt/sampling.py
4 files changed, 22 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/42036/1
diff --git a/tests/samplingTests.py b/tests/samplingTests.py
index ab85834..0b0bd2b 100644
--- a/tests/samplingTests.py
+++ b/tests/samplingTests.py
@@ -262,11 +262,13 @@
'rxRate': 0.0,
'txRate': 0.0,
}
- self._hs = sampling.HostStatsThread(self.log)
- self.assertEquals(self._hs.get(), expected)
+ self.assertEquals(hoststats.produce(None, None), expected)
def testSamplesWraparound(self):
- NUM = sampling.HostStatsThread.AVERAGING_WINDOW + 1
+ NUM = sampling.HOST_STATS_AVERAGING_WINDOW + 1
+
+ samples = sampling.SampleWindow(
+ sampling.HOST_STATS_AVERAGING_WINDOW)
class FakeEvent(object):
def __init__(self, *args):
@@ -299,16 +301,16 @@
pass
with MonkeyPatchScope([(sampling, 'HostSample', FakeHostSample)]):
- self._hs = sampling.HostStatsThread(self.log)
+ self._hs = sampling.HostStatsThread(self.log, samples)
self._hs._sampleInterval = 0
# we cannot monkey patch, it will interfer on threading internals
self._hs._stopEvent = FakeEvent()
self._hs.start()
self._hs.join()
- first, last, _ = self._hs._samples.stats()
+ first, last, _ = samples.stats()
self.assertEqual(first.id,
FakeHostSample.counter -
- sampling.HostStatsThread.AVERAGING_WINDOW)
+ sampling.HOST_STATS_AVERAGING_WINDOW)
self.assertEqual(last.id,
FakeHostSample.counter - 1)
diff --git a/vdsm/API.py b/vdsm/API.py
index 397f87e..e05a939 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -43,6 +43,8 @@
import storage.volume
import storage.sd
import storage.image
+from virt import hoststats
+from virt import sampling
from virt import vmstatus
from virt.vmdevices import graphics
from virt.vmdevices import hwclass
@@ -1318,7 +1320,8 @@
hooks.before_get_stats()
stats = {}
decStats = {'elapsedTime': self._cif.elapsed_time}
- decStats.update(self._cif._hostStats.get())
+ first_sample, last_sample, _ = sampling.host_samples.stats()
+ decStats.update(hoststats.produce(first_sample, last_sample))
if self._cif.irs:
decStats['storageDomains'] = self._cif.irs.repoStats()
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index c8ef6f6..6cd5e7f 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -94,7 +94,8 @@
self.gluster = None
try:
self.vmContainer = {}
- self._hostStats = sampling.HostStatsThread(log=log)
+ self._hostStats = sampling.HostStatsThread(
+ log, sampling.host_samples)
self._hostStats.start()
self._startTime = time.time()
self.lastRemoteAccess = 0
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 401bae9..40cb3ee 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -37,7 +37,6 @@
from vdsm.config import config
from .utils import ExpiringCache
-from . import hoststats
import caps
@@ -524,19 +523,24 @@
return doms
+HOST_STATS_AVERAGING_WINDOW = 5
+
+
+host_samples = SampleWindow(size=HOST_STATS_AVERAGING_WINDOW)
+
+
class HostStatsThread(threading.Thread):
"""
A thread that periodically samples host statistics.
"""
- AVERAGING_WINDOW = 5
_CONNLOG = logging.getLogger('connectivity')
- def __init__(self, log):
+ def __init__(self, log, samples):
threading.Thread.__init__(self)
self.daemon = True
self._log = log
self._stopEvent = threading.Event()
- self._samples = SampleWindow(size=self.AVERAGING_WINDOW)
+ self._samples = samples
self._pid = os.getpid()
self._ncpus = max(os.sysconf('SC_NPROCESSORS_ONLN'), 1)
@@ -569,10 +573,6 @@
except:
if not self._stopEvent.isSet():
self._log.exception("Error while sampling stats")
-
- def get(self):
- first_sample, last_sample, _ = self._samples.stats()
- return hoststats.produce(first_sample, last_sample)
def _getLinkSpeed(dev):
--
To view, visit https://gerrit.ovirt.org/42036
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I80d919b0adb48a40d41f387543f14be265610405
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: Renaming policycoreutils-python dependency for fedora 23 and...
by ybronhei@redhat.com
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Renaming policycoreutils-python dependency for fedora 23 and above
......................................................................
Renaming policycoreutils-python dependency for fedora 23 and above
The utilities of policycoreutils-python is renamed to
policycoreutils-python-utils in fedora 23
Change-Id: I4d0b9fbfd77419cbf885c7663d799f19213592f5
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1246626
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M vdsm.spec.in
1 file changed, 8 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/19/44019/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 4772416..aafd309 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -91,7 +91,11 @@
BuildRequires: m2crypto
BuildRequires: mom >= 0.4.5
BuildRequires: openssl
+%if 0%{?fedora} >= 23
+BuildRequires: policycoreutils-python-utils
+%else
BuildRequires: policycoreutils-python
+%endif # fedora 23
BuildRequires: psmisc
BuildRequires: python-cpopen >= 1.3
BuildRequires: python-inotify
@@ -197,7 +201,11 @@
Requires: initscripts >= 9.42.2-1
Requires: device-mapper-multipath >= 0.4.9-56
Requires: e2fsprogs >= 1.41.14
+%if 0%{?fedora} >= 23
+Requires: policycoreutils-python-utils
+%else
Requires: policycoreutils-python
+%endif # fedora 23
Requires: sed >= 4.2.1-10
Requires: ed
Requires: lvm2 >= 2.02.98-15
--
To view, visit https://gerrit.ovirt.org/44019
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4d0b9fbfd77419cbf885c7663d799f19213592f5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: Raise python-cpopen requirement to 1.4
by ybronhei@redhat.com
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Raise python-cpopen requirement to 1.4
......................................................................
Raise python-cpopen requirement to 1.4
Change-Id: I4c5d62281cfba20eed51f9960065b192f7a209d3
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1264667
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M vdsm.spec.in
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/24/46724/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index bced975..e63936e 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -88,7 +88,7 @@
BuildRequires: openssl
BuildRequires: policycoreutils-python
BuildRequires: psmisc
-BuildRequires: python-cpopen >= 1.3
+BuildRequires: python-cpopen >= 1.4
BuildRequires: python-inotify
BuildRequires: python-ioprocess >= 0.14
BuildRequires: python-pthreading
@@ -121,7 +121,7 @@
Requires: python-netaddr
Requires: python-inotify
Requires: python-argparse
-Requires: python-cpopen >= 1.3
+Requires: python-cpopen >= 1.4
Requires: python-ioprocess >= 0.14
Requires: python-pthreading >= 0.1.3-3
Requires: python-six
@@ -298,7 +298,7 @@
%package python
Summary: VDSM python libraries
Requires: %{name}-infra = %{version}-%{release}
-Requires: python-cpopen >= 1.2.3-5
+Requires: python-cpopen >= 1.4
Requires: m2crypto
Requires: python-ioprocess >= 0.14
--
To view, visit https://gerrit.ovirt.org/46724
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c5d62281cfba20eed51f9960065b192f7a209d3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: sampling: add 'ncpus' property to HostSample
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: sampling: add 'ncpus' property to HostSample
......................................................................
sampling: add 'ncpus' property to HostSample
to decouple HostStatsThread and hoststats.produce().
Change-Id: I0e7d549b7772e3f38eec2dd9b91bbc6416b549bf
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/hoststats.py
M vdsm/virt/sampling.py
2 files changed, 7 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/35/42035/1
diff --git a/vdsm/virt/hoststats.py b/vdsm/virt/hoststats.py
index 57c6954..7a23743 100644
--- a/vdsm/virt/hoststats.py
+++ b/vdsm/virt/hoststats.py
@@ -26,7 +26,7 @@
import v2v
-def produce(ncpus, first_sample, last_sample):
+def produce(first_sample, last_sample):
stats = _empty_stats()
if first_sample is None:
@@ -45,10 +45,10 @@
jiffies = (
last_sample.totcpu.user - first_sample.totcpu.user) % (2 ** 32)
- stats['cpuUser'] = jiffies / interval / ncpus
+ stats['cpuUser'] = jiffies / interval / last_sample.ncpus
jiffies = (
last_sample.totcpu.sys - first_sample.totcpu.sys) % (2 ** 32)
- stats['cpuSys'] = jiffies / interval / ncpus
+ stats['cpuSys'] = jiffies / interval / last_sample.ncpus
stats['cpuIdle'] = max(0.0,
100.0 - stats['cpuUser'] - stats['cpuSys'])
stats['memUsed'] = last_sample.memUsed
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 5729a54..401bae9 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -232,7 +232,7 @@
d[p] = {'free': str(free)}
return d
- def __init__(self, pid):
+ def __init__(self, pid, ncpus):
"""
Initialize a HostSample.
@@ -242,6 +242,7 @@
super(HostSample, self).__init__()
self.interfaces = _get_interfaces_and_samples()
self.pidcpu = PidCpuSample(pid)
+ self.ncpus = ncpus
self.totcpu = TotalCpuSample()
meminfo = utils.readMemInfo()
freeOrCached = (meminfo['MemFree'] +
@@ -553,7 +554,7 @@
time.sleep(self._sampleInterval)
while not self._stopEvent.isSet():
try:
- sample = HostSample(self._pid)
+ sample = HostSample(self._pid, self._ncpus)
self._samples.append(sample)
second_last = self._samples.last(nth=2)
if second_last is None:
@@ -571,7 +572,7 @@
def get(self):
first_sample, last_sample, _ = self._samples.stats()
- return hoststats.produce(self._ncpus, first_sample, last_sample)
+ return hoststats.produce(first_sample, last_sample)
def _getLinkSpeed(dev):
--
To view, visit https://gerrit.ovirt.org/42035
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e7d549b7772e3f38eec2dd9b91bbc6416b549bf
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: virt: periodic: avoid NotConnectedError spam
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: periodic: avoid NotConnectedError spam
......................................................................
virt: periodic: avoid NotConnectedError spam
periodic operations have well known races on
VM startup and VM shutdown.
These races are well known, because periodic are
asynchronous with respect VM startup/shutdown,
and are benign because operations are just supposed
to be retried next cycle.
Under high load and/or unresponsive libvirt, we may
have log spam for Vm._dom being unconnected.
Let's avoid useless and scary stacktraces in the logs.
X-Backport-To: 3.6
Change-Id: I920e3b0b0e80e0a66ad199607068424986933d3a
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/periodic.py
1 file changed, 8 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/44813/1
diff --git a/vdsm/virt/periodic.py b/vdsm/virt/periodic.py
index a2ee8ba..6a2841b 100644
--- a/vdsm/virt/periodic.py
+++ b/vdsm/virt/periodic.py
@@ -32,6 +32,7 @@
from vdsm.utils import monotonic_time
from . import sampling
+from . import virdomain
# just a made up number. Maybe should be equal to number of cores?
@@ -268,7 +269,13 @@
return self._vm.isDomainReadyForCommands()
def __call__(self):
- self._execute()
+ try:
+ self._execute()
+ except virdomain.NotConnectedError:
+ # no worries, let's retry again next time.
+ # but let's not spam logs with useless stacktraces.
+ self._vm.log.warning('could not run on %s: domain not connected',
+ self._vm.id)
class UpdateVolumes(_RunnableVmOperation):
--
To view, visit https://gerrit.ovirt.org/44813
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I920e3b0b0e80e0a66ad199607068424986933d3a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: WIP: RFC: factor out periodic operations
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: WIP: RFC: factor out periodic operations
......................................................................
WIP: RFC: factor out periodic operations
Factor the periodic operation implementations
using a common subclass.
This patch has little benefit on its own, but
helps to reduce the size of the followup patch.
WARNING: this patch is not yet ready for review,
let alone merging. It is a proof of concept and
live demo.
Change-Id: I283331ecfa5b47c147f0a42cd4a6b51a49308fe7
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/periodic.py
1 file changed, 18 insertions(+), 30 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/44548/4
diff --git a/vdsm/virt/periodic.py b/vdsm/virt/periodic.py
index 632674f..e3801d6 100644
--- a/vdsm/virt/periodic.py
+++ b/vdsm/virt/periodic.py
@@ -256,20 +256,26 @@
return 'VmDispatcher(%s)' % self._create
-class UpdateVolumes(object):
+class _RunnableVmOperation(object):
def __init__(self, vm):
self._vm = vm
-
- @property
- def required(self):
- # Avoid queries from storage during recovery process
- return self._vm.isDisksStatsCollectionEnabled()
@property
def runnable(self):
return self._vm.isDomainReadyForCommands()
def __call__(self):
+ self._execute()
+
+
+class UpdateVolumes(_RunnableVmOperation):
+
+ @property
+ def required(self):
+ # Avoid queries from storage during recovery process
+ return self._vm.isDisksStatsCollectionEnabled()
+
+ def _execute(self):
for drive in self._vm.getDiskDevices():
# TODO: If this block (it is actually possible?)
# we must make sure we don't overwrite good data
@@ -277,25 +283,17 @@
self._vm.updateDriveVolume(drive)
-class NumaInfoMonitor(object):
- def __init__(self, vm):
- self._vm = vm
+class NumaInfoMonitor(_RunnableVmOperation):
@property
def required(self):
return self._vm.hasGuestNumaNode
- @property
- def runnable(self):
- return self._vm.isDomainReadyForCommands()
-
- def __call__(self):
+ def _execute(self):
self._vm.updateNumaInfo()
-class BlockjobMonitor(object):
- def __init__(self, vm):
- self._vm = vm
+class BlockjobMonitor(_RunnableVmOperation):
@property
def required(self):
@@ -306,26 +304,16 @@
# monitor (most often true).
return self._vm.hasVmJobs
- @property
- def runnable(self):
- return self._vm.isDomainReadyForCommands()
-
- def __call__(self):
+ def _execute(self):
self._vm.updateVmJobs()
-class DriveWatermarkMonitor(object):
- def __init__(self, vm):
- self._vm = vm
+class DriveWatermarkMonitor(_RunnableVmOperation):
@property
def required(self):
# Avoid queries from storage during recovery process
return self._vm.isDisksStatsCollectionEnabled()
- @property
- def runnable(self):
- return self._vm.isDomainReadyForCommands()
-
- def __call__(self):
+ def _execute(self):
self._vm.extendDrivesIfNeeded()
--
To view, visit https://gerrit.ovirt.org/44548
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I283331ecfa5b47c147f0a42cd4a6b51a49308fe7
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
8 years, 7 months
Change in vdsm[master]: json cli: use ssl when creating a socket
by ykaplan@redhat.com
Yeela Kaplan has uploaded a new change for review.
Change subject: json cli: use ssl when creating a socket
......................................................................
json cli: use ssl when creating a socket
We want to be compatible with xmlrpc cli using regular ssl,
instead of current m2crypto.
Change-Id: I2fa15584eed90945cdf2eb8cad17ed7697678932
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M lib/vdsm/utils.py
M lib/yajsonrpc/stompreactor.py
2 files changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/45611/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index b7818eb..6f65275 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -1255,12 +1255,14 @@
return count * size
-def create_connected_socket(host, port, sslctx=None, timeout=None):
+def create_connected_socket(host, port, sslctx=None, timeout=None, m2c=True):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if sslctx:
- if _m2cEnabled:
+ if _m2cEnabled and m2c:
sock = SSL.Connection(sslctx.context)
else:
+ if _m2cEnabled:
+ import ssl
sock = ssl.wrap_socket(sock,
keyfile=sslctx.key_file,
certfile=sslctx.cert_file,
diff --git a/lib/yajsonrpc/stompreactor.py b/lib/yajsonrpc/stompreactor.py
index 7b63525..c9e8062 100644
--- a/lib/yajsonrpc/stompreactor.py
+++ b/lib/yajsonrpc/stompreactor.py
@@ -558,7 +558,8 @@
thread.setDaemon(True)
thread.start()
- client = StompClient(utils.create_connected_socket(host, port, sslctx),
+ client = StompClient(utils.create_connected_socket(host, port,
+ sslctx, m2c=False),
reactor)
jsonclient = JsonRpcClient(
--
To view, visit https://gerrit.ovirt.org/45611
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2fa15584eed90945cdf2eb8cad17ed7697678932
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: vdscli: map invocation params to dictionary
by Piotr Kliczewski
Piotr Kliczewski has uploaded a new change for review.
Change subject: vdscli: map invocation params to dictionary
......................................................................
vdscli: map invocation params to dictionary
We need to be more flexible with parameters provided during execution of
vdscli methods. Now we use api schema to name all the params so we can
match them properly on the server side.
With this change we can call vdscli methods as regular method and do
mapping behind the scene.
Code used for xmlrpc looked like:
self.vdscli.addNetwork(bridge,
*self._get_net_args(vlan, bond, nics, opts))
In above case we are required to prepare named params as array.
Now we can call it:
self.vdscli.addNetwork(bridge,
vlan=vlan, bond=bond, nics=nics, opts=opts))
as well as we can provide only optional params as we want.
This is first step which enable us to provide client side schema
validation.
It is required to extract schema files from jsonrpc rpm due to
dependency needed for python rpm. Now we make schema rpm required for
jsonrpc and python rpm.
Change-Id: Ibac6eab3c519becb29d2b3551111d671bbb79df5
Signed-off-by: pkliczewski <piotr.kliczewski(a)gmail.com>
---
M lib/vdsm/jsonrpcvdscli.py
M tests/crossImportsTests.py.in
M vdsm.spec.in
3 files changed, 29 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/45429/1
diff --git a/lib/vdsm/jsonrpcvdscli.py b/lib/vdsm/jsonrpcvdscli.py
index 6e65e0d..e1efb3f 100644
--- a/lib/vdsm/jsonrpcvdscli.py
+++ b/lib/vdsm/jsonrpcvdscli.py
@@ -28,6 +28,7 @@
JsonRpcRequest, \
JsonRpcNoResponseError
+from rpc import vdsmapi
from vdsm import response
from .config import config
@@ -58,10 +59,19 @@
class _Server(object):
def __init__(self, client, compat):
+ self._vapi = vdsmapi.get_api()
self._client = client
self._compat = compat
- def _callMethod(self, methodName, *args):
+ def prepare_args(self, className, methodName, args, kwargs):
+ sym = self._vapi['commands'][className][methodName]
+ allargs = sym.get('data', {}).keys()
+ allargs = [arg[1:] if arg.startswith('*') else arg for arg in allargs]
+ params = dict(zip(allargs, args))
+ params.update(kwargs)
+ return params
+
+ def _callMethod(self, methodName, *args, **kwargs):
try:
method = _COMMAND_CONVERTER[methodName]
except KeyError as e:
@@ -69,7 +79,10 @@
"arguments: %s error: %s" %
(methodName, args, e))
- req = JsonRpcRequest(method, args, reqId=str(uuid4()))
+ class_name, method_name = method.split('.')
+ params = self.prepare_args(class_name, method_name, args, kwargs)
+
+ req = JsonRpcRequest(method, params, reqId=str(uuid4()))
responses = self._client.call(req)
if responses:
resp = responses[0]
diff --git a/tests/crossImportsTests.py.in b/tests/crossImportsTests.py.in
index a3e1d81..acb4ea3 100644
--- a/tests/crossImportsTests.py.in
+++ b/tests/crossImportsTests.py.in
@@ -51,4 +51,7 @@
else:
mods = get_mods(os.path.join(get_python_lib(), pkg_name))
+ # ignore schema dept for this module
+ mods.remove('jsonrpcvdscli')
+
__import__(pkg_name, fromlist=mods)
diff --git a/vdsm.spec.in b/vdsm.spec.in
index d4c1198..729b322 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -260,9 +260,16 @@
An XMLRPC interface for interacting with vdsmd. Primary control interface for
ovirt-engine and vdsClient.
+%package schema
+Summary: VDSM schema
+
+%description schema
+Contains api schema file
+
%package jsonrpc
Summary: VDSM API Server
Requires: %{name}-python = %{version}-%{release}
+Requires: %{name}-schema = %{version}-%{release}
Requires: %{name}-yajsonrpc = %{version}-%{release}
Obsoletes: vdsm-api < 4.16
@@ -301,6 +308,7 @@
Requires: python-cpopen >= 1.2.3-5
Requires: m2crypto
Requires: python-ioprocess >= 0.14
+Requires: %{name}-schema = %{version}-%{release}
%description python
Shared libraries between the various VDSM packages.
@@ -1340,9 +1348,11 @@
%{_datadir}/%{vdsm_name}/rpc/__init__.py*
%{_datadir}/%{vdsm_name}/rpc/bindingjsonrpc.py*
%{_datadir}/%{vdsm_name}/rpc/Bridge.py*
+%{python_sitelib}/yajsonrpc/__init__.py*
+
+%files schema
%{_datadir}/%{vdsm_name}/rpc/vdsmapi-schema.json
%{python_sitelib}/vdsmapi.py*
-%{python_sitelib}/yajsonrpc/__init__.py*
%if ! 0%{?with_gluster}
%exclude %{_datadir}/%{vdsm_name}/rpc/vdsmapi-gluster-schema.json
%endif
--
To view, visit https://gerrit.ovirt.org/45429
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibac6eab3c519becb29d2b3551111d671bbb79df5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
8 years, 7 months
Change in vdsm[master]: tests: Introduce schema parsing tests
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: tests: Introduce schema parsing tests
......................................................................
tests: Introduce schema parsing tests
Change-Id: I48c2d2cb260e175ad119ece4c5e36552bb303ada
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M tests/schemaTests.py
1 file changed, 88 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/45464/1
diff --git a/tests/schemaTests.py b/tests/schemaTests.py
index e00edba..c6fc89b 100644
--- a/tests/schemaTests.py
+++ b/tests/schemaTests.py
@@ -17,6 +17,10 @@
# Refer to the README and COPYING files for full details of the license
#
+import textwrap
+from contextlib import contextmanager
+
+from testlib import temporaryPath
from testlib import VdsmTestCase as TestCaseBase
from rpc import vdsmapi
@@ -92,3 +96,87 @@
def testTokenizeRaiseOnInvalidData(self):
generator = vdsmapi.tokenize("{'a': invalid, 'b': 'c'}")
self.assertRaises(ValueError, list, generator)
+
+
+class ParseTest(TestCaseBase):
+ blank_schema = {'types': {}, 'enums': {}, 'aliases': {},
+ 'maps': {}, 'commands': {}, 'unions': {}}
+
+ @contextmanager
+ def load_api(self, data):
+ vdsmapi._api_info = None
+ data = textwrap.dedent(data)
+ with temporaryPath(data=data) as filename:
+ yield vdsmapi.get_api(filename)
+
+ def assertTypeRelation(self, api, type_a, type_b):
+ self.assertIn(type_b, api['unions'][type_a])
+ self.assertIn(type_a, api['unions'][type_b])
+
+ def test_empty_schema(self):
+ with self.load_api('') as api:
+ self.assertEqual(self.blank_schema, api)
+
+ def test_unknown_symbol_type(self):
+ with self.load_api('''
+ {'foo': 'bar', 'data': ['a', 'b', 'c']}
+ ''') as api:
+ self.assertEqual(self.blank_schema, api)
+
+ def test_single_type(self):
+ with self.load_api('''
+ {'type': 'foo', 'data': {'a': 'str'}}
+ ''') as api:
+ self.assertIn('foo', api['types'])
+ self.assertEqual('str', api['types']['foo']['data']['a'])
+
+ def test_single_enum(self):
+ with self.load_api('''
+ {'enum': 'foo', 'data': ['a', 'b', 'c']}
+ ''') as api:
+ self.assertEqual(['a', 'b', 'c'], api['enums']['foo']['data'])
+
+ def test_single_alias(self):
+ with self.load_api('''
+ {'alias': 'UUID', 'data': 'str'}
+ ''') as api:
+ self.assertEqual('str', api['aliases']['UUID']['data'])
+
+ def test_single_map(self):
+ map = {'map': 'foo', 'key': 'str', 'value': 'str'}
+ with self.load_api(str(map)) as api:
+ self.assertEqual(map, api['maps']['foo'])
+
+ def test_single_command(self):
+ cmd = {'command': {'class': 'foo', 'name': 'bar'},
+ 'data': {'a': 'uint'}, 'returns': 'str'}
+ with self.load_api(str(cmd)) as api:
+ self.assertEqual(cmd, api['commands']['foo']['bar'])
+
+ def test_command_parameter_order(self):
+ # The parser will preserve the order of dict keys when loading
+ with self.load_api('''
+ {'command': {'class': 'foo', 'name': 'bar'},
+ 'data': {'a': 'uint', 'b': 'str', 'c': 'int'}}
+ ''') as api:
+ self.assertEqual(['a', 'b', 'c'],
+ api['commands']['foo']['bar']['data'].keys())
+
+ def test_type_union(self):
+ with self.load_api('''
+ {'enum': 'ThingTypes', 'data': ['person', 'place']}
+
+ {'type': 'Thing',
+ 'data': {'specificType': 'ThingTypes', 'name': 'str'},
+ 'union': ['Person', 'Place']}
+
+ {'type': 'Person',
+ 'data': {'specificType': 'ThingTypes', 'name': 'str',
+ 'address': 'str'}}
+
+ {'type': 'Place',
+ 'data': {'specificType': 'ThingTypes', 'name': 'str',
+ 'longitude': 'float', 'latitude': 'float'}}
+ ''') as api:
+ self.assertTypeRelation(api, 'Thing', 'Person')
+ self.assertTypeRelation(api, 'Thing', 'Place')
--
To view, visit https://gerrit.ovirt.org/45464
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I48c2d2cb260e175ad119ece4c5e36552bb303ada
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: WIP: rename stats cache to vm stats cache
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: WIP: rename stats cache to vm stats cache
......................................................................
WIP: rename stats cache to vm stats cache
Future patch want to modernize HostStats* and
port it to periodic Operations infrastructure.
To make room for this change and reduce
ambiguity, re-introduced the ubiquitous
vm* prefix.
No changes besides naming.
Change-Id: If38c49f686dfc2bc0994d444ff24c7736f2e951b
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/samplingTests.py
M tests/vmfakelib.py
M vdsm/virt/periodic.py
M vdsm/virt/sampling.py
M vdsm/virt/vm.py
5 files changed, 16 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/40371/1
diff --git a/tests/samplingTests.py b/tests/samplingTests.py
index 2624dd7..1f2a65c 100644
--- a/tests/samplingTests.py
+++ b/tests/samplingTests.py
@@ -250,13 +250,13 @@
self.assertTrue(self._sampleCount >= self.STOP_SAMPLE)
-class StatsCacheTests(TestCaseBase):
+class VmStatsCacheTests(TestCaseBase):
FAKE_CLOCK_STEP = 1
def setUp(self):
self.clock = 0
- self.cache = sampling.StatsCache(clock=self.fake_monotonic_time)
+ self.cache = sampling.VmStatsCache(clock=self.fake_monotonic_time)
def fake_monotonic_time(self):
self.clock += self.FAKE_CLOCK_STEP
diff --git a/tests/vmfakelib.py b/tests/vmfakelib.py
index d8ce6ce..544eb5a 100644
--- a/tests/vmfakelib.py
+++ b/tests/vmfakelib.py
@@ -201,7 +201,7 @@
fake._guestCpuRunning = runCpu
if status is not None:
fake._lastStatus = status
- sampling.stats_cache.add(fake.id)
+ sampling.vm_stats_cache.add(fake.id)
yield fake
diff --git a/vdsm/virt/periodic.py b/vdsm/virt/periodic.py
index a3f8cc6..00615c3 100644
--- a/vdsm/virt/periodic.py
+++ b/vdsm/virt/periodic.py
@@ -94,7 +94,7 @@
sampling.VMBulkSampler(
libvirtconnection.get(cif),
cif.getVMs,
- sampling.stats_cache),
+ sampling.vm_stats_cache),
config.getint('vars', 'vm_sample_interval')),
# we do this only until we get high water mark notifications
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 6804406..89f109b 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -375,7 +375,7 @@
EMPTY_SAMPLE = StatsSample(None, None, None, None)
-class StatsCache(object):
+class VmStatsCache(object):
"""
Cache for bulk stats samples.
Provide facilities to retrieve per-vm samples, and the glue code to deal
@@ -391,7 +391,7 @@
VDSM has countermeasures for those cases. Stuck threads are replaced,
thanks to Executor. But still, before to be destroyed, a replaced
- thread can mistakenly try to add a sample to a StatsCache.
+ thread can mistakenly try to add a sample to a VmStatsCache.
Because of worker thread replacement, that sample from stuck thread
can be stale.
@@ -402,7 +402,7 @@
between a well behaving call and an unblocked stuck call.
"""
- _log = logging.getLogger("sampling.StatsCache")
+ _log = logging.getLogger("sampling.VmStatsCache")
def __init__(self, clock=utils.monotonic_time):
self._clock = clock
@@ -478,7 +478,7 @@
self._vm_last_timestamp[vmid] = monotonic_ts
-stats_cache = StatsCache()
+vm_stats_cache = VmStatsCache()
# this value can be tricky to tune.
@@ -492,18 +492,18 @@
class VMBulkSampler(object):
- def __init__(self, conn, get_vms, stats_cache,
+ def __init__(self, conn, get_vms, vm_stats_cache,
stats_flags=0, timeout=_TIMEOUT):
self._conn = conn
self._get_vms = get_vms
- self._stats_cache = stats_cache
+ self._vm_stats_cache = vm_stats_cache
self._stats_flags = stats_flags
self._skip_doms = ExpiringCache(timeout)
self._sampling = Stage()
self._log = logging.getLogger("sampling.VMBulkSampler")
def __call__(self):
- timestamp = self._stats_cache.clock()
+ timestamp = self._vm_stats_cache.clock()
# we are deep in the hot path. bool(ExpiringCache)
# *is* costly so we should avoid it if we can.
fast_path = (self._sampling.empty and not self._skip_doms)
@@ -514,7 +514,7 @@
# If everything's ok, we can skip all the costly checks.
bulk_stats = self._conn.getAllDomainStats(
self._stats_flags)
- self._stats_cache.put(_translate(bulk_stats), timestamp)
+ self._vm_stats_cache.put(_translate(bulk_stats), timestamp)
else:
# A previous call got stuck, or not every domain
# has properly recovered. Thus we must whitelist domains.
@@ -523,7 +523,7 @@
if doms:
bulk_stats = self._conn.domainListGetStats(
doms, self._stats_flags)
- self._stats_cache.put(_translate(bulk_stats), timestamp)
+ self._vm_stats_cache.put(_translate(bulk_stats), timestamp)
def _get_responsive_doms(self):
vms = self._get_vms()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index dcc215b..2b7e3eb 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1308,7 +1308,7 @@
decStats = {}
try:
- vm_sample = sampling.stats_cache.get(self.id)
+ vm_sample = sampling.vm_stats_cache.get(self.id)
decStats = vmstats.produce(self,
vm_sample.first_value,
vm_sample.last_value,
@@ -1675,7 +1675,7 @@
nic.name)
self._guestEventTime = self._startTime
- sampling.stats_cache.add(self.id)
+ sampling.vm_stats_cache.add(self.id)
try:
self.guestAgent.connect()
except Exception:
@@ -3454,7 +3454,7 @@
self.lastStatus = vmstatus.POWERING_DOWN
# Terminate the VM's creation thread.
self._incomingMigrationFinished.set()
- sampling.stats_cache.remove(self.id)
+ sampling.vm_stats_cache.remove(self.id)
self.guestAgent.stop()
if self._dom:
result = self._destroyVmGraceful()
--
To view, visit https://gerrit.ovirt.org/40371
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If38c49f686dfc2bc0994d444ff24c7736f2e951b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 7 months