Ejemplo n.º 1
0
 def __init__(self, **kwargs):
     super(FakeShareClient, self).__init__()
     self.auth_token = kwargs['token']
     self.management_url = kwargs['endpoint']
     self.shares = mock.Mock()
     self.share_access_rules = mock.Mock()
     self.share_groups = mock.Mock()
     self.share_types = mock.Mock()
     self.share_type_access = mock.Mock()
     self.quotas = mock.Mock()
     self.quota_classes = mock.Mock()
     self.share_snapshots = mock.Mock()
     self.share_snapshot_export_locations = mock.Mock()
     self.share_snapshot_instances = mock.Mock()
     self.share_replicas = mock.Mock()
     self.share_replica_export_locations = mock.Mock()
     self.share_networks = mock.Mock()
     self.share_network_subnets = mock.Mock()
     self.security_services = mock.Mock()
     self.shares.resource_class = osc_fakes.FakeResource(None, {})
     self.share_instance_export_locations = mock.Mock()
     self.share_export_locations = mock.Mock()
     self.share_snapshot_instance_export_locations = mock.Mock()
     self.share_export_locations.resource_class = (
         osc_fakes.FakeResource(None, {}))
     self.messages = mock.Mock()
     self.availability_zones = mock.Mock()
     self.services = mock.Mock()
     self.share_instances = mock.Mock()
     self.pools = mock.Mock()
     self.limits = mock.Mock()
     self.share_group_types = mock.Mock()
     self.share_group_type_access = mock.Mock()
Ejemplo n.º 2
0
 def __init__(self, **kwargs):
     super(FakeShareClient, self).__init__()
     self.auth_token = kwargs['token']
     self.management_url = kwargs['endpoint']
     self.shares = mock.Mock()
     self.share_access_rules = mock.Mock()
     self.share_types = mock.Mock()
     self.share_type_access = mock.Mock()
     self.shares.resource_class = osc_fakes.FakeResource(None, {})
     self.share_export_locations = mock.Mock()
     self.share_export_locations.resource_class = (osc_fakes.FakeResource(
         None, {}))
Ejemplo n.º 3
0
    def create_one_export_location(attrs=None):
        """Create a fake share export location

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        share_export_location_info = {
            "created_at": 'time-' + uuid.uuid4().hex,
            "fake_path": "/foo/el/path",
            "fake_share_instance_id": 'share-instance-id' + uuid.uuid4().hex,
            "fake_uuid": "foo_el_uuid",
            "id": "id-" + uuid.uuid4().hex,
            "is_admin_only": False,
            "preferred": False,
            "updated_at": 'time-' + uuid.uuid4().hex,
        }

        share_export_location_info.update(attrs)
        share_export_location = osc_fakes.FakeResource(info=copy.deepcopy(
            share_export_location_info),
            loaded=True)
        return share_export_location
Ejemplo n.º 4
0
    def create_one_share_group_type(attrs=None, methods=None):
        """Create a fake share group type

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}
        methods = methods or {}

        share_group_type_info = {
            "is_public": True,
            "group_specs": {
                "snapshot_support": True
            },
            "share_types": ['share-types-id-' + uuid.uuid4().hex],
            "id": 'share-group-type-id-' + uuid.uuid4().hex,
            "name": 'share-group-type-name-' + uuid.uuid4().hex,
            "is_default": False
        }

        share_group_type_info.update(attrs)
        share_group_type = osc_fakes.FakeResource(info=copy.deepcopy(
                                                  share_group_type_info),
                                                  methods=methods,
                                                  loaded=True)
        return share_group_type
