Skip to content

Commit 4c2e852

Browse files
committed
volume: Add 'volume group *' commands
These mirror the 'cinder group-*' commands, with arguments copied across essentially verbatim. The only significant departures are the replacement of "tenant" terminology with "project" and the merging of the various volume group replication action commands into the parent volume group (e.g. 'openstack volume group set --enable-replication' instead of 'cinder group enable-replication') volume group create volume group delete volume group list volume group show volume group set volume group failover Change-Id: I3b2c0cb92b8a53cc1c0cefa3313b80f59c9e5835 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
1 parent 5faa9ef commit 4c2e852

8 files changed

Lines changed: 1162 additions & 9 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
============
2+
volume group
3+
============
4+
5+
Block Storage v3
6+
7+
.. autoprogram-cliff:: openstack.volume.v3
8+
:command: volume group create
9+
10+
.. autoprogram-cliff:: openstack.volume.v3
11+
:command: volume group delete
12+
13+
.. autoprogram-cliff:: openstack.volume.v3
14+
:command: volume group list
15+
16+
.. autoprogram-cliff:: openstack.volume.v3
17+
:command: volume group failover
18+
19+
.. autoprogram-cliff:: openstack.volume.v3
20+
:command: volume group set
21+
22+
.. autoprogram-cliff:: openstack.volume.v3
23+
:command: volume group show

doc/source/cli/commands.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ referring to both Compute and Volume quotas.
159159
* ``volume backend pool``: (**Volume**) volume backend storage pools
160160
* ``volume backup record``: (**Volume**) volume record that can be imported or exported
161161
* ``volume backend``: (**Volume**) volume backend storage
162+
* ``volume group``: (**Volume**) group of volumes
162163
* ``volume host``: (**Volume**) the physical computer for volumes
163164
* ``volume message``: (**Volume**) volume API internal messages detailing volume failure messages
164165
* ``volume qos``: (**Volume**) quality-of-service (QoS) specification for volumes

