Change in vdsm[master]: hsm.py: volUUID is not member of HSM class
by lbednar@redhat.com
Lukas Bednar has uploaded a new change for review.
Change subject: hsm.py: volUUID is not member of HSM class
......................................................................
hsm.py: volUUID is not member of HSM class
Change-Id: I5adc1fb40d54b7a887a4aba44c8884c876d5613a
Signed-off-by: Lukas Bednar <lbednar(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/24313/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 9420931..41917f3 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -692,7 +692,7 @@
volFormat = volToExtend.getFormat()
if not volToExtend.isLeaf():
- raise se.VolumeNonWritable(self.volUUID)
+ raise se.VolumeNonWritable(volUUID)
if volFormat != volume.COW_FORMAT:
# This method is used only with COW volumes (see docstring),
--
To view, visit http://gerrit.ovirt.org/24313
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5adc1fb40d54b7a887a4aba44c8884c876d5613a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lukas Bednar <lbednar(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: WIP tests: add VM startup tests
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: WIP tests: add VM startup tests
......................................................................
WIP tests: add VM startup tests
Add more tests addressing the VM startup and XML processing.
Those tests will be used for the planned split/refactoring of XML
processing and device handling.
Change-Id: Ia647d207bd30b6adc55e25e67198470eacd2144e
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/vmTests.py
M tests/vmTestsData.py
2 files changed, 186 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/26257/1
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 552a1a7..277b959 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -27,6 +27,7 @@
from virt import vm
from virt import vmexitreason
+from virt import vmstatus
from vdsm import constants
from vdsm import define
from testrunner import VdsmTestCase as TestCaseBase
@@ -37,12 +38,21 @@
from monkeypatch import MonkeyPatch, MonkeyPatchScope
from vmTestsData import CONF_TO_DOMXML_X86_64
from vmTestsData import CONF_TO_DOMXML_PPC64
+from vmTestsData import VM_PARAMS
-class ConnectionMock:
- def domainEventRegisterAny(self, *arg):
+class ConnectionMock(object):
+ XML = ''
+ def createXML(self, domxml, flags):
+ class FakeDom(object):
+ def __init__(self, xml=''):
+ self.xml = xml
+ def XMLDesc(self, *args):
+ return self.xml if self.xml else self.XML
+ return FakeDom(domxml)
+
+ def domainEventRegisterAny(self, *args):
pass
-
class TestVm(TestCaseBase):
@@ -696,6 +706,23 @@
self.assertBuildCmdLine(CONF_TO_DOMXML_PPC64)
+class FakeIRS(object):
+ def getVolumeSize(self, *args, **kwargs):
+ return {
+ 'status': { 'code': 0 },
+ 'truesize': 0,
+ 'apparentsize': 0
+ }
+
+
+class FakeClientIF(object):
+ def __init__(self):
+ self.irs = FakeIRS()
+
+ def prepareVolumePath(self, *args, **kwargs):
+ return ''
+
+
@contextmanager
def FakeVM(params=None):
with namedTemporaryDir() as tmpDir:
@@ -704,7 +731,7 @@
lambda x: ConnectionMock())]):
vmParams = {'vmId': 'TESTING'}
vmParams.update({} if params is None else params)
- yield vm.Vm(None, vmParams)
+ yield vm.Vm(FakeClientIF(), vmParams)
@expandPermutations
@@ -799,3 +826,10 @@
stats = fake.getStats()
self.assertEqual(stats['exitReason'], exitReason)
self.assertEqual(stats['exitMessage'], msg)
+
+
+class TestVmStartup(TestCaseBase):
+ def testParamsCreate(self):
+ with FakeVM(VM_PARAMS[0]) as vm:
+ vm._startUnderlyingVm()
+ self.assertEqual(vm.lastStatus, vmstatus.UP)
diff --git a/tests/vmTestsData.py b/tests/vmTestsData.py
index 80af18e..3b3c6d0 100644
--- a/tests/vmTestsData.py
+++ b/tests/vmTestsData.py
@@ -151,3 +151,151 @@
</qemu:commandline>
</domain>
""", )]
+
+
+VM_PARAMS = [{
+ 'acpiEnable': 'true',
+ 'emulatedMachine': 'pc-1.0',
+ 'vmId': '2f50cbb4-f80f-4761-bb0d-1d351f497af7',
+ 'memGuaranteedSize': 1024,
+ 'spiceSslCipherSuite': 'DEFAULT',
+ 'timeOffset': '0',
+ 'displayPort': '-1',
+ 'displaySecurePort': '-1',
+ 'cpuType': 'Conroe',
+ 'smp': '1',
+ 'custom': {
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebbadevice_156942ac-5c99-496b-8c6a-3ffab96c3164device_e2e8af70-760d-4d07-b27e-cbbcb638affb':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=e2e8af70-760d-4d07-b27e-cbbcb638affb, device=ide, type=CONTROLLER, bootOrder=0, specParams={}, address={bus=0x00, domain=0x0000, type=pci, slot=0x01, function=0x1}, managed=false, plugged=true, readOnly=false, deviceAlias=ide0, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=7a09b642-7018-43b8-9938-33432b99cdc1, device=unix, type=CHANNEL, bootOrder=0, specParams={}, address={port=1, bus=0, controller=0, type=virtio-serial}, managed=false, plugged=true, readOnly=false, deviceAlias=channel0, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebbadevice_156942ac-5c99-496b-8c6a-3ffab96c3164device_e2e8af70-760d-4d07-b27e-cbbcb638affbdevice_87060fa4-d4d9-4140-9915-73babd76fc12':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=87060fa4-d4d9-4140-9915-73babd76fc12, device=virtio-serial, type=CONTROLLER, bootOrder=0, specParams={}, address={bus=0x00, domain=0x0000, type=pci, slot=0x04, function=0x0}, managed=false, plugged=true, readOnly=false, deviceAlias=virtio-serial0, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebbadevice_156942ac-5c99-496b-8c6a-3ffab96c3164':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=156942ac-5c99-496b-8c6a-3ffab96c3164, device=spicevmc, type=CHANNEL, bootOrder=0, specParams={}, address={port=3, bus=0, controller=0, type=virtio-serial}, managed=false, plugged=true, readOnly=false, deviceAlias=channel2, customProperties={}, snapshotId=null}',
+ 'device_7a09b642-7018-43b8-9938-33432b99cdc1device_dce622cc-29fa-431d-b10f-677903ffebba':
+ 'VmDevice {vmId=2f50cbb4-f80f-4761-bb0d-1d351f497af7, deviceId=dce622cc-29fa-431d-b10f-677903ffebba, device=unix, type=CHANNEL, bootOrder=0, specParams={}, address={port=2, bus=0, controller=0, type=virtio-serial}, managed=false, plugged=true, readOnly=false, deviceAlias=channel1, customProperties={}, snapshotId=null}'
+ },
+ 'vmType': 'kvm',
+ 'memSize': 10240,
+ 'smpCoresPerSocket': '1',
+ 'vmName': 'satelit',
+ 'nice': '0',
+ 'smartcardEnable': 'false',
+ 'keyboardLayout': 'en-us',
+ 'kvmEnable': 'true',
+ 'pitReinjection': 'false',
+ 'transparentHugePages': 'true',
+ 'devices': [ {
+ 'device': 'qxl',
+ 'specParams': {
+ 'vram': '32768',
+ 'ram': '65536',
+ 'heads': '1'
+ },
+ 'type': 'video',
+ 'deviceId': '21fbf3bc-a4e0-4706-a2f2-af14f3433a2d',
+ 'address': {
+ 'slot': '0x02',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ }
+ }, {
+ 'index': '2',
+ 'iface': 'ide',
+ 'bootOrder': '2',
+ 'specParams': {
+ 'path': ''
+ },
+ 'readonly': 'true',
+ 'deviceId': 'af3420c5-b179-4761-ac69-85831cee3b49',
+ 'address': {
+ 'bus': '1',
+ 'controller': '0',
+ 'type': 'drive',
+ 'target': '0',
+ 'unit': '0'
+ },
+ 'device': 'cdrom',
+ 'shared': 'false',
+ 'path': '',
+ 'type': 'disk'
+ }, {
+ 'index': 0,
+ 'iface': 'virtio',
+ 'format': 'raw',
+ 'bootOrder': '1',
+ 'poolID': '5849b030-626e-47cb-ad90-3ce782d831b3',
+ 'volumeID': '82231f1f-2c7a-4aee-a596-af209fe5e081',
+ 'imageID': 'faa6b382-eaa7-48d4-80fb-3e5999e1a167',
+ 'specParams': {},
+ 'readonly': 'false',
+ 'domainID': '041e8dbe-f405-4aca-bb78-3bf3cc7dc190',
+ 'optional': 'false',
+ 'deviceId': 'faa6b382-eaa7-48d4-80fb-3e5999e1a167',
+ 'address': {
+ 'slot': '0x05',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'disk',
+ 'shared': 'false',
+ 'propagateErrors': 'off',
+ 'type': 'disk'
+ }, {
+ 'nicModel': 'pv',
+ 'macAddr': '00:1a:4a:69:90:dd',
+ 'linkActive': 'true',
+ 'network': 'VPO_IPPROXY',
+ 'filter': 'vdsm-no-mac-spoofing',
+ 'specParams': {
+ 'inbound': {
+ 'average': 25600,
+ 'peak': 26880,
+ 'burst': 256000
+ },
+ 'outbound': {
+ 'average': 25600,
+ 'peak': 26880,
+ 'burst': 256000
+ }
+ },
+ 'deviceId': '10591bf3-0131-480a-8f89-5b8db7d49cd8',
+ 'address': {
+ 'slot': '0x07',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'bridge',
+ 'type': 'interface'
+ }, {
+ 'device': 'memballoon',
+ 'specParams': {
+ 'model': 'virtio'
+ },
+ 'type': 'balloon',
+ 'deviceId': 'b9561cf2-37f0-4e64-bc7b-8c1921c06f9b'
+ }, {
+ 'index': '0',
+ 'specParams': {},
+ 'deviceId': 'd02fc85d-4862-4e0f-a7c5-eadce3509935',
+ 'address': {
+ 'slot': '0x03',
+ 'bus': '0x00',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'scsi',
+ 'model': 'virtio-scsi',
+ 'type': 'controller'
+ }],
+ 'spiceSecureChannels': 'smain,sinputs,scursor,splayback,srecord,sdisplay,susbredir,ssmartcard',
+ 'display': 'qxl'
+},]
--
To view, visit http://gerrit.ovirt.org/26257
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia647d207bd30b6adc55e25e67198470eacd2144e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: volumeTests: add BlockDomainMetadataSlotTest
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: volumeTests: add BlockDomainMetadataSlotTest
......................................................................
volumeTests: add BlockDomainMetadataSlotTest
A new test has been added to check the metadata slot selection.
Change-Id: I0ff018625443ce7cf75d3edf11644544e7f23dde
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M tests/volumeTests.py
1 file changed, 37 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/26266/1
diff --git a/tests/volumeTests.py b/tests/volumeTests.py
index 6e4a3b2..5b6476a 100644
--- a/tests/volumeTests.py
+++ b/tests/volumeTests.py
@@ -24,7 +24,9 @@
from testrunner import VdsmTestCase as TestCaseBase
-from storage import outOfProcess, fileSD
+from storage import blockSD, blockVolume, fileSD, outOfProcess
+
+SDBLKSZ = 512
class FileDomainMockObject(fileSD.FileStorageDomain):
@@ -40,7 +42,6 @@
class FileVolumeGetVSizeTest(TestCaseBase):
VOLSIZE = 1024
- SDBLKSZ = 512
def setUp(self):
self.mountpoint = tempfile.mkdtemp()
@@ -54,13 +55,44 @@
volPath = os.path.join(imgPath, self.volUUID)
os.makedirs(imgPath)
- open(volPath, "w").truncate(self.VOLSIZE * self.SDBLKSZ)
+ open(volPath, "w").truncate(self.VOLSIZE * SDBLKSZ)
self.sdobj = FileDomainMockObject(self.mountpoint, self.sdUUID)
def tearDown(self):
shutil.rmtree(self.mountpoint)
def test(self):
- volSize = int(self.sdobj.getVSize(self.imgUUID, self.volUUID) /
- self.SDBLKSZ)
+ volSize = int(
+ self.sdobj.getVSize(self.imgUUID, self.volUUID) / SDBLKSZ)
assert volSize == self.VOLSIZE
+
+
+class BlockDomainMockObject(blockSD.BlockStorageDomain):
+ DOMAIN_VERSION = 3
+
+ def __init__(self, sdUUID, occupiedMetadataSlots=None):
+ self.sdUUID = sdUUID
+ self.stat = None
+ self.logBlkSize = SDBLKSZ
+ self.occupiedMetadataSlots = occupiedMetadataSlots
+
+ def getVersion(self):
+ return self.DOMAIN_VERSION
+
+ def _getOccupiedMetadataSlots(self):
+ return self.occupiedMetadataSlots
+
+
+class BlockDomainMetadataSlotTest(TestCaseBase):
+ OCCUPIED_METADATA_SLOTS = [(4, 1), (7, 1)]
+ EXPECTED_METADATA_SLOT = 5
+
+ def setUp(self):
+ self.sdUUID = str(uuid.uuid4())
+ self.blksd = BlockDomainMockObject(self.sdUUID,
+ self.OCCUPIED_METADATA_SLOTS)
+
+ def testMetaSlotSelection(self):
+ with blockVolume.BlockVolume._tagCreateLock:
+ mdSlot = self.blksd.getVolumeMetadataSlot(None, 1)
+ self.assertEqual(mdSlot, self.EXPECTED_METADATA_SLOT)
--
To view, visit http://gerrit.ovirt.org/26266
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ff018625443ce7cf75d3edf11644544e7f23dde
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: Makefile.am: create vdsm logs on make install
by Douglas Schilling Landgraf
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: Makefile.am: create vdsm logs on make install
......................................................................
Makefile.am: create vdsm logs on make install
Currently during the RPM install vdsm creates the below logs files:
/var/log/vdsm/{metadata.log,mom.log,supervdsm.log,vdsm.log}
and we should do the same for non rpm distro.
Change-Id: I7f5dc4ca01fecddc5226255e37b0bab68b8c479f
Signed-off-by: Douglas Schilling Landgraf <dougsland(a)redhat.com>
---
M vdsm/Makefile.am
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/23882/1
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 66b9af5..5e7f2cf 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -167,6 +167,10 @@
$(MKDIR_P) $(DESTDIR)$(vdsmlibdir)/upgrade
$(MKDIR_P) $(DESTDIR)$(vdsmbackupdir)
$(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/libvirt/qemu/channels
+ touch $(DESTDIR)$(vdsmlogdir)/{metadata.log,mom.log,supervdsm.log,vdsm.log}
+ chmod 0644 $(DESTDIR)$(vdsmlogdir)/{metadata.log,mom.log,supervdsm.log,vdsm.log}
+ chown $(VDSMUSER):$(VDSMGROUP) $(DESTDIR)$(vdsmlogdir)/{metadata.log,mom.log,vdsm.log}
+ chown root:root $(DESTDIR)$(vdsmlogdir)/supervdsm.log
uninstall-local: \
uninstall-data-dhclient-hooks \
--
To view, visit http://gerrit.ovirt.org/23882
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f5dc4ca01fecddc5226255e37b0bab68b8c479f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: sp: improve pool creation error handling
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: sp: improve pool creation error handling
......................................................................
sp: improve pool creation error handling
Change-Id: I0cce08e368dec092222c081609d0663d7990ab10
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/sp.py
1 file changed, 17 insertions(+), 14 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/22818/1
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 4f4765e..247973c 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -620,27 +620,30 @@
# lock
# TBD: create will receive only master domain and further attaches
# should be done under SPM
-
- # Master domain was already attached (in createMaster),
- # no need to reattach
- for sdUUID in domList:
- # No need to attach the master
- if sdUUID != msdUUID:
- self.attachSD(sdUUID)
+ try:
+ for sdUUID in domList:
+ # Master domain was already attached (in createMaster)
+ if sdUUID != msdUUID:
+ self.attachSD(sdUUID)
+ except Exception:
+ # FIXME: detachSD will fail for the master domain, we need a
+ # special handling (master must be detached from the pool).
+ self.__cleanupDomains(domList, msdUUID, masterVersion)
except Exception:
- self.log.error("Create pool %s canceled ", poolName, exc_info=True)
+ self.log.exception('create pool %s canceled', self.spUUID)
try:
fileUtils.cleanupdir(self.poolPath)
- self.__cleanupDomains(domList, msdUUID, masterVersion)
- except:
- self.log.error("Cleanup failed due to an unexpected error",
- exc_info=True)
+ except Exception:
+ self.log.exception('pool %s cleanup failed', self.spUUID)
raise
finally:
self._setUnsafe()
-
self._releaseTemporaryClusterLock(msdUUID)
- self.stopMonitoringDomains()
+ # stopMonitoringDomains needs masterDomain and the monitoring
+ # domains threads are started only if the master was properly
+ # initialized and set
+ if self.masterDomain:
+ self.stopMonitoringDomains()
return True
--
To view, visit http://gerrit.ovirt.org/22818
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0cce08e368dec092222c081609d0663d7990ab10
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: vm: small refactor for _normalizeVdsmImg
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: vm: small refactor for _normalizeVdsmImg
......................................................................
vm: small refactor for _normalizeVdsmImg
Change-Id: Ie68292eee4b82fbe8527e3960739979cfe117dfa
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 18 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/19157/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 92d274e..2605f24 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1779,25 +1779,26 @@
break
return str(idx)
- def _normalizeVdsmImg(self, drv):
- drv['reqsize'] = drv.get('reqsize', '0') # Backward compatible
- if 'device' not in drv:
- drv['device'] = 'disk'
+ def _normalizeVdsmImg(self, drive):
+ drive['device'] = drive.get('device', 'disk') # Disk by default
+ drive['reqsize'] = drive.get('reqsize', '0') # Backward compatible
- if drv['device'] == 'disk':
- res = self.cif.irs.getVolumeSize(drv['domainID'], drv['poolID'],
- drv['imageID'], drv['volumeID'])
- try:
- drv['truesize'] = res['truesize']
- drv['apparentsize'] = res['apparentsize']
- except KeyError:
- self.log.error("Unable to get volume size for %s",
- drv['volumeID'], exc_info=True)
- raise RuntimeError("Volume %s is corrupted or missing" %
- drv['volumeID'])
+ if drive['device'] == 'disk':
+ volInfo = self.cif.irs.getVolumeInfo(
+ drive['domainID'], drive['poolID'], drive['imageID'],
+ drive['volumeID'])
+
+ if volInfo.get('status', {}).get('code', -1):
+ self.log.error(
+ "Unable to get volume info for %s", drive['volumeID'])
+ raise RuntimeError(
+ "Volume %s is corrupted or missing" % drive['volumeID'])
+
+ drive['truesize'] = volInfo['info']['truesize']
+ drive['apparentsize'] = volInfo['info']['apparentsize']
else:
- drv['truesize'] = 0
- drv['apparentsize'] = 0
+ drive['truesize'] = 0
+ drive['apparentsize'] = 0
@classmethod
def _normalizeDriveSharedAttribute(self, drive):
--
To view, visit http://gerrit.ovirt.org/19157
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie68292eee4b82fbe8527e3960739979cfe117dfa
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: vmDevices: introduce VmDeviceContainer
by mpoledni@redhat.com
Martin Polednik has uploaded a new change for review.
Change subject: vmDevices: introduce VmDeviceContainer
......................................................................
vmDevices: introduce VmDeviceContainer
EARLY WORK IN PROGRESS: VmDeviceContainer is structure that will allow
us to store devices as a class instances while keeping backwards
compatibility with old self.conf['devices']
Change-Id: I65debd35115da078df0c0cb6f50c57feb984c5a3
Signed-off-by: Martin Polednik <mpoledni(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 33 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/21138/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 5ae54d7..36cdbb1 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1727,6 +1727,39 @@
return m
+class VmDeviceContainer(dict):
+ @property
+ def legacy(self):
+ """
+ Return list of device dicts that represents backwards-compatible
+ self.conf['devices']
+
+ [..., {..., 'type': 'disk', ...}, ...]
+ """
+ deviceList = []
+ for key in self.keys():
+ for device in self[key]:
+ # loop through devices __slots__ and return all set attributes
+ deviceList.append(dict((attr, getattr(device, attr))
+ for attr in device.__slots__
+ if hasattr(device, attr)))
+
+ return deviceList
+
+ def restoreLegacy(self, state):
+ """
+ Reconstruct container using old self.conf['devices'] structure of
+
+ [..., {..., 'type': 'disk', ...}, ...]
+ to
+
+ VmDeviceContainer[DISK_DEVICES] =
+ [..., {..., 'type': 'disk', ...}, ...]
+ """
+ for device in state:
+ self[device['type']] = device
+
+
class Vm(object):
"""
Used for abstracting communication between various parts of the
--
To view, visit http://gerrit.ovirt.org/21138
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65debd35115da078df0c0cb6f50c57feb984c5a3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: vmDevices: add mechanism to persist vmDevice defaults
by mpoledni@redhat.com
Martin Polednik has uploaded a new change for review.
Change subject: vmDevices: add mechanism to persist vmDevice defaults
......................................................................
vmDevices: add mechanism to persist vmDevice defaults
Multiple vmDevices such as BalloonDevice or watchdogDevice currently
do not persist their defaults in class attributes but rather use them in
XML directly, hiding their existence. This patch aims to change this
behavior by implementing vmDevice._defaults(), which adds the default
attributes to instance directly to enable future persistence of these
classes.
Change-Id: Idc8383cbce78490c8dfab1c253883a06459f1547
Signed-off-by: Martin Polednik <mpoledni(a)redhat.com>
---
M tests/vmTests.py
M vdsm/vm.py
2 files changed, 45 insertions(+), 29 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/21066/1
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 1f69f0a..5c813fc 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -261,7 +261,7 @@
def testWatchdogXML(self):
watchdogXML = '<watchdog action="none" model="i6300esb"/>'
- dev = {'device': 'watchdog', 'type': 'watchdog',
+ dev = {'device': 'watchdog',
'specParams': {'model': 'i6300esb', 'action': 'none'}}
watchdog = vm.WatchdogDevice(self.conf, self.log, **dev)
self.assertXML(watchdog.getXML(), watchdogXML)
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 796735f..36b9598 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1167,6 +1167,7 @@
class VmDevice(object):
def __init__(self, conf, log, **kwargs):
+ self.specParams = {}
for attr, value in kwargs.iteritems():
try:
setattr(self, attr, value)
@@ -1175,6 +1176,10 @@
self.conf = conf
self.log = log
self._deviceXML = None
+ self._defaults()
+
+ def _defaults(self):
+ pass
def __str__(self):
attrs = [':'.join((a, str(getattr(self, a)))) for a in dir(self)
@@ -1192,10 +1197,13 @@
elemAttrs['type'] = deviceType
for attrName in attributes:
- if not hasattr(self, attrName):
+ if attrName in self.specParams:
+ attr = self.specParams[attrName]
+ elif hasattr(self, attrName):
+ attr = getattr(self, attrName)
+ else:
continue
- attr = getattr(self, attrName)
if isinstance(attr, dict):
element.appendChildWithArgs(attrName, **attr)
else:
@@ -1215,37 +1223,44 @@
class ControllerDevice(VmDevice):
+ def _defaults(self):
+ if self.device == 'virtio-serial':
+ if 'index' not in self.specParams:
+ self.index = '0'
+ if 'ports' not in self.specParams:
+ self.ports = '16'
def getXML(self):
"""
Create domxml for controller device
"""
ctrl = self.createXmlElem('controller', self.device,
- ['index', 'model', 'master', 'address'])
- if self.device == 'virtio-serial':
- ctrl.setAttrs(index='0', ports='16')
+ ['index', 'model', 'master', 'address',
+ 'ports'])
return ctrl
class VideoDevice(VmDevice):
+ def _defaults(self):
+ if 'vram' not in self.specParams:
+ self.specParams['vram'] = '32768'
+ if 'heads' not in self.specParams:
+ self.specParams['heads'] = '1'
def getXML(self):
"""
Create domxml for video device
"""
video = self.createXmlElem('video', None, ['address'])
- sourceAttrs = {'vram': self.specParams.get('vram', '32768'),
- 'heads': self.specParams.get('heads', '1')}
- if 'ram' in self.specParams:
- sourceAttrs['ram'] = self.specParams['ram']
+ model = self.createXmlElem('model', self.device,
+ ['vram', 'heads', 'ram'])
- video.appendChildWithArgs('model', type=self.device, **sourceAttrs)
+ video.appendChild(model)
return video
class SoundDevice(VmDevice):
-
def getXML(self):
"""
Create domxml for sound device
@@ -1256,7 +1271,6 @@
class NetworkInterfaceDevice(VmDevice):
-
def __init__(self, conf, log, **kwargs):
# pyLint can't tell that the Device.__init__() will
# set a nicModel attribute, so modify the kwarg list
@@ -1646,7 +1660,6 @@
class BalloonDevice(VmDevice):
-
def getXML(self):
"""
Create domxml for a memory balloon device.
@@ -1662,11 +1675,11 @@
class WatchdogDevice(VmDevice):
- def __init__(self, *args, **kwargs):
- super(WatchdogDevice, self).__init__(*args, **kwargs)
-
- if not hasattr(self, 'specParams'):
- self.specParams = {}
+ def _defaults(self):
+ if 'model' not in self.specParams:
+ self.specParams['model'] = 'i6300esb'
+ if 'action' not in self.specParams:
+ self.specParams['action'] = 'none'
def getXML(self):
"""
@@ -1677,9 +1690,8 @@
function='0x0'/>
</watchdog>
"""
- m = self.createXmlElem(self.type, None, ['address'])
- m.setAttrs(model=self.specParams.get('model', 'i6300esb'),
- action=self.specParams.get('action', 'none'))
+ m = self.createXmlElem(self.device, None, ['address', 'model',
+ 'action'])
return m
@@ -1692,11 +1704,8 @@
<address ... />
</smartcard>
"""
- card = self.createXmlElem(self.device, None, ['address'])
- sourceAttrs = {'mode': self.specParams['mode']}
- if sourceAttrs['mode'] != 'host':
- sourceAttrs['type'] = self.specParams['type']
- card.setAttrs(**sourceAttrs)
+ card = self.createXmlElem(self.device, None, ['address', 'mode',
+ 'type'])
return card
@@ -1713,6 +1722,12 @@
class ConsoleDevice(VmDevice):
+ def _defaults(self):
+ self.type = 'pty'
+ self.port = '0'
+ self.specParams['type'] = 'virtio'
+ self.specParams['port'] = '0'
+
def getXML(self):
"""
Create domxml for a console device.
@@ -1721,8 +1736,9 @@
<target type='virtio' port='0'/>
</console>
"""
- m = self.createXmlElem('console', 'pty')
- m.appendChildWithArgs('target', type='virtio', port='0')
+ m = self.createXmlElem(self.device, self.type)
+ m.appendChildWithArgs('target', None, type=self.specParams['type'],
+ port=self.specParams['port'])
return m
--
To view, visit http://gerrit.ovirt.org/21066
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc8383cbce78490c8dfab1c253883a06459f1547
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: gluster: [WIP]Get size information of gluster volume
by avishwan@redhat.com
Aravinda VK has uploaded a new change for review.
Change subject: gluster: [WIP]Get size information of gluster volume
......................................................................
gluster: [WIP]Get size information of gluster volume
Change-Id: I358d4f3bf793ecc1a01e0592d68919d1405f6e19
Signed-off-by: Aravinda VK <avishwan(a)redhat.com>
---
M client/vdsClientGluster.py
M vdsm.spec.in
M vdsm/gluster/Makefile.am
M vdsm/gluster/__init__.py
M vdsm/gluster/api.py
A vdsm/gluster/gfapi.py
6 files changed, 100 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/17822/1
diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 90af83e..644bfe3 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -424,6 +424,17 @@
pp.pprint(status)
return status['status']['code'], status['status']['message']
+ def do_glusterVolumeSize(self, args):
+ params = self._eqSplit(args)
+ try:
+ volumeName = params.get('volumeName', '')
+ except:
+ raise ValueError
+
+ status = self.s.glusterVolumeSize(volumeName)
+ pp.pprint(status)
+ return status['status']['code'], status['status']['message']
+
def getGlusterCmdDict(serv):
return \
@@ -705,4 +716,9 @@
'not set'
'(swift, glusterd, smb, memcached)'
)),
+ 'glusterVolumeSize': (
+ serv.do_glusterVolumeSize,
+ ('volumeName=<volume name>',
+ 'Returns total, available and used space status of gluster volume'
+ )),
}
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 21b3565..e49e102 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1271,6 +1271,7 @@
%doc COPYING
%{_datadir}/%{vdsm_name}/gluster/api.py*
%{_datadir}/%{vdsm_name}/gluster/vdsmapi-gluster-schema.json
+%{_datadir}/%{vdsm_name}/gluster/gfapi.py*
%{_datadir}/%{vdsm_name}/gluster/hooks.py*
%{_datadir}/%{vdsm_name}/gluster/services.py*
%endif
diff --git a/vdsm/gluster/Makefile.am b/vdsm/gluster/Makefile.am
index dd5434d..9c2989f 100644
--- a/vdsm/gluster/Makefile.am
+++ b/vdsm/gluster/Makefile.am
@@ -26,6 +26,7 @@
api.py \
cli.py \
exception.py \
+ gfapi.py \
hooks.py \
hostname.py \
services.py \
diff --git a/vdsm/gluster/__init__.py b/vdsm/gluster/__init__.py
index bec70ea..e5a2fd6 100644
--- a/vdsm/gluster/__init__.py
+++ b/vdsm/gluster/__init__.py
@@ -22,7 +22,7 @@
import tempfile
from functools import wraps
-MODULE_LIST = ('cli', 'hooks', 'services')
+MODULE_LIST = ('cli', 'hooks', 'services', 'gfapi')
def makePublic(func):
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 4bd8308..89546c1 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -287,6 +287,22 @@
status = self.svdsmProxy.glusterServicesGet(serviceNames)
return {'services': status}
+ @exportAsVerb
+ def volumeSize(self, volumeName, options=None):
+ data = self.svdsmProxy.glusterVolumeStatvfs(volumeName)
+ # f_blocks = Total number of blocks
+ # f_bfree = Total number of blocks free
+ # f_bavail = Total number of blocks available for non root user
+ # total blocks available = f_blocks - (f_bfree - f_bavail)
+ total_blocks_available = data['f_blocks'] - \
+ (data['f_bfree'] - data['f_bavail'])
+ return {
+ 'total': total_blocks_available * data.f_bsize / 1024,
+ 'free': data['f_bavail'] * data['f_bsize'] / 1024,
+ 'used': (total_blocks_available - data['f_bavail']) * \
+ data['f_bsize'] / 1024
+ }
+
def getGlusterMethods(gluster):
l = []
diff --git a/vdsm/gluster/gfapi.py b/vdsm/gluster/gfapi.py
new file mode 100644
index 0000000..abfdabd
--- /dev/null
+++ b/vdsm/gluster/gfapi.py
@@ -0,0 +1,65 @@
+#
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+from ctypes import *
+
+# import exception as ge
+from . import makePublic
+
+GLUSTER_VOL_PROTOCAL='tcp'
+GLUSTER_VOL_HOST='localhost'
+GLUSTER_VOL_PORT=24007
+
+class Stat (Structure):
+ _fields_ = [
+ ('f_bsize', c_ulong),
+ ('f_frsize', c_ulong),
+ ('f_blocks', c_ulong),
+ ('f_bfree', c_ulong),
+ ('f_bavail', c_ulong),
+ ('f_files', c_ulong),
+ ('f_ffree', c_ulong),
+ ('f_favail', c_ulong),
+ ('f_fsid', c_ulong),
+ ('f_flag', c_ulong),
+ ('f_namemax', c_ulong),
+ ('__f_spare', c_int * 6),
+ ]
+
+
+api = CDLL("libgfapi.so",RTLD_GLOBAL)
+api.glfs_statvfs.restype = c_int
+api.glfs_statvfs.argtypes = [c_void_p, c_char_p, POINTER(Stat)]
+
+@makePublic
+def volumeStatvfs(volumeId):
+ path = "/"
+ fs = api.glfs_new(volumeId)
+ api.glfs_set_volfile_server(fs,
+ GLUSTER_VOL_PROTOCAL,
+ GLUSTER_VOL_HOST,
+ GLUSTER_VOL_PORT)
+ api.glfs_init(fs)
+
+ x = Stat()
+ rc = api.glfs_statvfs(fs, path, byref(x))
+ statvfsData = {}
+ for k in x._fields_:
+ statvfsData[k[0]] = getattr(x, k[0])
+ return statvfsData
--
To view, visit http://gerrit.ovirt.org/17822
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I358d4f3bf793ecc1a01e0592d68919d1405f6e19
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Aravinda VK <avishwan(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: xmlrpc: Fix connection reset on Python 2.6
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: xmlrpc: Fix connection reset on Python 2.6
......................................................................
xmlrpc: Fix connection reset on Python 2.6
When request is aborted before the reading the entire request, closing the
socket cause the other side to receive connection reset, and loose the response
data. Python 2.7 introduced the shutdown_request method, fixing this issue.
This patch check if SimpleXMLRPCServer has the shutdown_request method, and if
not, do a clean request shutdwon in close_request.
Change-Id: Id77a32bb0d4fff13ee680eade52a2f60e4e808b5
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/utils.py
1 file changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/24026/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index 9429308..eeea5d4 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -158,6 +158,23 @@
logRequests, allow_none, encoding,
bind_and_activate)
+ # Fix for connection reset issue when running on Python 2.6. This happens
+ # when request is aborted before the reading the entire request. Closing
+ # the socket cause the other side to receive connection reset, and loose
+ # the response data. Python 2.7 introduced the shutdown_request method,
+ # fixing this issue. If we run on a version without this method, we will do
+ # a clean shutdown in close_request instead.
+ if not hasattr(SimpleXMLRPCServer, 'shutdown_request'):
+ def close_request(self, request):
+ # From Python 2.7 SocketServer.TCPServer.shutdown_request
+ try:
+ # Explicitly shutdown. socket.close() merely releases the
+ # socket and waits for GC to perform the actual close.
+ request.shutdown(socket.SHUT_WR)
+ except socket.error:
+ pass # Some platforms may raise ENOTCONN here
+ SimpleXMLRPCServer.close_request(self, request)
+
#Threaded version of SimpleXMLRPCServer
class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn,
--
To view, visit http://gerrit.ovirt.org/24026
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id77a32bb0d4fff13ee680eade52a2f60e4e808b5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years, 9 months