Change in vdsm[master]: virt: Improve spacing
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: virt: Improve spacing
......................................................................
virt: Improve spacing
Separting logic blocks make it easier to to understand the flow.
Change-Id: I94b751112db67398891820035a9ec06abed59c3b
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/vmdevices/storage.py
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/67/40067/1
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 799f66c..af1ddd2 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -333,14 +333,17 @@
if self.extSharedState == DRIVE_SHARED_TYPE.SHARED:
diskelem.appendChildWithArgs('shareable')
+
if hasattr(self, 'readonly') and utils.tobool(self.readonly):
diskelem.appendChildWithArgs('readonly')
elif self.device == 'floppy' and not hasattr(self, 'readonly'):
# floppies are used only internally for sysprep, so
# they are readonly unless explicitely stated otherwise
diskelem.appendChildWithArgs('readonly')
+
if hasattr(self, 'serial'):
diskelem.appendChildWithArgs('serial', text=self.serial)
+
if hasattr(self, 'bootOrder'):
diskelem.appendChildWithArgs('boot', order=self.bootOrder)
@@ -380,10 +383,12 @@
def _getDriverXML(self):
driver = vmxml.Element('driver')
driverAttrs = {'name': 'qemu'}
+
if self.blockDev:
driverAttrs['io'] = 'native'
else:
driverAttrs['io'] = 'threads'
+
if self.format == 'cow':
driverAttrs['type'] = 'qcow2'
elif self.format:
@@ -396,6 +401,7 @@
driverAttrs['error_policy'] = 'enospace'
else:
driverAttrs['error_policy'] = 'stop'
+
driver.setAttrs(**driverAttrs)
return driver
--
To view, visit https://gerrit.ovirt.org/40067
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I94b751112db67398891820035a9ec06abed59c3b
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: Extract helpers for major XML elements
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: virt: Extract helpers for major XML elements
......................................................................
virt: Extract helpers for major XML elements
Now drive xml is built using small helper methods creating each of the
elements. This is more maintainable and will allow creating drive replica
xml without code duplication.
Change-Id: I6ef6a38d3abc14413f1001a8673f38fce8d828b7
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/vmdevices/storage.py
1 file changed, 58 insertions(+), 45 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/40066/1
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 37ed8c9..799f66c 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -324,6 +324,35 @@
</disk>
"""
self._validate()
+ diskelem = self.createXmlElem('disk', self.diskType,
+ ['device', 'address', 'sgio'])
+ diskelem.setAttrs(snapshot='no')
+
+ diskelem.appendChild(self._getSourceXML())
+ diskelem.appendChild(self._getTargetXML())
+
+ if self.extSharedState == DRIVE_SHARED_TYPE.SHARED:
+ diskelem.appendChildWithArgs('shareable')
+ if hasattr(self, 'readonly') and utils.tobool(self.readonly):
+ diskelem.appendChildWithArgs('readonly')
+ elif self.device == 'floppy' and not hasattr(self, 'readonly'):
+ # floppies are used only internally for sysprep, so
+ # they are readonly unless explicitely stated otherwise
+ diskelem.appendChildWithArgs('readonly')
+ if hasattr(self, 'serial'):
+ diskelem.appendChildWithArgs('serial', text=self.serial)
+ if hasattr(self, 'bootOrder'):
+ diskelem.appendChildWithArgs('boot', order=self.bootOrder)
+
+ if self.device == 'disk' or self.device == 'lun':
+ diskelem.appendChild(self._getDriverXML())
+
+ if hasattr(self, 'specParams') and 'ioTune' in self.specParams:
+ diskelem.appendChild(self._getIotuneXML())
+
+ return diskelem
+
+ def _getSourceXML(self):
source = vmxml.Element('source')
if self.diskType == DISK_TYPE.BLOCK:
source.setAttrs(dev=self.path)
@@ -340,57 +369,41 @@
source.setAttrs(startupPolicy='optional')
else:
raise RuntimeError("Unsupported diskType %r", self.diskType)
+ return source
- diskelem = self.createXmlElem('disk', self.diskType,
- ['device', 'address', 'sgio'])
- diskelem.setAttrs(snapshot='no')
- diskelem.appendChild(source)
-
- targetAttrs = {'dev': self.name}
+ def _getTargetXML(self):
+ target = vmxml.Element('target', dev=self.name)
if self.iface:
- targetAttrs['bus'] = self.iface
- diskelem.appendChildWithArgs('target', **targetAttrs)
+ target.setAttrs(bus=self.iface)
+ return target
- if self.extSharedState == DRIVE_SHARED_TYPE.SHARED:
- diskelem.appendChildWithArgs('shareable')
- if hasattr(self, 'readonly') and utils.tobool(self.readonly):
- diskelem.appendChildWithArgs('readonly')
- elif self.device == 'floppy' and not hasattr(self, 'readonly'):
- # floppies are used only internally for sysprep, so
- # they are readonly unless explicitely stated otherwise
- diskelem.appendChildWithArgs('readonly')
- if hasattr(self, 'serial'):
- diskelem.appendChildWithArgs('serial', text=self.serial)
- if hasattr(self, 'bootOrder'):
- diskelem.appendChildWithArgs('boot', order=self.bootOrder)
+ def _getDriverXML(self):
+ driver = vmxml.Element('driver')
+ driverAttrs = {'name': 'qemu'}
+ if self.blockDev:
+ driverAttrs['io'] = 'native'
+ else:
+ driverAttrs['io'] = 'threads'
+ if self.format == 'cow':
+ driverAttrs['type'] = 'qcow2'
+ elif self.format:
+ driverAttrs['type'] = 'raw'
- if self.device == 'disk' or self.device == 'lun':
- driverAttrs = {'name': 'qemu'}
- if self.blockDev:
- driverAttrs['io'] = 'native'
- else:
- driverAttrs['io'] = 'threads'
- if self.format == 'cow':
- driverAttrs['type'] = 'qcow2'
- elif self.format:
- driverAttrs['type'] = 'raw'
+ driverAttrs['cache'] = self.cache
- driverAttrs['cache'] = self.cache
+ if (self.propagateErrors == 'on' or
+ utils.tobool(self.propagateErrors)):
+ driverAttrs['error_policy'] = 'enospace'
+ else:
+ driverAttrs['error_policy'] = 'stop'
+ driver.setAttrs(**driverAttrs)
+ return driver
- if (self.propagateErrors == 'on' or
- utils.tobool(self.propagateErrors)):
- driverAttrs['error_policy'] = 'enospace'
- else:
- driverAttrs['error_policy'] = 'stop'
- diskelem.appendChildWithArgs('driver', **driverAttrs)
-
- if hasattr(self, 'specParams') and 'ioTune' in self.specParams:
- iotune = vmxml.Element('iotune')
- for key, value in self.specParams['ioTune'].iteritems():
- iotune.appendChildWithArgs(key, text=str(value))
- diskelem.appendChild(iotune)
-
- return diskelem
+ def _getIotuneXML(self):
+ iotune = vmxml.Element('iotune')
+ for key, value in self.specParams['ioTune'].iteritems():
+ iotune.appendChildWithArgs(key, text=str(value))
+ return iotune
def _validate(self):
if self.device != 'lun' and hasattr(self, 'sgio'):
--
To view, visit https://gerrit.ovirt.org/40066
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ef6a38d3abc14413f1001a8673f38fce8d828b7
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: Separate validation from getXML
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: virt: Separate validation from getXML
......................................................................
virt: Separate validation from getXML
Extract _validate() method and move the validation code into it, and add
missing tests for sgio and cow format.
Change-Id: I00916c13850e335fb13e74a13b52b71560bfb797
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/vmStorageTests.py
M vdsm/virt/vmdevices/storage.py
2 files changed, 27 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/40065/1
diff --git a/tests/vmStorageTests.py b/tests/vmStorageTests.py
index 1d577c7..055d1c9 100644
--- a/tests/vmStorageTests.py
+++ b/tests/vmStorageTests.py
@@ -129,6 +129,22 @@
@expandPermutations
+class DriveValidation(VdsmTestCase):
+
+ @permutations([["disk"], ["cdrom"], ["floppy"]])
+ def test_sgio_without_lun(self, device):
+ self.check(device=device, sgio='unfiltered')
+
+ def test_cow_with_lun(self):
+ self.check(device='lun', format='cow')
+
+ def check(self, **kw):
+ conf = drive_config(**kw)
+ drive = Drive({}, self.log, **conf)
+ self.assertRaises(ValueError, drive.getXML)
+
+
+@expandPermutations
class DriveExSharedStatusTests(VdsmTestCase):
def test_default_not_shared(self):
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 5ace5cc..37ed8c9 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -323,6 +323,7 @@
<serial>54-a672-23e5b495a9ea</serial>
</disk>
"""
+ self._validate()
source = vmxml.Element('source')
if self.diskType == DISK_TYPE.BLOCK:
source.setAttrs(dev=self.path)
@@ -363,12 +364,6 @@
if hasattr(self, 'bootOrder'):
diskelem.appendChildWithArgs('boot', order=self.bootOrder)
- if self.device != 'lun' and hasattr(self, 'sgio'):
- raise ValueError("sgio attribute can be set only for LUN devices")
-
- if self.device == 'lun' and self.format == 'cow':
- raise ValueError("cow format is not supported for LUN devices")
-
if self.device == 'disk' or self.device == 'lun':
driverAttrs = {'name': 'qemu'}
if self.blockDev:
@@ -390,10 +385,19 @@
diskelem.appendChildWithArgs('driver', **driverAttrs)
if hasattr(self, 'specParams') and 'ioTune' in self.specParams:
- self._validateIoTuneParams(self.specParams['ioTune'])
iotune = vmxml.Element('iotune')
for key, value in self.specParams['ioTune'].iteritems():
iotune.appendChildWithArgs(key, text=str(value))
diskelem.appendChild(iotune)
return diskelem
+
+ def _validate(self):
+ if self.device != 'lun' and hasattr(self, 'sgio'):
+ raise ValueError("sgio attribute can be set only for LUN devices")
+
+ if self.device == 'lun' and self.format == 'cow':
+ raise ValueError("cow format is not supported for LUN devices")
+
+ if hasattr(self, 'specParams') and 'ioTune' in self.specParams:
+ self._validateIoTuneParams(self.specParams['ioTune'])
--
To view, visit https://gerrit.ovirt.org/40065
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I00916c13850e335fb13e74a13b52b71560bfb797
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: Set source attributes consistently
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: virt: Set source attributes consistently
......................................................................
virt: Set source attributes consistently
For "block" and "network" we were using source.setAttrs(key=value), but
for file we were using less clear source.setAttrs(**dict).
Change-Id: I4bcc3846428c7f2cc14cf19254617378b668404a
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/vmdevices/storage.py
1 file changed, 2 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/40064/1
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 8cb78fb..5ace5cc 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -334,10 +334,9 @@
'transport': self.volumeInfo['volTransport']}
source.appendChildWithArgs('host', **hostAttrs)
elif self.diskType == DISK_TYPE.FILE:
- sourceAttrs = {DISK_TYPE.FILE: self.path}
+ source.setAttrs(file=self.path)
if self.device == 'cdrom' or self.device == 'floppy':
- sourceAttrs['startupPolicy'] = 'optional'
- source.setAttrs(**sourceAttrs)
+ source.setAttrs(startupPolicy='optional')
else:
raise RuntimeError("Unsupported diskType %r", self.diskType)
--
To view, visit https://gerrit.ovirt.org/40064
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bcc3846428c7f2cc14cf19254617378b668404a
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: Set defualt device in __init__
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: virt: Set defualt device in __init__
......................................................................
virt: Set defualt device in __init__
Set Drive.device in __init__ instead of getXML().
Change-Id: I533c25075869d8e233e02f7f314d27f13fe203f6
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/vmdevices/storage.py
1 file changed, 1 insertion(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/40063/1
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 12625f1..8cb78fb 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -65,6 +65,7 @@
if not kwargs.get('serial'):
self.serial = kwargs.get('imageID'[-20:]) or ''
super(Drive, self).__init__(conf, log, **kwargs)
+ self.device = getattr(self, 'device', 'disk')
# Keep sizes as int
self.reqsize = int(kwargs.get('reqsize', '0')) # Backward compatible
self.truesize = int(kwargs.get('truesize', '0'))
@@ -322,8 +323,6 @@
<serial>54-a672-23e5b495a9ea</serial>
</disk>
"""
- self.device = getattr(self, 'device', 'disk')
-
source = vmxml.Element('source')
if self.diskType == DISK_TYPE.BLOCK:
source.setAttrs(dev=self.path)
--
To view, visit https://gerrit.ovirt.org/40063
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I533c25075869d8e233e02f7f314d27f13fe203f6
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: Extract Drive.diskType property
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: virt: Extract Drive.diskType property
......................................................................
virt: Extract Drive.diskType property
This is the first step in breaking getXML() to separate methods for
rendering individual elements, required to create replica disk xml
without code duplication.
The diskType property is also required for Ceph support, where it will
be sent from the engine. This property helps the rest of the code to work
in the same way if diskType was sent from the engine (new engine) or
deduced from blockDev and networkDev properties (old engine).
Change-Id: Iec13ca58ee4f3db919198bdeae781473a97e072d
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/vmdevices/storage.py
1 file changed, 24 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/40062/1
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 82642d3..12625f1 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -27,6 +27,12 @@
from .core import Base
+class DISK_TYPE:
+ BLOCK = "block"
+ NETWORK = "network"
+ FILE = "file"
+
+
class DRIVE_SHARED_TYPE:
NONE = "none"
EXCLUSIVE = "exclusive"
@@ -176,7 +182,7 @@
@property
def networkDev(self):
try:
- return self.volumeInfo['volType'] == "network"
+ return self.volumeInfo['volType'] == DISK_TYPE.NETWORK
except AttributeError:
# To handle legacy and removable drives.
return False
@@ -207,6 +213,15 @@
# invalidating cached blockDev.
self._blockDev = None
self._path = path
+
+ @property
+ def diskType(self):
+ if self.blockDev:
+ return DISK_TYPE.BLOCK
+ elif self.networkDev:
+ return DISK_TYPE.NETWORK
+ else:
+ return DISK_TYPE.FILE
@property
def transientDisk(self):
@@ -310,24 +325,24 @@
self.device = getattr(self, 'device', 'disk')
source = vmxml.Element('source')
- if self.blockDev:
- deviceType = 'block'
+ if self.diskType == DISK_TYPE.BLOCK:
source.setAttrs(dev=self.path)
- elif self.networkDev:
- deviceType = 'network'
+ elif self.diskType == DISK_TYPE.NETWORK:
source.setAttrs(protocol=self.volumeInfo['protocol'],
name=self.volumeInfo['path'])
hostAttrs = {'name': self.volumeInfo['volfileServer'],
'port': self.volumeInfo['volPort'],
'transport': self.volumeInfo['volTransport']}
source.appendChildWithArgs('host', **hostAttrs)
- else:
- deviceType = 'file'
- sourceAttrs = {'file': self.path}
+ elif self.diskType == DISK_TYPE.FILE:
+ sourceAttrs = {DISK_TYPE.FILE: self.path}
if self.device == 'cdrom' or self.device == 'floppy':
sourceAttrs['startupPolicy'] = 'optional'
source.setAttrs(**sourceAttrs)
- diskelem = self.createXmlElem('disk', deviceType,
+ else:
+ raise RuntimeError("Unsupported diskType %r", self.diskType)
+
+ diskelem = self.createXmlElem('disk', self.diskType,
['device', 'address', 'sgio'])
diskelem.setAttrs(snapshot='no')
diskelem.appendChild(source)
--
To view, visit https://gerrit.ovirt.org/40062
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec13ca58ee4f3db919198bdeae781473a97e072d
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]: vm payload: Add Joliet FS support
by eshachar@redhat.com
Eldan Shachar has uploaded a new change for review.
Change subject: vm payload: Add Joliet FS support
......................................................................
vm payload: Add Joliet FS support
Current payload ISO only uses Rock Ridge extension, as a result
Windows VMs can't use payloads with long filenames. This fix
adds the Joliet extension to the generated ISO.
Change-Id: I45a48e53b93aa36aaf43100cdb8cdf00bbf18263
Bug-Url: https://bugzilla.redhat.com/1205058
Signed-off-by: Eldan Shachar <eshachar(a)redhat.com>
---
M vdsm/mkimage.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/39900/1
diff --git a/vdsm/mkimage.py b/vdsm/mkimage.py
index 2b69a18..7633662 100644
--- a/vdsm/mkimage.py
+++ b/vdsm/mkimage.py
@@ -123,7 +123,7 @@
_decodeFilesIntoDir(files, dirname)
isopath = _getFileName(vmId, files)
- command = [EXT_MKISOFS, '-R', '-o', isopath]
+ command = [EXT_MKISOFS, '-R', '-J', '-o', isopath]
if volumeName is not None:
command.extend(['-V', volumeName])
command.extend([dirname])
--
To view, visit https://gerrit.ovirt.org/39900
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I45a48e53b93aa36aaf43100cdb8cdf00bbf18263
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eldan Shachar <eshachar(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: vmdevices: move storage methods to storage module
by Martin Polednik
Martin Polednik has uploaded a new change for review.
Change subject: vmdevices: move storage methods to storage module
......................................................................
vmdevices: move storage methods to storage module
Some of the methods found in VM class are heavily related to
legacy configuration parsing for storage. These can be safely moved to
storage module, reducing VM class polution and contributing to a better
code.
Change-Id: Ie7b2db4ba7569ff0170a948b2954064c99c804a0
Signed-off-by: Martin Polednik <mpolednik(a)redhat.com>
---
M vdsm/virt/vm.py
M vdsm/virt/vmdevices/storage.py
2 files changed, 66 insertions(+), 62 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/33/40133/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 8dabd9b..901537d 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -799,40 +799,6 @@
drv['truesize'] = 0
drv['apparentsize'] = 0
- def __legacyDrives(self):
- """
- Backward compatibility for qa scripts that specify direct paths.
- """
- legacies = []
- DEVICE_SPEC = ((0, 'hda'), (1, 'hdb'), (2, 'hdc'), (3, 'hdd'))
- for index, linuxName in DEVICE_SPEC:
- path = self.conf.get(linuxName)
- if path:
- legacies.append({'type': hwclass.DISK,
- 'device': 'disk', 'path': path,
- 'iface': 'ide', 'index': index,
- 'truesize': 0})
- return legacies
-
- def __removableDrives(self):
- removables = [{
- 'type': hwclass.DISK,
- 'device': 'cdrom',
- 'iface': vmdevices.storage.DEFAULT_INTERFACE_FOR_ARCH[self.arch],
- 'path': self.conf.get('cdrom', ''),
- 'index': 2,
- 'truesize': 0}]
- floppyPath = self.conf.get('floppy')
- if floppyPath:
- removables.append({
- 'type': hwclass.DISK,
- 'device': 'floppy',
- 'path': floppyPath,
- 'iface': 'fdc',
- 'index': 0,
- 'truesize': 0})
- return removables
-
def buildConfDevices(self):
"""
Return the "devices" section of this Vm's conf.
@@ -851,7 +817,9 @@
devConf = utils.picklecopy(self.conf['devices'])
except KeyError:
# (very) old Engines do not send device configuration
- devices[hwclass.DISK] = self.getConfDrives()
+ devices[hwclass.DISK] = \
+ vmdevices.storage.mapping_from_legacy_conf(self.conf,
+ self.arch)
devices[hwclass.NIC] = self.getConfNetworkInterfaces()
devices[hwclass.SOUND] = self.getConfSound()
devices[hwclass.VIDEO] = self.getConfVideo()
@@ -1007,33 +975,6 @@
'nicModel': model, 'network': bridge,
'device': 'bridge'})
return nics
-
- def getConfDrives(self):
- """
- Normalize drives provided by conf.
- """
- # FIXME
- # Will be better to change the self.conf but this implies an API change
- # Remove this when the API parameters will be consistent.
- confDrives = self.conf.get('drives', [])
- if not confDrives:
- confDrives.extend(self.__legacyDrives())
- confDrives.extend(self.__removableDrives())
-
- for drv in confDrives:
- drv['type'] = hwclass.DISK
- drv['format'] = drv.get('format') or 'raw'
- drv['propagateErrors'] = drv.get('propagateErrors') or 'off'
- drv['readonly'] = False
- drv['shared'] = False
- # FIXME: For BC we have now two identical keys: iface = if
- # Till the day that conf will not returned as a status anymore.
- drv['iface'] = drv.get('iface') or \
- drv.get(
- 'if',
- vmdevices.storage.DEFAULT_INTERFACE_FOR_ARCH[self.arch])
-
- return confDrives
def updateDriveIndex(self, drv):
if not drv['iface'] in self._usedIndices:
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 19531d8..1b91991 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -27,6 +27,7 @@
from .. import vmxml
from .core import Base
+from . import hwclass
DEFAULT_INTERFACE_FOR_ARCH = {caps.Architecture.X86_64: 'ide',
caps.Architecture.PPC64: 'scsi',
@@ -45,6 +46,68 @@
return (cls.NONE, cls.EXCLUSIVE, cls.SHARED, cls.TRANSIENT)
+def mapping_from_legacy_conf(conf, arch):
+ """
+ Returns a list of drive specification dictionaries from legacy vm.conf
+ """
+ conf_drives = conf.get('drives', [])
+ if not conf_drives:
+ conf_drives.extend(__mapping_from_legacy_direct_paths(conf))
+ conf_drives.extend(__mapping_from_legacy_removable_drives(conf, arch))
+
+ for drive in conf_drives:
+ drive['type'] = hwclass.DISK
+ drive['format'] = drive.get('format') or 'raw'
+ drive['propagateErrors'] = drive.get('propagateErrors') or 'off'
+ drive['readonly'] = False
+ drive['shared'] = False
+ # FIXME: For BC we have now two identical keys: iface = if
+ # Till the day that conf will not returned as a status anymore.
+ drive['iface'] = drive.get('iface') or \
+ drive.get('if', DEFAULT_INTERFACE_FOR_ARCH[arch])
+
+ return conf_drives
+
+
+def __mapping_from_legacy_direct_paths(conf):
+ """
+ Backward compatibility for qa scripts that specify direct paths.
+ """
+ legacies = []
+ device_spec = ((0, 'hda'), (1, 'hdb'), (2, 'hdc'), (3, 'hdd'))
+ for index, linux_name in device_spec:
+ path = conf.get(linux_name)
+ if path:
+ legacies.append({'type': hwclass.DISK,
+ 'device': 'disk', 'path': path,
+ 'iface': 'ide', 'index': index,
+ 'truesize': 0})
+ return legacies
+
+
+def __mapping_from_legacy_removable_drives(conf, arch):
+ removables = [{
+ 'type': hwclass.DISK,
+ 'device': 'cdrom',
+ 'iface': DEFAULT_INTERFACE_FOR_ARCH[arch],
+ 'path': conf.get('cdrom', ''),
+ 'index': 2,
+ 'truesize': 0}]
+
+ floppy_path = conf.get('floppy')
+
+ if floppy_path:
+ removables.append({
+ 'type': hwclass.DISK,
+ 'device': 'floppy',
+ 'path': floppy_path,
+ 'iface': 'fdc',
+ 'index': 0,
+ 'truesize': 0})
+
+ return removables
+
+
class Drive(Base):
__slots__ = ('iface', '_path', 'readonly', 'bootOrder', 'domainID',
'poolID', 'imageID', 'UUID', 'volumeID', 'format',
--
To view, visit https://gerrit.ovirt.org/40133
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie7b2db4ba7569ff0170a948b2954064c99c804a0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: netconfpersistence: refactor _getConfig and _clearDisk
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: netconfpersistence: refactor _getConfig and _clearDisk
......................................................................
netconfpersistence: refactor _getConfig and _clearDisk
Does the same, with less lines of code and less logging.
Change-Id: Ifaf1cca94d184d079a06e07a9b4d5d2bcca42377
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/netconfpersistence.py
1 file changed, 13 insertions(+), 24 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/37418/1
diff --git a/lib/vdsm/netconfpersistence.py b/lib/vdsm/netconfpersistence.py
index f0aac38..cd8b4e1 100644
--- a/lib/vdsm/netconfpersistence.py
+++ b/lib/vdsm/netconfpersistence.py
@@ -1,5 +1,5 @@
#
-# Copyright 2013 Red Hat, Inc.
+# Copyright 2013-2015 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
@@ -19,6 +19,7 @@
#
import errno
+from glob import iglob
import json
import logging
import os
@@ -124,18 +125,12 @@
raise
def _getConfigs(self, path):
- networkEntities = {}
- try:
- for fileName in os.listdir(path):
- fullPath = path + fileName
- networkEntities[fileName] = self._getConfigDict(fullPath)
- except OSError as ose:
- if ose.errno == errno.ENOENT:
- logging.debug('Non-existing config set.')
- else:
- raise
+ network_entities = {}
+ for fullpath in iglob(os.path.join(path, '*')):
+ basename = os.path.basename(fullpath)
+ network_entities[basename] = self._getConfigDict(fullpath)
- return networkEntities
+ return network_entities
@staticmethod
def _setConfig(config, path):
@@ -153,19 +148,13 @@
utils.rmFile(path)
def _clearDisk(self):
- try:
- logging.info('Clearing %s and %s', self.networksPath,
- self.bondingsPath)
- for filePath in os.listdir(self.networksPath):
- self._removeConfig(self.networksPath + filePath)
+ logging.info('Clearing %s and %s', self.networksPath,
+ self.bondingsPath)
+ for fullpath in iglob(os.path.join(self.networksPath, '*')):
+ self._removeConfig(fullpath)
- for filePath in os.listdir(self.bondingsPath):
- self._removeConfig(self.bondingsPath + filePath)
- except OSError as ose:
- if ose.errno == errno.ENOENT:
- logging.debug('No existent config to clear.')
- else:
- raise
+ for fullpath in iglob(os.path.join(self.bondingsPath, '*')):
+ self._removeConfig(fullpath)
def delete(self):
self.networks = {}
--
To view, visit http://gerrit.ovirt.org/37418
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifaf1cca94d184d079a06e07a9b4d5d2bcca42377
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
8 years, 11 months
Change in vdsm[master]: network: no need to log when network persistence path doesn'...
by ibarkan@redhat.com
Ido Barkan has uploaded a new change for review.
Change subject: network: no need to log when network persistence path doesn't exist.
......................................................................
network: no need to log when network persistence path doesn't exist.
Running configuraiton may not exists in many cases and this is OK.
Those messages were contaminating supervdsm.log and are a source of
confusion and red herring.
Change-Id: I6f998b5ec7a5d0d07e35afdcc9a9d76b42b3c6a0
Signed-off-by: Ido Barkan <ibarkan(a)redhat.com>
---
M lib/vdsm/netconfpersistence.py
1 file changed, 7 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/40415/1
diff --git a/lib/vdsm/netconfpersistence.py b/lib/vdsm/netconfpersistence.py
index 436123c..26534eb 100644
--- a/lib/vdsm/netconfpersistence.py
+++ b/lib/vdsm/netconfpersistence.py
@@ -138,16 +138,14 @@
raise
def _getConfigs(self, path):
+ if not os.path.exists(path):
+ return {}
+
networkEntities = {}
- try:
- for fileName in os.listdir(path):
- fullPath = path + fileName
- networkEntities[fileName] = self._getConfigDict(fullPath)
- except OSError as ose:
- if ose.errno == errno.ENOENT:
- logging.debug('Non-existing config set.')
- else:
- raise
+
+ for fileName in os.listdir(path):
+ fullPath = path + fileName
+ networkEntities[fileName] = self._getConfigDict(fullPath)
return networkEntities
--
To view, visit https://gerrit.ovirt.org/40415
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6f998b5ec7a5d0d07e35afdcc9a9d76b42b3c6a0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan(a)redhat.com>
8 years, 11 months