doc/source/cli/data/cinder.csv

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ force-delete,volume delete --force,"Attempts force-delete of volume regardless o
4444
freeze-host,volume host set --disable,Freeze and disable the specified cinder-volume host.
4545
get-capabilities,volume backend capability show,Show capabilities of a volume backend. Admin only.
4646
get-pools,volume backend pool list,Show pool information for backends. Admin only.
47-
group-create,,Creates a group. (Supported by API versions 3.13 - 3.latest)
47+
group-create,volume group create,Creates a group. (Supported by API versions 3.13 - 3.latest)
4848
group-create-from-src,,Creates a group from a group snapshot or a source group. (Supported by API versions 3.14 - 3.latest)
49-
group-delete,,Removes one or more groups. (Supported by API versions 3.13 - 3.latest)
50-
group-disable-replication,,Disables replication for group. (Supported by API versions 3.38 - 3.latest)
51-
group-enable-replication,,Enables replication for group. (Supported by API versions 3.38 - 3.latest)
52-
group-failover-replication,,Fails over replication for group. (Supported by API versions 3.38 - 3.latest)
53-
group-list,,Lists all groups. (Supported by API versions 3.13 - 3.latest)
54-
group-list-replication-targets,,Lists replication targets for group. (Supported by API versions 3.38 - 3.latest)
55-
group-show,,Shows details of a group. (Supported by API versions 3.13 - 3.latest)
49+
group-delete,volume group delete,Removes one or more groups. (Supported by API versions 3.13 - 3.latest)
50+
group-disable-replication,volume group set --disable-replication,Disables replication for group. (Supported by API versions 3.38 - 3.latest)
51+
group-enable-replication,volume group set --enable-replication,Enables replication for group. (Supported by API versions 3.38 - 3.latest)
52+
group-failover-replication,volume group failover,Fails over replication for group. (Supported by API versions 3.38 - 3.latest)
53+
group-list,volume group list,Lists all groups. (Supported by API versions 3.13 - 3.latest)
54+
group-list-replication-targets,volume group list --replication-targets,Lists replication targets for group. (Supported by API versions 3.38 - 3.latest)
55+
group-show,volume group show,Shows details of a group. (Supported by API versions 3.13 - 3.latest)
5656
group-snapshot-create,,Creates a group snapshot. (Supported by API versions 3.14 - 3.latest)
5757
group-snapshot-delete,,Removes one or more group snapshots. (Supported by API versions 3.14 - 3.latest)
5858
group-snapshot-list,,Lists all group snapshots. (Supported by API versions 3.14 - 3.latest)
@@ -65,7 +65,7 @@ group-type-key,,Sets or unsets group_spec for a group type. (Supported by API ve
6565
group-type-list,,Lists available 'group types'. (Admin only will see private types) (Supported by API versions 3.11 - 3.latest)
6666
group-type-show,,Show group type details. (Supported by API versions 3.11 - 3.latest)
6767
group-type-update,,Updates group type name description and/or is_public. (Supported by API versions 3.11 - 3.latest)
68-
group-update,,Updates a group. (Supported by API versions 3.13 - 3.latest)
68+
group-update,volume group set,Updates a group. (Supported by API versions 3.13 - 3.latest)
6969
image-metadata,volume set --image-property,Sets or deletes volume image metadata.
7070
image-metadata-show,volume show,Shows volume image metadata.
7171
list,volume list,Lists all volumes.

openstackclient/tests/unit/volume/v3/fakes.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ def __init__(self, **kwargs):
3232

3333
self.attachments = mock.Mock()
3434
self.attachments.resource_class = fakes.FakeResource(None, {})
35+
self.groups = mock.Mock()
36+
self.groups.resource_class = fakes.FakeResource(None, {})
37+
self.group_types = mock.Mock()
38+
self.group_types.resource_class = fakes.FakeResource(None, {})
3539
self.messages = mock.Mock()
3640
self.messages.resource_class = fakes.FakeResource(None, {})
3741
self.volumes = mock.Mock()
3842
self.volumes.resource_class = fakes.FakeResource(None, {})
43+
self.volume_types = mock.Mock()
44+
self.volume_types.resource_class = fakes.FakeResource(None, {})
3945

4046

4147
class TestVolume(utils.TestCommand):
@@ -59,6 +65,111 @@ def setUp(self):
5965

6066
# TODO(stephenfin): Check if the responses are actually the same
6167
FakeVolume = volume_v2_fakes.FakeVolume
68+
FakeVolumeType = volume_v2_fakes.FakeVolumeType
69+
70+
71+
class FakeVolumeGroup:
72+
"""Fake one or more volume groups."""
73+
74+
@staticmethod
75+
def create_one_volume_group(attrs=None):
76+
"""Create a fake group.
77+
78+
:param attrs: A dictionary with all attributes of group
79+
:return: A FakeResource object with id, name, status, etc.
80+
"""
81+
attrs = attrs or {}
82+
83+
group_type = attrs.pop('group_type', None) or uuid.uuid4().hex
84+
volume_types = attrs.pop('volume_types', None) or [uuid.uuid4().hex]
85+
86+
# Set default attribute
87+
group_info = {
88+
'id': uuid.uuid4().hex,
89+
'status': random.choice([
90+
'available',
91+
]),
92+
'availability_zone': f'az-{uuid.uuid4().hex}',
93+
'created_at': '2015-09-16T09:28:52.000000',
94+
'name': 'first_group',
95+
'description': f'description-{uuid.uuid4().hex}',
96+
'group_type': group_type,
97+
'volume_types': volume_types,
98+
'volumes': [f'volume-{uuid.uuid4().hex}'],
99+
'group_snapshot_id': None,
100+
'source_group_id': None,
101+
'project_id': f'project-{uuid.uuid4().hex}',
102+
}
103+
104+
# Overwrite default attributes if there are some attributes set
105+
group_info.update(attrs)
106+
107+
group = fakes.FakeResource(
108+
None,
109+
group_info,
110+
loaded=True)
111+
return group
112+
113+
@staticmethod
114+
def create_volume_groups(attrs=None, count=2):
115+
"""Create multiple fake groups.
116+
117+
:param attrs: A dictionary with all attributes of group
118+
:param count: The number of groups to be faked
119+
:return: A list of FakeResource objects
120+
"""
121+
groups = []
122+
for n in range(0, count):
123+
groups.append(FakeVolumeGroup.create_one_volume_group(attrs))
124+
125+
return groups
126+
127+
128+
class FakeVolumeGroupType:
129+
"""Fake one or more volume group types."""
130+
131+
@staticmethod
132+
def create_one_volume_group_type(attrs=None):
133+
"""Create a fake group type.
134+
135+
:param attrs: A dictionary with all attributes of group type
136+
:return: A FakeResource object with id, name, description, etc.
137+
"""
138+
attrs = attrs or {}
139+
140+
# Set default attribute
141+
group_type_info = {
142+
'id': uuid.uuid4().hex,
143+
'name': f'group-type-{uuid.uuid4().hex}',
144+
'description': f'description-{uuid.uuid4().hex}',
145+
'is_public': random.choice([True, False]),
146+
'group_specs': {},
147+
}
148+
149+
# Overwrite default attributes if there are some attributes set
150+
group_type_info.update(attrs)
151+
152+
group_type = fakes.FakeResource(
153+
None,
154+
group_type_info,
155+
loaded=True)
156+
return group_type
157+
158+
@staticmethod
159+
def create_volume_group_types(attrs=None, count=2):
160+
"""Create multiple fake group types.
161+
162+
:param attrs: A dictionary with all attributes of group type
163+
:param count: The number of group types to be faked
164+
:return: A list of FakeResource objects
165+
"""
166+
group_types = []
167+
for n in range(0, count):
168+
group_types.append(
169+
FakeVolumeGroupType.create_one_volume_group_type(attrs)
170+
)
171+
172+
return group_types
62173

63174

64175
class FakeVolumeMessage:

0 commit comments

Comments
 (0)