Skip to content

Commit d727a65

Browse files
committed
volume: Add 'block storage cluster *' commands
These mirror the 'cinder cluster-*' commands, with arguments copied across essentially verbatim. The only significant departure is the replacement of "tenant" terminology with "project". block storage cluster list block storage cluster set block storage cluster show We used the 'block storage' terminology rather than simply 'volume' to allow us to start distinguishing between the volume service and a volume resource. Change-Id: I9105a9e4a139af4929e3b1f3a6de6c9a53e0b598 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
1 parent dabaec5 commit d727a65

8 files changed

Lines changed: 793 additions & 4 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=====================
2+
block storage cluster
3+
=====================
4+
5+
Block Storage v3
6+
7+
.. autoprogram-cliff:: openstack.volume.v3
8+
:command: block storage cluster *

doc/source/cli/commands.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ referring to both Compute and Volume quotas.
7676
* ``address scope``: (**Network**) a scope of IPv4 or IPv6 addresses
7777
* ``aggregate``: (**Compute**) a grouping of compute hosts
7878
* ``availability zone``: (**Compute**, **Network**, **Volume**) a logical partition of hosts or block storage or network services
79+
* ``block storage cluster``: (**Volume**) clusters of volume services
7980
* ``catalog``: (**Identity**) service catalog
8081
* ``command``: (**Internal**) installed commands in the OSC process
8182
* ``compute agent``: (**Compute**) a cloud Compute agent available to a hypervisor

doc/source/cli/data/cinder.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ cgsnapshot-create,consistency group snapshot create,Creates a cgsnapshot.
2020
cgsnapshot-delete,consistency group snapshot delete,Removes one or more cgsnapshots.
2121
cgsnapshot-list,consistency group snapshot list,Lists all cgsnapshots.
2222
cgsnapshot-show,consistency group snapshot show,Shows cgsnapshot details.
23-
cluster-disable,,Disables clustered services. (Supported by API versions 3.7 - 3.latest)
24-
cluster-enable,,Enables clustered services. (Supported by API versions 3.7 - 3.latest)
25-
cluster-list,,Lists clustered services with optional filtering. (Supported by API versions 3.7 - 3.latest)
26-
cluster-show,,Show detailed information on a clustered service. (Supported by API versions 3.7 - 3.latest)
23+
cluster-disable,block storage cluster set --disable,Disables clustered services. (Supported by API versions 3.7 - 3.latest)
24+
cluster-enable,block storage cluster set --enable,Enables clustered services. (Supported by API versions 3.7 - 3.latest)
25+
cluster-list,block storage cluster list,Lists clustered services with optional filtering. (Supported by API versions 3.7 - 3.latest)
26+
cluster-show,block storage cluster show,Show detailed information on a clustered service. (Supported by API versions 3.7 - 3.latest)
2727
consisgroup-create,consistency group create,Creates a consistency group.
2828
consisgroup-create-from-src,consistency group create --consistency-group-snapshot,Creates a consistency group from a cgsnapshot or a source CG
2929
consisgroup-delete,consistency group delete,Removes one or more consistency groups.

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

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

3333
self.attachments = mock.Mock()
3434
self.attachments.resource_class = fakes.FakeResource(None, {})
35+
self.clusters = mock.Mock()
36+
self.clusters.resource_class = fakes.FakeResource(None, {})
3537
self.groups = mock.Mock()
3638
self.groups.resource_class = fakes.FakeResource(None, {})
3739
self.group_snapshots = mock.Mock()
@@ -70,6 +72,58 @@ def setUp(self):
7072
FakeVolumeType = volume_v2_fakes.FakeVolumeType
7173

7274

75+
class FakeCluster:
76+
"""Fake one or more clusters."""
77+
78+
@staticmethod
79+
def create_one_cluster(attrs=None):
80+
"""Create a fake service cluster.
81+
82+
:param attrs: A dictionary with all attributes of service cluster
83+
:return: A FakeResource object with id, name, status, etc.
84+
"""
85+
attrs = attrs or {}
86+
87+
# Set default attribute
88+
cluster_info = {
89+
'name': f'cluster-{uuid.uuid4().hex}',
90+
'binary': f'binary-{uuid.uuid4().hex}',
91+
'state': random.choice(['up', 'down']),
92+
'status': random.choice(['enabled', 'disabled']),
93+
'disabled_reason': None,
94+
'num_hosts': random.randint(1, 64),
95+
'num_down_hosts': random.randint(1, 64),
96+
'last_heartbeat': '2015-09-16T09:28:52.000000',
97+
'created_at': '2015-09-16T09:28:52.000000',
98+
'updated_at': '2015-09-16T09:28:52.000000',
99+
'replication_status': None,
100+
'frozen': False,
101+
'active_backend_id': None,
102+
}
103+
104+
# Overwrite default attributes if there are some attributes set
105+
cluster_info.update(attrs)
106+
107+
return fakes.FakeResource(
108+
None,
109+
cluster_info,
110+
loaded=True)
111+
112+
@staticmethod
113+
def create_clusters(attrs=None, count=2):
114+
"""Create multiple fake service clusters.
115+
116+
:param attrs: A dictionary with all attributes of service cluster
117+
:param count: The number of service clusters to be faked
118+
:return: A list of FakeResource objects
119+
"""
120+
clusters = []
121+
for n in range(0, count):
122+
clusters.append(FakeCluster.create_one_cluster(attrs))
123+
124+
return clusters
125+
126+
73127
class FakeVolumeGroup:
74128
"""Fake one or more volume groups."""
75129

0 commit comments

Comments
 (0)