Change in vdsm[master]: Avoid hsm image deletions.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Avoid hsm image deletions.
......................................................................
Avoid hsm image deletions.
This code was introduced to fix BZ#560389.
The bug was in Image.delete() which was already removed.
Related to BZ#965184.
Change-Id: Ie1ec2ea8793a4ad63453559bc5f663b65f9b9336
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/blockSD.py
M vdsm/storage/fileSD.py
M vdsm/storage/sd.py
3 files changed, 0 insertions(+), 24 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/17193/1
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 72b3ef0..6507cbf 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -416,7 +416,6 @@
# _extendlock is used to prevent race between
# VG extend and LV extend.
self._extendlock = threading.Lock()
- self.imageGarbageCollector()
self._registerResourceNamespaces()
self._lastUncachedSelftest = 0
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index 1651825..0042aab 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -165,7 +165,6 @@
if not self.oop.fileUtils.pathExists(self.metafile):
raise se.StorageDomainMetadataNotFound(sdUUID, self.metafile)
- self.imageGarbageCollector()
self._registerResourceNamespaces()
@property
@@ -515,20 +514,6 @@
mount.getMountFromTarget(self.mountpoint).umount()
raise se.FileStorageDomainStaleNFSHandle()
raise
-
- def imageGarbageCollector(self):
- """
- Image Garbage Collector
- remove the remnants of the removed images (they could be left sometimes
- (on NFS mostly) due to lazy file removal
- """
- removedPattern = os.path.join(self.domaindir, sd.DOMAIN_IMAGES,
- sd.REMOVED_IMAGE_PREFIX + '*')
- removedImages = self.oop.glob.glob(removedPattern)
- self.log.debug("Removing remnants of deleted images %s" %
- removedImages)
- for imageDir in removedImages:
- self.oop.fileUtils.cleanupdir(imageDir)
def templateRelink(self, imgUUID, volUUID):
"""
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index fd79059..c764d2d 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -786,11 +786,3 @@
def isData(self):
return self.getMetaParam(DMDK_CLASS) == DATA_DOMAIN
-
- def imageGarbageCollector(self):
- """
- Image Garbage Collector
- remove the remnants of the removed images (they could be left sometimes
- (on NFS mostly) due to lazy file removal
- """
- pass
--
To view, visit http://gerrit.ovirt.org/17193
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1ec2ea8793a4ad63453559bc5f663b65f9b9336
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: Refactor StoragePool.getPoolParams()
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Refactor StoragePool.getPoolParams()
......................................................................
Refactor StoragePool.getPoolParams()
Change-Id: Ibbeaaaf67a39f3ca8b27252fc631a91f266d1adc
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/sp.py
1 file changed, 4 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/19232/1
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 38eda39..d5a8b4e 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -734,21 +734,10 @@
@unsecured
def getPoolParams(self):
- file = open(self._poolFile, "r")
- for line in file:
- pair = line.strip().split("=")
- if len(pair) == 2:
- if pair[0] == "id":
- hostId = int(pair[1])
- elif pair[0] == "scsiKey":
- scsiKey = pair[1]
- elif pair[0] == "sdUUID":
- msdUUID = pair[1]
- elif pair[0] == "version":
- masterVersion = pair[1]
- file.close()
-
- return hostId, scsiKey, msdUUID, masterVersion
+ lines = open(self._poolFile, "r").readlines()
+ params = dict(line.strip().split('=') for line in lines if '=' in line)
+ return tuple(params[k] for k in ('hostId', 'scsiKey', 'msdUUID',
+ 'masterVersion'))
@unsecured
def createMaster(self, poolName, domain, masterVersion, leaseParams):
--
To view, visit http://gerrit.ovirt.org/19232
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibbeaaaf67a39f3ca8b27252fc631a91f266d1adc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: vdsm: Get underlying device info moved to Device classes
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: vdsm: Get underlying device info moved to Device classes
......................................................................
vdsm: Get underlying device info moved to Device classes
Change-Id: I8f797baece3601b885777784f611b420523828f7
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 379 insertions(+), 396 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/19732/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 4f2f35d..d23cd21 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1196,6 +1196,98 @@
element.setAttrs(**elemAttrs)
return element
+ @classmethod
+ def _getDeviceAlias(cls, device):
+ return device.getElementsByTagName('alias')[0].getAttribute('name')
+
+ @classmethod
+ def _getDeviceAddress(cls, device):
+ """
+ Obtain device's address from libvirt
+ """
+ address = {}
+ dom = device.getElementsByTagName('address')[0]
+ # Parse address to create proper dictionary.
+ # Libvirt device's address definition is:
+ # PCI = {'type':'pci', 'domain':'0x0000', 'bus':'0x00',
+ # 'slot':'0x0c', 'function':'0x0'}
+ # IDE = {'type':'drive', 'controller':'0', 'bus':'0', 'unit':'0'}
+ for key in dom.attributes.keys():
+ address[key.strip()] = dom.getAttribute(key).strip()
+
+ return address
+
+ @classmethod
+ def _defaultUpdate(cls, element, type, desc, devices, conf, **kwargs):
+ getAddress = kwargs.get('address', True)
+ getAddressRequired = False
+ if 'getAddressRequired' in kwargs:
+ getAddressRequired = kwargs.get('aliasRequired')
+ getAddress = getAddressRequired
+
+ default = desc.getElementsByTagName(element)
+ for x in default:
+ if getAddressRequired:
+ if not x.getElementsByTagName('address'):
+ continue
+
+ address = None
+ if getAddress:
+ address = cls._getDeviceAddress(x)
+
+ alias = cls._getDeviceAliasName(x)
+
+ for x in devices[type]:
+ if address and not hasattr(x, 'address'):
+ x.address = address
+ if alias and not hasattr(x, 'alias'):
+ x.alias = alias
+
+ for dev in conf['devices']:
+ if dev['type'] == type:
+ if address and not dev.get('address'):
+ dev['address'] = address
+ if alias and not dev.get('alias'):
+ dev['alias'] = alias
+
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ pass
+
+
+class UnknownDevice(VmDevice):
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain unknown devices info from libvirt.
+
+ Unknown device is a device that has an address but wasn't
+ passed during VM creation request.
+ """
+ def isKnownDevice(alias):
+ for dev in conf['devices']:
+ if dev.get('alias') == alias:
+ return True
+ return False
+
+ for x in desc.childNodes:
+ # Ignore empty nodes and devices without address
+ if (x.nodeName == '#text' or
+ not x.getElementsByTagName('address')):
+ continue
+
+ alias = cls._getDeviceAliasName(x)
+ if not isKnownDevice(alias):
+ address = cls._getDeviceAddress(x)
+ # I general case we assume that device has attribute 'type',
+ # if it hasn't getAttribute returns ''.
+ device = x.getAttribute('type')
+ newDev = {'type': x.nodeName,
+ 'alias': alias,
+ 'device': device,
+ 'address': address}
+ conf['devices'].append(newDev)
+
class GeneralDevice(VmDevice):
@@ -1219,6 +1311,52 @@
return ctrl
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain controller devices info from libvirt.
+ """
+ controllers = desc.getElementsByTagName('controller')
+ for x in controllers:
+ # Ignore controller devices without address
+ if not x.getElementsByTagName('address'):
+ continue
+ alias = cls._getDeviceAliasName(x)
+ device = x.getAttribute('type')
+ # Get model and index. Relevant for USB controllers.
+ model = x.getAttribute('model')
+ index = x.getAttribute('index')
+
+ # Get controller address
+ address = cls._getDeviceAddress(x)
+
+ # In case the controller has index and/or model, they
+ # are compared. Currently relevant for USB controllers.
+ for ctrl in 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
+ # 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 conf['devices']:
+ if ((dev['type'] == CONTROLLER_DEVICES) and
+ (dev['device'] == device) and
+ (not 'index' in dev or dev['index'] == index) and
+ (not 'model' in dev or dev['model'] == model)):
+ dev['address'] = address
+ dev['alias'] = alias
+ knownDev = True
+ # Add unknown controller device to vm's conf
+ if not knownDev:
+ conf['devices'].append({'type': CONTROLLER_DEVICES,
+ 'device': device,
+ 'address': address,
+ 'alias': alias})
+
class VideoDevice(VmDevice):
@@ -1235,6 +1373,34 @@
video.appendChildWithArgs('model', type=self.device, **sourceAttrs)
return video
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain video devices info from libvirt.
+ """
+ videos = desc.getElementsByTagName('video')
+ for x in videos:
+ alias = cls._getDeviceAliasName(x)
+ # Get video card address
+ address = cls._getDeviceAddress(x)
+
+ # FIXME. We have an identification problem here.
+ # Video card device has not unique identifier, except the alias
+ # (but backend not aware to device's aliases). So, for now
+ # we can only assign the address according to devices order.
+ for vc in devices[VIDEO_DEVICES]:
+ if not hasattr(vc, 'address') or not hasattr(vc, 'alias'):
+ vc.alias = alias
+ vc.address = address
+ break
+ # Update vm's conf with address
+ for dev in conf['devices']:
+ if ((dev['type'] == VIDEO_DEVICES) and
+ (not dev.get('address') or not dev.get('alias'))):
+ dev['address'] = address
+ dev['alias'] = alias
+ break
+
class SoundDevice(VmDevice):
@@ -1245,6 +1411,34 @@
sound = self.createXmlElem('sound', None, ['address'])
sound.setAttrs(model=self.device)
return sound
+
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain sound devices info from libvirt.
+ """
+ soundDevices = desc.getElementsByTagName('sound')
+ for x in soundDevices:
+ alias = cls._getDeviceAliasName(x)
+ # Get sound card address
+ address = cls._getDeviceAddress(x)
+
+ # FIXME. We have an identification problem here.
+ # Sound device has not unique identifier, except the alias
+ # (but backend not aware to device's aliases). So, for now
+ # we can only assign the address according to devices order.
+ for sc in devices[SOUND_DEVICES]:
+ if not hasattr(sc, 'address') or not hasattr(sc, 'alias'):
+ sc.alias = alias
+ sc.address = address
+ break
+ # Update vm's conf with address
+ for dev in conf['devices']:
+ if ((dev['type'] == SOUND_DEVICES) and
+ (not dev.get('address') or not dev.get('alias'))):
+ dev['address'] = address
+ dev['alias'] = alias
+ break
class NetworkInterfaceDevice(VmDevice):
@@ -1337,6 +1531,73 @@
bandwidth.appendChildWithArgs('outbound', **outbound)
iface.appendChild(bandwidth)
return iface
+
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain network interface info from libvirt.
+ """
+ # TODO use xpath instead of parseString (here and elsewhere)
+ interfaces = desc.getElementsByTagName('interface')
+ for x in interfaces:
+ devType = x.getAttribute('type')
+ mac = x.getElementsByTagName('mac')[0].getAttribute('address')
+ alias = cls._getDeviceAliasName(x)
+ if devType == 'hostdev':
+ name = alias
+ model = 'passthrough'
+ else:
+ name = x.getElementsByTagName('target')[0].getAttribute('dev')
+ model = x.getElementsByTagName('model')[0].getAttribute('type')
+
+ network = None
+ try:
+ if x.getElementsByTagName('link')[0].getAttribute('state') == \
+ 'down':
+ linkActive = False
+ else:
+ linkActive = True
+ except IndexError:
+ linkActive = True
+ source = x.getElementsByTagName('source')
+ if source:
+ network = source[0].getAttribute('bridge')
+ if not network:
+ network = source[0].getAttribute('network')
+ network = network[len(netinfo.LIBVIRT_NET_PREFIX):]
+
+ # Get nic address
+ address = cls._getDeviceAddress(x)
+ for nic in devices[NIC_DEVICES]:
+ if nic.macAddr.lower() == mac.lower():
+ nic.name = name
+ nic.alias = alias
+ nic.address = address
+ nic.linkActive = linkActive
+ # Update vm's conf with address for known nic devices
+ knownDev = False
+ for dev in conf['devices']:
+ if (dev['type'] == NIC_DEVICES and
+ dev['macAddr'].lower() == mac.lower()):
+ dev['address'] = address
+ dev['alias'] = alias
+ dev['name'] = name
+ dev['linkActive'] = linkActive
+ knownDev = True
+ # Add unknown nic device to vm's conf
+ if not knownDev:
+ nicDev = {'type': NIC_DEVICES,
+ 'device': devType,
+ 'macAddr': mac,
+ 'nicModel': model,
+ 'address': address,
+ 'alias': alias,
+ 'name': name,
+ 'linkActive': linkActive}
+ if network:
+ nicDev['network'] = network
+ conf['devices'].append(nicDev)
+
class Drive(VmDevice):
@@ -1625,6 +1886,71 @@
return diskelem
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain block devices info from libvirt.
+ """
+ disks = desc.getElementsByTagName('disk')
+ # FIXME! We need to gather as much info as possible from the libvirt.
+ # In the future we can return this real data to management instead of
+ # vm's conf
+ for x in disks:
+ sources = x.getElementsByTagName('source')
+ if sources:
+ devPath = (sources[0].getAttribute('file') or
+ sources[0].getAttribute('dev'))
+ else:
+ devPath = ''
+
+ target = x.getElementsByTagName('target')
+ name = target[0].getAttribute('dev') if target else ''
+ alias = cls._getDeviceAliasName(x)
+ readonly = bool(x.getElementsByTagName('readonly'))
+ boot = x.getElementsByTagName('boot')
+ bootOrder = boot[0].getAttribute('order') if boot else ''
+
+ devType = x.getAttribute('device')
+ if devType == 'disk':
+ # raw/qcow2
+ drv = x.getElementsByTagName('driver')[0].getAttribute('type')
+ else:
+ drv = 'raw'
+ # Get disk address
+ address = cls._getDeviceAddress(x)
+
+ for d in devices[DISK_DEVICES]:
+ if d.path == devPath:
+ d.name = name
+ d.type = devType
+ d.drv = drv
+ d.alias = alias
+ d.address = address
+ d.readonly = readonly
+ if bootOrder:
+ d.bootOrder = bootOrder
+ # Update vm's conf with address for known disk devices
+ knownDev = False
+ for dev in conf['devices']:
+ if dev['type'] == DISK_DEVICES and dev['path'] == devPath:
+ dev['name'] = name
+ dev['address'] = address
+ dev['alias'] = alias
+ dev['readonly'] = str(readonly)
+ if bootOrder:
+ dev['bootOrder'] = bootOrder
+ knownDev = True
+ # Add unknown disk device to vm's conf
+ if not knownDev:
+ iface = 'ide' if address['type'] == 'drive' else 'pci'
+ diskDev = {'type': DISK_DEVICES, 'device': devType,
+ 'iface': iface, 'path': devPath, 'name': name,
+ 'address': address, 'alias': alias,
+ 'readonly': str(readonly)}
+ if bootOrder:
+ diskDev['bootOrder'] = bootOrder
+ conf['devices'].append(diskDev)
+
class BalloonDevice(VmDevice):
@@ -1640,6 +1966,15 @@
m = self.createXmlElem(self.device, None, ['address'])
m.setAttrs(model=self.specParams['model'])
return m
+
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain balloon device info from libvirt.
+ """
+ balloon = desc.getElementsByTagName('memballoon')
+ cls._defaultUpdate('watchdog', WATCHDOG_DEVICES, desc, devices, conf,
+ addressRequired=False)
class WatchdogDevice(VmDevice):
@@ -1657,6 +1992,14 @@
action=self.specParams['action'])
return m
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain watchdog device info from libvirt.
+ """
+ cls._defaultUpdate('watchdog', WATCHDOG_DEVICES, desc, devices, conf,
+ addressRequired=True)
+
class SmartCardDevice(VmDevice):
def getXML(self):
@@ -1673,6 +2016,13 @@
sourceAttrs['type'] = self.specParams['type']
card.setAttrs(**sourceAttrs)
return card
+
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain smartcard device info from libvirt.
+ """
+ cls._defaultUpdate('smartcard', SMARTCARD_DEVICES, desc, devices, conf)
class RedirDevice(VmDevice):
@@ -1700,6 +2050,13 @@
m.appendChildWithArgs('target', type='virtio', port='0')
return m
+ @classmethod
+ def updateFromDesc(cls, desc, devices, conf):
+ """
+ Obtain the alias for the console device from libvirt
+ """
+ cls._defaultUpdate('console', CONSOLE_DEVICES, desc, devices, conf,
+ address=False)
class Vm(object):
"""
@@ -1713,6 +2070,18 @@
# limit threads number until the libvirt lock will be fixed
_ongoingCreations = threading.BoundedSemaphore(4)
MigrationSourceThreadClass = MigrationSourceThread
+ DeviceMapping = ((DISK_DEVICES, Drive),
+ (NIC_DEVICES, NetworkInterfaceDevice),
+ (SOUND_DEVICES, SoundDevice),
+ (VIDEO_DEVICES, VideoDevice),
+ (CONTROLLER_DEVICES, ControllerDevice),
+ (GENERAL_DEVICES, GeneralDevice),
+ (BALLOON_DEVICES, BalloonDevice),
+ (WATCHDOG_DEVICES, WatchdogDevice),
+ (CONSOLE_DEVICES, ConsoleDevice),
+ (REDIR_DEVICES, RedirDevice),
+ (SMARTCARD_DEVICES, SmartCardDevice))
+
def _makeChannelPath(self, deviceName):
return constants.P_LIBVIRT_VMCHANNELS + self.id + '.' + deviceName
@@ -2747,7 +3116,7 @@
self._qemuguestSocketFile.decode('utf-8'),
_QEMU_GA_DEVICE_NAME)
domxml.appendInput()
- domxml.appendGraphics()
+ domxml.appendGraphics()
self._appendDevices(domxml)
@@ -2785,19 +3154,12 @@
Obtain underlying vm's devices info from libvirt.
"""
devicesXml = self._getDevicesXml()
- self._getUnderlyingNetworkInterfaceInfo(devicesXml=devicesXml)
- self._getUnderlyingDriveInfo(devicesXml=devicesXml)
+ for _, cls in self.DeviceMapping:
+ cls.updateFromDesc(devicesXml, self._devices, self.conf)
self._getUnderlyingDisplayPort(xml=self._lastXMLDesc.dom())
- self._getUnderlyingSoundDeviceInfo(devicesXml=devicesXml)
- self._getUnderlyingVideoDeviceInfo(devicesXml=devicesXml)
- self._getUnderlyingControllerDeviceInfo(devicesXml=devicesXml)
- self._getUnderlyingBalloonDeviceInfo(devicesXml=devicesXml)
- self._getUnderlyingWatchdogDeviceInfo(devicesXml=devicesXml)
- self._getUnderlyingSmartcardDeviceInfo(devicesXml=devicesXml)
- self._getUnderlyingConsoleDeviceInfo(devicesXml=devicesXml)
self._updateAgentChannels(devicesXml=devicesXml)
# Obtain info of all unknown devices. Must be last!
- self._getUnderlyingUnknownDeviceInfo(devicesXml=devicesXml)
+ UnknownDevice.updateFromDesc(devicesXml, self._devices, self.conf)
def _updateAgentChannels(self, devicesXml):
"""
@@ -2914,19 +3276,7 @@
else:
devices = self.getConfDevices()
- devMap = {DISK_DEVICES: Drive,
- NIC_DEVICES: NetworkInterfaceDevice,
- SOUND_DEVICES: SoundDevice,
- VIDEO_DEVICES: VideoDevice,
- CONTROLLER_DEVICES: ControllerDevice,
- GENERAL_DEVICES: GeneralDevice,
- BALLOON_DEVICES: BalloonDevice,
- WATCHDOG_DEVICES: WatchdogDevice,
- REDIR_DEVICES: RedirDevice,
- CONSOLE_DEVICES: ConsoleDevice,
- SMARTCARD_DEVICES: SmartCardDevice}
-
- for devType, devClass in devMap.items():
+ for devType, devClass in self.DeviceMapping:
for dev in devices[devType]:
self._devices[devType].append(devClass(self.conf, self.log,
**dev))
@@ -3066,10 +3416,9 @@
with self._confLock:
self.conf['devices'].append(nicParams)
self.saveState()
- self._getUnderlyingNetworkInterfaceInfo(
- devicesXml=self._getDevicesXml())
- hooks.after_nic_hotplug(nicXml, self.conf,
- params=customProps)
+ NetworkInterfaceDevice.updateFromDesc(self._getDevicesXml(),
+ self._devices, self.conf)
+ hooks.after_nic_hotplug(nicXml, self.conf, params=customProps)
if hasattr(nic, 'portMirroring'):
mirroredNetworks = []
@@ -3327,7 +3676,8 @@
with self._confLock:
self.conf['devices'].append(diskParams)
self.saveState()
- self._getUnderlyingDriveInfo(devicesXml=self._getDevicesXml())
+ Drive.updateFromDesc(self._getDevicesXml(), self._devices,
+ self.conf)
hooks.after_disk_hotplug(driveXml, self.conf,
params=customProps)
@@ -4397,308 +4747,6 @@
self.saveState()
return {'status': doneCode}
- def _getUnderlyingDeviceAliasName(self, devXml):
- return devXml.getElementsByTagName('alias')[0].getAttribute('name')
-
- def _getUnderlyingDeviceAddress(self, devXml):
- """
- Obtain device's address from libvirt
- """
- address = {}
- adrXml = devXml.getElementsByTagName('address')[0]
- # Parse address to create proper dictionary.
- # Libvirt device's address definition is:
- # PCI = {'type':'pci', 'domain':'0x0000', 'bus':'0x00',
- # 'slot':'0x0c', 'function':'0x0'}
- # IDE = {'type':'drive', 'controller':'0', 'bus':'0', 'unit':'0'}
- for key in adrXml.attributes.keys():
- address[key.strip()] = adrXml.getAttribute(key).strip()
-
- return address
-
- def _getUnderlyingUnknownDeviceInfo(self, devicesXml):
- """
- Obtain unknown devices info from libvirt.
-
- Unknown device is a device that has an address but wasn't
- passed during VM creation request.
- """
- def isKnownDevice(alias):
- for dev in self.conf['devices']:
- if dev.get('alias') == alias:
- return True
- return False
-
- for x in devicesXml.childNodes:
- # Ignore empty nodes and devices without address
- if (x.nodeName == '#text' or
- not x.getElementsByTagName('address')):
- continue
-
- alias = self._getUnderlyingDeviceAliasName(x)
- if not isKnownDevice(alias):
- address = self._getUnderlyingDeviceAddress(x)
- # I general case we assume that device has attribute 'type',
- # if it hasn't getAttribute returns ''.
- device = x.getAttribute('type')
- newDev = {'type': x.nodeName,
- 'alias': alias,
- 'device': device,
- 'address': address}
- self.conf['devices'].append(newDev)
-
- def _getUnderlyingControllerDeviceInfo(self, devicesXml):
- """
- Obtain controller devices info from libvirt.
- """
- ctrlsxml = devicesXml.getElementsByTagName('controller')
- for x in ctrlsxml:
- # Ignore controller devices without address
- if not x.getElementsByTagName('address'):
- continue
- alias = self._getUnderlyingDeviceAliasName(x)
- device = x.getAttribute('type')
- # Get model and index. Relevant for USB controllers.
- model = x.getAttribute('model')
- index = x.getAttribute('index')
-
- # Get controller address
- address = self._getUnderlyingDeviceAddress(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
- # 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
- (not 'index' in dev or dev['index'] == index) and
- (not 'model' in dev or dev['model'] == model)):
- dev['address'] = address
- dev['alias'] = 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})
-
- def _getUnderlyingBalloonDeviceInfo(self, devicesXml):
- """
- Obtain balloon device info from libvirt.
- """
- balloonxml = devicesXml.getElementsByTagName('memballoon')
- for x in balloonxml:
- # Ignore balloon devices without address.
- if not x.getElementsByTagName('address'):
- address = None
- else:
- address = self._getUnderlyingDeviceAddress(x)
- alias = self._getUnderlyingDeviceAliasName(x)
-
- for dev in self._devices[BALLOON_DEVICES]:
- if address and not hasattr(dev, 'address'):
- dev.address = address
- if not hasattr(dev, 'alias'):
- dev.alias = alias
-
- for dev in self.conf['devices']:
- if dev['type'] == BALLOON_DEVICES:
- if address and not dev.get('address'):
- dev['address'] = address
- if not dev.get('alias'):
- dev['alias'] = alias
-
- def _getUnderlyingConsoleDeviceInfo(self, devicesXml):
- """
- Obtain the alias for the console device from libvirt
- """
- consolexml = devicesXml.getElementsByTagName('console')
- for x in consolexml:
- # All we care about is the alias
- alias = self._getUnderlyingDeviceAliasName(x)
- for dev in self._devices[CONSOLE_DEVICES]:
- if not hasattr(dev, 'alias'):
- dev.alias = alias
-
- for dev in self.conf['devices']:
- if dev['device'] == CONSOLE_DEVICES and \
- not dev.get('alias'):
- dev['alias'] = alias
-
- def _getUnderlyingSmartcardDeviceInfo(self, devicesXml):
- """
- Obtain smartcard device info from libvirt.
- """
- smartcardxml = devicesXml.getElementsByTagName('smartcard')
- for x in smartcardxml:
- if not x.getElementsByTagName('address'):
- continue
-
- address = self._getUnderlyingDeviceAddress(x)
- alias = self._getUnderlyingDeviceAliasName(x)
-
- for dev in self._devices[SMARTCARD_DEVICES]:
- if not hasattr(dev, 'address'):
- dev.address = address
- dev.alias = alias
-
- for dev in self.conf['devices']:
- if dev['device'] == SMARTCARD_DEVICES and \
- not dev.get('address'):
- dev['address'] = address
- dev['alias'] = alias
-
- def _getUnderlyingWatchdogDeviceInfo(self, devicesXml):
- """
- Obtain watchdog device info from libvirt.
- """
- watchdogxml = devicesXml.getElementsByTagName('watchdog')
- for x in watchdogxml:
-
- # PCI watchdog has "address" different from ISA watchdog
- if x.getElementsByTagName('address'):
- address = self._getUnderlyingDeviceAddress(x)
- alias = self._getUnderlyingDeviceAliasName(x)
-
- for wd in self._devices[WATCHDOG_DEVICES]:
- if not hasattr(wd, 'address') or not hasattr(wd, 'alias'):
- wd.address = address
- wd.alias = 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
-
- def _getUnderlyingVideoDeviceInfo(self, devicesXml):
- """
- Obtain video devices info from libvirt.
- """
- videosxml = devicesXml.getElementsByTagName('video')
- for x in videosxml:
- alias = self._getUnderlyingDeviceAliasName(x)
- # Get video card address
- address = self._getUnderlyingDeviceAddress(x)
-
- # FIXME. We have an identification problem here.
- # Video card device has not unique identifier, except the alias
- # (but backend not aware to device's aliases). So, for now
- # 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
- 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
- break
-
- def _getUnderlyingSoundDeviceInfo(self, devicesXml):
- """
- Obtain sound devices info from libvirt.
- """
- soundsxml = devicesXml.getElementsByTagName('sound')
- for x in soundsxml:
- alias = self._getUnderlyingDeviceAliasName(x)
- # Get sound card address
- address = self._getUnderlyingDeviceAddress(x)
-
- # FIXME. We have an identification problem here.
- # Sound device has not unique identifier, except the alias
- # (but backend not aware to device's aliases). So, for now
- # 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
- 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
- break
-
- def _getUnderlyingDriveInfo(self, devicesXml):
- """
- Obtain block devices info from libvirt.
- """
- disksxml = devicesXml.getElementsByTagName('disk')
- # FIXME! We need to gather as much info as possible from the libvirt.
- # In the future we can return this real data to management instead of
- # vm's conf
- for x in disksxml:
- sources = x.getElementsByTagName('source')
- if sources:
- devPath = (sources[0].getAttribute('file') or
- sources[0].getAttribute('dev'))
- else:
- devPath = ''
-
- target = x.getElementsByTagName('target')
- name = target[0].getAttribute('dev') if target else ''
- alias = self._getUnderlyingDeviceAliasName(x)
- readonly = bool(x.getElementsByTagName('readonly'))
- boot = x.getElementsByTagName('boot')
- bootOrder = boot[0].getAttribute('order') if boot else ''
-
- devType = x.getAttribute('device')
- if devType == 'disk':
- # raw/qcow2
- drv = x.getElementsByTagName('driver')[0].getAttribute('type')
- else:
- drv = 'raw'
- # Get disk address
- address = self._getUnderlyingDeviceAddress(x)
-
- for d in self._devices[DISK_DEVICES]:
- if d.path == devPath:
- d.name = name
- d.type = devType
- d.drv = drv
- d.alias = alias
- d.address = address
- d.readonly = readonly
- if bootOrder:
- d.bootOrder = bootOrder
- # Update vm's conf with address for known disk devices
- knownDev = False
- for dev in self.conf['devices']:
- if dev['type'] == DISK_DEVICES and dev['path'] == devPath:
- dev['name'] = name
- dev['address'] = address
- dev['alias'] = alias
- dev['readonly'] = str(readonly)
- if bootOrder:
- dev['bootOrder'] = bootOrder
- knownDev = True
- # Add unknown disk device to vm's conf
- if not knownDev:
- iface = 'ide' if address['type'] == 'drive' else 'pci'
- diskDev = {'type': DISK_DEVICES, 'device': devType,
- 'iface': iface, 'path': devPath, 'name': name,
- 'address': address, 'alias': alias,
- 'readonly': str(readonly)}
- if bootOrder:
- diskDev['bootOrder'] = bootOrder
- self.conf['devices'].append(diskDev)
-
def _getUnderlyingDisplayPort(self, xml):
"""
Obtain display port info from libvirt.
@@ -4710,71 +4758,6 @@
port = graphics.getAttribute('tlsPort')
if port:
self.conf['displaySecurePort'] = port
-
- def _getUnderlyingNetworkInterfaceInfo(self, devicesXml):
- """
- Obtain network interface info from libvirt.
- """
- # TODO use xpath instead of parseString (here and elsewhere)
- ifsxml = devicesXml.getElementsByTagName('interface')
- for x in ifsxml:
- devType = x.getAttribute('type')
- mac = x.getElementsByTagName('mac')[0].getAttribute('address')
- alias = self._getUnderlyingDeviceAliasName(x)
- if devType == 'hostdev':
- name = alias
- model = 'passthrough'
- else:
- name = x.getElementsByTagName('target')[0].getAttribute('dev')
- model = x.getElementsByTagName('model')[0].getAttribute('type')
-
- network = None
- try:
- if x.getElementsByTagName('link')[0].getAttribute('state') == \
- 'down':
- linkActive = False
- else:
- linkActive = True
- except IndexError:
- linkActive = True
- source = x.getElementsByTagName('source')
- if source:
- network = source[0].getAttribute('bridge')
- if not network:
- network = source[0].getAttribute('network')
- network = network[len(netinfo.LIBVIRT_NET_PREFIX):]
-
- # Get nic address
- address = self._getUnderlyingDeviceAddress(x)
- for nic in self._devices[NIC_DEVICES]:
- if nic.macAddr.lower() == mac.lower():
- nic.name = name
- nic.alias = alias
- nic.address = address
- nic.linkActive = linkActive
- # Update vm's conf with address for known nic devices
- knownDev = False
- for dev in self.conf['devices']:
- if (dev['type'] == NIC_DEVICES and
- dev['macAddr'].lower() == mac.lower()):
- dev['address'] = address
- dev['alias'] = alias
- dev['name'] = name
- dev['linkActive'] = linkActive
- knownDev = True
- # Add unknown nic device to vm's conf
- if not knownDev:
- nicDev = {'type': NIC_DEVICES,
- 'device': devType,
- 'macAddr': mac,
- 'nicModel': model,
- 'address': address,
- 'alias': alias,
- 'name': name,
- 'linkActive': linkActive}
- if network:
- nicDev['network'] = network
- self.conf['devices'].append(nicDev)
def _setWriteWatermarks(self):
"""
--
To view, visit http://gerrit.ovirt.org/19732
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f797baece3601b885777784f611b420523828f7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: vdsm: export mininum kernel via caps
by Douglas Schilling Landgraf
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: vdsm: export mininum kernel via caps
......................................................................
vdsm: export mininum kernel via caps
Export to engine the minimum kernel required for vdsm.
Change-Id: I16c496e1a77639c39fae733e3a34c974b6f10b5c
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=966158
Signed-off-by: Douglas Schilling Landgraf <dougsland(a)redhat.com>
---
M .gitignore
M configure.ac
M vdsm.spec.in
M vdsm/Makefile.am
R vdsm/caps.py.in
5 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/19792/1
diff --git a/.gitignore b/.gitignore
index 295e1fb..290bf67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,6 +50,7 @@
vdsm.spec
vdsm/dsaversion.py
vdsm/dumpStorageTable.py
+vdsm/caps.py
vdsm/logger.conf
vdsm/mk_sysprep_floppy
vdsm/mom.conf
diff --git a/configure.ac b/configure.ac
index 93b6b96..694242d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,6 +119,10 @@
AC_SUBST([SNLKUSER], [sanlock])
AC_SUBST([SNLKGROUP], [sanlock])
+# Minimum Kernel
+AC_SUBST([KERNEL_MINIMUM_VERSION_EL6], [2.6.32-279.9.1])
+AC_SUBST([KERNEL_MINIMUM_UPSTREAM], [3.6])
+
# VDSM default paths
AC_SUBST([vdsmdir], ['${datarootdir}/vdsm'])
AC_SUBST([vdsmconfdir], ['${sysconfdir}/vdsm'])
diff --git a/vdsm.spec.in b/vdsm.spec.in
index e175ff8..942d417 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -150,7 +150,7 @@
Requires: device-mapper-multipath >= 0.4.9-52
Requires: e2fsprogs >= 1.41.12-11
Requires: fence-agents
-Requires: kernel >= 2.6.32-279.9.1
+Requires: kernel >= @KERNEL_MINIMUM_VERSION_EL6@
Requires: sanlock >= 2.3-4, sanlock-python
Requires: initscripts >= 9.03.31-2.el6_3.1
Requires: policycoreutils >= 2.0.83-19.30
@@ -179,7 +179,7 @@
Requires: iscsi-initiator-utils >= 6.2.0.872-14
Requires: device-mapper-multipath >= 0.4.9-18
Requires: e2fsprogs >= 1.41.14
-Requires: kernel >= 3.6
+Requires: kernel >= @KERNEL_MINIMUM_UPSTREAM@
Requires: sanlock >= 2.4-2, sanlock-python
Requires: policycoreutils-python
Requires: sed >= 4.2.1-10
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 305ef6b..f135f73 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -27,7 +27,6 @@
API.py \
BindingXMLRPC.py \
blkid.py \
- caps.py \
clientIF.py \
configNetwork.py \
debugPluginClient.py \
@@ -64,6 +63,7 @@
$(NULL)
nodist_vdsm_PYTHON = \
+ caps.py \
dsaversion.py \
dumpStorageTable.py
@@ -94,6 +94,7 @@
vdsmd.8
CLEANFILES = \
+ caps.py \
config.log \
$(nodist_vdsm_SCRIPTS) \
$(nodist_vdsmlib_PYTHON) \
@@ -103,6 +104,7 @@
$(nodist_man8_MANS)
EXTRA_DIST = \
+ caps.py.in \
dsaversion.py.in \
dumpStorageTable.py.in \
libvirt_password \
diff --git a/vdsm/caps.py b/vdsm/caps.py.in
similarity index 96%
rename from vdsm/caps.py
rename to vdsm/caps.py.in
index 3a7a6a2..fd6d528 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py.in
@@ -318,7 +318,16 @@
except:
logging.error('kernel build time not found', exc_info=True)
t = '0'
- return dict(version=ver, release=rel, buildtime=t)
+
+ # kernel minimum version
+ osname = getos()
+ if osname == OSName.RHEL:
+ kernel_min_version = '@KERNEL_MINIMUM_VERSION_EL6@'
+ else:
+ kernel_min_version = '@KERNEL_MINIMUM_UPSTREAM@'
+
+ return dict(version=ver, release=rel, buildtime=t,
+ kernel_minimum_version=kernel_min_version)
pkgs = {'kernel': kernelDict()}
--
To view, visit http://gerrit.ovirt.org/19792
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I16c496e1a77639c39fae733e3a34c974b6f10b5c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: lvm: refresh on mda permission mismatch
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: lvm: refresh on mda permission mismatch
......................................................................
lvm: refresh on mda permission mismatch
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=905665
Change-Id: I6a77b967a057329a90499d7707074befe756b68a
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/lvm.py
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/20121/1
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 0c2964e..3686570 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -1299,6 +1299,9 @@
changelv(vg, lv, ("--permission", permission))
except se.StorageException:
l = getLV(vg, lv)
+ if l.attr.permission == 'R':
+ refreshLV(vg, lv)
+ l = getLV(vg, lv)
if l.writeable == rw:
# Ignore the error since lv is now rw, hoping that the error was
# because lv was already rw, see BZ#654691. We may hide here
--
To view, visit http://gerrit.ovirt.org/20121
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a77b967a057329a90499d7707074befe756b68a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: hooks: macbind - This hook support binding specified mac add...
by hchiramm@redhat.com
humble devassy has uploaded a new change for review.
Change subject: hooks: macbind - This hook support binding specified mac address to custom/other bridge than the currently defined bridge in ovirt. This hook is also capable of binding a mac address to openvswitch bridge.
......................................................................
hooks: macbind - This hook support binding specified
mac address to custom/other bridge than the currently defined
bridge in ovirt. This hook is also capable of binding
a mac address to openvswitch bridge.
Change-Id: I0356dfab224a9082b44aae1c66df050f7456301c
Signed-off-by: Humble Chirammal <hchiramm(a)redhat.com>
---
A vdsm_hooks/macbind/Makefile.am
A vdsm_hooks/macbind/README
A vdsm_hooks/macbind/before_vm_start.py
3 files changed, 187 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/17895/1
diff --git a/vdsm_hooks/macbind/Makefile.am b/vdsm_hooks/macbind/Makefile.am
new file mode 100644
index 0000000..27dc5af
--- /dev/null
+++ b/vdsm_hooks/macbind/Makefile.am
@@ -0,0 +1,30 @@
+#
+# 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
+#
+
+EXTRA_DIST = \
+ before_vm_start.py
+
+install-data-local:
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ $(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_macbind
+
+uninstall-local:
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_macbind
diff --git a/vdsm_hooks/macbind/README b/vdsm_hooks/macbind/README
new file mode 100644
index 0000000..15bcfeb
--- /dev/null
+++ b/vdsm_hooks/macbind/README
@@ -0,0 +1,39 @@
+macbind vdsm hook:
+============
+This hook goes through all of the VM's interfaces and manipulate its
+XML file acccording to the input. This can be used to attach a VM nic
+to a specific bridge which is available in the hypervisor for 'that' VM run
+or permanently.
+
+
+One specific use case being attach a virtual network interface to an
+openvswitch bridge. Other being, attach vm nic to a different bridge
+than the defined/default bridge for that NIC.
+
+
+Syntax:
+ macbind=macaddress-brName-portType,...
+
+where:
+
+macaddress: specify a macaddress which need to be attached to the VM
+brName : Bridge Name available in hypervisor
+portType : This have to either 'ovs' or 'lb' or ''
+
+For ex:
+
+macbind= 00:1a:4a:41:d2:5f-ovsbr0-ovs,00:1a:4a:41:d2:b8-br88-lb
+
+Installation:
+* Use the engine-config to append the appropriate custom property as such:
+ sudo engine-config -s UserDefinedVMProperties=
+ 'previousProperties;macbind=^.*$' --cver=3.2
+
+* Verify that the macbind custom property was properly added:
+ sudo engine-config -g UserDefinedVMProperties
+
+Usage:
+In the VM configuration window, open the custom properites tab
+and add macbind=
+
+NOTE: Live migration is **not** tested.
diff --git a/vdsm_hooks/macbind/before_vm_start.py b/vdsm_hooks/macbind/before_vm_start.py
new file mode 100755
index 0000000..5606614
--- /dev/null
+++ b/vdsm_hooks/macbind/before_vm_start.py
@@ -0,0 +1,118 @@
+#!/usr/bin/python
+
+import os
+import sys
+import hooking
+import traceback
+
+'''
+
+macbind:
+
+syntax:
+macbind=macaddress-brName-portType,...
+refer README for more details.
+
+
+if 'ovs' as portType:
+
+<interface type='bridge'>
+ <mac address='00:1a:4a:41:d2:5f'/>
+ <source bridge='ovsbr0'/>
+ <model type='virtio'/>
+ <virtualport type='openvswitch'/>
+ <filterref filter='vdsm-no-mac-spoofing'/>
+ <link state='up'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+</interface>
+
+If 'lb' or '' as portType:
+The given bridge will be replaced with current bridge:
+
+<interface type='bridge'>
+ <mac address='00:1a:4a:41:d2:b8'/>
+ <source bridge='br0'/>
+ <model type='virtio'/>
+ <filterref filter='vdsm-no-mac-spoofing'/>
+ <link state='up'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+</interface>
+
+'''
+
+
+def createVportElement(domxml, porttype):
+ vPort = domxml.createElement('virtualport')
+ vPort.setAttribute('type', 'openvswitch')
+ return vPort
+
+
+def createSbridgeElement(domxml, brName):
+ sBridge = domxml.createElement('source')
+ sBridge.setAttribute('bridge', brName)
+ return sBridge
+
+
+def removeElement(interface, Element):
+ interface.removeChild(Element)
+
+
+if 'macbind' in os.environ:
+ try:
+
+ macbinds = os.environ['macbind']
+ domxml = hooking.read_domxml()
+ macAddr = ''
+ brName = ''
+ pType = ''
+
+ for nic in macbinds.split(','):
+ try:
+ macAddr, brName, pType = nic.split('-')
+ macAddr = macAddr.strip()
+ brName = brName.strip()
+ pType = pType.strip()
+
+ except ValueError:
+ sys.stderr.write('macbind: input error, expected '
+ 'macbind:macAddr:brName:pType,'
+ 'where brName is bridgename'
+ 'pType can be ovs|lb')
+ sys.exit(2)
+ if pType == "ovs":
+ command = ['/usr/bin/ovs-vsctl', 'br-exists %s' % (brName)]
+ retcode, out, err = hooking.execCmd(
+ command, sudo=False, raw=True)
+ if retcode != 0:
+ sys.stderr.write('macbind: Error in finding ovsbridge:'
+ '%s: %s, err = %s' %
+ (brName, ' '.join(command), err))
+ continue
+ if pType == "lb" or pType == '':
+ command = ['/usr/sbin/brctl', 'show', brName]
+ retcode, out, err = hooking.execCmd(
+ command, sudo=False, raw=True)
+
+ if err or retcode != 0:
+ sys.stderr.write('macbind: Error in finding Linuxbridge:'
+ ' %s \n: %s, err = %s\n' %
+ (brName, ' '.join(command), err))
+ continue
+
+ for interface in domxml.getElementsByTagName('interface'):
+ for macaddress in interface.getElementsByTagName('mac'):
+ addr = macaddress.getAttribute('address')
+ if addr == macAddr:
+ for bridge in interface.getElementsByTagName('source'):
+ interface.removeChild(bridge)
+ interface.appendChild(
+ createSbridgeElement(domxml, brName))
+ if pType == "ovs":
+ interface.appendChild(
+ createVportElement(domxml, 'openvswitch'))
+
+ hooking.write_domxml(domxml)
+ except:
+ sys.stderr.write('macbind: [unexpected error]: %s\n' %
+ traceback.format_exc())
+ sys.exit(2)
--
To view, visit http://gerrit.ovirt.org/17895
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0356dfab224a9082b44aae1c66df050f7456301c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: humble devassy <hchiramm(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: Adding remove\disable verbs to vdsm-tool for admin usages
by ybronhei@redhat.com
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Adding remove\disable verbs to vdsm-tool for admin usages
......................................................................
Adding remove\disable verbs to vdsm-tool for admin usages
The spec will be modified separately to use vdsm-tool instead of hard-coded
operations
Change-Id: Ie7f2c031436a6d202f856c24d9c9420c8bfdf6df
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M lib/vdsm/constants.py.in
M lib/vdsm/tool/configurator.py
M lib/vdsm/tool/passwd.py
M lib/vdsm/tool/seboolsetup.py
4 files changed, 118 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/21772/1
diff --git a/lib/vdsm/constants.py.in b/lib/vdsm/constants.py.in
index 790a3a0..43e13da 100644
--- a/lib/vdsm/constants.py.in
+++ b/lib/vdsm/constants.py.in
@@ -80,6 +80,15 @@
P_VDSM_EXEC = '@LIBEXECDIR@'
#
+# Configuration file definitions
+#
+SYSCONF_PATH = '@sysconfdir@'
+P_SYSTEMCTL_CONF = SYSCONF_PATH + '/sysctl.d/vdsm'
+P_VDSM_LCONF = SYSCONF_PATH + '/libvirt/libvirtd.conf'
+P_VDSM_LDCONF = SYSCONF_PATH + '/sysconfig/libvirtd'
+P_VDSM_QCONF = SYSCONF_PATH + '/libvirt/qemu.conf'
+
+#
# External programs (sorted, please keep in order).
#
EXT_BLKID = '@BLKID_PATH@'
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index 51eda80..a30827a 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -21,11 +21,13 @@
import sys
import grp
import argparse
+import tempfile
+import shutil
from .. import utils
from . import service, expose
-from ..constants import P_VDSM_EXEC, DISKIMAGE_GROUP
-from ..constants import QEMU_PROCESS_GROUP, VDSM_GROUP
+from ..constants import P_VDSM_EXEC, DISKIMAGE_GROUP, QEMU_PROCESS_GROUP, \
+ VDSM_GROUP, P_VDSM_LCONF, P_VDSM_QCONF, P_VDSM_LDCONF, P_SYSTEMCTL_CONF
class _ModuleConfigure(object):
@@ -47,6 +49,35 @@
def isconfigured(self):
return True
+ def removeConf(self, filename, beginField=None, endField=None):
+ newfile = []
+ if not beginField and not endField:
+ return
+ else:
+ with open(filename, 'r') as f:
+ skip = False
+ for line in f.readlines():
+ if beginField and endField:
+ if skip:
+ if line.startswith(endField):
+ skip = False
+ continue
+ if line.startswith(beginField):
+ skip = True
+ continue
+ elif beginField:
+ if line.startswith(beginField):
+ continue
+ else:
+ if line.endswith('%s\n' % endField):
+ continue
+ newfile.append(line)
+ tmp_file = tempfile.NamedTemporaryFile(delete=False)
+ tname = tmp_file.name
+ tmp_file.writelines(newfile)
+ tmp_file.close()
+ shutil.move(tname, filename)
+
class LibvirtModuleConfigure(_ModuleConfigure):
def __init__(self):
@@ -57,6 +88,28 @@
def getServices(self):
return ["supervdsmd", "vdsmd", "libvirtd"]
+
+ def removeConf(self):
+ vdsm_ver = '-4.9.10'
+ conf_prefix = '## beginning of configuration section by vdsm' + \
+ vdsm_ver
+ conf_suffix = '## end of configuration section by vdsm' + vdsm_ver
+
+ conf_paths = [
+ P_VDSM_LCONF,
+ P_VDSM_QCONF,
+ P_VDSM_LDCONF,
+ ]
+ for path in conf_paths:
+ try:
+ super(LibvirtModuleConfigure, self).removeConf(path,
+ conf_prefix,
+ conf_suffix)
+ except OSError, e:
+ if e.errno != os.errno.EEXIST:
+ raise
+
+ utils.rmFile(P_SYSTEMCTL_CONF)
def _exec_libvirt_configure(self, action):
"""
@@ -113,6 +166,9 @@
def getServices(self):
return ['sanlock']
+
+ def removeConf(self):
+ pass
def configure(self):
"""
@@ -257,6 +313,25 @@
raise RuntimeError("Config is not valid. Check conf files")
+@expose("remove-config")
+def remove_config(*args):
+ """
+ Remove vdsm configuration from conf files
+ """
+ args = _parse_args('remove-config')
+ m = [
+ c.getName() for c in __configurers
+ if c.getName() in args.modules and not c.removeConf()
+ ]
+ if m:
+ sys.stdout.write(
+ "Could not remove configuration for modules %s\n" % ','.join(m),
+ )
+ ret = False
+ if not ret:
+ raise RuntimeError("Remove configuration failed")
+
+
def _parse_args(action):
parser = argparse.ArgumentParser('vdsm-tool %s' % (action))
allModules = [n.getName() for n in __configurers]
diff --git a/lib/vdsm/tool/passwd.py b/lib/vdsm/tool/passwd.py
index 0b127c8..4e40948 100644
--- a/lib/vdsm/tool/passwd.py
+++ b/lib/vdsm/tool/passwd.py
@@ -43,4 +43,17 @@
stderr=subprocess.PIPE, close_fds=True)
output, err = p.communicate()
if p.returncode != 0:
- raise Exception("Set password failed: %s" % (err, ))
+ raise RuntimeError("Set password failed: %s" % (err, ))
+
+
+@expose("remove-saslpasswd")
+def remove_saslpasswd():
+ """
+ Remove vdsm password for libvirt connection
+ """
+ script = ['/usr/sbin/saslpasswd2', '-p', '-a', 'libvirt', '-d',
+ constants.SASL_USERNAME]
+ p = subprocess.Popen(script)
+ output, err = p.communicate()
+ if p.returncode != 0:
+ raise RuntimeError("Remove password failed: %s" % (err, ))
diff --git a/lib/vdsm/tool/seboolsetup.py b/lib/vdsm/tool/seboolsetup.py
index f664ecd..7c1effa 100644
--- a/lib/vdsm/tool/seboolsetup.py
+++ b/lib/vdsm/tool/seboolsetup.py
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
+import selinux
from . import expose
SEBOOL_ENABLED = "on"
@@ -63,3 +64,20 @@
def sebool_unconfig():
"""Disable the required selinux booleans"""
setup_booleans(False)
+
+
+@expose("clear-selinux-policy")
+def clear_selinux_policy():
+ """
+ Clear the changes of selinux policy
+ """
+ selinux_policys = [
+ 'virt_use_nfs',
+ 'virt_use_sanlock',
+ 'sanlock_use_nfs',
+ ]
+
+ if selinux.is_selinux_enabled():
+ for policy in selinux_policys:
+ selinux.security_set_boolean(policy, 0)
+ selinux.security_commit_booleans()
--
To view, visit http://gerrit.ovirt.org/21772
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie7f2c031436a6d202f856c24d9c9420c8bfdf6df
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: Initial commit of the tool for starting VM without the manag...
by Pablo Iranzo Gómez
Pablo Iranzo Gómez has uploaded a new change for review.
Change subject: Initial commit of the tool for starting VM without the manager being available
......................................................................
Initial commit of the tool for starting VM without the manager being available
Change-Id: I9a70b31ce0730194880406701316f219c9f92ceb
Signed-off-by: Pablo <Pablo.Iranzo(a)gmail.com>
---
A contrib/forceVMstart/vdsEmergency-1.0.0.py
1 file changed, 490 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/9473/1
diff --git a/contrib/forceVMstart/vdsEmergency-1.0.0.py b/contrib/forceVMstart/vdsEmergency-1.0.0.py
new file mode 100644
index 0000000..41fe068
--- /dev/null
+++ b/contrib/forceVMstart/vdsEmergency-1.0.0.py
@@ -0,0 +1,490 @@
+#!/usr/bin/env python
+#
+# Copyright 2010 Red Hat, Inc.
+#
+# Licensed to you under 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.
+#
+# Require Packages: python-iniparse
+
+import getopt
+import sys
+import commands
+import os
+import socket
+from xml.dom.minidom import parse, parseString
+
+try:
+ from iniparse import ConfigParser
+except:
+ print "Package python-iniparse is required, please install"
+ print "#yum install python-iniparse -y"
+ sys.exit(1)
+
+
+# Adding vdsm .pyc libraries to python path
+sys.path.append("/usr/share/vdsm")
+
+try:
+ import vdscli
+except:
+ print "Cannot import vdscli, please contact Red Hat support"
+ sys.exit(1)
+
+try:
+ import vdsClient
+except:
+ print "Cannot import vdsClient, please contact Red Hat support"
+ sys.exit(1)
+
+# General Macros
+VERSION = "1.0.0"
+VDSM_PORT = "54321"
+
+#DEBUG MODE
+DEBUG = "False" # True or False
+
+#########################################################################
+
+class vdsmEmergency:
+
+ ##########################################################################
+ # __init__() #
+ # Description: Initialize method #
+ ##########################################################################
+ def __init__(self):
+ sslRet = self.checkSSLvdsm()
+ self.useSSL = sslRet
+ self.truststore = None
+
+ ##########################################################################
+ # do_connect() #
+ # Description: Do a connection with vdsm daemon #
+ ##########################################################################
+ def do_connect(self, server, port):
+ print "Trying to connect to vdsmd host (%s).." % server
+
+ # Connection Validation
+ sk = socket.socket()
+ try:
+ sk.connect((server, int(VDSM_PORT)))
+ except Exception, e:
+ print "Unable to connect %s" % server
+ sk.close()
+ return -1
+
+ self.s = vdscli.connect(server + ':' + port, self.useSSL, self.truststore)
+
+ print "OK, Connected to vdsmd!"
+ return 0
+
+ ##########################################################################
+ # checkRoot() #
+ # Description: check if the user running the script is root #
+ ##########################################################################
+ def checkRoot(self):
+ if os.geteuid() != 0:
+ print "You must be root to run this script."
+ sys.exit(2)
+
+ ##########################################################################
+ # getIpRHEVM() #
+ # Description: get the IP from RHEVM Interface #
+ ##########################################################################
+ def getIpRHEVM(self):
+
+ # TODO: avoid this kind of hack, find a better approach (vdsClient provide the IP of rhevm interface?)
+ strCmd = "ifconfig rhevm | grep \"inet addr\" | cut -d \':\' -f 2 | cut -d \' \' -f 1"
+ retCmd = commands.getstatusoutput(strCmd)
+ if retCmd[0] != 0:
+ print "Error getting IP from rhevm interface"
+ sys.exit(1)
+
+ return retCmd[1]
+ ##########################################################################
+ # checkSSLvdsm() #
+ # Description: check if vdsm is running as SSL or without it #
+ ##########################################################################
+ def checkSSLvdsm(self):
+
+ cfg = ConfigParser()
+ cfg.read('/etc/vdsm/vdsm.conf')
+ cfg.get('vars', 'ssl')
+
+ return cfg.data.vars.ssl
+
+
+ ##########################################################################
+ # checkVmRunning() #
+ # Description: check if the vms are running #
+ ##########################################################################
+ def checkVmRunning(self, otherHostsList, VmsToStart):
+
+ hosts = None
+ vms = None
+ i = 0
+ j = 0
+
+ if otherHostsList == None:
+ return -1
+
+ if VmsToStart == None:
+ return -1
+
+ vms = VmsToStart.split(",")
+ hosts = otherHostsList.split(",")
+
+ # Let's check if all other Hosts are running the VirtualMachine
+ while (i <> len(hosts)):
+ ret = VE.do_connect(hosts[i], VDSM_PORT)
+ if ret < 0:
+ sys.exit(1)
+ response = self.s.list()
+ if response['status']['code'] != 0:
+ print "cannot execute list operation, err:" + response['status']['message']
+
+ # Checking VM status
+ for s in self.s.getAllVmStats()['statsList']:
+ j = 0
+
+ # print all vms in each host
+ while j < len(vms):
+ if DEBUG == "True":
+ print len(vms)
+ print s['vmId']
+ print hosts[i]
+ print vms[j]
+
+ vmIdCurr = self.getVmId(vms[j])
+
+ if DEBUG == "True":
+ print vmIdCurr
+ print s['vmId']
+
+ if s['vmId'] == vmIdCurr and s['status'] == "Up":
+ print "Cannot continue, the VM %s is running in host %s" % (vms[j], hosts[i])
+ sys.exit(1)
+ j = j + 1
+
+ # counter for hosts
+ i = i + 1
+
+ print "OK, the vm(s) specified are not running on the host(s) informed, continuing.."
+
+ ##########################################################################
+ # checkSPM() #
+ # Description: check if the host which is running this script is the SPM #
+ ##########################################################################
+ def checkSPM(self):
+ self.spUUID = None
+ self.spmStatus = None
+
+ ip_rhevm_interface = self.getIpRHEVM()
+ self.do_connect(ip_rhevm_interface, VDSM_PORT)
+
+ try:
+ list = self.s.getConnectedStoragePoolsList()
+ except:
+ print "Cannot execute getConnectedStoragePoolsList()"
+ sys.exit(1)
+
+ for entry in list['poollist']:
+ self.spUUID = entry
+
+ if not self.spUUID:
+ print "Cannot locate Storage Pools List.. aborting!"
+ sys.exit(1)
+
+ try:
+ status = self.s.getSpmStatus(self.spUUID)
+ except:
+ print "Cannot execute getSpmStatus()"
+ sys.exit(1)
+
+ self.spmStatus = status['spm_st']['spmStatus']
+
+ if self.spmStatus <> "SPM":
+ print "This host is not the current SPM, status [%s]" % self.spmStatus
+ sys.exit(1)
+
+
+ ######################################################################
+ # getVmId() #
+ # Description: get the vmId from the vmName used as argument #
+ ######################################################################
+ def getVmId(self, vmName):
+ path = "/rhev/data-center/%s/vms" % (self.spUUID)
+
+ # First verify which domainID contain de XML files
+ try:
+ dirList = os.listdir(path)
+ except:
+ print "Cannot locate the dir with ovf files.. aborting!"
+ sys.exit(1)
+
+ #Read all content of xml(s) file(s)
+ for fname in dirList:
+
+ pathOVF = path + "/" + fname + "/" + fname + ".ovf"
+
+ dom = parse(pathOVF)
+
+ # Getting vmId field
+ i = 0
+ attr = 0
+ for node in dom.getElementsByTagName('Section'):
+ while ( i < len(node.attributes)):
+ attr = node.attributes.items()
+ if attr[i][0] == "ovf:id":
+ vmId = attr[i][1]
+ i = i + 1
+
+ # Getting vmName field
+ for node in dom.getElementsByTagName('Content'):
+ if node.childNodes[0].firstChild <> None:
+ if node.childNodes[0].firstChild.nodeValue == vmName:
+ return vmId
+
+
+
+ def _parseDriveSpec(self, spec):
+ if ',' in spec:
+ d = {}
+ for s in spec.split(','):
+ k, v = s.split(':', 1)
+ if k == 'domain': d['domainID'] = v
+ if k == 'pool': d['poolID'] = v
+ if k == 'image': d['imageID'] = v
+ if k == 'volume': d['volumeID'] = v
+ if k == 'boot': d['boot'] = v
+ if k == 'format': d['format'] = v
+ return d
+ return spec
+
+ ######################################################################
+ # readXML() #
+ # Description: read all xml available pointed to Direcory path and #
+ # parse for specific fields #
+ ######################################################################
+ def readXML(self, VmsStotart, destHostStart):
+
+ # number of Vms found
+ nrmVms = 0
+ cmd = {}
+ # Path to XML files
+ # example default path:
+ # /rhev/data-center/1a516f64-f091-4785-9278-362037513408/vms
+ path = "/rhev/data-center/%s/vms" % (self.spUUID)
+
+ # First verify which domainID contain de XML files
+ try:
+ dirList = os.listdir(path)
+ except:
+ print "Cannot locate the dir with ovf files.. aborting!"
+ sys.exit(1)
+
+ #Read all content of xml(s) file(s)
+ for fname in dirList:
+
+ pathOVF = path + "/" + fname + "/" + fname + ".ovf"
+ cmd['display']="vnc"
+ cmd['kvmEnable']="True"
+ cmd['tabletEnable']="True"
+ cmd['vmEnable']="True"
+ cmd['irqChip']="True"
+ cmd['nice']=0
+ cmd['keyboardLayout']="en-us"
+ cmd['acpiEnable']="True"
+ cmd['tdf']="True"
+
+ dom = parse(pathOVF)
+
+ # Getting vmId field
+ i = 0
+ attr = 0
+ for node in dom.getElementsByTagName('Section'):
+ while ( i < len(node.attributes)):
+ attr = node.attributes.items()
+ if attr[i][0] == "ovf:id":
+ cmd["vmId"] = attr[i][1]
+ i = i + 1
+
+ # Getting vmName field
+ for node in dom.getElementsByTagName('Content'):
+ if node.childNodes[0].firstChild <> None:
+ self.vmName = node.childNodes[0].firstChild.nodeValue
+ cmd['vmName'] = self.vmName
+
+ # Getting image and volume
+ i = 0
+ attr = 0
+ for node in dom.getElementsByTagName('Disk'):
+ while (i <> len(node.attributes)):
+ attr = node.attributes.items()
+ if attr[i][0] == "ovf:fileRef":
+ storage = attr[i][1]
+ data = storage.split("/")
+ image = data[0]
+ volume = data[1]
+ i += 1
+
+ # Getting VM format, boot
+ i = 0
+ attr =0
+ for node in dom.getElementsByTagName('Disk'):
+ while (i <> len(node.attributes)):
+ attr = node.attributes.items()
+ if attr[i][0] == "ovf:volume-format":
+ format = attr[i][1]
+
+ if attr[i][0] == "ovf:boot":
+ vmBoot = attr[i][1]
+
+ if attr[i][0] == "ovf:disk-interface":
+ ifFormat = attr[i][1]
+
+ i += 1
+
+ if format == "COW":
+ vmFormat = ":cow"
+ elif format == "RAW":
+ vmFormat = ":raw"
+
+
+ if ifFormat == "VirtIO":
+ ifDisk = "virtio"
+ elif ifFormat == "IDE":
+ ifDisk = "ide"
+ drives = []
+ # Getting Drive, bridge, memSize, macAddr, smp, smpCoresPerSocket
+ for node in dom.getElementsByTagName('Item'):
+ # Getting Drive
+ if node.childNodes[0].firstChild <> None:
+ str = node.childNodes[0].firstChild.nodeValue
+ if str.find("Drive") > -1:
+
+ tmp = "pool:" + self.spUUID + ",domain:" + node.childNodes[7].firstChild.nodeValue + ",image:" + image + ",volume:" + volume + ",boot:" + vmBoot + ",format" + vmFormat + ",if:" + ifDisk
+ #param,value = tmp.split("=",1)
+ drives += [self._parseDriveSpec(tmp)]
+ cmd['drives'] = drives
+
+ # Getting bridge
+ nicMod = None
+ if node.childNodes[0].firstChild.nodeValue == "Ethernet adapter on rhevm":
+ if node.childNodes[3].firstChild.nodeValue == "3":
+ nicMod = "pv" #VirtIO
+ elif node.childNodes[3].firstChild.nodeValue == "2":
+ nicMod = "e1000" #e1000
+ elif node.childNodes[3].firstChild.nodeValue == "1":
+ nicMod = "rtl8139" #rtl8139
+
+ cmd['nicModel'] = nicMod
+ cmd['bridge'] = node.childNodes[4].firstChild.nodeValue
+
+ # Getting memSize field
+ str = node.childNodes[0].firstChild.nodeValue
+ if str.find("MB of memory") > -1:
+ cmd['memSize'] = node.childNodes[5].firstChild.nodeValue
+
+ # Getting smp and smpCoresPerSocket fields
+ str = node.childNodes[0].firstChild.nodeValue
+ if str.find("virtual cpu") > -1:
+ cmd["smp="] = node.childNodes[4].firstChild.nodeValue
+ cmd["smpCoresPerSocket"] = node.childNodes[5].firstChild.nodeValue
+
+ # Getting macAddr field
+ if node.childNodes[0].firstChild.nodeValue == "Ethernet adapter on rhevm":
+ if len(node.childNodes) > 6:
+ cmd['macAddr'] = node.childNodes[6].firstChild.nodeValue
+
+ # if node.childNodes < 6 it`s a template entry, so ignore
+ if len(node.childNodes) > 6:
+ # print only vms to start
+ try:
+ checkvms = VmsToStart.split(",")
+ except:
+ print "Please use , between vms name, avoid space"
+ self.usage()
+
+ i = 0
+ while (i <> len(checkvms)):
+ if self.vmName == checkvms[i]:
+ nrmVms = nrmVms + 1
+ self.startVM(cmd, destHostStart)
+ i += 1
+
+ print "Total VMs found: %s" % nrmVms
+
+ ######################################################################
+ # startVM() #
+ # Description: start the VM #
+ ######################################################################
+ def startVM(self, cmd, destHostStart):
+
+ self.do_connect(destHostStart, VDSM_PORT)
+ #print cmd
+ #cmd1 = dict(cmd)
+ #print cmd1
+ ret = self.s.create(cmd)
+ #print ret
+ print "Triggered VM [%s]" % self.vmName
+
+ ######################################################################
+ # usage() #
+ # Description: shows the program params #
+ ######################################################################
+ def usage(self):
+ print "Usage: " + sys.argv[0] + " [OPTIONS]"
+ print "\t--destHost \t RHEV-H host which will start the VM"
+ print "\t--otherHostsList\t All RHEV-H hosts"
+ print "\t--vms \t Specify the Names of which VMs to start"
+ print "\t--version \t List version release"
+ print "\t--help \t This help menu\n"
+
+ print "Example:"
+ print "\t" + sys.argv[0] + " --destHost LinuxSrv1 --otherHostsList Megatron,Jerry --vms vm1,vm2,vm3,vm4"
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+
+ otherHostsList = ''
+ VmsToStart = None
+ destHostStart = None
+
+ VE = vdsmEmergency()
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "Vd:ho:v:", ["destHost=", "otherHostsList=", "vms=", "help", "version"])
+ except getopt.GetoptError, err:
+ # print help information and exit:
+ print(err) # will print something like "option -a not recognized"
+ VE.usage()
+ sys.exit(2)
+ for o, a in opts:
+ if o in ("-d", "--destHost"):
+ destHostStart = a
+ print ""
+ elif o in ("-h", "--help"):
+ VE.usage()
+ sys.exit()
+ elif o in ("-o", "--otherHostsList"):
+ otherHostsList = a
+ elif o in ("-v", "--vms"):
+ VmsToStart = a
+ elif o in ("-V", "--version"):
+ print VERSION
+ else:
+ assert False, "unhandled option"
+
+ argc = len(sys.argv)
+ if argc < 2:
+ VE.usage()
+
+ VE.checkSPM()
+
+ # Include the destHost to verify
+ otherHostsList += ",%s" % destHostStart
+ VE.checkVmRunning(otherHostsList, VmsToStart)
+
+ VE.readXML(VmsToStart, destHostStart)
--
To view, visit http://gerrit.ovirt.org/9473
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a70b31ce0730194880406701316f219c9f92ceb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Pablo Iranzo Gómez <Pablo.Iranzo(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: (Schema) Change ConnectionRef actions to work on a single co...
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: (Schema) Change ConnectionRef actions to work on a single connection
......................................................................
(Schema) Change ConnectionRef actions to work on a single connection
This was the original intention of the API. The reason we started
supporting multiple connections in a single call is because of the
overhead inherent in XML-RPC. The new API can multiplex calls and has
practically no overhead per call.
Also, refID is not an UUID
Change-Id: I5747f2161d039cfaa82c0797e63ff58dbffbe8ac
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm_api/vdsmapi-schema.json
1 file changed, 21 insertions(+), 44 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/7148/1
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index e782613..b103b28 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -2250,16 +2250,16 @@
{'command': {'class': 'Global', 'name': 'setSafeNetworkConfig'}}
-## Category: @ConnectionRefs ##################################################
+## Category: @ConnectionRef ##################################################
##
-# @ConnectionRefs.init:
+# @ConnectionRef.init:
#
-# Initialize a ConnectionRefs API object.
+# Initialize a ConnectionRef API object.
#
# Since: 4.10.0
# XXX: Extension: object constructors
##
-{'init': 'ConnectionRefs'}
+{'init': 'ConnectionRef'}
##
# @IscsiPortal:
@@ -2444,60 +2444,37 @@
'connectionInfo': 'ConnectionRefParameters'}}
##
-# @ConnectionRefArgsMap:
-#
-# A mapping of connection arguments indexed by ConnectionRef UUID.
-#
-# Since: 4.10.0
-##
-{'map': 'ConnectionRefArgsMap',
- 'key': 'UUID', 'value': 'ConnectionRefArgs'}
-
-##
-# @ConnectionRefArgsStatusMap:
-#
-# A mapping of status codes indexed by ConnectionRef UUID.
-#
-# Since: 4.10.0
-##
-{'map': 'ConnectionRefArgsStatusMap',
- 'key': 'UUID', 'value': 'int'}
-
-##
-# @ConnectionRefs.acquire:
+# @ConnectionRef.acquire:
#
# Acquire one or more new storage connection references.
#
-# @conRefArgs: Connection parameters
+# @refID: The identifier to be assigned to the new connection reference.
+# Users are encouraged to mangle they information into the string
+# to prevent collisions and declare ownership.
+# eg.
+# ENGINE_CONNECTION_3213
#
-# Returns:
-# @results: A dictionary of status codes indexed by the same @UUID values in
-# @conRefArgs.
+# This way managers can tell which connections are owned by whome.
+# @conRefArgs: Connection parameters.
#
# Since: 4.10.0
# XXX: Extension: map data type ['key type', 'val type']
##
-{'command': {'class': 'ConnectionRefs', 'name': 'acquire'},
- 'data': {'conRefArgs': 'ConnectionRefArgsMap'},
- 'returns': {'results': 'ConnectionRefArgsStatusMap'}}
+{'command': {'class': 'ConnectionRef', 'name': 'acquire'},
+ 'data': {'refID', 'str', 'conRefArgs': 'ConnectionRefArgs'}}
##
-# @ConnectionRefs.release:
+# @ConnectionRef.release:
#
# Release one or more storage connection references.
#
-# @refIDs: A list of @UUID values
-#
-# Returns:
-# @results: A dictionary of status codes indexed by the same @UUID values that
-# were passed in @0.
+# @refIDs: A list of string values.
#
# Since: 4.10.0
# XXX: Extension: list data type
##
-{'command': {'class': 'ConnectionRefs', 'name': 'release'},
- 'data': {'refIDs': ['UUID']},
- 'returns': {'results': 'ConnectionRefArgsStatusMap'}}
+{'command': {'class': 'ConnectionRef', 'name': 'release'},
+ 'data': {'refID': 'str'}}
##
# @ConnectionRefMap:
@@ -2507,10 +2484,10 @@
# Since: 4.10.0
##
{'map': 'ConnectionRefMap',
- 'key': 'UUID', 'value': 'ConnectionRef'}
+ 'key': 'str', 'value': 'ConnectionRef'}
##
-# @ConnectionRefs.statuses:
+# @ConnectionRef.statuses:
#
# Get information about all registered storage connection references.
#
@@ -2519,7 +2496,7 @@
#
# Since: 4.10.0
##
-{'command': {'class': 'ConnectionRefs', 'name': 'statuses'},
+{'command': {'class': 'ConnectionRef', 'name': 'statuses'},
'returns': {'connectionslist': 'ConnectionRefMap'}}
## Category: @ISCSIConnection ##################################################
--
To view, visit http://gerrit.ovirt.org/7148
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5747f2161d039cfaa82c0797e63ff58dbffbe8ac
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: Logging shouldn't reach the terminal console
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: Logging shouldn't reach the terminal console
......................................................................
Logging shouldn't reach the terminal console
In this patch:
* Change the log facility to LOG_DAEMON for SysLogHandler
* Remove the handler_console (it's unused now but we don't want anyone
to start using it)
* Few format cleanups
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
Change-Id: I749a58362db5daec44ed5b0f7f116e14eadd6043
---
M vdsm/logger.conf.in
1 file changed, 6 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/7980/1
diff --git a/vdsm/logger.conf.in b/vdsm/logger.conf.in
index edd4616..f523306 100644
--- a/vdsm/logger.conf.in
+++ b/vdsm/logger.conf.in
@@ -2,7 +2,7 @@
keys=root,vds,Storage,metadata,SuperVdsm
[handlers]
-keys=console,syslog,logfile,metadata
+keys=syslog,logfile,metadata
[formatters]
keys=long,simple,none,sysform
@@ -40,7 +40,7 @@
level=WARNING
class=handlers.SysLogHandler
formatter=sysform
-args=('/dev/log', handlers.SysLogHandler.LOG_USER)
+args=('/dev/log', handlers.SysLogHandler.LOG_DAEMON)
[handler_logfile]
class=logging.handlers.WatchedFileHandler
@@ -55,25 +55,14 @@
level=WARNING
formatter=long
-[handler_console]
-class: StreamHandler
-args: []
-formatter: none
-
[formatter_simple]
-format: %(name)s:%(levelname)s: %(message)s
+format=%(name)s:%(levelname)s: %(message)s
[formatter_none]
-format: %(message)s
+format=%(message)s
[formatter_long]
-format: %(threadName)s::%(levelname)s::%(asctime)s::%(module)s::%(lineno)d::%(name)s::(%(funcName)s) %(message)s
+format=%(threadName)s::%(levelname)s::%(asctime)s::%(module)s::%(lineno)d::%(name)s::(%(funcName)s) %(message)s
[formatter_sysform]
-format= vdsm %(name)s %(levelname)s %(message)s
-datefmt=
-
-
-
-
-
+format=vdsm %(name)s %(levelname)s %(message)s
--
To view, visit http://gerrit.ovirt.org/7980
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I749a58362db5daec44ed5b0f7f116e14eadd6043
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 4 months