Skip to content

Commit 5ec4290

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add commands for "consistency group snapshot""
2 parents 1c2b0c6 + 3907137 commit 5ec4290

7 files changed

Lines changed: 727 additions & 0 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
==========================
2+
consistency group snapshot
3+
==========================
4+
5+
Block Storage v2
6+
7+
consistency group snapshot create
8+
---------------------------------
9+
10+
Create new consistency group snapshot.
11+
12+
.. program:: consistency group snapshot create
13+
.. code:: bash
14+
15+
os consistency group snapshot create
16+
[--consistency-group <consistency-group>]
17+
[--description <description>]
18+
[<snapshot-name>]
19+
20+
.. option:: --consistency-group <consistency-group>
21+
22+
Consistency group to snapshot (name or ID)
23+
(default to be the same as <snapshot-name>)
24+
25+
.. option:: --description <description>
26+
27+
Description of this consistency group snapshot
28+
29+
.. _consistency_group_snapshot_create-snapshot-name:
30+
.. option:: <snapshot-name>
31+
32+
Name of new consistency group snapshot (default to None)
33+
34+
consistency group snapshot delete
35+
---------------------------------
36+
37+
Delete consistency group snapshot(s)
38+
39+
.. program:: consistency group snapshot delete
40+
.. code:: bash
41+
42+
os consistency group snapshot delete
43+
<consistency-group-snapshot> [<consistency-group-snapshot> ...]
44+
45+
.. _consistency_group_snapshot_delete-consistency-group-snapshot:
46+
.. describe:: <consistency-group-snapshot>
47+
48+
Consistency group snapshot(s) to delete (name or ID)
49+
50+
consistency group snapshot list
51+
-------------------------------
52+
53+
List consistency group snapshots.
54+
55+
.. program:: consistency group snapshot list
56+
.. code:: bash
57+
58+
os consistency group snapshot list
59+
[--all-projects]
60+
[--long]
61+
[--status <status>]
62+
[--consistency-group <consistency-group>]
63+
64+
.. option:: --all-projects
65+
66+
Show detail for all projects. Admin only.
67+
(defaults to False)
68+
69+
.. option:: --long
70+
71+
List additional fields in output
72+
73+
.. option:: --status <status>
74+
75+
Filters results by a status
76+
("available", "error", "creating", "deleting" or "error_deleting")
77+
78+
.. option:: --consistency-group <consistency-group>
79+
80+
Filters results by a consistency group (name or ID)
81+
82+
consistency group snapshot show
83+
-------------------------------
84+
85+
Display consistency group snapshot details.
86+
87+
.. program:: consistency group snapshot show
88+
.. code:: bash
89+
90+
os consistency group snapshot show
91+
<consistency-group-snapshot>
92+
93+
.. _consistency_group_snapshot_show-consistency-group-snapshot:
94+
.. describe:: <consistency-group-snapshot>
95+
96+
Consistency group snapshot to display (name or ID)

doc/source/commands.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ referring to both Compute and Volume quotas.
8181
* ``compute service``: (**Compute**) a cloud Compute process running on a host
8282
* ``configuration``: (**Internal**) OpenStack client configuration
8383
* ``consistency group``: (**Volume**) a consistency group of volumes
84+
* ``consistency group snapshot``: (**Volume**) a point-in-time copy of a consistency group
8485
* ``console log``: (**Compute**) server console text dump
8586
* ``console url``: (**Compute**) server remote console URL
8687
* ``consumer``: (**Identity**) OAuth-based delegatee

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ def __init__(self, **kwargs):
224224
self.quota_classes.resource_class = fakes.FakeResource(None, {})
225225
self.consistencygroups = mock.Mock()
226226
self.consistencygroups.resource_class = fakes.FakeResource(None, {})
227+
self.cgsnapshots = mock.Mock()
228+
self.cgsnapshots.resource_class = fakes.FakeResource(None, {})
227229
self.auth_token = kwargs['token']
228230
self.management_url = kwargs['endpoint']
229231

@@ -548,6 +550,82 @@ def create_consistency_groups(attrs=None, count=2):
548550
return consistency_groups
549551

550552

553+
class FakeConsistencyGroupSnapshot(object):
554+
"""Fake one or more consistency group snapshot."""
555+
556+
@staticmethod
557+
def create_one_consistency_group_snapshot(attrs=None):
558+
"""Create a fake consistency group snapshot.
559+
560+
:param Dictionary attrs:
561+
A dictionary with all attributes
562+
:return:
563+
A FakeResource object with id, name, description, etc.
564+
"""
565+
attrs = attrs or {}
566+
567+
# Set default attributes.
568+
consistency_group_snapshot_info = {
569+
"id": 'id-' + uuid.uuid4().hex,
570+
"name": 'backup-name-' + uuid.uuid4().hex,
571+
"description": 'description-' + uuid.uuid4().hex,
572+
"status": "error",
573+
"consistencygroup_id": 'consistency-group-id' + uuid.uuid4().hex,
574+
"created_at": 'time-' + uuid.uuid4().hex,
575+
}
576+
577+
# Overwrite default attributes.
578+
consistency_group_snapshot_info.update(attrs)
579+
580+
consistency_group_snapshot = fakes.FakeResource(
581+
info=copy.deepcopy(consistency_group_snapshot_info),
582+
loaded=True)
583+
return consistency_group_snapshot
584+
585+
@staticmethod
586+
def create_consistency_group_snapshots(attrs=None, count=2):
587+
"""Create multiple fake consistency group snapshots.
588+
589+
:param Dictionary attrs:
590+
A dictionary with all attributes
591+
:param int count:
592+
The number of consistency group snapshots to fake
593+
:return:
594+
A list of FakeResource objects faking the
595+
consistency group snapshots
596+
"""
597+
consistency_group_snapshots = []
598+
for i in range(0, count):
599+
consistency_group_snapshot = (
600+
FakeConsistencyGroupSnapshot.
601+
create_one_consistency_group_snapshot(attrs)
602+
)
603+
consistency_group_snapshots.append(consistency_group_snapshot)
604+
605+
return consistency_group_snapshots
606+
607+
@staticmethod
608+
def get_consistency_group_snapshots(snapshots=None, count=2):
609+
"""Get an iterable MagicMock object with a list of faked cgsnapshots.
610+
611+
If consistenct group snapshots list is provided, then initialize
612+
the Mock object with the list. Otherwise create one.
613+
614+
:param List snapshots:
615+
A list of FakeResource objects faking consistency group snapshots
616+
:param Integer count:
617+
The number of consistency group snapshots to be faked
618+
:return
619+
An iterable Mock object with side_effect set to a list of faked
620+
consistency groups
621+
"""
622+
if snapshots is None:
623+
snapshots = (FakeConsistencyGroupSnapshot.
624+
create_consistency_group_snapshots(count))
625+
626+
return mock.Mock(side_effect=snapshots)
627+
628+
551629
class FakeExtension(object):
552630
"""Fake one or more extension."""
553631

0 commit comments

Comments
 (0)