Remove traits from Response, add adapter to bld()s

Recently pypowervm removed the traits parameter from the Response
constructor, and added an adapter parameter to the various wrapper bld
methods.

Change-Id: I80fa269112ed305225d80f2cad84f80f937f44d3
This commit is contained in:
Eric Fried 2015-05-01 16:16:50 -05:00
parent 53cf30c8bf
commit f4864f23cd
6 changed files with 27 additions and 25 deletions

View File

@ -122,7 +122,7 @@ class TestSSPDiskAdapter(test.TestCase):
:return: pypowervm.adapter.Response suitable for mocking
pypowervm.adapter.Adapter.search or read.
"""
resp = pvm_adp.Response('meth', 'path', status, 'reason', {}, None)
resp = pvm_adp.Response('meth', 'path', status, 'reason', {})
resp.entry = None
resp.feed = None
if entry_or_list is None:
@ -168,12 +168,12 @@ class TestSSPDiskAdapter(test.TestCase):
def test_init_TooManyClustersFound(self):
"""Search-by-name returns more than one result."""
clust1 = pvm_clust.Cluster.bld('newclust1',
pvm_stg.PV.bld('hdisk1'),
clust1 = pvm_clust.Cluster.bld(None, 'newclust1',
pvm_stg.PV.bld(None, 'hdisk1'),
pvm_clust.Node.bld('vios1'))
clust2 = pvm_clust.Cluster.bld('newclust2',
pvm_stg.PV.bld('hdisk2'),
pvm_clust.Node.bld('vios2'))
clust2 = pvm_clust.Cluster.bld(None, 'newclust2',
pvm_stg.PV.bld(None, 'hdisk2'),
pvm_clust.Node.bld(None, 'vios2'))
self.mock_search.return_value = self._bld_resp(
entry_or_list=[clust1.entry, clust2.entry])
self.assertRaises(ssp.TooManyClustersFound, self._get_ssp_stor)
@ -187,12 +187,12 @@ class TestSSPDiskAdapter(test.TestCase):
def test_init_NoConfigTooManyClusters(self):
"""No SSP name specified in config, more than one SSP on host."""
cfg.CONF.clear_override('cluster_name')
clust1 = pvm_clust.Cluster.bld('newclust1',
pvm_stg.PV.bld('hdisk1'),
pvm_clust.Node.bld('vios1'))
clust2 = pvm_clust.Cluster.bld('newclust2',
pvm_stg.PV.bld('hdisk2'),
pvm_clust.Node.bld('vios2'))
clust1 = pvm_clust.Cluster.bld(None, 'newclust1',
pvm_stg.PV.bld(None, 'hdisk1'),
pvm_clust.Node.bld(None, 'vios1'))
clust2 = pvm_clust.Cluster.bld(None, 'newclust2',
pvm_stg.PV.bld(None, 'hdisk2'),
pvm_clust.Node.bld(None, 'vios2'))
self.apt.read.return_value = self._bld_resp(
entry_or_list=[clust1.entry, clust2.entry])
self.assertRaises(ssp.NoConfigTooManyClusters, self._get_ssp_stor)
@ -306,7 +306,7 @@ class TestSSPDiskAdapter(test.TestCase):
ssp_stor = self._get_ssp_stor()
img = dict(id='image-id', size=b2G)
# Mock the 'existing' image LU
img_lu = pvm_stg.LU.bld('image_image_id', 123,
img_lu = pvm_stg.LU.bld(None, 'image_image_id', 123,
typ=pvm_stg.LUType.IMAGE)
ssp_stor._ssp_wrap.logical_units.append(img_lu)
@ -348,20 +348,22 @@ class TestSSPDiskAdapter(test.TestCase):
def test_delete_disks(self):
def _mk_img_lu(idx):
lu = pvm_stg.LU.bld('img_lu%d' % idx, 123,
lu = pvm_stg.LU.bld(None, 'img_lu%d' % idx, 123,
typ=pvm_stg.LUType.IMAGE)
lu._udid('xxImage-LU-UDID-%d' % idx)
return lu
def _mk_dsk_lu(idx, cloned_from_idx):
lu = pvm_stg.LU.bld('dsk_lu%d' % idx, 123, typ=pvm_stg.LUType.DISK)
lu = pvm_stg.LU.bld(None, 'dsk_lu%d' % idx, 123,
typ=pvm_stg.LUType.DISK)
lu._udid('xxDisk-LU-UDID-%d' % idx)
lu._cloned_from_udid('yyImage-LU-UDID-%d' % cloned_from_idx)
return lu
# We should be ignoring the return value from update - but it still
# needs to be wrappable
self.apt.update_by_path.return_value = pvm_stg.SSP.bld('ssp', []).entry
self.apt.update_by_path.return_value = pvm_stg.SSP.bld(
None, 'ssp', []).entry
ssp_stor = self._get_ssp_stor()
ssp1 = ssp_stor._ssp_wrap
# Seed the SSP with three clones backed to two images:
@ -392,7 +394,7 @@ class TestSSPDiskAdapter(test.TestCase):
'67dca605-3923-34da-bd8f-26a378fc817f')
def mklu(udid):
lu = pvm_stg.LU.bld('lu_%s' % udid, 1)
lu = pvm_stg.LU.bld(None, 'lu_%s' % udid, 1)
lu._udid('27%s' % udid)
return lu

View File

@ -80,8 +80,8 @@ class TestPowerVMDriver(test.TestCase):
self.crt_lpar_p = mock.patch('nova_powervm.virt.powervm.vm.crt_lpar')
self.crt_lpar = self.crt_lpar_p.start()
resp = pvm_adp.Response('method', 'path', 'status', 'reason', {}, None)
resp.entry = pvm_lpar.LPAR._bld().entry
resp = pvm_adp.Response('method', 'path', 'status', 'reason', {})
resp.entry = pvm_lpar.LPAR._bld(None).entry
self.crt_lpar.return_value = pvm_lpar.LPAR.wrap(resp)
def tearDown(self):
@ -438,8 +438,8 @@ class TestPowerVMDriver(test.TestCase):
# Set up the mocks to the resize operation.
inst = objects.Instance(**powervm.TEST_INSTANCE)
host = self.drv.get_host_ip_addr()
resp = pvm_adp.Response('method', 'path', 'status', 'reason', {}, None)
resp.entry = pvm_lpar.LPAR._bld().entry
resp = pvm_adp.Response('method', 'path', 'status', 'reason', {})
resp.entry = pvm_lpar.LPAR._bld(None).entry
self.apt.read.return_value = resp
# Catch root disk resize smaller.

View File

@ -71,7 +71,7 @@ class TestVM(test.TestCase):
cache.remove('n1')
self.assertEqual(cache.lookup('n1', fetch=False), None)
# Not in cache, search returns no results (empty feed)
emptyfeed = pvm_adp.Response('meth', 'path', 200, 'reason', {}, None)
emptyfeed = pvm_adp.Response('meth', 'path', 200, 'reason', {})
emptyfeed.feed = mock.MagicMock()
emptyfeed.feed.entries = []
self.apt.read.return_value = emptyfeed

View File

@ -229,7 +229,7 @@ class SSPDiskAdapter(disk_drv.DiskAdapter):
:param: lpar_uuid: The pypowervm UUID that corresponds to the VM.
"""
# Create the LU structure
lu = pvm_stg.LU.bld_ref(disk_info.name, disk_info.udid)
lu = pvm_stg.LU.bld_ref(self.adapter, disk_info.name, disk_info.udid)
# Add the mapping to *each* VIOS on the LPAR's host.
# Note that the LPAR's host is likely to be the same as self.host_uuid,

View File

@ -226,7 +226,7 @@ class ConfigDrivePowerVM(object):
# Ensure that there is a virtual optical media repository within it.
if len(found_vg.vmedia_repos) == 0:
vopt_repo = pvm_stg.VMediaRepos.bld('vopt',
vopt_repo = pvm_stg.VMediaRepos.bld(self.adapter, 'vopt',
str(CONF.vopt_media_rep_size))
found_vg.vmedia_repos = [vopt_repo]
found_vg = found_vg.update(self.adapter)

View File

@ -259,7 +259,7 @@ class VscsiVolumeAdapter(v_driver.FibreChannelVolumeAdapter):
:param vios_uuid: The UUID of the vios for the pypowervm adapter.
:param device_name: The The hdisk device name
"""
pv = pvm_stor.PV.bld(device_name)
pv = pvm_stor.PV.bld(adapter, device_name)
tsk_map.add_vscsi_mapping(adapter, host_uuid, vios_uuid, vm_uuid, pv)
def _get_udid(self, instance, vios_uuid, volume_id):