python-openstackclient 8.0.0__py3-none-any.whl → 8.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openstackclient/compute/client.py +5 -0
- openstackclient/compute/v2/console.py +7 -0
- openstackclient/compute/v2/console_connection.py +48 -0
- openstackclient/compute/v2/keypair.py +10 -3
- openstackclient/compute/v2/server.py +75 -10
- openstackclient/compute/v2/server_event.py +1 -1
- openstackclient/identity/common.py +79 -0
- openstackclient/identity/v3/application_credential.py +2 -2
- openstackclient/identity/v3/domain.py +62 -43
- openstackclient/identity/v3/group.py +113 -68
- openstackclient/identity/v3/project.py +17 -0
- openstackclient/identity/v3/user.py +38 -5
- openstackclient/image/client.py +5 -0
- openstackclient/image/v2/image.py +11 -11
- openstackclient/network/client.py +0 -6
- openstackclient/network/v2/floating_ip.py +58 -29
- openstackclient/network/v2/network_qos_rule.py +3 -11
- openstackclient/network/v2/router.py +1 -1
- openstackclient/network/v2/security_group.py +5 -4
- openstackclient/network/v2/security_group_rule.py +1 -1
- openstackclient/shell.py +1 -1
- openstackclient/tests/functional/base.py +5 -1
- openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
- openstackclient/tests/unit/compute/v2/fakes.py +81 -305
- openstackclient/tests/unit/compute/v2/test_console.py +18 -1
- openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
- openstackclient/tests/unit/compute/v2/test_flavor.py +1 -1
- openstackclient/tests/unit/compute/v2/test_keypair.py +12 -5
- openstackclient/tests/unit/compute/v2/test_server.py +169 -46
- openstackclient/tests/unit/compute/v2/test_server_backup.py +32 -71
- openstackclient/tests/unit/compute/v2/test_server_event.py +2 -2
- openstackclient/tests/unit/compute/v2/test_server_image.py +33 -72
- openstackclient/tests/unit/compute/v2/test_server_migration.py +4 -4
- openstackclient/tests/unit/identity/v3/test_application_credential.py +47 -25
- openstackclient/tests/unit/identity/v3/test_domain.py +115 -105
- openstackclient/tests/unit/identity/v3/test_group.py +353 -202
- openstackclient/tests/unit/identity/v3/test_project.py +16 -0
- openstackclient/tests/unit/identity/v3/test_user.py +86 -6
- openstackclient/tests/unit/image/v1/test_image.py +8 -9
- openstackclient/tests/unit/image/v2/test_image.py +49 -49
- openstackclient/tests/unit/network/v2/fakes.py +405 -485
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +13 -19
- openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
- openstackclient/tests/unit/network/v2/test_ndp_proxy.py +1 -3
- openstackclient/tests/unit/network/v2/test_network.py +4 -4
- openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
- openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
- openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
- openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
- openstackclient/tests/unit/network/v2/test_port.py +17 -17
- openstackclient/tests/unit/network/v2/test_router.py +73 -57
- openstackclient/tests/unit/network/v2/test_security_group_network.py +25 -27
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +1 -3
- openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +33 -39
- openstackclient/tests/unit/volume/v2/fakes.py +1 -2
- openstackclient/tests/unit/volume/v2/test_service.py +57 -91
- openstackclient/tests/unit/volume/v2/test_volume.py +108 -105
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
- openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
- openstackclient/tests/unit/volume/v3/test_service.py +221 -141
- openstackclient/tests/unit/volume/v3/test_volume.py +130 -119
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +1 -1
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +682 -47
- openstackclient/volume/v2/service.py +41 -38
- openstackclient/volume/v2/volume.py +63 -37
- openstackclient/volume/v2/volume_backup.py +9 -3
- openstackclient/volume/v2/volume_snapshot.py +121 -84
- openstackclient/volume/v3/block_storage_log_level.py +22 -28
- openstackclient/volume/v3/service.py +105 -14
- openstackclient/volume/v3/volume.py +200 -39
- openstackclient/volume/v3/volume_backup.py +24 -19
- openstackclient/volume/v3/volume_snapshot.py +485 -10
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/AUTHORS +8 -0
- python_openstackclient-8.1.0.dist-info/METADATA +264 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/RECORD +83 -81
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/entry_points.txt +7 -6
- python_openstackclient-8.1.0.dist-info/pbr.json +1 -0
- python_openstackclient-8.0.0.dist-info/METADATA +0 -166
- python_openstackclient-8.0.0.dist-info/pbr.json +0 -1
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/WHEEL +0 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/top_level.txt +0 -0
|
@@ -941,6 +941,22 @@ class TestProjectList(TestProject):
|
|
|
941
941
|
)
|
|
942
942
|
self.assertEqual(datalist, tuple(data))
|
|
943
943
|
|
|
944
|
+
def test_project_list_with_option_enabled(self):
|
|
945
|
+
arglist = ['--enabled']
|
|
946
|
+
verifylist = [('is_enabled', True)]
|
|
947
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
948
|
+
|
|
949
|
+
# In base command class Lister in cliff, abstract method take_action()
|
|
950
|
+
# returns a tuple containing the column names and an iterable
|
|
951
|
+
# containing the data to be listed.
|
|
952
|
+
columns, data = self.cmd.take_action(parsed_args)
|
|
953
|
+
|
|
954
|
+
kwargs = {'is_enabled': True}
|
|
955
|
+
self.projects_mock.list.assert_called_with(**kwargs)
|
|
956
|
+
|
|
957
|
+
self.assertEqual(self.columns, columns)
|
|
958
|
+
self.assertEqual(self.datalist, tuple(data))
|
|
959
|
+
|
|
944
960
|
|
|
945
961
|
class TestProjectSet(TestProject):
|
|
946
962
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
|
@@ -44,6 +44,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
|
|
|
44
44
|
'name',
|
|
45
45
|
'description',
|
|
46
46
|
'password_expires_at',
|
|
47
|
+
'options',
|
|
47
48
|
)
|
|
48
49
|
|
|
49
50
|
def setUp(self):
|
|
@@ -63,6 +64,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
|
|
|
63
64
|
self.user.name,
|
|
64
65
|
self.user.description,
|
|
65
66
|
self.user.password_expires_at,
|
|
67
|
+
getattr(self.user, 'options', {}),
|
|
66
68
|
)
|
|
67
69
|
|
|
68
70
|
self.identity_sdk_client.find_domain.return_value = self.domain
|
|
@@ -163,6 +165,53 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
|
|
|
163
165
|
self.assertEqual(self.columns, columns)
|
|
164
166
|
self.assertEqual(self.datalist, data)
|
|
165
167
|
|
|
168
|
+
def test_user_create_password_prompt_no_warning(self):
|
|
169
|
+
arglist = [
|
|
170
|
+
'--password-prompt',
|
|
171
|
+
self.user.name,
|
|
172
|
+
]
|
|
173
|
+
verifylist = [
|
|
174
|
+
('password', None),
|
|
175
|
+
('password_prompt', True),
|
|
176
|
+
('enable', False),
|
|
177
|
+
('disable', False),
|
|
178
|
+
('name', self.user.name),
|
|
179
|
+
]
|
|
180
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
181
|
+
import logging
|
|
182
|
+
|
|
183
|
+
# Mock the password prompt
|
|
184
|
+
mocker = mock.Mock()
|
|
185
|
+
mocker.return_value = 'abc123'
|
|
186
|
+
|
|
187
|
+
# Use assertLogs to verify no warnings are logged
|
|
188
|
+
logger = 'openstackclient.identity.v3.user'
|
|
189
|
+
with mock.patch("osc_lib.utils.get_password", mocker):
|
|
190
|
+
with self.assertLogs(logger, level='WARNING') as log_ctx:
|
|
191
|
+
logging.getLogger(logger).warning(
|
|
192
|
+
"Dummy warning for test setup"
|
|
193
|
+
)
|
|
194
|
+
columns, data = self.cmd.take_action(parsed_args)
|
|
195
|
+
|
|
196
|
+
self.assertEqual(1, len(log_ctx.records))
|
|
197
|
+
self.assertIn(
|
|
198
|
+
"Dummy warning for test setup", log_ctx.output[0]
|
|
199
|
+
)
|
|
200
|
+
self.assertNotIn(
|
|
201
|
+
"No password was supplied", ''.join(log_ctx.output)
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
# Set expected values
|
|
205
|
+
kwargs = {
|
|
206
|
+
'name': self.user.name,
|
|
207
|
+
'is_enabled': True,
|
|
208
|
+
'password': 'abc123',
|
|
209
|
+
}
|
|
210
|
+
self.identity_sdk_client.create_user.assert_called_with(**kwargs)
|
|
211
|
+
|
|
212
|
+
self.assertEqual(self.columns, columns)
|
|
213
|
+
self.assertEqual(self.datalist, data)
|
|
214
|
+
|
|
166
215
|
def test_user_create_email(self):
|
|
167
216
|
arglist = [
|
|
168
217
|
'--email',
|
|
@@ -232,6 +281,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
|
|
|
232
281
|
self.user.name,
|
|
233
282
|
self.user.description,
|
|
234
283
|
self.user.password_expires_at,
|
|
284
|
+
getattr(self.user, 'options', {}),
|
|
235
285
|
)
|
|
236
286
|
self.assertEqual(datalist, data)
|
|
237
287
|
|
|
@@ -279,6 +329,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
|
|
|
279
329
|
self.user.name,
|
|
280
330
|
self.user.description,
|
|
281
331
|
self.user.password_expires_at,
|
|
332
|
+
getattr(self.user, 'options', {}),
|
|
282
333
|
)
|
|
283
334
|
self.assertEqual(datalist, data)
|
|
284
335
|
|
|
@@ -988,6 +1039,24 @@ class TestUserList(identity_fakes.TestIdentityv3):
|
|
|
988
1039
|
self.assertEqual(self.columns, columns)
|
|
989
1040
|
self.assertEqual(self.datalist, tuple(data))
|
|
990
1041
|
|
|
1042
|
+
def test_user_list_with_option_enabled(self):
|
|
1043
|
+
arglist = ['--enabled']
|
|
1044
|
+
verifylist = [('is_enabled', True)]
|
|
1045
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
1046
|
+
|
|
1047
|
+
# In base command class Lister in cliff, abstract method take_action()
|
|
1048
|
+
# returns a tuple containing the column names and an iterable
|
|
1049
|
+
# containing the data to be listed.
|
|
1050
|
+
columns, data = self.cmd.take_action(parsed_args)
|
|
1051
|
+
|
|
1052
|
+
kwargs = {'domain_id': None, 'is_enabled': True}
|
|
1053
|
+
self.identity_sdk_client.users.assert_called_with(**kwargs)
|
|
1054
|
+
self.identity_sdk_client.find_user.assert_not_called()
|
|
1055
|
+
self.identity_sdk_client.group_users.assert_not_called()
|
|
1056
|
+
|
|
1057
|
+
self.assertEqual(self.columns, columns)
|
|
1058
|
+
self.assertEqual(self.datalist, tuple(data))
|
|
1059
|
+
|
|
991
1060
|
|
|
992
1061
|
class TestUserSet(identity_fakes.TestIdentityv3):
|
|
993
1062
|
project = sdk_fakes.generate_fake_resource(_project.Project)
|
|
@@ -1686,11 +1755,14 @@ class TestUserSetPassword(identity_fakes.TestIdentityv3):
|
|
|
1686
1755
|
# Mock getting user current password.
|
|
1687
1756
|
with self._mock_get_password(current_pass):
|
|
1688
1757
|
result = self.cmd.take_action(parsed_args)
|
|
1758
|
+
self.assertIsNone(result)
|
|
1759
|
+
|
|
1760
|
+
conn = self.app.client_manager.sdk_connection
|
|
1761
|
+
user_id = conn.config.get_auth().get_user_id(conn.identity)
|
|
1689
1762
|
|
|
1690
1763
|
self.identity_sdk_client.update_user.assert_called_with(
|
|
1691
|
-
current_password=current_pass, password=new_pass
|
|
1764
|
+
user=user_id, current_password=current_pass, password=new_pass
|
|
1692
1765
|
)
|
|
1693
|
-
self.assertIsNone(result)
|
|
1694
1766
|
|
|
1695
1767
|
def test_user_create_password_prompt(self):
|
|
1696
1768
|
current_pass = 'old_pass'
|
|
@@ -1700,11 +1772,14 @@ class TestUserSetPassword(identity_fakes.TestIdentityv3):
|
|
|
1700
1772
|
# Mock getting user current and new password.
|
|
1701
1773
|
with self._mock_get_password(current_pass, new_pass):
|
|
1702
1774
|
result = self.cmd.take_action(parsed_args)
|
|
1775
|
+
self.assertIsNone(result)
|
|
1776
|
+
|
|
1777
|
+
conn = self.app.client_manager.sdk_connection
|
|
1778
|
+
user_id = conn.config.get_auth().get_user_id(conn.identity)
|
|
1703
1779
|
|
|
1704
1780
|
self.identity_sdk_client.update_user.assert_called_with(
|
|
1705
|
-
current_password=current_pass, password=new_pass
|
|
1781
|
+
user=user_id, current_password=current_pass, password=new_pass
|
|
1706
1782
|
)
|
|
1707
|
-
self.assertIsNone(result)
|
|
1708
1783
|
|
|
1709
1784
|
def test_user_password_change_no_prompt(self):
|
|
1710
1785
|
current_pass = 'old_pass'
|
|
@@ -1722,11 +1797,14 @@ class TestUserSetPassword(identity_fakes.TestIdentityv3):
|
|
|
1722
1797
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
1723
1798
|
|
|
1724
1799
|
result = self.cmd.take_action(parsed_args)
|
|
1800
|
+
self.assertIsNone(result)
|
|
1801
|
+
|
|
1802
|
+
conn = self.app.client_manager.sdk_connection
|
|
1803
|
+
user_id = conn.config.get_auth().get_user_id(conn.identity)
|
|
1725
1804
|
|
|
1726
1805
|
self.identity_sdk_client.update_user.assert_called_with(
|
|
1727
|
-
current_password=current_pass, password=new_pass
|
|
1806
|
+
user=user_id, current_password=current_pass, password=new_pass
|
|
1728
1807
|
)
|
|
1729
|
-
self.assertIsNone(result)
|
|
1730
1808
|
|
|
1731
1809
|
|
|
1732
1810
|
class TestUserShow(identity_fakes.TestIdentityv3):
|
|
@@ -1779,6 +1857,7 @@ class TestUserShow(identity_fakes.TestIdentityv3):
|
|
|
1779
1857
|
'name',
|
|
1780
1858
|
'description',
|
|
1781
1859
|
'password_expires_at',
|
|
1860
|
+
'options',
|
|
1782
1861
|
)
|
|
1783
1862
|
self.assertEqual(collist, columns)
|
|
1784
1863
|
datalist = (
|
|
@@ -1790,6 +1869,7 @@ class TestUserShow(identity_fakes.TestIdentityv3):
|
|
|
1790
1869
|
self.user.name,
|
|
1791
1870
|
self.user.description,
|
|
1792
1871
|
self.user.password_expires_at,
|
|
1872
|
+
getattr(self.user, 'options', {}),
|
|
1793
1873
|
)
|
|
1794
1874
|
self.assertEqual(datalist, data)
|
|
1795
1875
|
|
|
@@ -54,9 +54,9 @@ class TestImageCreate(image_fakes.TestImagev1):
|
|
|
54
54
|
def setUp(self):
|
|
55
55
|
super().setUp()
|
|
56
56
|
|
|
57
|
-
self.image_client.create_image =
|
|
58
|
-
self.image_client.find_image =
|
|
59
|
-
self.image_client.update_image =
|
|
57
|
+
self.image_client.create_image.return_value = self.new_image
|
|
58
|
+
self.image_client.find_image.return_value = self.new_image
|
|
59
|
+
self.image_client.update_image.return_value = self.new_image
|
|
60
60
|
|
|
61
61
|
# Get the command object to test
|
|
62
62
|
self.cmd = image.CreateImage(self.app, None)
|
|
@@ -212,8 +212,8 @@ class TestImageDelete(image_fakes.TestImagev1):
|
|
|
212
212
|
super().setUp()
|
|
213
213
|
|
|
214
214
|
# This is the return value for utils.find_resource()
|
|
215
|
-
self.image_client.find_image =
|
|
216
|
-
self.image_client.delete_image =
|
|
215
|
+
self.image_client.find_image.return_value = self._image
|
|
216
|
+
self.image_client.delete_image.return_value = None
|
|
217
217
|
|
|
218
218
|
# Get the command object to test
|
|
219
219
|
self.cmd = image.DeleteImage(self.app, None)
|
|
@@ -261,7 +261,6 @@ class TestImageList(image_fakes.TestImagev1):
|
|
|
261
261
|
def setUp(self):
|
|
262
262
|
super().setUp()
|
|
263
263
|
|
|
264
|
-
self.image_client.images = mock.Mock()
|
|
265
264
|
self.image_client.images.side_effect = [
|
|
266
265
|
[self._image],
|
|
267
266
|
[],
|
|
@@ -441,8 +440,8 @@ class TestImageSet(image_fakes.TestImagev1):
|
|
|
441
440
|
super().setUp()
|
|
442
441
|
|
|
443
442
|
# This is the return value for utils.find_resource()
|
|
444
|
-
self.image_client.find_image =
|
|
445
|
-
self.image_client.update_image =
|
|
443
|
+
self.image_client.find_image.return_value = self._image
|
|
444
|
+
self.image_client.update_image.return_value = self._image
|
|
446
445
|
|
|
447
446
|
# Get the command object to test
|
|
448
447
|
self.cmd = image.SetImage(self.app, None)
|
|
@@ -712,7 +711,7 @@ class TestImageShow(image_fakes.TestImagev1):
|
|
|
712
711
|
def setUp(self):
|
|
713
712
|
super().setUp()
|
|
714
713
|
|
|
715
|
-
self.image_client.find_image =
|
|
714
|
+
self.image_client.find_image.return_value = self._image
|
|
716
715
|
|
|
717
716
|
# Get the command object to test
|
|
718
717
|
self.cmd = image.ShowImage(self.app, None)
|
|
@@ -17,8 +17,9 @@ import io
|
|
|
17
17
|
import tempfile
|
|
18
18
|
from unittest import mock
|
|
19
19
|
|
|
20
|
-
from
|
|
20
|
+
from openstack.block_storage.v2 import volume as _volume
|
|
21
21
|
from openstack import exceptions as sdk_exceptions
|
|
22
|
+
from openstack.test import fakes as sdk_fakes
|
|
22
23
|
from osc_lib.cli import format_columns
|
|
23
24
|
from osc_lib import exceptions
|
|
24
25
|
|
|
@@ -37,12 +38,6 @@ class TestImage(image_fakes.TestImagev2, volume_fakes.TestVolume):
|
|
|
37
38
|
self.project_mock.reset_mock()
|
|
38
39
|
self.domain_mock = self.identity_client.domains
|
|
39
40
|
self.domain_mock.reset_mock()
|
|
40
|
-
self.volumes_mock = self.volume_client.volumes
|
|
41
|
-
fake_body = {
|
|
42
|
-
'os-volume_upload_image': {'volume_type': {'name': 'fake_type'}}
|
|
43
|
-
}
|
|
44
|
-
self.volumes_mock.upload_to_image.return_value = (200, fake_body)
|
|
45
|
-
self.volumes_mock.reset_mock()
|
|
46
41
|
|
|
47
42
|
|
|
48
43
|
class TestImageCreate(TestImage):
|
|
@@ -312,7 +307,6 @@ class TestImageCreate(TestImage):
|
|
|
312
307
|
|
|
313
308
|
columns, data = self.cmd.take_action(parsed_args)
|
|
314
309
|
|
|
315
|
-
# ImageManager.create(name=, **)
|
|
316
310
|
self.image_client.create_image.assert_called_with(
|
|
317
311
|
name=self.new_image.name,
|
|
318
312
|
allow_duplicates=True,
|
|
@@ -322,20 +316,19 @@ class TestImageCreate(TestImage):
|
|
|
322
316
|
)
|
|
323
317
|
self.image_client.get_image.assert_called_once_with(self.new_image)
|
|
324
318
|
|
|
325
|
-
@mock.patch('osc_lib.utils.find_resource')
|
|
326
319
|
@mock.patch('openstackclient.image.v2.image.get_data_from_stdin')
|
|
327
|
-
def test_image_create_from_volume(self, mock_get_data_f
|
|
328
|
-
fake_vol_id = 'fake-volume-id'
|
|
320
|
+
def test_image_create_from_volume(self, mock_get_data_f):
|
|
329
321
|
mock_get_data_f.return_value = None
|
|
330
322
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
323
|
+
volume = sdk_fakes.generate_fake_resource(_volume.Volume)
|
|
324
|
+
self.volume_sdk_client.find_volume.return_value = volume
|
|
325
|
+
self.volume_sdk_client.upload_volume_to_image.return_value = {
|
|
326
|
+
'volume_type': {'name': 'fake_type'}
|
|
327
|
+
}
|
|
335
328
|
|
|
336
329
|
arglist = [
|
|
337
330
|
'--volume',
|
|
338
|
-
|
|
331
|
+
volume.id,
|
|
339
332
|
self.new_image.name,
|
|
340
333
|
]
|
|
341
334
|
verifylist = [
|
|
@@ -345,53 +338,60 @@ class TestImageCreate(TestImage):
|
|
|
345
338
|
|
|
346
339
|
columns, data = self.cmd.take_action(parsed_args)
|
|
347
340
|
|
|
348
|
-
self.
|
|
349
|
-
|
|
350
|
-
False,
|
|
341
|
+
self.volume_sdk_client.upload_volume_to_image.assert_called_once_with(
|
|
342
|
+
volume.id,
|
|
351
343
|
self.new_image.name,
|
|
352
|
-
|
|
353
|
-
'raw',
|
|
344
|
+
force=False,
|
|
345
|
+
disk_format='raw',
|
|
346
|
+
container_format='bare',
|
|
354
347
|
visibility=None,
|
|
355
348
|
protected=None,
|
|
356
349
|
)
|
|
357
350
|
|
|
358
|
-
@mock.patch('osc_lib.utils.find_resource')
|
|
359
351
|
@mock.patch('openstackclient.image.v2.image.get_data_from_stdin')
|
|
360
|
-
def
|
|
361
|
-
self, mock_get_data_f, mock_get_vol
|
|
362
|
-
):
|
|
363
|
-
fake_vol_id = 'fake-volume-id'
|
|
352
|
+
def test_image_create_from_volume_pre_v31(self, mock_get_data_f):
|
|
364
353
|
mock_get_data_f.return_value = None
|
|
365
354
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
355
|
+
volume = sdk_fakes.generate_fake_resource(_volume.Volume)
|
|
356
|
+
self.volume_sdk_client.find_volume.return_value = volume
|
|
357
|
+
self.volume_sdk_client.upload_volume_to_image.return_value = {
|
|
358
|
+
'volume_type': {'name': 'fake_type'}
|
|
359
|
+
}
|
|
370
360
|
|
|
371
|
-
arglist = [
|
|
361
|
+
arglist = [
|
|
362
|
+
'--volume',
|
|
363
|
+
volume.id,
|
|
364
|
+
self.new_image.name,
|
|
365
|
+
'--public',
|
|
366
|
+
]
|
|
372
367
|
verifylist = [
|
|
373
368
|
('name', self.new_image.name),
|
|
374
369
|
]
|
|
375
370
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
376
371
|
|
|
377
|
-
self.assertRaises(
|
|
372
|
+
exc = self.assertRaises(
|
|
378
373
|
exceptions.CommandError, self.cmd.take_action, parsed_args
|
|
379
374
|
)
|
|
375
|
+
self.assertIn('--os-volume-api-version 3.1 or greater ', str(exc))
|
|
380
376
|
|
|
381
|
-
@mock.patch('osc_lib.utils.find_resource')
|
|
382
377
|
@mock.patch('openstackclient.image.v2.image.get_data_from_stdin')
|
|
383
|
-
def test_image_create_from_volume_v31(self, mock_get_data_f
|
|
384
|
-
self.
|
|
378
|
+
def test_image_create_from_volume_v31(self, mock_get_data_f):
|
|
379
|
+
self.set_volume_api_version('3.1')
|
|
385
380
|
|
|
386
|
-
fake_vol_id = 'fake-volume-id'
|
|
387
381
|
mock_get_data_f.return_value = None
|
|
388
382
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
383
|
+
volume = sdk_fakes.generate_fake_resource(_volume.Volume)
|
|
384
|
+
self.volume_sdk_client.find_volume.return_value = volume
|
|
385
|
+
self.volume_sdk_client.upload_volume_to_image.return_value = {
|
|
386
|
+
'volume_type': {'name': 'fake_type'}
|
|
387
|
+
}
|
|
393
388
|
|
|
394
|
-
arglist = [
|
|
389
|
+
arglist = [
|
|
390
|
+
'--volume',
|
|
391
|
+
volume.id,
|
|
392
|
+
self.new_image.name,
|
|
393
|
+
'--public',
|
|
394
|
+
]
|
|
395
395
|
verifylist = [
|
|
396
396
|
('name', self.new_image.name),
|
|
397
397
|
]
|
|
@@ -399,12 +399,12 @@ class TestImageCreate(TestImage):
|
|
|
399
399
|
|
|
400
400
|
columns, data = self.cmd.take_action(parsed_args)
|
|
401
401
|
|
|
402
|
-
self.
|
|
403
|
-
|
|
404
|
-
False,
|
|
402
|
+
self.volume_sdk_client.upload_volume_to_image.assert_called_once_with(
|
|
403
|
+
volume.id,
|
|
405
404
|
self.new_image.name,
|
|
406
|
-
|
|
407
|
-
'raw',
|
|
405
|
+
force=False,
|
|
406
|
+
disk_format='raw',
|
|
407
|
+
container_format='bare',
|
|
408
408
|
visibility='public',
|
|
409
409
|
protected=False,
|
|
410
410
|
)
|
|
@@ -914,7 +914,7 @@ class TestImageList(TestImage):
|
|
|
914
914
|
self.assertEqual(ret_limit, len(tuple(data)))
|
|
915
915
|
|
|
916
916
|
def test_image_list_project_option(self):
|
|
917
|
-
self.image_client.find_image =
|
|
917
|
+
self.image_client.find_image.return_value = self._image
|
|
918
918
|
arglist = [
|
|
919
919
|
'--project',
|
|
920
920
|
'nova',
|
|
@@ -931,7 +931,7 @@ class TestImageList(TestImage):
|
|
|
931
931
|
|
|
932
932
|
@mock.patch('osc_lib.utils.find_resource')
|
|
933
933
|
def test_image_list_marker_option(self, fr_mock):
|
|
934
|
-
self.image_client.find_image =
|
|
934
|
+
self.image_client.find_image.return_value = self._image
|
|
935
935
|
|
|
936
936
|
arglist = [
|
|
937
937
|
'--marker',
|
|
@@ -1721,7 +1721,7 @@ class TestImageShow(TestImage):
|
|
|
1721
1721
|
def setUp(self):
|
|
1722
1722
|
super().setUp()
|
|
1723
1723
|
|
|
1724
|
-
self.image_client.find_image =
|
|
1724
|
+
self.image_client.find_image.return_value = self._data
|
|
1725
1725
|
|
|
1726
1726
|
# Get the command object to test
|
|
1727
1727
|
self.cmd = _image.ShowImage(self.app, None)
|