Rebase for pypowervm/nova changes

The pypowervm API library and core nova recently had some changes.  This
change provides a rebase for those changes.  It updates:
 - Property support on the volume groups
 - Updating for flavor objects in Nova

Change-Id: Ia85db9414f3947e8f4274f24ce533254ed41fa86
This commit is contained in:
Drew Thorstensen 2015-02-03 08:41:48 -06:00
parent 238b415f4f
commit 52f553d81b
3 changed files with 29 additions and 37 deletions

View File

@ -1,4 +1,3 @@
# Copyright 2014 IBM Corp.
#
# All Rights Reserved.
#
@ -18,25 +17,26 @@
import os
import sys
SYS_META = {
'instance_type_memory_mb': 2048,
'instance_type_swap': 0,
'instance_type_vcpu_weight': None,
'instance_type_root_gb': 1,
'instance_type_id': 2,
'instance_type_name': u'm1.small',
'instance_type_ephemeral_gb': 0,
'instance_type_rxtx_factor': 1.0,
'instance_type_flavorid': u'1',
'instance_type_vcpus': 1
}
from nova.objects import flavor
TEST_FLAVOR = flavor.Flavor(memory_mb=2048,
swap=0,
vcpu_weight=None,
root_gb=1,
id=2,
name=u'm1.small',
ephemeral_gb=0,
rxtx_factor=1.0,
flavorid=u'1',
vcpus=1)
TEST_INSTANCE = {
'id': 1,
'uuid': '49629a5c-f4c4-4721-9511-9725786ff2e5',
'display_name': 'Fake Instance',
'instance_type_id': '5',
'system_metadata': SYS_META
'flavor': TEST_FLAVOR
}
# NOTE(mikal): All of this is because if dnspython is present in your
@ -53,4 +53,4 @@ os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
import eventlet
eventlet.monkey_patch(os=False)
eventlet.monkey_patch(os=False)

View File

@ -112,13 +112,12 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova_powervm.virt.powervm.vm.crt_lpar')
@mock.patch('nova_powervm.virt.powervm.vm.UUIDCache')
@mock.patch('nova.virt.configdrive.required_by')
@mock.patch('nova.context.get_admin_context')
@mock.patch('nova.objects.flavor.Flavor.get_by_id')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage')
@mock.patch('pypowervm.jobs.power.power_on')
def test_spawn_ops(self, mock_pwron, mock_disk, mock_get_flv, mock_get_ctx,
mock_cfg_drv, mock_uuidcache, mock_crt, mock_find,
mock_apt, mock_sess):
def test_spawn_ops(self, mock_pwron, mock_disk, mock_get_flv, mock_cfg_drv,
mock_uuidcache, mock_crt, mock_find, mock_apt,
mock_sess):
"""Validates the PowerVM driver operations."""
drv = driver.PowerVMDriver(fake.FakeVirtAPI())
@ -153,14 +152,13 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova_powervm.virt.powervm.vios.add_vscsi_mapping')
@mock.patch('nova_powervm.virt.powervm.vm.UUIDCache')
@mock.patch('nova.virt.configdrive.required_by')
@mock.patch('nova.context.get_admin_context')
@mock.patch('nova.objects.flavor.Flavor.get_by_id')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage')
@mock.patch('pypowervm.jobs.power.power_on')
def test_spawn_with_cfg(self, mock_pwron, mock_disk, mock_get_flv,
mock_get_ctx, mock_cfg_drv, mock_val_vopt,
mock_vios_vscsi, mock_uuidcache, mock_cfg_vopt,
mock_crt, mock_find, mock_apt, mock_sess):
mock_cfg_drv, mock_val_vopt, mock_vios_vscsi,
mock_uuidcache, mock_cfg_vopt, mock_crt, mock_find,
mock_apt, mock_sess):
"""Validates the PowerVM spawn w/ config drive operations."""
drv = driver.PowerVMDriver(fake.FakeVirtAPI())
@ -193,15 +191,14 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova_powervm.virt.powervm.vm.dlt_lpar')
@mock.patch('nova_powervm.virt.powervm.vm.UUIDCache')
@mock.patch('nova.virt.configdrive.required_by')
@mock.patch('nova.context.get_admin_context')
@mock.patch('nova.objects.flavor.Flavor.get_by_id')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage')
@mock.patch('pypowervm.jobs.power.power_on')
@mock.patch('pypowervm.jobs.power.power_off')
def test_spawn_ops_rollback(self, mock_pwroff, mock_pwron, mock_disk,
mock_get_flv, mock_get_ctx, mock_cfg_drv,
mock_uuidcache, mock_dlt, mock_crt, mock_find,
mock_apt, mock_sess):
mock_get_flv, mock_cfg_drv, mock_uuidcache,
mock_dlt, mock_crt, mock_find, mock_apt,
mock_sess):
"""Validates the PowerVM driver operations. Will do a rollback."""
drv = driver.PowerVMDriver(fake.FakeVirtAPI())
drv.init_host('FakeHost')

View File

@ -153,11 +153,9 @@ class ConfigDrivePowerVM(object):
# Now, find the vopt in the vg and remove it from the list
vmedia_repo = None
optical_media = None
vopt_media = None
for vmedia in vol_grp.get_vmedia_repos():
optical_media = vmedia.get_optical_media()
for vopt in optical_media:
for vmedia in vol_grp.vmedia_repos:
for vopt in vmedia.optical_media:
if vopt.media_name == file_name:
vmedia_repo = vmedia
vopt_media = vopt
@ -169,8 +167,7 @@ class ConfigDrivePowerVM(object):
return
# Remove the entry from the wrapper and then do an update
optical_media.remove(vopt_media)
vmedia_repo.set_optical_media(optical_media)
vmedia_repo.optical_media.remove(vopt_media)
self.adapter.update(vol_grp._element, vol_grp.etag, vios_w.VIO_ROOT,
root_id=self.vios_uuid, child_type=vg.VG_ROOT,
child_id=CONF.vopt_media_volume_group)
@ -227,13 +224,11 @@ class ConfigDrivePowerVM(object):
vol_grp=CONF.vopt_media_volume_group)
# Ensure that there is a virtual optical media repository within it.
vmedia_repos = found_vg.get_vmedia_repos()
vmedia_repos = found_vg.vmedia_repos
if len(vmedia_repos) == 0:
vopt_repo = vg.crt_vmedia_repo('vopt',
str(CONF.vopt_media_rep_size))
vmedia_repos = [vg.VirtualMediaRepository(vopt_repo)]
# TODO(IBM) This fails because its appending at the end...
found_vg.set_vmedia_repos(vmedia_repos)
found_vg.vmedia_repos = [vg.VirtualMediaRepository(vopt_repo)]
self.adapter.update(found_vg._entry.element, resp.headers['etag'],
pvmc.VIOS, self.vios_uuid, pvmc.VOL_GROUP,
found_vg.uuid)