def fake_share(**kwargs): share = { 'id': 'fakeid', 'name': 'fakename', 'size': 1, 'share_proto': 'NFS', 'share_network_id': 'fake share network id', 'export_location': '127.0.0.1:/mnt/nfs/volume-00002', } share.update(kwargs) return db_fakes.FakeModel(share)
def fake_snapshot(**kwargs): snapshot = { 'id': 'fakesnapshotid', 'share_name': 'fakename', 'share_id': 'fakeid', 'name': 'fakesnapshotname', 'share_size': 1, 'share_proto': 'fake_proto', 'export_location': 'fake_location:/fake_share', } snapshot.update(kwargs) return db_fakes.FakeModel(snapshot)
def fake_snapshot(**kwargs): snapshot = { 'id': 'fakesnapshotid', 'share_name': 'fakename', 'share_id': 'fakeid', 'name': 'fakesnapshotname', 'share_proto': 'NFS', 'export_location': '127.0.0.1:/mnt/nfs/volume-00002', 'share': {'size': 1}, } snapshot.update(kwargs) return db_fakes.FakeModel(snapshot)
def setUp(self): super(ViewBuilderTest, self).setUp() self.expected_resource_dict = { 'id': 'fake_resource_id', 'foo': 'quz', 'fred': 'bob', 'alice': 'waldo', 'spoon': 'spam', 'xyzzy': 'qwerty', } self.fake_resource = db_fakes.FakeModel(self.expected_resource_dict) self.view_builder = fakes.FakeResourceViewBuilder()
def fake_share(**kwargs): share = { 'id': 'fakeid', 'name': 'fakename', 'size': 1, 'share_proto': 'fake_proto', 'share_network_id': 'fake share network id', 'share_server_id': 'fake share server id', 'export_location': 'fake_location:/fake_share', 'project_id': 'fake_project_uuid', } share.update(kwargs) return db_fakes.FakeModel(share)
def fake_share(**kwargs): share = { 'id': 'fakeid', 'name': 'fakename', 'size': 1, 'share_proto': 'fake_proto', 'share_network_id': 'fake share network id', 'share_server_id': 'fake share server id', 'export_location': 'fake_location:/fake_share', 'project_id': 'fake_project_uuid', 'availability_zone': 'fake_az', 'snapshot_support': 'True', } share.update(kwargs) return db_fakes.FakeModel(share)
def fake_share(**kwargs): share = { 'id': 'fake_id', 'size': 1, 'share_type_id': '7450f16e-4c7f-42ab-90f1-c1cfb2a6bc70', 'share_proto': 'nfs', 'share_network_id': 'fake_network_id', 'share_server_id': 'fake_server_id', 'host': ['None'], 'export_locations': [{ 'path': '172.24.44.10:/nfs/volume-00002' }], } share.update(kwargs) return db_fakes.FakeModel(share)
def fake_snapshot_instance(base_snapshot=None, **kwargs): if base_snapshot is None: base_snapshot = fake_snapshot() snapshot_instance = { 'id': 'fakesnapshotinstanceid', 'snapshot_id': base_snapshot['id'], 'status': constants.STATUS_CREATING, 'progress': '0%', 'provider_location': 'i_live_here_actually', 'share_name': 'fakename', 'share_id': 'fakeshareinstanceid', 'share_instance_id': 'fakeshareinstanceid', } snapshot_instance.update(kwargs) return db_fakes.FakeModel(snapshot_instance)
def fake_access(id, **kwargs): access = { 'id': id, 'share_id': 'fakeshareid', 'access_type': 'fakeacctype', 'access_to': 'fakeaccto', 'state': 'fakeactive', 'STATE_NEW': 'fakenew', 'STATE_ACTIVE': 'fakeactive', 'STATE_DELETING': 'fakedeleting', 'STATE_DELETED': 'fakedeleted', 'STATE_ERROR': 'fakeerror', } access.update(kwargs) return db_fakes.FakeModel(access)
def fake_snapshot(create_instance=False, **kwargs): instance_keys = ('instance_id', 'snapshot_id', 'share_instance_id', 'status', 'progress', 'provider_location') snapshot_keys = ('id', 'share_name', 'share_id', 'name', 'share_size', 'share_proto', 'instance', 'aggregate_status', 'share', 'project_id', 'size') instance_kwargs = {k: kwargs.get(k) for k in instance_keys if k in kwargs} snapshot_kwargs = {k: kwargs.get(k) for k in snapshot_keys if k in kwargs} aggregate_status = snapshot_kwargs.get( 'aggregate_status', instance_kwargs.get( 'status', constants.STATUS_CREATING)) snapshot = { 'id': 'fakesnapshotid', 'share_name': 'fakename', 'share_id': 'fakeid', 'name': 'fakesnapshotname', 'share_size': 1, 'share_proto': 'fake_proto', 'instance': None, 'share': 'fake_share', 'aggregate_status': aggregate_status, 'project_id': 'fakeprojectid', 'size': 1, 'user_id': 'xyzzy', } snapshot.update(snapshot_kwargs) if create_instance: if 'instance_id' in instance_kwargs: instance_kwargs['id'] = instance_kwargs.pop('instance_id') snapshot['instance'] = fake_snapshot_instance( base_snapshot=snapshot, **instance_kwargs) snapshot['status'] = snapshot['instance']['status'] snapshot['provider_location'] = ( snapshot['instance']['provider_location'] ) snapshot['progress'] = snapshot['instance']['progress'] snapshot['instances'] = snapshot['instance'], else: snapshot['status'] = constants.STATUS_AVAILABLE snapshot['progress'] = '0%' snapshot['provider_location'] = 'fake' snapshot.update(instance_kwargs) return db_fakes.FakeModel(snapshot)
def fake_share_instance(base_share=None, **kwargs): if base_share is None: share = fake_share() else: share = base_share share_instance = { 'share_id': share['id'], 'id': "fakeinstanceid", 'status': "active", } for attr in models.ShareInstance._proxified_properties: share_instance[attr] = getattr(share, attr, None) return db_fakes.FakeModel(share_instance)
def fake_replica_request_spec(as_primitive=True, **kwargs): request_spec = { 'share_properties': fake_share( id='f0e4bb5e-65f0-11e5-9d70-feff819cdc9f'), 'share_instance_properties': fake_replica( id='9c0db763-a109-4862-b010-10f2bd395295'), 'share_proto': 'nfs', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'snapshot_id': None, 'share_type': 'fake_share_type', 'consistency_group': None, } request_spec.update(kwargs) if as_primitive: return request_spec else: return db_fakes.FakeModel(request_spec)
def fake_share_type(**kwargs): share_type = { 'id': "fakesharetype", 'name': "fakesharetypename", 'is_public': False, 'extra_specs': { 'driver_handles_share_servers': 'False', } } extra_specs = kwargs.pop('extra_specs', {}) for key, value in extra_specs.items(): share_type['extra_specs'][key] = value share_type.update(kwargs) return db_fakes.FakeModel(share_type)
def fake_replica(id=None, as_primitive=True, for_manager=False, **kwargs): replica = { 'id': id or uuidutils.generate_uuid(), 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'deleted': False, 'host': 'openstack@BackendZ#PoolA', 'status': 'available', 'scheduled_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'launched_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'terminated_at': None, 'replica_state': None, 'availability_zone_id': 'f6e146d0-65f0-11e5-9d70-feff819cdc9f', 'export_locations': [{ 'path': 'path1' }, { 'path': 'path2' }], 'share_network_id': '4ccd5318-65f1-11e5-9d70-feff819cdc9f', 'share_server_id': '53099868-65f1-11e5-9d70-feff819cdc9f', 'access_rules_status': constants.SHARE_INSTANCE_RULES_SYNCING, } if for_manager: replica.update({ 'user_id': None, 'project_id': None, 'share_type_id': None, 'size': None, 'display_name': None, 'display_description': None, 'replication_type': None, 'snapshot_id': None, 'share_proto': None, 'is_public': None, 'share_group_id': None, 'source_share_group_snapshot_member_id': None, 'availability_zone': 'fake_az', }) replica.update(kwargs) if as_primitive: return replica else: return db_fakes.FakeModel(replica)
def fake_replica_request_spec(as_primitive=True, **kwargs): replica = fake_replica(id='9c0db763-a109-4862-b010-10f2bd395295') all_replica_hosts = ','.join(['fake_active_replica_host', replica['host']]) request_spec = { 'share_properties': fake_share(id='f0e4bb5e-65f0-11e5-9d70-feff819cdc9f'), 'share_instance_properties': replica, 'share_proto': 'nfs', 'share_id': 'f0e4bb5e-65f0-11e5-9d70-feff819cdc9f', 'snapshot_id': None, 'share_type': 'fake_share_type', 'share_group': None, 'active_replica_host': 'fake_active_replica_host', 'all_replica_hosts': all_replica_hosts, } request_spec.update(kwargs) if as_primitive: return request_spec else: return db_fakes.FakeModel(request_spec)
def fake_snapshot_instance(base_snapshot=None, **kwargs): if base_snapshot is None: base_snapshot = fake_snapshot() snapshot_instance = { 'id': 'fakesnapshotinstanceid', 'snapshot_id': base_snapshot['id'], 'status': constants.STATUS_CREATING, 'progress': '0%', 'provider_location': 'i_live_here_actually', 'share_name': 'fakename', 'share_id': 'fakeshareinstanceid', 'share_instance_id': 'fakeshareinstanceid', 'deleted': False, 'updated_at': datetime.datetime(2016, 3, 21, 0, 5, 58), 'created_at': datetime.datetime(2016, 3, 21, 0, 5, 58), 'deleted_at': None, 'share': fake_share(), } snapshot_instance.update(kwargs) return db_fakes.FakeModel(snapshot_instance)
def fake_share_instance(base_share=None, **kwargs): if base_share is None: share = fake_share() else: share = base_share share_instance = { 'share_id': share['id'], 'id': "fakeinstanceid", 'status': "active", 'host': 'fakehost', 'share_network_id': 'fakesharenetworkid', 'share_server_id': 'fakeshareserverid', } for attr in models.ShareInstance._proxified_properties: share_instance[attr] = getattr(share, attr, None) share_instance.update(kwargs) return db_fakes.FakeModel(share_instance)
def fake_share(**kwargs): share = { 'id': 'fakeid', 'name': 'fakename', 'size': 1, 'share_proto': 'fake_proto', 'share_network_id': 'fake share network id', 'share_server_id': 'fake share server id', 'share_type_id': 'fake share type id', 'export_location': 'fake_location:/fake_share', 'project_id': 'fake_project_uuid', 'availability_zone': 'fake_az', 'snapshot_support': 'True', 'replication_type': None, 'is_busy': False, 'consistency_group_id': 'fakecgid', 'instance': {'host': 'fakehost'}, } share.update(kwargs) return db_fakes.FakeModel(share)
def fake_share_server(**kwargs): share_server = { 'id': 'fake' } share_server.update(kwargs) return db_fakes.FakeModel(share_server)
def fake_share_no_export_location(**kwargs): share = { 'share_id': 'fakeshareid', } share.update(kwargs) return db_fakes.FakeModel(share)