Ejemplo n.º 5
0
    def create_one_share_group(attrs=None, methods=None):
        """Create a fake share group

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}
        methods = methods or {}

        share_group = {
            "id": 'share-group-id-' + uuid.uuid4().hex,
            'name': None,
            'created_at': datetime.datetime.now().isoformat(),
            'status': 'available',
            'description': None,
            'availability_zone': None,
            "project_id": 'project-id-' + uuid.uuid4().hex,
            'host': None,
            'share_group_type_id': 'share-group-type-id-' + uuid.uuid4().hex,
            'source_share_group_snapshot_id': None,
            'share_network_id': None,
            'share_server_id': None,
            'share_types': ['share-types-id-' + uuid.uuid4().hex],
            'consistent_snapshot_support': None
        }

        share_group.update(attrs)
        share_group = osc_fakes.FakeResource(info=copy.deepcopy(
            share_group),
            methods=methods,
            loaded=True)
        return share_group
Ejemplo n.º 6
0
    def create_one_share_subnet(attrs=None):
        """Create a fake share network subnet

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        share_network_subnet = {
            "availability_zone": None,
            "cidr": "10.0.0.0/24",
            "created_at": datetime.datetime.now().isoformat(),
            "gateway": "10.0.0.1",
            'id': str(uuid.uuid4()),
            "ip_version": 4,
            "mtu": "1500",
            "network_type": "vlan",
            "neutron_net_id": str(uuid.uuid4()),
            "neutron_subnet_id": str(uuid.uuid4()),
            "segmentation_id": 1010,
            "share_network_id": str(uuid.uuid4()),
            "share_network_name": str(uuid.uuid4()),
            "updated_at": datetime.datetime.now().isoformat(),
        }

        share_network_subnet.update(attrs)
        share_network_subnet = osc_fakes.FakeResource(info=copy.deepcopy(
            share_network_subnet),
            loaded=True)
        return share_network_subnet
Ejemplo n.º 7
0
    def create_one_snapshot_instance(attrs=None, methods=None):
        """Create a fake share snapshot instance

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}
        methods = methods or {}
        share_snapshot_instance = {
            'id': 'snapshot-instance-id-' + uuid.uuid4().hex,
            'snapshot_id': 'snapshot-id-' + uuid.uuid4().hex,
            'status': None,
            'created_at': datetime.datetime.now().isoformat(),
            'updated_at': datetime.datetime.now().isoformat(),
            'share_id': 'share-id-' + uuid.uuid4().hex,
            'share_instance_id': 'share-instance-id-' + uuid.uuid4().hex,
            'progress': None,
            'provider_location': None
        }

        share_snapshot_instance.update(attrs)
        share_snapshot_instance = osc_fakes.FakeResource(info=copy.deepcopy(
            share_snapshot_instance),
            methods=methods,
            loaded=True)
        return share_snapshot_instance
Ejemplo n.º 8
0
    def create_one_snapshot(attrs=None, methods=None):
        """Create a fake share snapshot

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}
        methods = methods or {}

        share_snapshot = {
            'created_at': datetime.datetime.now().isoformat(),
            'description': 'description-' + uuid.uuid4().hex,
            'id': 'snapshot-id-' + uuid.uuid4().hex,
            'name': 'name-' + uuid.uuid4().hex,
            'project_id': 'project-id-' + uuid.uuid4().hex,
            'provider_location': None,
            'share_id': 'share-id-' + uuid.uuid4().hex,
            'share_proto': 'NFS',
            'share_size': 1,
            'size': 1,
            'status': None,
            'user_id': 'user-id-' + uuid.uuid4().hex
        }

        share_snapshot.update(attrs)
        share_snapshot = osc_fakes.FakeResource(
            info=copy.deepcopy(share_snapshot), methods=methods, loaded=True)
        return share_snapshot
Ejemplo n.º 9
0
    def create_fake_quotas(attrs=None):
        """Create a fake quota set

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        quotas_info = {
            'gigabytes': 1000,
            'id': 'tenant-id-c96a43119a40ec7d01794cb8',
            'share_group_snapshots': 50,
            'share_groups': 50,
            'share_networks': 10,
            'shares': 50,
            'shapshot_gigabytes': 1000,
            'snapshots': 50
        }

        quotas_info.update(attrs)
        quotas = osc_fakes.FakeResource(info=copy.deepcopy(quotas_info),
                                        loaded=True)
        return quotas
Ejemplo n.º 10
0
    def create_one_export_location(attrs=None):
        """Create a fake snapshot export location

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        snapshot_export_location_info = {
            "created_at": 'time-' + uuid.uuid4().hex,
            "id": "id-" + uuid.uuid4().hex,
            "is_admin_only": False,
            "links": [],
            "path": "/path/to/fake/snapshot/snapshot",
            "share_snapshot_instance_id": 'instance-id' + uuid.uuid4().hex,
            "updated_at": 'time-' + uuid.uuid4().hex,
        }

        snapshot_export_location_info.update(attrs)
        snapshot_export_location = osc_fakes.FakeResource(info=copy.deepcopy(
            snapshot_export_location_info),
            loaded=True)
        return snapshot_export_location
