def __init__(self, username=None, api_key=None, project_id=None, auth_url=None, insecure=False, timeout=None, tenant_id=None, project_name=None, region_name=None, endpoint_type='publicURL', extensions=None, service_type=constants.V2_SERVICE_TYPE, service_name=None, retries=None, http_log_debug=False, input_auth_token=None, session=None, auth=None, cacert=None, service_catalog_url=None, user_agent='python-manilaclient', use_keyring=False, force_new_token=False, cached_token_lifetime=300, api_version=manilaclient.API_MIN_VERSION, user_id=None, user_domain_id=None, user_domain_name=None, project_domain_id=None, project_domain_name=None, cert=None, password=None, **kwargs): self.username = username self.password = password or api_key self.tenant_id = tenant_id or project_id self.tenant_name = project_name self.user_id = user_id self.project_id = project_id or tenant_id self.project_name = project_name self.user_domain_id = user_domain_id self.user_domain_name = user_domain_name self.project_domain_id = project_domain_id self.project_domain_name = project_domain_name self.endpoint_type = endpoint_type self.auth_url = auth_url self.region_name = region_name self.cacert = cacert self.cert = cert self.insecure = insecure self.use_keyring = use_keyring self.force_new_token = force_new_token self.cached_token_lifetime = cached_token_lifetime service_name = kwargs.get("share_service_name", service_name) def check_deprecated_arguments(): deprecated = { 'share_service_name': 'service_name', 'proxy_tenant_id': None, 'proxy_token': None, 'os_cache': 'use_keyring', 'api_key': 'password', } for arg, replacement in six.iteritems(deprecated): if kwargs.get(arg, None) is None: continue replacement_msg = "" if replacement is not None: replacement_msg = " Use %s instead." % replacement msg = "Argument %(arg)s is deprecated.%(repl)s" % { 'arg': arg, 'repl': replacement_msg } warnings.warn(msg) check_deprecated_arguments() if input_auth_token and not service_catalog_url: msg = ("For token-based authentication you should " "provide 'input_auth_token' and 'service_catalog_url'.") raise exceptions.ClientException(msg) self.project_id = tenant_id if tenant_id is not None else project_id self.keystone_client = None self.session = session # NOTE(u_glide): token authorization has highest priority. # That's why session and/or password will be ignored # if token is provided. if not input_auth_token: if session: self.keystone_client = adapter.LegacyJsonAdapter( session=session, auth=auth, interface=endpoint_type, service_type=service_type, service_name=service_name, region_name=region_name) input_auth_token = self.keystone_client.session.get_token(auth) else: self.keystone_client = self._get_keystone_client() input_auth_token = self.keystone_client.auth_token if not input_auth_token: raise RuntimeError("Not Authorized") if session and not service_catalog_url: service_catalog_url = self.keystone_client.session.get_endpoint( auth, interface=endpoint_type, service_type=service_type) elif not service_catalog_url: catalog = self.keystone_client.service_catalog.get_endpoints( service_type) for catalog_entry in catalog.get(service_type, []): if (catalog_entry.get("interface") == (endpoint_type.lower().split("url")[0]) or catalog_entry.get(endpoint_type)): if (region_name and not region_name == (catalog_entry.get( "region", catalog_entry.get("region_id")))): continue service_catalog_url = catalog_entry.get( "url", catalog_entry.get(endpoint_type)) break if not service_catalog_url: raise RuntimeError("Could not find Manila endpoint in catalog") self.api_version = api_version self.client = httpclient.HTTPClient(service_catalog_url, input_auth_token, user_agent, insecure=insecure, cacert=cacert, timeout=timeout, retries=retries, http_log_debug=http_log_debug, api_version=self.api_version) self.limits = limits.LimitsManager(self) self.services = services.ServiceManager(self) self.security_services = security_services.SecurityServiceManager(self) self.share_networks = share_networks.ShareNetworkManager(self) self.quota_classes = quota_classes.QuotaClassSetManager(self) self.quotas = quotas.QuotaSetManager(self) self.shares = shares.ShareManager(self) self.share_instances = share_instances.ShareInstanceManager(self) self.share_snapshots = share_snapshots.ShareSnapshotManager(self) self.share_types = share_types.ShareTypeManager(self) self.share_type_access = share_type_access.ShareTypeAccessManager(self) self.share_servers = share_servers.ShareServerManager(self) self.pools = scheduler_stats.PoolManager(self) self.consistency_groups = ( consistency_groups.ConsistencyGroupManager(self)) self.cg_snapshots = ( cg_snapshots.ConsistencyGroupSnapshotManager(self)) self._load_extensions(extensions)
def __init__(self, username=None, project_id=None, auth_url=None, insecure=False, timeout=None, tenant_id=None, project_name=None, region_name=None, endpoint_type='publicURL', extensions=None, service_type=constants.V2_SERVICE_TYPE, service_name=None, retries=None, http_log_debug=False, input_auth_token=None, session=None, auth=None, cacert=None, service_catalog_url=None, user_agent='python-manilaclient', use_keyring=False, force_new_token=False, cached_token_lifetime=300, api_version=manilaclient.API_MIN_VERSION, user_id=None, user_domain_id=None, user_domain_name=None, project_domain_id=None, project_domain_name=None, cert=None, password=None, **kwargs): self.username = username self.password = password self.tenant_id = tenant_id or project_id self.tenant_name = project_name self.user_id = user_id self.project_id = project_id or tenant_id self.project_name = project_name self.user_domain_id = user_domain_id self.user_domain_name = user_domain_name self.project_domain_id = project_domain_id self.project_domain_name = project_domain_name self.endpoint_type = endpoint_type self.auth_url = auth_url self.region_name = region_name self.cacert = cacert self.cert = cert self.insecure = insecure self.use_keyring = use_keyring self.force_new_token = force_new_token self.cached_token_lifetime = cached_token_lifetime if input_auth_token and not service_catalog_url: msg = ("For token-based authentication you should " "provide 'input_auth_token' and 'service_catalog_url'.") raise exceptions.ClientException(msg) self.project_id = tenant_id if tenant_id is not None else project_id self.keystone_client = None self.session = session # NOTE(u_glide): token authorization has highest priority. # That's why session and/or password will be ignored # if token is provided. if not input_auth_token: if session: self.keystone_client = adapter.LegacyJsonAdapter( session=session, auth=auth, interface=endpoint_type, service_type=service_type, service_name=service_name, region_name=region_name) input_auth_token = self.keystone_client.session.get_token(auth) else: self.keystone_client = self._get_keystone_client() input_auth_token = self.keystone_client.auth_token if not input_auth_token: raise RuntimeError("Not Authorized") if session and not service_catalog_url: service_catalog_url = self.keystone_client.session.get_endpoint( auth, interface=endpoint_type, service_type=service_type) elif not service_catalog_url: catalog = self.keystone_client.service_catalog.get_endpoints( service_type) for catalog_entry in catalog.get(service_type, []): if (catalog_entry.get("interface") == (endpoint_type.lower().split("url")[0]) or catalog_entry.get(endpoint_type)): if (region_name and not region_name == (catalog_entry.get( "region", catalog_entry.get("region_id")))): continue service_catalog_url = catalog_entry.get( "url", catalog_entry.get(endpoint_type)) break if not service_catalog_url: raise RuntimeError("Could not find Manila endpoint in catalog") self.api_version = api_version self.client = httpclient.HTTPClient(service_catalog_url, input_auth_token, user_agent, insecure=insecure, cacert=cacert, cert=cert, timeout=timeout, retries=retries, http_log_debug=http_log_debug, api_version=self.api_version) self.availability_zones = availability_zones.AvailabilityZoneManager( self) self.limits = limits.LimitsManager(self) self.messages = messages.MessageManager(self) self.services = services.ServiceManager(self) self.security_services = security_services.SecurityServiceManager(self) self.share_networks = share_networks.ShareNetworkManager(self) self.share_network_subnets = ( share_network_subnets.ShareNetworkSubnetManager(self)) self.quota_classes = quota_classes.QuotaClassSetManager(self) self.quotas = quotas.QuotaSetManager(self) self.shares = shares.ShareManager(self) self.share_export_locations = ( share_export_locations.ShareExportLocationManager(self)) self.share_groups = share_groups.ShareGroupManager(self) self.share_group_snapshots = ( share_group_snapshots.ShareGroupSnapshotManager(self)) self.share_group_type_access = ( share_group_type_access.ShareGroupTypeAccessManager(self)) self.share_group_types = share_group_types.ShareGroupTypeManager(self) self.share_instances = share_instances.ShareInstanceManager(self) self.share_instance_export_locations = ( share_instance_export_locations.ShareInstanceExportLocationManager( self)) self.share_snapshots = share_snapshots.ShareSnapshotManager(self) self.share_snapshot_instances = ( share_snapshot_instances.ShareSnapshotInstanceManager(self)) self.share_snapshot_export_locations = ( share_snapshot_export_locations.ShareSnapshotExportLocationManager( self)) self.share_snapshot_instance_export_locations = ( share_snapshot_instance_export_locations. ShareSnapshotInstanceExportLocationManager(self)) self.share_types = share_types.ShareTypeManager(self) self.share_type_access = share_type_access.ShareTypeAccessManager(self) self.share_servers = share_servers.ShareServerManager(self) self.share_replicas = share_replicas.ShareReplicaManager(self) self.share_replica_export_locations = ( share_replica_export_locations.ShareReplicaExportLocationManager( self)) self.pools = scheduler_stats.PoolManager(self) self.share_access_rules = ( share_access_rules.ShareAccessRuleManager(self)) self._load_extensions(extensions)