diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-08-17 16:31:40 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-09-28 09:31:04 +0800 |
| commit | 8d63b8b263ca4011761b062331d53d9b53b5031d (patch) | |
| tree | c979efd2695ad4b5ca493e4005ba8e6df10819cd /openstackclient/tests/unit/volume/v2/fakes.py | |
| parent | 81a2b9a6bc40e6d815a41c23a0324f474612118b (diff) | |
| download | python-openstackclient-8d63b8b263ca4011761b062331d53d9b53b5031d.tar.gz | |
Implement "consistency group list" command
Add "consistency group" object in volume v2 (v2 only)
and implement "consistency group list" command
Change-Id: Ifa90d97f4b223f9a5b00708cff07fa2c5e2635f0
Implements: bp cinder-command-support
Partial-Bug: #1613964
Co-Authored-By: Sheel Rana <ranasheel2000@gmail.com>
Diffstat (limited to 'openstackclient/tests/unit/volume/v2/fakes.py')
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/fakes.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/volume/v2/fakes.py b/openstackclient/tests/unit/volume/v2/fakes.py index 2aeea60a..5e1d16e1 100644 --- a/openstackclient/tests/unit/volume/v2/fakes.py +++ b/openstackclient/tests/unit/volume/v2/fakes.py @@ -222,6 +222,8 @@ class FakeVolumeClient(object): self.quotas.resource_class = fakes.FakeResource(None, {}) self.quota_classes = mock.Mock() self.quota_classes.resource_class = fakes.FakeResource(None, {}) + self.consistencygroups = mock.Mock() + self.consistencygroups.resource_class = fakes.FakeResource(None, {}) self.auth_token = kwargs['token'] self.management_url = kwargs['endpoint'] @@ -493,6 +495,59 @@ class FakeBackup(object): return mock.Mock(side_effect=backups) +class FakeConsistencyGroup(object): + """Fake one or more consistency group.""" + + @staticmethod + def create_one_consistency_group(attrs=None): + """Create a fake consistency group. + + :param Dictionary attrs: + A dictionary with all attributes + :return: + A FakeResource object with id, name, description, etc. + """ + attrs = attrs or {} + + # Set default attributes. + consistency_group_info = { + "id": 'backup-id-' + uuid.uuid4().hex, + "name": 'backup-name-' + uuid.uuid4().hex, + "description": 'description-' + uuid.uuid4().hex, + "status": "error", + "availability_zone": 'zone' + uuid.uuid4().hex, + "created_at": 'time-' + uuid.uuid4().hex, + "volume_types": ['volume-type1'], + } + + # Overwrite default attributes. + consistency_group_info.update(attrs) + + consistency_group = fakes.FakeResource( + info=copy.deepcopy(consistency_group_info), + loaded=True) + return consistency_group + + @staticmethod + def create_consistency_groups(attrs=None, count=2): + """Create multiple fake consistency groups. + + :param Dictionary attrs: + A dictionary with all attributes + :param int count: + The number of consistency groups to fake + :return: + A list of FakeResource objects faking the consistency groups + """ + consistency_groups = [] + for i in range(0, count): + consistency_group = ( + FakeConsistencyGroup.create_one_consistency_group(attrs)) + consistency_groups.append(consistency_group) + + return consistency_groups + + class FakeExtension(object): """Fake one or more extension.""" |
