Skip to content

Commit

Permalink
Use implicit volume creation
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Apr 18, 2019
1 parent fb47c03 commit f934427
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
11 changes: 9 additions & 2 deletions IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,14 @@ def get_volumes(driver, image, radl):
disk_size = None
if disk_url:
volume = driver.ex_get_volume(os.path.basename(disk_url))
disk_url = volume.id
disk = {
'boot_index': cont,
'device_name': disk_device,
'source_type': "volume",
'delete_on_termination': False,
'destination_type': "volume",
'uuid': volume.id
}
else:
disk_size = system.getFeature("disk." + str(cont) + ".size").getValue('G')

Expand All @@ -828,7 +835,7 @@ def get_volumes(driver, image, radl):
'delete_on_termination': True,
'volume_size': disk_size
}
res.append(disk)
res.append(disk)
cont += 1

return res
Expand Down
15 changes: 13 additions & 2 deletions test/unit/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def test_20_launch(self, save_data, get_driver):
disk.0.image.url = 'ost://server.com/ami-id' and
disk.0.os.credentials.username = 'user' and
disk.1.size=1GB and
disk.1.device='hdb'
disk.1.device='hdb' and
disk.2.image.url = 'ost://server.com/vol-id' and
disk.2.device='hdc'
)"""
radl = radl_parse.parse_radl(radl_data)
radl.check()
Expand Down Expand Up @@ -174,6 +176,9 @@ def test_20_launch(self, save_data, get_driver):
image = MagicMock()
image.id = 'imageid'
driver.get_image.return_value = image
vol = MagicMock()
vol.id = 'volid'
driver.ex_get_volume.return_value = vol

inf = InfrastructureInfo()
inf.auth = auth
Expand All @@ -193,7 +198,13 @@ def test_20_launch(self, save_data, get_driver):
'device_name': 'vdb',
'source_type': 'blank',
'destination_type': 'volume',
'delete_on_termination': True}
'delete_on_termination': True},
{'boot_index': 2,
'delete_on_termination': False,
'destination_type': 'volume',
'device_name': 'vdc',
'source_type': 'volume',
'uuid': 'volid'}
]
self.assertEqual(driver.create_node.call_args_list[0][1]['ex_blockdevicemappings'], mappings)

Expand Down

0 comments on commit f934427

Please sign in to comment.