Change in vdsm[master]: [WIP] vm: cleanup of vm.py - removed old api references
mpoledni at redhat.com
mpoledni at redhat.com
Tue Aug 13 20:03:11 UTC 2013
Martin Polednik has uploaded a new change for review.
Change subject: [WIP] vm: cleanup of vm.py - removed old api references
......................................................................
[WIP] vm: cleanup of vm.py
- removed old api references
Change-Id: I2712148b670c9f85beaea40a0b2e870d829b2b4b
Signed-off-by: mpolednik <mpoledni at redhat.com>
---
M vdsm/vm.py
1 file changed, 2 insertions(+), 171 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/18047/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index a0b7310..e16a316 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1811,172 +1811,6 @@
dev['target'] = int(self.conf.get('memSize')) * 1024
return devices
- def buildConfDevices(self):
- """
- Return the "devices" section of this Vm's conf.
- If missing, create it according to old API.
- """
- # For BC we need to save previous behaviour for old type parameters.
- # The new/old type parameter will be distinguished
- # by existence/absence of the 'devices' key
- devices = {}
- # Build devices structure
- if self.conf.get('devices') is None:
- with self._confLock:
- self.conf['devices'] = []
- devices[DISK_DEVICES] = self.getConfDrives()
- devices[NIC_DEVICES] = self.getConfNetworkInterfaces()
- devices[SOUND_DEVICES] = self.getConfSound()
- devices[VIDEO_DEVICES] = self.getConfVideo()
- devices[CONTROLLER_DEVICES] = self.getConfController()
- devices[GENERAL_DEVICES] = []
- devices[BALLOON_DEVICES] = []
- devices[WATCHDOG_DEVICES] = []
- devices[SMARTCARD_DEVICES] = self.getConfSmartcard()
- devices[REDIR_DEVICES] = []
- devices[CONSOLE_DEVICES] = []
- else:
- devices = self.getConfDevices()
-
- # libvirt only support one watchdog device
- if len(devices[WATCHDOG_DEVICES]) > 1:
- raise ValueError("only a single watchdog device is supported")
- if len(devices[WATCHDOG_DEVICES]) == 1:
- if not 'specParams' in devices[WATCHDOG_DEVICES][0]:
- devices[WATCHDOG_DEVICES][0]['specParams'] = {}
- if not 'model' in devices[WATCHDOG_DEVICES][0]['specParams']:
- devices[WATCHDOG_DEVICES][0]['specParams']['model'] = \
- 'i6300esb'
- if not 'action' in devices[WATCHDOG_DEVICES][0]['specParams']:
- devices[WATCHDOG_DEVICES][0]['specParams']['action'] = 'none'
-
- if len(devices[CONSOLE_DEVICES]) > 1:
- raise ValueError("Only a single console device is supported")
-
- # Normalize vdsm images
- for drv in devices[DISK_DEVICES]:
- if isVdsmImage(drv):
- self._normalizeVdsmImg(drv)
-
- # Preserve old behavior. Since libvirt add a memory balloon device
- # to all guests, we need to specifically request not to add it.
- if len(devices[BALLOON_DEVICES]) == 0:
- devices[BALLOON_DEVICES].append({
- 'type': BALLOON_DEVICES,
- 'device': 'memballoon',
- 'specParams': {
- 'model': 'none'}})
-
- return devices
-
- def getConfController(self):
- """
- Normalize controller device.
- """
- controllers = []
- # For now we create by default only 'virtio-serial' controller
- controllers.append({'type': CONTROLLER_DEVICES,
- 'device': 'virtio-serial'})
- return controllers
-
- def getConfVideo(self):
- """
- Normalize video device provided by conf.
- """
- vcards = []
- if self.conf.get('display') == 'vnc':
- devType = 'cirrus'
- elif self.conf.get('display') == 'qxl':
- devType = 'qxl'
-
- monitors = int(self.conf.get('spiceMonitors', '1'))
- vram = '65536' if (monitors <= 2) else '32768'
- for idx in range(monitors):
- vcards.append({'type': VIDEO_DEVICES, 'specParams': {'vram': vram},
- 'device': devType})
-
- return vcards
-
- def getConfSmartcard(self):
- """
- Normalize smartcard device (now there is only one)
- """
- cards = []
- if self.conf.get('smartcard'):
- cards.append({'device': SMARTCARD_DEVICES,
- 'specParams': {'mode': 'passthrough',
- 'type': 'spicevmc'}})
- return cards
-
- def getConfSound(self):
- """
- Normalize sound device provided by conf.
- """
- scards = []
- if self.conf.get('soundDevice'):
- scards.append({'type': SOUND_DEVICES,
- 'device': self.conf.get('soundDevice')})
-
- return scards
-
- def getConfNetworkInterfaces(self):
- """
- Normalize networks interfaces provided by conf.
- """
- nics = []
- macs = self.conf.get('macAddr', '').split(',')
- models = self.conf.get('nicModel', '').split(',')
- bridges = self.conf.get('bridge', DEFAULT_BRIDGE).split(',')
- if macs == ['']:
- macs = []
- if models == ['']:
- models = []
- if bridges == ['']:
- bridges = []
- if len(models) < len(macs) or len(models) < len(bridges):
- raise ValueError('Bad nic specification')
- if models and not (macs or bridges):
- raise ValueError('Bad nic specification')
- if not macs or not models or not bridges:
- return ''
- macs = macs + [macs[-1]] * (len(models) - len(macs))
- bridges = bridges + [bridges[-1]] * (len(models) - len(bridges))
-
- for mac, model, bridge in zip(macs, models, bridges):
- if model == 'pv':
- model = 'virtio'
- nics.append({'type': NIC_DEVICES, 'macAddr': mac,
- 'nicModel': model, 'network': bridge,
- 'device': 'bridge'})
- return nics
-
- def getConfDrives(self):
- """
- Normalize drives provided by conf.
- """
- # FIXME
- # Will be better to change the self.conf but this implies an API change
- # Remove this when the API parameters will be consistent.
- confDrives = self.conf.get('drives', [])
- if not confDrives:
- confDrives.extend(self.__legacyDrives())
- confDrives.extend(self.__removableDrives())
-
- for drv in confDrives:
- drv['type'] = DISK_DEVICES
- drv['format'] = drv.get('format') or 'raw'
- drv['propagateErrors'] = drv.get('propagateErrors') or 'off'
- drv['readonly'] = False
- drv['shared'] = False
- # FIXME: For BC we have now two identical keys: iface = if
- # Till the day that conf will not returned as a status anymore.
- drv['iface'] = drv.get('iface') or drv.get('if', 'ide')
-
- # Update indices for drives devices
- self.normalizeDrivesIndices(confDrives)
-
- return confDrives
-
def updateDriveIndex(self, drv):
if not drv['iface'] in self._usedIndices:
self._usedIndices[drv['iface']] = []
@@ -2825,9 +2659,9 @@
def _run(self):
self.log.info("VM wrapper has started")
self.conf['smp'] = self.conf.get('smp', '1')
+ devices = self.getConfDevices()
if not 'recover' in self.conf:
- devices = self.buildConfDevices()
self.preparePaths(devices[DISK_DEVICES])
# Update self.conf with updated devices
# For old type vmParams, new 'devices' key will be
@@ -2851,10 +2685,7 @@
# For BC we should to keep running VM run after vdsm upgrade.
# So, because this vm doesn't have normalize conf we need to build
# it in recovery flow
- if not self.conf.get('devices'):
- devices = self.buildConfDevices()
- else:
- devices = self.getConfDevices()
+ pass
devMap = {DISK_DEVICES: Drive,
NIC_DEVICES: NetworkInterfaceDevice,
--
To view, visit http://gerrit.ovirt.org/18047
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2712148b670c9f85beaea40a0b2e870d829b2b4b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni at redhat.com>
More information about the vdsm-patches
mailing list