Ejemplo n.º 11
0
    def create_one_sharetype(attrs=None, methods=None):
        """Create a fake share type

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}
        methods = methods or {}

        share_type_info = {
            "required_extra_specs": {
                "driver_handles_share_servers": True
            },
            "share_type_access:is_public": True,
            "extra_specs": {
                "replication_type": "readable",
                "driver_handles_share_servers": True,
                "mount_snapshot_support": False,
                "revert_to_snapshot_support": False,
                "create_share_from_snapshot_support": True,
                "snapshot_support": True
            },
            "id": 'share-type-id-' + uuid.uuid4().hex,
            "name": 'share-type-name-' + uuid.uuid4().hex,
            "is_default": False,
            "description": 'share-type-description-' + uuid.uuid4().hex
        }

        share_type_info.update(attrs)
        share_type = osc_fakes.FakeResource(
            info=copy.deepcopy(share_type_info), methods=methods, loaded=True)
        return share_type
Ejemplo n.º 12
0
    def create_one_access_rule(attrs=None):
        """Create a fake share access rule

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        share_access_rule = {
            'id': 'access_rule-id-' + uuid.uuid4().hex,
            'share_id': 'share-id-' + uuid.uuid4().hex,
            'access_level': 'rw',
            'access_to': 'demo',
            'access_type': 'user',
            'state': 'queued_to_apply',
            'access_key': None,
            'created_at': datetime.datetime.now().isoformat(),
            'updated_at': None,
            'properties': {}
        }

        share_access_rule.update(attrs)
        share_access_rule = osc_fakes.FakeResource(
            info=copy.deepcopy(share_access_rule), loaded=True)
        return share_access_rule
Ejemplo n.º 13
0
    def create_fake_service(attrs=None):
        """Create a fake share service

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        share_service_info = {
            "binary": "manila-share",
            "host": "fake_host@fake_backend",
            "id": uuid.uuid4().hex,
            "status": "enabled",
            "state": "up",
            "updated_at": 'time-' + uuid.uuid4().hex,
            "zone": "fake_zone"
        }

        share_service_info.update(attrs)
        share_service = osc_fakes.FakeResource(info=copy.deepcopy(
            share_service_info),
            loaded=True)
        return share_service
Ejemplo n.º 14
0
    def create_one_share_instance(attrs=None, methods=None):
        """Create a fake share instance

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """
        attrs = attrs or {}
        methods = methods or {}

        share_instance = {
            'status': None,
            'progress': None,
            'share_id': 'share-id-' + uuid.uuid4().hex,
            'availability_zone': None,
            'replica_state': None,
            'created_at': datetime.datetime.now().isoformat(),
            'cast_rules_to_readonly': False,
            'share_network_id': 'sn-id-' + uuid.uuid4().hex,
            'share_server_id': 'ss-id-' + uuid.uuid4().hex,
            'host': None,
            'access_rules_status': None,
            'id': 'instance-id-' + uuid.uuid4().hex
        }

        share_instance.update(attrs)
        share_instance = osc_fakes.FakeResource(info=copy.deepcopy(
            share_instance),
            methods=methods,
            loaded=True)
        return share_instance
Ejemplo n.º 15
0
    def create_one_message(attrs=None):
        """Create a fake message

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        message = {
            'id': 'message-id-' + uuid.uuid4().hex,
            'action_id': '001',
            'detail_id': '002',
            'user_message': 'user message',
            'message_level': 'ERROR',
            'resource_type': 'SHARE',
            'resource_id': 'resource-id-' + uuid.uuid4().hex,
            'created_at': datetime.datetime.now().isoformat(),
            'expires_at': (
                datetime.datetime.now() + datetime.timedelta(days=30)
            ).isoformat(),
            'request_id': 'req-' + uuid.uuid4().hex,
        }

        message.update(attrs)
        message = osc_fakes.FakeResource(info=copy.deepcopy(
            message),
            loaded=True)
        return message
Ejemplo n.º 16
0
    def create_one_share(attrs=None, methods=None):
        """Create a fake share.

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with flavor_id, image_id, and so on
        """

        attrs = attrs or {}
        methods = methods or {}

        # set default attributes.
        share_info = {
            "status": None,
            "share_server_id": None,
            "project_id": 'project-id-' + uuid.uuid4().hex,
            "name": 'share-name-' + uuid.uuid4().hex,
            "share_type": 'share-type-' + uuid.uuid4().hex,
            "share_type_name": "default",
            "availability_zone": None,
            "created_at": 'time-' + uuid.uuid4().hex,
            "share_network_id": None,
            "share_group_id": None,
            "share_proto": "NFS",
            "host": None,
            "access_rules_status": "active",
            "has_replicas": False,
            "replication_type": None,
            "task_state": None,
            "snapshot_support": True,
            "snapshot_id": None,
            "is_public": True,
            "metadata": {},
            "id": 'share-id-' + uuid.uuid4().hex,
            "size": random.randint(1, 20),
            "description": 'share-description-' + uuid.uuid4().hex,
            "user_id": 'share-user-id-' + uuid.uuid4().hex,
            "create_share_from_snapshot_support": False,
            "mount_snapshot_support": False,
            "revert_to_snapshot_support": False,
            "source_share_group_snapshot_member_id": None,
            "scheduler_hints": {},
        }

        # Overwrite default attributes.
        share_info.update(attrs)

        share = osc_fakes.FakeResource(info=copy.deepcopy(share_info),
                                       methods=methods,
                                       loaded=True)
        return share
