summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorNikita Gerasimov <nikita.gerasimov@oracle.com>2016-12-05 20:47:40 +0300
committerSteve Martinelli <s.martinelli@gmail.com>2017-01-26 02:02:30 +0000
commit95c8661f86e74c9d5217869a740da11350f1f0eb (patch)
tree343e46cc4f0030ab5bd7a45246b4e8eae66ac320 /openstackclient/tests
parenta05e2762dca25e4717655b0d3e78209998d61a69 (diff)
downloadpython-openstackclient-95c8661f86e74c9d5217869a740da11350f1f0eb.tar.gz
Switch server create to block_device_mapping_v2
Current compute_client.servers.create() relies on block_device_mapping arg which is legacy[1]. "block_device_mapping" format require device_name which is leads to hard-coded hack in --volume key handler to KVM specific. "block_device_mapping_v2" format is more friendly to hypervisiors. Support of block_device_mapping_v2 appear in python-novaclient 2.16.0, openstackclient require at least 2.29.0 Makes options --volume and --block-device-mapping work simultaneously. Appends --block-device-mapping data even if --volume used. After bug 1383338 only --volume was taken when both are used. [1]http://docs.openstack.org/developer/nova/block_device_mapping.html NOTE(dtroyer): I moved the new test_boot_from_volume() functional test to Ie51b1c375c5940856ec76a5770df3c6bd18a3eba to test our previous behaviour. The only changes required to support the new behaviour should be that the empty_volume is now attached in that test. Change-Id: I7bac3d870dd9ca404093142f8bce22a62e49180d Closes-Bug: 1647406 Closes-Bug: 1497845
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/functional/compute/v2/test_server.py12
-rw-r--r--openstackclient/tests/unit/compute/v2/test_server.py23
2 files changed, 22 insertions, 13 deletions
diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py
index b6ef8587..119ef05c 100644
--- a/openstackclient/tests/functional/compute/v2/test_server.py
+++ b/openstackclient/tests/functional/compute/v2/test_server.py
@@ -417,19 +417,23 @@ class ServerTests(base.TestCase):
# NOTE(dtroyer): Prior to https://review.openstack.org/#/c/407111
# --block-device-mapping was ignored if --volume
- # present on the command line, so this volume should
- # not be attached.
+ # present on the command line. Now we should see the
+ # attachment.
cmd_output = json.loads(self.openstack(
'volume show -f json ' +
empty_volume_name
))
attachments = cmd_output['attachments']
self.assertEqual(
- 0,
+ 1,
len(attachments),
)
self.assertEqual(
- "available",
+ server['id'],
+ attachments[0]['server_id'],
+ )
+ self.assertEqual(
+ "in-use",
cmd_output['status'],
)
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py
index 54f36209..53189aa2 100644
--- a/openstackclient/tests/unit/compute/v2/test_server.py
+++ b/openstackclient/tests/unit/compute/v2/test_server.py
@@ -308,7 +308,7 @@ class TestServerCreate(TestServer):
userdata=None,
key_name=None,
availability_zone=None,
- block_device_mapping={},
+ block_device_mapping_v2=[],
nics=[],
scheduler_hints={},
config_drive=None,
@@ -363,7 +363,7 @@ class TestServerCreate(TestServer):
userdata=None,
key_name='keyname',
availability_zone=None,
- block_device_mapping={},
+ block_device_mapping_v2=[],
nics=[],
scheduler_hints={'a': ['b', 'c']},
config_drive=None,
@@ -443,7 +443,7 @@ class TestServerCreate(TestServer):
userdata=None,
key_name=None,
availability_zone=None,
- block_device_mapping={},
+ block_device_mapping_v2=[],
nics=[{'net-id': 'net1_uuid',
'v4-fixed-ip': '',
'v6-fixed-ip': '',
@@ -500,7 +500,7 @@ class TestServerCreate(TestServer):
userdata=None,
key_name=None,
availability_zone=None,
- block_device_mapping={},
+ block_device_mapping_v2=[],
nics=[],
scheduler_hints={},
config_drive=None,
@@ -550,7 +550,7 @@ class TestServerCreate(TestServer):
userdata=None,
key_name=None,
availability_zone=None,
- block_device_mapping={},
+ block_device_mapping_v2=[],
nics=[],
scheduler_hints={},
config_drive=None,
@@ -605,7 +605,7 @@ class TestServerCreate(TestServer):
userdata=mock_file,
key_name=None,
availability_zone=None,
- block_device_mapping={},
+ block_device_mapping_v2=[],
nics=[],
scheduler_hints={},
config_drive=None,
@@ -656,9 +656,14 @@ class TestServerCreate(TestServer):
userdata=None,
key_name=None,
availability_zone=None,
- block_device_mapping={
- 'vda': real_volume_mapping
- },
+ block_device_mapping_v2=[{
+ 'device_name': 'vda',
+ 'uuid': real_volume_mapping.split(':', 1)[0],
+ 'destination_type': 'volume',
+ 'source_type': 'volume',
+ 'delete_on_termination': '0',
+ 'volume_size': ''
+ }],
nics=[],
scheduler_hints={},
config_drive=None,