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@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'])
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 1:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/18061/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 1:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17890/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 1:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/18061/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17890/ : SUCCESS
Nir Soffer has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 1: Verified+1
Francesco Romani has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 1: Code-Review+1
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 2:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17918/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 2:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/18090/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 2:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/18090/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17918/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 3:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18028/
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 3:
Build Started (2/2)
0 -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1257/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 3:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18028/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1257/ : 0
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 4:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18134/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 4:
Build Started (2/2)
0 -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1363/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 4:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18134/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1363/ : 0
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 5:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18177/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 5:
Build Started (2/2)
0 -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1407/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 5:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18177/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1407/ : 0
Adam Litke has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 5: Code-Review+2
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 6:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 6:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18379/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 6:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1609/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 6:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18379/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1609/ : SUCCESS
Federico Simoncelli has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 6: Code-Review+1
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 7:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has submitted this change and it was merged.
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@redhat.com Reviewed-on: https://gerrit.ovirt.org/40065 Reviewed-by: Francesco Romani fromani@redhat.com Reviewed-by: Adam Litke alitke@redhat.com Reviewed-by: Federico Simoncelli fsimonce@redhat.com --- M tests/vmStorageTests.py M vdsm/virt/vmdevices/storage.py 2 files changed, 27 insertions(+), 7 deletions(-)
Approvals: Adam Litke: Looks good to me, approved Nir Soffer: Verified Federico Simoncelli: Looks good to me, but someone else must approve Francesco Romani: Looks good to me, but someone else must approve
automation@ovirt.org has posted comments on this change.
Change subject: virt: Separate validation from getXML ......................................................................
Patch Set 8:
* Update tracker::IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org