Ejemplo n.º 17
0
    def create_one_share_network(attrs=None, methods=None):
        """Create a fake share network

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}
        methods = methods or {}

        share_network = {
            'id': str(uuid.uuid4()),
            'project_id': uuid.uuid4().hex,
            'created_at': datetime.datetime.now().isoformat(),
            'description': 'description-' + uuid.uuid4().hex,
            'name': 'name-' + uuid.uuid4().hex,
            "status": "active",
            "security_service_update_support": True,
            'share_network_subnets': [
                {
                    'id': str(uuid.uuid4()),
                    "availability_zone": None,
                    "created_at": datetime.datetime.now().isoformat(),
                    "updated_at": datetime.datetime.now().isoformat(),
                    "segmentation_id": 1010,
                    "neutron_net_id": str(uuid.uuid4()),
                    "neutron_subnet_id": str(uuid.uuid4()),
                    "ip_version": 4,
                    "cidr": "10.0.0.0/24",
                    "network_type": "vlan",
                    "mtu": "1500",
                    "gateway": "10.0.0.1"
                },
            ],
        }

        share_network.update(attrs)
        share_network = osc_fakes.FakeResource(info=copy.deepcopy(
            share_network),
            methods=methods,
            loaded=True)
        return share_network
Ejemplo n.º 18
0
    def create_one_access_rule(attrs={}):
        """Create a fake snapshot access rule

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        snapshot_access_rule = {
            'access_to': 'demo',
            'access_type': 'user',
            'id': 'access_rule-id-' + uuid.uuid4().hex,
            'state': 'queued_to_apply'
        }

        snapshot_access_rule.update(attrs)
        snapshot_access_rule = osc_fakes.FakeResource(info=copy.deepcopy(
            snapshot_access_rule),
            loaded=True)
        return snapshot_access_rule
Ejemplo n.º 19
0
    def create_one_availability_zone(attrs=None):
        """Create a fake share availability zone

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        availability_zone = {
            "id": 'id-' + uuid.uuid4().hex,
            "name": 'name-' + uuid.uuid4().hex,
            "created_at": 'time-' + uuid.uuid4().hex,
            "updated_at": 'time-' + uuid.uuid4().hex,
        }

        availability_zone.update(attrs)
        availability_zone = osc_fakes.FakeResource(info=copy.deepcopy(
            availability_zone),
            loaded=True)
        return availability_zone
Ejemplo n.º 20
0
    def create_one_share_pool(attrs=None):
        """Create a fake share pool

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object
        """

        attrs = attrs or {}

        share_pool = {
            "name": 'fake_pool@gamma#fake_pool',
            "host": 'fake_host_' + uuid.uuid4().hex,
            "backend": 'fake_backend_' + uuid.uuid4().hex,
            "pool": 'fake_pool_' + uuid.uuid4().hex,
            "capabilities": {'fake_capability': uuid.uuid4().hex}
        }

        share_pool.update(attrs)
        share_pool = osc_fakes.FakeResource(info=copy.deepcopy(
            share_pool),
            loaded=True)
        return share_pool
Ejemplo n.º 21
0
    def create_one_snapshot_instance(attrs=None, methods=None):
        """Create a fake share snapshot instance export locations

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}
        methods = methods or {}
        share_snapshot_instance_export_location = {
            'id': 'snapshot-instance-export-location-id-' + uuid.uuid4().hex,
            'is_admin_only': False,
            'path': '0.0.0.0/:fake-share-instance-export-location-id',
        }

        share_snapshot_instance_export_location.update(attrs)
        share_snapshot_instance_export_location = osc_fakes.FakeResource(
            info=copy.deepcopy(
                share_snapshot_instance_export_location),
            methods=methods,
            loaded=True)
        return share_snapshot_instance_export_location