summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/volume/v3/fakes.py
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-06-09 17:45:56 +0100
committerStephen Finucane <sfinucan@redhat.com>2022-05-13 11:59:23 +0100
commitd727a6502369a6a7244ef1c07c1c483dbe0a8dab (patch)
tree0b88c67fe8dbd02fc62a37c3926eca2c4eb24ff3 /openstackclient/tests/unit/volume/v3/fakes.py
parentdabaec5a7b1b9786a8f91eebef738bf755faf059 (diff)
downloadpython-openstackclient-d727a6502369a6a7244ef1c07c1c483dbe0a8dab.tar.gz
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>
Diffstat (limited to 'openstackclient/tests/unit/volume/v3/fakes.py')
-rw-r--r--openstackclient/tests/unit/volume/v3/fakes.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/volume/v3/fakes.py b/openstackclient/tests/unit/volume/v3/fakes.py
index 9040b2be..81ff0a98 100644
--- a/openstackclient/tests/unit/volume/v3/fakes.py
+++ b/openstackclient/tests/unit/volume/v3/fakes.py
@@ -32,6 +32,8 @@ class FakeVolumeClient(object):
self.attachments = mock.Mock()
self.attachments.resource_class = fakes.FakeResource(None, {})
+ self.clusters = mock.Mock()
+ self.clusters.resource_class = fakes.FakeResource(None, {})
self.groups = mock.Mock()
self.groups.resource_class = fakes.FakeResource(None, {})
self.group_snapshots = mock.Mock()
@@ -70,6 +72,58 @@ FakeVolume = volume_v2_fakes.FakeVolume
FakeVolumeType = volume_v2_fakes.FakeVolumeType
+class FakeCluster:
+ """Fake one or more clusters."""
+
+ @staticmethod
+ def create_one_cluster(attrs=None):
+ """Create a fake service cluster.
+
+ :param attrs: A dictionary with all attributes of service cluster
+ :return: A FakeResource object with id, name, status, etc.
+ """
+ attrs = attrs or {}
+
+ # Set default attribute
+ cluster_info = {
+ 'name': f'cluster-{uuid.uuid4().hex}',
+ 'binary': f'binary-{uuid.uuid4().hex}',
+ 'state': random.choice(['up', 'down']),
+ 'status': random.choice(['enabled', 'disabled']),
+ 'disabled_reason': None,
+ 'num_hosts': random.randint(1, 64),
+ 'num_down_hosts': random.randint(1, 64),
+ 'last_heartbeat': '2015-09-16T09:28:52.000000',
+ 'created_at': '2015-09-16T09:28:52.000000',
+ 'updated_at': '2015-09-16T09:28:52.000000',
+ 'replication_status': None,
+ 'frozen': False,
+ 'active_backend_id': None,
+ }
+
+ # Overwrite default attributes if there are some attributes set
+ cluster_info.update(attrs)
+
+ return fakes.FakeResource(
+ None,
+ cluster_info,
+ loaded=True)
+
+ @staticmethod
+ def create_clusters(attrs=None, count=2):
+ """Create multiple fake service clusters.
+
+ :param attrs: A dictionary with all attributes of service cluster
+ :param count: The number of service clusters to be faked
+ :return: A list of FakeResource objects
+ """
+ clusters = []
+ for n in range(0, count):
+ clusters.append(FakeCluster.create_one_cluster(attrs))
+
+ return clusters
+
+
class FakeVolumeGroup:
"""Fake one or more volume groups."""