Change in vdsm[master]: pyroute2: release() is deprecated
by phoracek@redhat.com
Petr Horáček has uploaded a new change for review.
Change subject: pyroute2: release() is deprecated
......................................................................
pyroute2: release() is deprecated
release() method is deprecated, use close() instead.
Change-Id: Idbfe663b6180654dba76d69ccc11ecbf14abff8e
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
---
M vdsm/network/configurators/pyroute_two.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/99/34199/1
diff --git a/vdsm/network/configurators/pyroute_two.py b/vdsm/network/configurators/pyroute_two.py
index 08df1c4..1e41266 100644
--- a/vdsm/network/configurators/pyroute_two.py
+++ b/vdsm/network/configurators/pyroute_two.py
@@ -164,4 +164,4 @@
libvirt.removeNetwork(network)
def releaseSocket(self):
- self.ip.release()
+ self.ip.close()
--
To view, visit http://gerrit.ovirt.org/34199
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idbfe663b6180654dba76d69ccc11ecbf14abff8e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
8 years, 10 months
Change in vdsm[master]: networkTests: setupNetworksAddBondWithManyVlans bond not found
by phoracek@redhat.com
Petr Horáček has uploaded a new change for review.
Change subject: networkTests: setupNetworksAddBondWithManyVlans bond not found
......................................................................
networkTests: setupNetworksAddBondWithManyVlans bond not found
testSetupNetworksAddBondWithManyVlans always fails on Jenkins
with 'bond0.0' not found in ...' error
(http://jenkins.ovirt.org/job/vdsm_master_network_functional_
tests_gerrit/1837/testReport/junit/networkTests/NetworkTest/
testSetupNetworksAddBondWithManyVlans_kwargs_False_/)
Change-Id: Iccd0ba18ac223a63c6633ee64772cfe6998288b1
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
---
M tests/functional/networkTests.py
1 file changed, 2 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/31855/1
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index ed45b2a..581400b 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -294,6 +294,8 @@
@ValidateRunningAsRoot
def testSetupNetworksAddBondWithManyVlans(self, bridged):
def assertDevStatsReported():
+ # import time
+ # time.sleep(1)
status, msg, hostStats = self.vdsm_net.getVdsStats()
self.assertEqual(status, SUCCESS, msg)
self.assertIn('network', hostStats)
--
To view, visit http://gerrit.ovirt.org/31855
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iccd0ba18ac223a63c6633ee64772cfe6998288b1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
8 years, 10 months
Change in vdsm[master]: client: add option to make quiet
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: client: add option to make quiet
......................................................................
client: add option to make quiet
When used for (quite brutal) benchmarking, the output
from vdsClient can add noise and can cause a (little)
slowdown.
Add an option to make it quiet.
Change-Id: Icbb9654b47fd993aee34b2292a1d94d1e4019b6a
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M client/vdsClient.py
1 file changed, 25 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/35340/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 583a0a2..d675228 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -183,11 +183,12 @@
self.useSSL = False
self.truststore = None
self.pretty = True
+ self.quiet = False
def do_connect(self, hostPort):
self.s = vdscli.connect(hostPort, self.useSSL, self.truststore)
- def ExecAndExit(self, response, parameterName='none'):
+ def printResponse(self, response, parameterName='none'):
if response['status']['code'] != 0:
print response['status']['message']
else:
@@ -202,6 +203,10 @@
printDict(response['info'], self.pretty)
else:
printDict(response['status'], self.pretty)
+
+ def ExecAndExit(self, response, parameterName='none'):
+ if not self.quiet:
+ self.printResponse(response, parameterName)
sys.exit(response['status']['code'])
def do_create(self, args):
@@ -309,7 +314,8 @@
if view == 'long':
if 'sysprepInf' in conf:
conf['sysprepInf'] = '<<exists>>'
- printConf(conf)
+ if not self.quiet:
+ printConf(conf)
elif view == 'table':
vmId = conf['vmId']
@@ -318,20 +324,23 @@
status = conf['status']
if allStats[vmId].get('monitorResponse') == '-1':
status += '*'
- print("%-36s %6s %-20s %-20s %-20s" %
- (vmId, conf.get('pid', 'none'),
- conf.get('vmName', '<< NO NAME >>'),
- status, allStats[vmId].get('guestIPs', '')))
+ if not self.quiet:
+ print("%-36s %6s %-20s %-20s %-20s" %
+ (vmId, conf.get('pid', 'none'),
+ conf.get('vmName', '<< NO NAME >>'),
+ status, allStats[vmId].get('guestIPs', '')))
elif view == 'ids':
- print conf['vmId']
+ if not self.quiet:
+ print conf['vmId']
sys.exit(response['status']['code'])
def do_destroy(self, args):
vmId = args[0]
response = self.s.destroy(vmId)
- print response['status']['message']
+ if not self.quiet:
+ print response['status']['message']
sys.exit(response['status']['code'])
def do_pause(self, args):
@@ -356,7 +365,8 @@
response = self.s.shutdown(vmId, delay, message, reboot)
else:
response = self.s.shutdown(vmId, delay, message)
- print response['status']['message']
+ if not self.quiet:
+ print response['status']['message']
sys.exit(response['status']['code'])
def do_setVmTicket(self, args):
@@ -2765,9 +2775,10 @@
commands.update(ge.getGlusterCmdDict(serv))
try:
- opts, args = getopt.getopt(sys.argv[1:], "hmso", ["help", "methods",
- "SSL", "truststore=",
- "oneliner"])
+ opts, args = getopt.getopt(sys.argv[1:],
+ "hmsoq",
+ ["help", "methods", "SSL", "truststore=",
+ "oneliner", "quiet"])
for o, v in opts:
if o == "-h" or o == "--help":
@@ -2782,6 +2793,8 @@
serv.truststore = v
if o == '-o' or o == '--oneliner':
serv.pretty = False
+ if o == '-q' or o == '--quiet':
+ serv.quiet = True
if len(args) < 2:
raise Exception("Need at least two arguments")
server, command = args[0:2]
--
To view, visit http://gerrit.ovirt.org/35340
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbb9654b47fd993aee34b2292a1d94d1e4019b6a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: client: vm params from JSON
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: client: vm params from JSON
......................................................................
client: vm params from JSON
the 'create' parameter accepts a configuration
file as source to define the parameters of the VM
being created.
This patch add support to
1. use JSON for this configuration file, so there is
little to no need to reformat data from Engine,
for example took from VDSM logs
2. use stdin as input, avoiding the need to write
(temporary) files.
Change-Id: Ic6a73bc0e5fe87eb1a48c708e7ea316c6d9df7e5
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M client/vdsClient.py
1 file changed, 95 insertions(+), 68 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/35292/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index aabf7a1..583a0a2 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -19,6 +19,7 @@
import sys
import ast
+import json
import getopt
import traceback
import xmlrpclib
@@ -204,74 +205,13 @@
sys.exit(response['status']['code'])
def do_create(self, args):
- params = {}
- drives = []
- devices = []
- cpuPinning = {}
- numaTune = {}
- guestNumaNodes = []
- confLines = []
- confFile = open(args[0])
- for line in confFile.readlines():
- line = re.sub("\s+", '', line)
- line = re.sub("\#.*", '', line)
- if line:
- confLines.append(line)
- if len(args) > 1:
- confLines.extend(args[1:])
- for line in confLines:
- if '=' in line:
- param, value = line.split("=", 1)
- if param == 'devices':
- devices.append(self._parseDriveSpec(value))
- elif param == 'drive':
- drives.append(self._parseDriveSpec(value))
- elif param == 'cpuPinning':
- cpuPinning, rStr = self._parseNestedSpec(value)
- elif param == 'numaTune':
- numaTune, rStr = self._parseNestedSpec(value)
- elif param == 'guestNumaNodes':
- guestNumaNodes.append(self._parseDriveSpec(value))
- elif param.startswith('custom_'):
- if 'custom' not in params:
- params['custom'] = {}
- params['custom'][param[7:]] = value
- else:
- if param in ('cdrom', 'floppy'):
- value = self._parseDriveSpec(value)
- params[param] = value
- else:
- params[line.strip()] = ''
- if cpuPinning:
- params['cpuPinning'] = cpuPinning
- if numaTune:
- params['numaTune'] = numaTune
- if guestNumaNodes:
- params['guestNumaNodes'] = guestNumaNodes
- if drives:
- params['drives'] = drives
- if devices:
- params['devices'] = devices
- # Backward compatibility for vdsClient users
- if 'vt' in params:
- params['kvmEnable'] = params['vt']
-
- if 'imageFile' in params:
- params['hda'] = params['imageFile']
-
- drives = ['hdd', 'hdc', 'hdb']
- if 'moreImages' in params:
- for image in params['moreImages'].split(','):
- params[drives.pop()] = image
-
- if 'sysprepInf' in params:
- infFile = open(params['sysprepInf'], 'rb')
- try:
- params['sysprepInf'] = xmlrpclib.Binary(infFile.read())
- finally:
- infFile.close()
-
- return self.ExecAndExit(self.s.create(params))
+ if args[0] == '-' or args[0].endswith('.json'):
+ params = self._readVmParamsFromJson(args)
+ else:
+ params = self._readVmParamsFromConf(args)
+ if params is not None:
+ return self.ExecAndExit(self.s.create(params))
+ return sys.exit(1)
def vmUpdateDevice(self, args):
params = self._eqSplit(args[1:])
@@ -1884,6 +1824,93 @@
return status['status']['code'], status['status']['message']
+ def _readVmParamsFromJson(self, args):
+ if args[0] == "-":
+ data = sys.stdin.read()
+ else:
+ try:
+ with open(args[0]) as f:
+ data = f.read()
+ except IOError as e:
+ print "failed to read VM config: %s" % str(e)
+ return None
+ try:
+ return json.loads(data)
+ except ValueError as e:
+ print "failed to decode VM config: %s" % str(e)
+ return None
+
+ def _readVmParamsFromConf(self, args):
+ params = {}
+ drives = []
+ devices = []
+ cpuPinning = {}
+ numaTune = {}
+ guestNumaNodes = []
+ confLines = []
+ confFile = open(args[0])
+ for line in confFile.readlines():
+ line = re.sub("\s+", '', line)
+ line = re.sub("\#.*", '', line)
+ if line:
+ confLines.append(line)
+ if len(args) > 1:
+ confLines.extend(args[1:])
+ for line in confLines:
+ if '=' in line:
+ param, value = line.split("=", 1)
+ if param == 'devices':
+ devices.append(self._parseDriveSpec(value))
+ elif param == 'drive':
+ drives.append(self._parseDriveSpec(value))
+ elif param == 'cpuPinning':
+ cpuPinning, rStr = self._parseNestedSpec(value)
+ elif param == 'numaTune':
+ numaTune, rStr = self._parseNestedSpec(value)
+ elif param == 'guestNumaNodes':
+ guestNumaNodes.append(self._parseDriveSpec(value))
+ elif param.startswith('custom_'):
+ if 'custom' not in params:
+ params['custom'] = {}
+ params['custom'][param[7:]] = value
+ else:
+ if param in ('cdrom', 'floppy'):
+ value = self._parseDriveSpec(value)
+ params[param] = value
+ else:
+ params[line.strip()] = ''
+ if cpuPinning:
+ params['cpuPinning'] = cpuPinning
+ if numaTune:
+ params['numaTune'] = numaTune
+ if guestNumaNodes:
+ params['guestNumaNodes'] = guestNumaNodes
+ if drives:
+ params['drives'] = drives
+ if devices:
+ params['devices'] = devices
+ # Backward compatibility for vdsClient users
+ if 'vt' in params:
+ params['kvmEnable'] = params['vt']
+
+ if 'imageFile' in params:
+ params['hda'] = params['imageFile']
+
+ drives = ['hdd', 'hdc', 'hdb']
+ if 'moreImages' in params:
+ for image in params['moreImages'].split(','):
+ params[drives.pop()] = image
+
+ if 'sysprepInf' in params:
+ infFile = open(params['sysprepInf'], 'rb')
+ try:
+ params['sysprepInf'] = xmlrpclib.Binary(infFile.read())
+ finally:
+ infFile.close()
+
+ return params
+
+
if __name__ == '__main__':
if _glusterEnabled:
serv = ge.GlusterService()
--
To view, visit http://gerrit.ovirt.org/35292
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6a73bc0e5fe87eb1a48c708e7ea316c6d9df7e5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: utils: Add stopwatch for timing operations
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: utils: Add stopwatch for timing operations
......................................................................
utils: Add stopwatch for timing operations
stopwatch is a context manager that make it easy to time block of code:
with stopwatch("foo.bar"):
foo.bar("baz")
Will log debug message:
foo.bar: 0.123 seconds
The log can be disabled by disabling the vds.stopwatch logger.
Change-Id: Ie0a60538936dbb4596243abe9d731779fd9efb47
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/utils.py
1 file changed, 11 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/29685/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index 2ba5762..1ae5cc7 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -26,6 +26,7 @@
Contains a reverse dictionary pointing from error string to its error code.
"""
+from contextlib import contextmanager
from collections import namedtuple, deque
from fnmatch import fnmatch
from StringIO import StringIO
@@ -669,6 +670,16 @@
return decorator
+@contextmanager
+def stopwatch(message, log=logging.getLogger('vds.stopwatch')):
+ start = time.time()
+ try:
+ yield
+ finally:
+ elapsed = time.time() - start
+ log.debug("%s: %.3f seconds", message, elapsed)
+
+
def tobool(s):
try:
if s is None:
--
To view, visit http://gerrit.ovirt.org/29685
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie0a60538936dbb4596243abe9d731779fd9efb47
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: virt: dev: implement from_xml for ControllerDevice
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: implement from_xml for ControllerDevice
......................................................................
virt: dev: implement from_xml for ControllerDevice
Change-Id: I4cf7df0495a58c81207e680732fe0e72b8b5b04c
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 27 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/33754/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index a6e68ae..05f0a2f 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -709,6 +709,17 @@
return ctrl
+ @classmethod
+ def from_xml(cls, conf, log, dev_xml):
+ alias = dev_xml.getElementsByTagName('alias')[0].getAttribute('name')
+ return cls(
+ conf, log,
+ alias=alias,
+ device=dev_xml.getAttribute('type'),
+ model=dev_xml.getAttribute('model'),
+ index=dev_xml.getAttribute('index'),
+ address=vmxml.device_address(dev_xml))
+
class SoundDevice(vmdevices.Base):
__slots__ = ('address', 'alias')
@@ -4726,41 +4737,37 @@
# Ignore controller devices without address
if not x.getElementsByTagName('address'):
continue
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
- device = x.getAttribute('type')
- # Get model and index. Relevant for USB controllers.
- model = x.getAttribute('model')
- index = x.getAttribute('index')
- # Get controller address
- address = vmxml.device_address(x)
+ dev = ControllerDevice.from_xml(x)
# In case the controller has index and/or model, they
# are compared. Currently relevant for USB controllers.
for ctrl in self._devices[CONTROLLER_DEVICES]:
- if ((ctrl.device == device) and
- (not hasattr(ctrl, 'index') or ctrl.index == index) and
- (not hasattr(ctrl, 'model') or ctrl.model == model)):
- ctrl.alias = alias
- ctrl.address = address
+ if ((ctrl.device == dev.device) and
+ (not hasattr(ctrl, 'index')
+ or ctrl.index == dev.index) and
+ (not hasattr(ctrl, 'model')
+ or ctrl.model == dev.model)):
+ ctrl.alias = dev.alias
+ ctrl.address = dev.address
# Update vm's conf with address for known controller devices
# In case the controller has index and/or model, they
# are compared. Currently relevant for USB controllers.
knownDev = False
for dev in self.conf['devices']:
if ((dev['type'] == CONTROLLER_DEVICES) and
- (dev['device'] == device) and
- ('index' not in dev or dev['index'] == index) and
- ('model' not in dev or dev['model'] == model)):
- dev['address'] = address
- dev['alias'] = alias
+ (dev['device'] == dev.device) and
+ ('index' not in dev or dev['index'] == dev.index) and
+ ('model' not in dev or dev['model'] == dev.model)):
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
knownDev = True
# Add unknown controller device to vm's conf
if not knownDev:
self.conf['devices'].append({'type': CONTROLLER_DEVICES,
- 'device': device,
- 'address': address,
- 'alias': alias})
+ 'device': dev.device,
+ 'address': dev.address,
+ 'alias': dev.alias})
def _getUnderlyingBalloonDeviceInfo(self):
"""
--
To view, visit http://gerrit.ovirt.org/33754
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4cf7df0495a58c81207e680732fe0e72b8b5b04c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: virt: dev: implement from_xml for SmartcardDevice
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: implement from_xml for SmartcardDevice
......................................................................
virt: dev: implement from_xml for SmartcardDevice
Change-Id: I395c49d1cd9af04527840a7d5aaf853d35aa122d
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 5 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/33753/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index e340ed0..a6e68ae 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4820,19 +4820,18 @@
if not x.getElementsByTagName('address'):
continue
- address = vmxml.device_address(x)
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
+ dev = SmartCardDevice.from_xml(x)
for dev in self._devices[SMARTCARD_DEVICES]:
if not hasattr(dev, 'address'):
- dev.address = address
- dev.alias = alias
+ dev.address = dev.address
+ dev.alias = dev.alias
for dev in self.conf['devices']:
if dev['device'] == SMARTCARD_DEVICES and \
not dev.get('address'):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
def _getUnderlyingWatchdogDeviceInfo(self):
"""
--
To view, visit http://gerrit.ovirt.org/33753
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I395c49d1cd9af04527840a7d5aaf853d35aa122d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: virt: dev: implement from_xml for WatchdogDevice
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: implement from_xml for WatchdogDevice
......................................................................
virt: dev: implement from_xml for WatchdogDevice
Change-Id: I8ceb0f85908c99454f0c981fa4318cc1989f0f7c
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 5 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/33752/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index a63c932..e340ed0 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4845,19 +4845,18 @@
# PCI watchdog has "address" different from ISA watchdog
if x.getElementsByTagName('address'):
- address = vmxml.device_address(x)
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
+ dev = WatchdogDevice.from_xml(x)
for wd in self._devices[WATCHDOG_DEVICES]:
if not hasattr(wd, 'address') or not hasattr(wd, 'alias'):
- wd.address = address
- wd.alias = alias
+ wd.address = dev.address
+ wd.alias = dev.alias
for dev in self.conf['devices']:
if ((dev['type'] == WATCHDOG_DEVICES) and
(not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
def _getUnderlyingVideoDeviceInfo(self):
"""
--
To view, visit http://gerrit.ovirt.org/33752
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ceb0f85908c99454f0c981fa4318cc1989f0f7c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: virt: dev: implement from_xml for SoundDevice
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: implement from_xml for SoundDevice
......................................................................
virt: dev: implement from_xml for SoundDevice
Change-Id: I04ffbb857557e9f438634465c3f13ca6446393e5
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 5 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/33751/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index d356da8..a63c932 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4892,9 +4892,7 @@
soundsxml = _domParseStr(self._lastXMLDesc).childNodes[0]. \
getElementsByTagName('devices')[0].getElementsByTagName('sound')
for x in soundsxml:
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
- # Get sound card address
- address = vmxml.device_address(x)
+ dev = SoundDevice.from_xml(x)
# FIXME. We have an identification problem here.
# Sound device has not unique identifier, except the alias
@@ -4902,15 +4900,15 @@
# we can only assign the address according to devices order.
for sc in self._devices[SOUND_DEVICES]:
if not hasattr(sc, 'address') or not hasattr(sc, 'alias'):
- sc.alias = alias
- sc.address = address
+ sc.alias = dev.alias
+ sc.address = dev.address
break
# Update vm's conf with address
for dev in self.conf['devices']:
if ((dev['type'] == SOUND_DEVICES) and
(not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
break
def _getDriveIdentification(self, dom):
--
To view, visit http://gerrit.ovirt.org/33751
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I04ffbb857557e9f438634465c3f13ca6446393e5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: virt: dev: bootstrap from_xml method
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: bootstrap from_xml method
......................................................................
virt: dev: bootstrap from_xml method
implement from_xml method, do incapsulate device
creation from xml description.
Use it for Video Devices.
Change-Id: I745909ce65ecb30da299d2d8afb1987a91581ace
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
M vdsm/virt/vmdevices.py
2 files changed, 11 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/33750/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 5b710a8..d356da8 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4866,9 +4866,7 @@
videosxml = _domParseStr(self._lastXMLDesc).childNodes[0]. \
getElementsByTagName('devices')[0].getElementsByTagName('video')
for x in videosxml:
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
- # Get video card address
- address = vmxml.device_address(x)
+ dev = vmdevices.VideoDevice.from_xml(x)
# FIXME. We have an identification problem here.
# Video card device has not unique identifier, except the alias
@@ -4876,15 +4874,15 @@
# we can only assign the address according to devices order.
for vc in self._devices[VIDEO_DEVICES]:
if not hasattr(vc, 'address') or not hasattr(vc, 'alias'):
- vc.alias = alias
- vc.address = address
+ vc.alias = dev.alias
+ vc.address = dev.address
break
# Update vm's conf with address
for dev in self.conf['devices']:
if ((dev['type'] == VIDEO_DEVICES) and
(not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
break
def _getUnderlyingSoundDeviceInfo(self):
diff --git a/vdsm/virt/vmdevices.py b/vdsm/virt/vmdevices.py
index 7b01cc4..14278e1 100644
--- a/vdsm/virt/vmdevices.py
+++ b/vdsm/virt/vmdevices.py
@@ -44,6 +44,12 @@
if not a.startswith('__')]
return ' '.join(attrs)
+ @classmethod
+ def from_xml(cls, conf, log, dev_xml):
+ alias = dev_xml.getElementsByTagName('alias')[0].getAttribute('name')
+ address = vmxml.device_address(dev_xml)
+ return cls(conf, log, alias=alias, address=address)
+
class VideoDevice(Base):
__slots__ = ('address',)
--
To view, visit http://gerrit.ovirt.org/33750
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I745909ce65ecb30da299d2d8afb1987a91581ace
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 11 months