Hello Sandro Bonazzola,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/37560
to review the following change.
Change subject: vdsm: use vdscli instead of vdsClient
......................................................................
vdsm: use vdscli instead of vdsClient
Dropping vdsClient usage in favor of
vdscli API.
Using vdscli allows to achieve a better error handling
and to have more control on what's going on.
Bug-Url: https://bugzilla.redhat.com/1144334
Bug-Url: https://bugzilla.redhat.com/1101553
Bug-Url: https://bugzilla.redhat.com/1142098
Related-To: https://bugzilla.redhat.com/1005923
Related-To: https://bugzilla.redhat.com/1150427
Change-Id: I0f17abcc4ec83a69832bdb5a986136831504da2c
Signed-off-by: Simone Tiraboschi <[email protected]>
Signed-off-by: Sandro Bonazzola <[email protected]>
---
M src/ovirt_hosted_engine_setup/constants.py
M src/ovirt_hosted_engine_setup/mixins.py
M src/ovirt_hosted_engine_setup/tasks.py
M src/plugins/ovirt-hosted-engine-setup/engine/add_disk.py
M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
M src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
M src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
M src/plugins/ovirt-hosted-engine-setup/network/bridge.py
M src/plugins/ovirt-hosted-engine-setup/storage/storage.py
M src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py
M src/plugins/ovirt-hosted-engine-setup/vdsmd/cpu.py
M src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py
M src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
M src/plugins/ovirt-hosted-engine-setup/vm/image.py
M src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
15 files changed, 261 insertions(+), 147 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup
refs/changes/60/37560/1
diff --git a/src/ovirt_hosted_engine_setup/constants.py
b/src/ovirt_hosted_engine_setup/constants.py
index 1af24b6..9d1bbc1 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -116,10 +116,6 @@
OVIRT_HOSTED_ENGINE_SETUP,
)
- VDS_CLIENT_DIR = os.path.join(
- DATADIR,
- 'vdsm',
- )
ENGINE_VM_TEMPLATE = os.path.join(
config.DATADIR,
OVIRT_HOSTED_ENGINE_SETUP,
@@ -687,7 +683,6 @@
VDSM_UID = 'OVEHOSTED_VDSM/vdsmUid'
KVM_GID = 'OVEHOSTED_VDSM/kvmGid'
VDS_CLI = 'OVEHOSTED_VDSM/vdscli'
- VDS_CLIENT = 'OVEHOSTED_VDSM/vdsClient'
@ohostedattrs(
answerfile=True,
@@ -796,6 +791,7 @@
'ohosted.network.firewallmanager.templates.available'
VDSMD_CONF_LOADED = 'ohosted.vdsm.conf.loaded'
HOST_ADDED = 'ohosted.engine.host.added'
+ VDSCLI_RECONNECTED = 'ohosted.engine.vdscli.reconnected'
HA_START = 'ohosted.engine.ha.start'
VDSM_LIBVIRT_CONFIGURED = 'ohosted.vdsm.libvirt.configured'
NODE_FILES_PERSIST_S = 'ohosted.node.files.persist.start'
diff --git a/src/ovirt_hosted_engine_setup/mixins.py
b/src/ovirt_hosted_engine_setup/mixins.py
index fdd4891..279f7aa 100644
--- a/src/ovirt_hosted_engine_setup/mixins.py
+++ b/src/ovirt_hosted_engine_setup/mixins.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -36,18 +36,11 @@
Hosted engine VM manipulation features for otopi Plugin objects
"""
+ POWER_MAX_TRIES = 10
+ POWER_DELAY = 1
TICKET_MAX_TRIES = 10
TICKET_DELAY = 1
POWEROFF_CHECK_INTERVALL = 1
-
- @property
- def _vdscommand(self):
- if not hasattr(self, '_vdscommand_val'):
- self._vdscommand_val = [self.command.get('vdsClient')]
- if self.environment[ohostedcons.VDSMEnv.USE_SSL]:
- self._vdscommand_val.append('-s')
- self._vdscommand_val.append('localhost')
- return self._vdscommand_val
def _generateTempVncPassword(self):
self.logger.info(
@@ -61,18 +54,20 @@
def _generateUserMessage(self, console_type):
displayPort = 5900
displaySecurePort = 5901
- serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT]
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
try:
- stats = serv.s.getVmStats(
+ stats = cli.getVmStats(
self.environment[ohostedcons.VMEnv.VM_UUID]
)
self.logger.debug(stats)
- if not stats['status']['code'] == 0:
+ if stats['status']['code'] != 0:
self.logger.error(stats['status']['message'])
else:
statsList = stats['statsList'][0]
- displaySecurePort = statsList['displaySecurePort']
- displayPort = statsList['displayPort']
+ displaySecurePort = statsList.get(
+ 'displaySecurePort', displaySecurePort
+ )
+ displayPort = statsList.get('displayPort', displayPort)
except Exception:
self.logger.debug(
'Error getting VM stats',
@@ -132,34 +127,170 @@
time.sleep(self.POWEROFF_CHECK_INTERVALL)
self.logger.info(_('Creating VM'))
- cmd = self._vdscommand + [
- 'create',
- ohostedcons.FileLocations.ENGINE_VM_CONF,
- ]
- self.execute(
- cmd,
- raiseOnError=True
- )
+ # TODO: check if we can move this to configurevm.py
+ # and get rid of the template.
+ conf = {
+ 'vmId': self.environment[ohostedcons.VMEnv.VM_UUID],
+ 'memSize': self.environment[ohostedcons.VMEnv.MEM_SIZE_MB],
+ 'display': self.environment[ohostedcons.VMEnv.CONSOLE_TYPE],
+ 'emulatedMachine': self.environment[
+ ohostedcons.VMEnv.EMULATED_MACHINE
+ ],
+ 'cpuType': self.environment[
+ ohostedcons.VDSMEnv.VDSM_CPU
+ ].replace('model_', ''),
+ 'spiceSecureChannels': (
+ 'smain,sdisplay,sinputs,scursor,splayback,'
+ 'srecord,ssmartcard,susbredir'
+ ),
+ 'vmName': ohostedcons.Const.HOSTED_ENGINE_VM_NAME,
+ 'smp': self.environment[ohostedcons.VMEnv.VCPUS],
+ 'devices': [
+ {
+ 'device': 'scsi',
+ 'model': 'virtio-scsi',
+ 'type': 'controller'
+ },
+ {
+ 'device': 'console',
+ 'specParams': {},
+ 'type': 'console',
+ 'deviceId': self.environment[
+ ohostedcons.VMEnv.CONSOLE_UUID
+ ],
+ 'alias': 'console0'
+ },
+ ],
+ }
+ cdrom = {
+ 'index': '2',
+ 'iface': 'ide',
+ 'address': {
+ 'controller': '0',
+ 'target': '0',
+ 'unit': '0',
+ 'bus': '1',
+ 'type': 'drive'
+ },
+ 'specParams': {},
+ 'readonly': 'true',
+ 'deviceId': self.environment[ohostedcons.VMEnv.CDROM_UUID],
+ 'path': (
+ self.environment[ohostedcons.VMEnv.CDROM]
+ if self.environment[
+ ohostedcons.VMEnv.CDROM
+ ] is not None
+ else ''
+ ),
+ 'device': 'cdrom',
+ 'shared': 'false',
+ 'type': 'disk',
+ }
+ if self.environment[ohostedcons.VMEnv.BOOT] == 'cdrom':
+ cdrom['bootOrder'] = '1'
+ conf['devices'].append(cdrom)
+ disk = {
+ 'index': '0',
+ 'iface': 'virtio',
+ 'format': 'raw',
+ 'poolID': ohostedcons.Const.BLANK_UUID,
+ 'volumeID': self.environment[ohostedcons.StorageEnv.VOL_UUID],
+ 'imageID': self.environment[ohostedcons.StorageEnv.IMG_UUID],
+ 'specParams': {},
+ 'readonly': 'false',
+ 'domainID': self.environment[ohostedcons.StorageEnv.SD_UUID],
+ 'optional': 'false',
+ 'deviceId': self.environment[ohostedcons.StorageEnv.IMG_UUID],
+ 'address': {
+ 'bus': '0x00',
+ 'slot': '0x06',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'disk',
+ 'shared': 'exclusive',
+ 'propagateErrors': 'off',
+ 'type': 'disk',
+ }
+ if self.environment[ohostedcons.VMEnv.BOOT] == 'disk':
+ disk['bootOrder'] = '1'
+ conf['devices'].append(disk)
+ nic = {
+ 'nicModel': 'pv',
+ 'macAddr': self.environment[ohostedcons.VMEnv.MAC_ADDR],
+ 'linkActive': 'true',
+ 'network': self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME],
+ 'filter': 'vdsm-no-mac-spoofing',
+ 'specParams': {},
+ 'deviceId': self.environment[ohostedcons.VMEnv.NIC_UUID],
+ 'address': {
+ 'bus': '0x00',
+ 'slot': '0x03',
+ 'domain': '0x0000',
+ 'type': 'pci',
+ 'function': '0x0'
+ },
+ 'device': 'bridge',
+ 'type': 'interface',
+ }
+ if self.environment[ohostedcons.VMEnv.BOOT] == 'pxe':
+ nic['bootOrder'] = '1'
+ conf['devices'].append(nic)
+
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
+ status = cli.create(conf)
+ self.logger.debug(status)
+ if status['status']['code'] != 0:
+ raise RuntimeError(
+ _(
+ 'Cannot create the VM: {message}'
+ ).format(
+ message=status['status']['message']
+ )
+ )
+ # Now it's in WaitForLaunch, need to be on powering up
+ powering = False
+ tries = self.POWER_MAX_TRIES
+ while not powering and tries > 0:
+ tries -= 1
+ stats = cli.getVmStats(
+ self.environment[ohostedcons.VMEnv.VM_UUID]
+ )
+ self.logger.debug(stats)
+ if stats['status']['code'] != 0:
+ raise RuntimeError(stats['status']['message'])
+ else:
+ statsList = stats['statsList'][0]
+ if statsList['status'] in ('Powering up', 'Up'):
+ powering = True
+ elif statsList['status'] == 'Down':
+ # VM creation failure
+ tries = 0
+ else:
+ time.sleep(self.POWER_DELAY)
+ if not powering:
+ raise RuntimeError(
+ _(
+ 'The VM is not powering up: please check VDSM logs'
+ )
+ )
+
password_set = False
tries = self.TICKET_MAX_TRIES
while not password_set and tries > 0:
tries -= 1
- try:
- cmd = self._vdscommand + [
- 'setVmTicket',
- self.environment[ohostedcons.VMEnv.VM_UUID],
- self.environment[ohostedcons.VMEnv.VM_PASSWD],
- self.environment[
- ohostedcons.VMEnv.VM_PASSWD_VALIDITY_SECS
- ],
- ]
- self.execute(
- cmd,
- raiseOnError=True
- )
+ status = cli.setVmTicket(
+ self.environment[ohostedcons.VMEnv.VM_UUID],
+ self.environment[ohostedcons.VMEnv.VM_PASSWD],
+ self.environment[
+ ohostedcons.VMEnv.VM_PASSWD_VALIDITY_SECS
+ ],
+ )
+ self.logger.debug(status)
+ if status['status']['code'] == 0:
password_set = True
- except RuntimeError as e:
- self.logger.debug(str(e))
+ else:
time.sleep(self.TICKET_DELAY)
if not password_set:
raise RuntimeError(
@@ -218,11 +349,9 @@
)
def _destroy_vm(self):
- cmd = self._vdscommand + [
- 'destroy',
- self.environment[ohostedcons.VMEnv.VM_UUID]
- ]
- self.execute(cmd, raiseOnError=True)
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
+ res = cli.destroy(self.environment[ohostedcons.VMEnv.VM_UUID])
+ self.logger.debug(res)
def _wait_vm_destroyed(self):
waiter = tasks.VMDownWaiter(self.environment)
diff --git a/src/ovirt_hosted_engine_setup/tasks.py
b/src/ovirt_hosted_engine_setup/tasks.py
index 173fed8..e0d298f 100644
--- a/src/ovirt_hosted_engine_setup/tasks.py
+++ b/src/ovirt_hosted_engine_setup/tasks.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -42,11 +42,11 @@
self.environment = environment
def wait(self):
- serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT]
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
wait = True
while wait:
self.logger.debug('Waiting for existing tasks to complete')
- statuses = serv.s.getAllTasksStatuses()
+ statuses = cli.getAllTasksStatuses()
code = statuses['status']['code']
message = statuses['status']['message']
if code != 0:
@@ -63,7 +63,7 @@
if tasksStatuses[taskID]['taskState'] != 'finished':
all_completed = False
else:
- serv.clearTask([taskID])
+ cli.clearTask(taskID)
if all_completed:
wait = False
else:
@@ -83,13 +83,13 @@
self.environment = environment
def wait(self):
- serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT]
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
down = False
destroyed = False
while not down:
time.sleep(self.POLLING_INTERVAL)
self.logger.debug('Waiting for VM down')
- response = serv.s.getVmStats(
+ response = cli.getVmStats(
self.environment[ohostedcons.VMEnv.VM_UUID]
)
code = response['status']['code']
@@ -120,12 +120,12 @@
self.environment = environment
def wait(self, sdUUID):
- serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT]
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
acquired = False
while not acquired:
time.sleep(self.POLLING_INTERVAL)
self.logger.debug('Waiting for domain monitor')
- response = serv.s.getVdsStats()
+ response = cli.getVdsStats()
self.logger.debug(response)
if response['status']['code'] != 0:
self.logger.debug(response['status']['message'])
diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/add_disk.py
b/src/plugins/ovirt-hosted-engine-setup/engine/add_disk.py
index 57825de..c5c687b 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/add_disk.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_disk.py
@@ -89,7 +89,7 @@
@plugin.event(
stage=plugin.Stages.STAGE_CLOSEUP,
after=(
- ohostedcons.Stages.HOST_ADDED,
+ ohostedcons.Stages.VDSCLI_RECONNECTED,
),
condition=(
lambda self: self.environment[
diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
index 0ad258a..598e043 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
@@ -45,7 +45,6 @@
from vdsm import netinfo
-from vdsm import vdscli
from ovirt_hosted_engine_setup import constants as ohostedcons
@@ -567,7 +566,7 @@
)
try:
- conn = vdscli.connect()
+ conn = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
net_info = netinfo.NetInfo(vds_info.capabilities(conn))
bridge_port = self.environment[ohostedcons.NetworkEnv.BRIDGE_IF]
if bridge_port in net_info.vlans:
@@ -672,6 +671,8 @@
engine_api,
self.environment[ohostedcons.EngineEnv.APP_HOST_NAME]
)
+ # TODO: host-deploy restarted vdscli so we need to
+ # connect again
if not up:
self.logger.error(
_(
diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
b/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
index 78c5c0b..c1e7d36 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
@@ -59,6 +59,10 @@
],
)
def _closeup(self):
+ # TODO: now mixins._create_vm dinamically generates
+ # VM config from env variables.
+ # It would be better to do it from the template
+ self.environment[ohostedcons.VMEnv.BOOT] = 'disk'
self.environment[ohostedcons.VMEnv.SUBST][
'@BOOT_DISK@'
] = ',bootOrder:1'
diff --git a/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
b/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
index ce3f9b4..b20c0ff 100644
--- a/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
+++ b/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -85,7 +85,7 @@
@plugin.event(
stage=plugin.Stages.STAGE_CLOSEUP,
after=(
- ohostedcons.Stages.HOST_ADDED,
+ ohostedcons.Stages.VDSCLI_RECONNECTED,
),
name=ohostedcons.Stages.HA_START,
)
@@ -102,18 +102,20 @@
waiter = tasks.VMDownWaiter(self.environment)
if not waiter.wait():
# The VM is down but not destroyed
- vdscommand = [self.command.get('vdsClient')]
- if self.environment[ohostedcons.VDSMEnv.USE_SSL]:
- vdscommand.append('-s')
- vdscommand += [
- 'localhost',
- 'destroy',
- self.environment[ohostedcons.VMEnv.VM_UUID],
- ]
- self.execute(
- vdscommand,
- raiseOnError=True
+ status = self.environment[
+ ohostedcons.VDSMEnv.VDS_CLI
+ ].destroy(
+ self.environment[ohostedcons.VMEnv.VM_UUID]
)
+ self.logger.debug(status)
+ if status['status']['code'] != 0:
+ self.logger.error(
+ _(
+ 'Cannot destroy the Hosted Engine VM: ' +
+ status['status']['message']
+ )
+ )
+ raise RuntimeError(status['status']['message'])
self.logger.info(_('Enabling and starting HA services'))
for service in (
ohostedcons.Const.HA_AGENT_SERVICE,
@@ -128,4 +130,5 @@
state=True,
)
+
# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-hosted-engine-setup/network/bridge.py
b/src/plugins/ovirt-hosted-engine-setup/network/bridge.py
index b62d21f..29cc680 100644
--- a/src/plugins/ovirt-hosted-engine-setup/network/bridge.py
+++ b/src/plugins/ovirt-hosted-engine-setup/network/bridge.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -34,7 +34,6 @@
from otopi import util
from otopi import plugin
from vdsm import netinfo
-from vdsm import vdscli
from ovirt_hosted_engine_setup import constants as ohostedcons
@@ -83,8 +82,6 @@
)
)
self._enabled = False
- else:
- self.command.detect('vdsClient')
@plugin.event(
stage=plugin.Stages.STAGE_CUSTOMIZATION,
@@ -196,7 +193,7 @@
)
def _misc(self):
self.logger.info(_('Configuring the management bridge'))
- conn = vdscli.connect()
+ conn = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
networks = {
self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]:
vds_info.network(
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
index df6bb8e..de82a38 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
@@ -555,6 +555,7 @@
domList,
mVer
)
+ self.logger.debug(status)
if status['status']['code'] != 0:
raise RuntimeError(status['status']['message'])
@@ -628,6 +629,7 @@
maxHostID,
version
)
+ self.logger.debug(status)
if status['status']['code'] != 0:
raise RuntimeError(status['status']['message'])
@@ -637,9 +639,9 @@
status = self.cli.spmStop(
spUUID,
)
+ self.logger.debug(status)
if status['status']['code'] != 0:
raise RuntimeError(status['status']['message'])
- self.logger.debug(status)
def _activateStorageDomain(self):
self.logger.debug('activateStorageDomain')
@@ -736,7 +738,7 @@
] = self.dialog.queryString(
name='OVEHOSTED_STORAGE_DATACENTER_NAME',
note=_(
- 'Local storage datacenter name is an internal name '
+ 'Local storage datacenter name is an internal name\n'
'and currently will not be shown in engine\'s admin UI.\n'
'Please enter local datacenter name [@DEFAULT@]: '
),
diff --git a/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py
b/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py
index 59db87b..0d2c4c2 100644
--- a/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py
+++ b/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -50,35 +50,14 @@
super(Plugin, self).__init__(context=context)
def _connect(self):
- vdsClient = util.loadModule(
- path=ohostedcons.FileLocations.VDS_CLIENT_DIR,
- name='vdsClient'
- )
- serv = None
- if vdsClient._glusterEnabled:
- serv = vdsClient.ge.GlusterService()
- else:
- serv = vdsClient.service()
- serv.useSSL = self.environment[ohostedcons.VDSMEnv.USE_SSL]
- if hasattr(vdscli, 'cannonizeAddrPort'):
- server, serverPort = vdscli.cannonizeAddrPort(
- 'localhost'
- ).split(':', 1)
- serv.do_connect(server, serverPort)
- else:
- hostPort = vdscli.cannonizeHostPort('localhost')
- serv.do_connect(hostPort)
-
cli = vdscli.connect()
self.environment[ohostedcons.VDSMEnv.VDS_CLI] = cli
-
- self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] = serv
vdsmReady = False
retry = 0
while not vdsmReady and retry < self.MAX_RETRY:
retry += 1
try:
- hwinfo = serv.s.getVdsHardwareInfo()
+ hwinfo = cli.getVdsHardwareInfo()
self.logger.debug(str(hwinfo))
if hwinfo['status']['code'] == 0:
vdsmReady = True
@@ -104,10 +83,6 @@
self.environment.setdefault(
ohostedcons.VDSMEnv.KVM_GID,
grp.getgrnam('kvm').gr_gid
- )
- self.environment.setdefault(
- ohostedcons.VDSMEnv.VDS_CLIENT,
- None
)
self.environment.setdefault(
ohostedcons.VDSMEnv.VDS_CLI,
@@ -196,5 +171,16 @@
)
self._connect()
+ @plugin.event(
+ stage=plugin.Stages.STAGE_CLOSEUP,
+ after=(
+ ohostedcons.Stages.HOST_ADDED,
+ ),
+ name=ohostedcons.Stages.VDSCLI_RECONNECTED,
+ )
+ def _closeup(self):
+ # We need to reconnect cause host-deploy
+ # restarted vdsm adding the host
+ self._connect()
# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-hosted-engine-setup/vdsmd/cpu.py
b/src/plugins/ovirt-hosted-engine-setup/vdsmd/cpu.py
index e413395..74ca6f6 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vdsmd/cpu.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vdsmd/cpu.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,6 @@
"""
-import sys
import gettext
@@ -65,21 +64,19 @@
super(Plugin, self).__init__(context=context)
def _getCompatibleCpuModels(self):
- self.logger.debug('Attempting to load the caps vdsm module')
- savedPath = sys.path
- ret = None
- try:
- sys.path.append(ohostedcons.FileLocations.VDS_CLIENT_DIR)
- caps = util.loadModule(
- path=ohostedcons.FileLocations.VDS_CLIENT_DIR,
- name='caps',
- )
- ret = (
- caps.CpuInfo().model(),
- caps._getCompatibleCpuModels(),
- )
- finally:
- sys.path = savedPath
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
+ caps = cli.getVdsCapabilities()
+ if caps['status']['code'] != 0:
+ raise RuntimeError(caps['status']['message'])
+ cpuModel = caps['info']['cpuModel']
+ cpuCompatibles = [
+ x for x in caps['info']['cpuFlags'].split(',')
+ if x.startswith('model_')
+ ]
+ ret = (
+ cpuModel,
+ cpuCompatibles
+ )
return ret
@plugin.event(
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py
b/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py
index f9d228b..2b229e0 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -115,8 +115,8 @@
info = json.decoder.JSONDecoder().decode('\n'.join(stdout))
source_size = int(info['virtual-size'])
- serv = self._parent.environment[ohostedcons.VDSMEnv.VDS_CLIENT]
- size = serv.s.getVolumeSize(
+ cli = self._parent.environment[ohostedcons.VDSMEnv.VDS_CLI]
+ size = cli.getVolumeSize(
self._parent.environment[ohostedcons.StorageEnv.SD_UUID],
self._parent.environment[ohostedcons.StorageEnv.SP_UUID],
self._parent.environment[ohostedcons.StorageEnv.IMG_UUID],
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
b/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
index 8ccaefb..b45cc8d 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -55,10 +55,6 @@
def __init__(self, context):
super(Plugin, self).__init__(context=context)
- self.vdsClient = util.loadModule(
- path=ohostedcons.FileLocations.VDS_CLIENT_DIR,
- name='vdsClient'
- )
@plugin.event(
stage=plugin.Stages.STAGE_INIT,
@@ -95,8 +91,8 @@
name=ohostedcons.Stages.VDSMD_LATE_SETUP_READY,
)
def _late_setup(self):
- serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT]
- response = serv.s.list()
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
+ response = cli.list()
if response['status']['code'] == 0:
self.logger.debug(response['vmList'])
if response['vmList']:
@@ -180,7 +176,7 @@
def _misc(self):
self.logger.info(_('Configuring VM'))
subst = {
- '@SP_UUID@': self.vdsClient.BLANK_UUID,
+ '@SP_UUID@': ohostedcons.Const.BLANK_UUID,
'@SD_UUID@': self.environment[
ohostedcons.StorageEnv.SD_UUID
],
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/image.py
b/src/plugins/ovirt-hosted-engine-setup/vm/image.py
index 4617a8d..65c3703 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/image.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/image.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -183,14 +183,14 @@
spUUID = self.environment[ohostedcons.StorageEnv.SP_UUID]
imgUUID = self.environment[ohostedcons.StorageEnv.IMG_UUID]
volUUID = self.environment[ohostedcons.StorageEnv.VOL_UUID]
- serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT]
+ cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
if self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in (
ohostedcons.DomainTypes.ISCSI,
):
# Checking the available space on VG where
# we have to preallocate the image
- vginfo = serv.s.getVGInfo(
+ vginfo = cli.getVGInfo(
self.environment[ohostedcons.StorageEnv.VG_UUID]
)
self.logger.debug(vginfo)
@@ -227,31 +227,36 @@
preallocate = ohostedcons.VolumeTypes.PREALLOCATED_VOL
diskType = 2
- status, message = serv.createVolume([
+ status = cli.createVolume(
sdUUID,
spUUID,
imgUUID,
- self.environment[ohostedcons.StorageEnv.IMAGE_SIZE_GB],
+ str(
+ int(
+ self.environment[ohostedcons.StorageEnv.IMAGE_SIZE_GB]
+ ) * pow(2, 30)
+ ),
volFormat,
preallocate,
diskType,
volUUID,
self.environment[ohostedcons.StorageEnv.IMAGE_DESC],
- ])
- if status == 0:
+ )
+ self.logger.debug(status)
+ if status['status']['code'] == 0:
self.logger.debug(
(
'Created volume {newUUID}, request was:\n'
'- image: {imgUUID}\n'
'- volume: {volUUID}'
).format(
- newUUID=message,
+ newUUID=status['status']['message'],
imgUUID=imgUUID,
volUUID=volUUID,
)
)
else:
- raise RuntimeError(message)
+ raise RuntimeError(status['status']['message'])
waiter = tasks.TaskWaiter(self.environment)
waiter.wait()
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
index b728d41..be6d95f 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
@@ -1,6 +1,6 @@
#
# ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2013-2014 Red Hat, Inc.
+# Copyright (C) 2013-2015 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -70,8 +70,6 @@
stage=plugin.Stages.STAGE_SETUP,
)
def _setup(self):
- # Can't use python api here, it will call sys.exit
- self.command.detect('vdsClient')
self.command.detect('remote-viewer')
@plugin.event(
--
To view, visit http://gerrit.ovirt.org/37560
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f17abcc4ec83a69832bdb5a986136831504da2c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: ovirt-hosted-engine-setup-1.2
Gerrit-Owner: Simone Tiraboschi <[email protected]>
Gerrit-Reviewer: Sandro Bonazzola <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches