def __init__(self, username=None, api_key=None, project_id=None, project_name=None, auth_url=None, magnum_url=None, endpoint_type='publicURL', service_type='container', region_name=None, input_auth_token=None): keystone = None if not input_auth_token: keystone = self.get_keystone_client(username=username, api_key=api_key, auth_url=auth_url, project_id=project_id, project_name=project_name) input_auth_token = keystone.auth_token if not input_auth_token: raise RuntimeError("Not Authorized") if not magnum_url: keystone = keystone or self.get_keystone_client( username=username, api_key=api_key, auth_url=auth_url, token=input_auth_token, project_id=project_id, project_name=project_name) magnum_url = keystone.service_catalog.url_for( service_type=service_type, endpoint_type=endpoint_type, region_name=region_name) http_cli_kwargs = { 'token': input_auth_token, # TODO(yuanying): - use insecure # 'insecure': kwargs.get('insecure'), # TODO(yuanying): - use timeout # 'timeout': kwargs.get('timeout'), # TODO(yuanying): - use ca_file # 'ca_file': kwargs.get('ca_file'), # TODO(yuanying): - use cert_file # 'cert_file': kwargs.get('cert_file'), # TODO(yuanying): - use key_file # 'key_file': kwargs.get('key_file'), 'auth_ref': None, } self.http_client = httpclient.HTTPClient(magnum_url, **http_cli_kwargs) self.bays = bays.BayManager(self.http_client) self.baymodels = baymodels.BayModelManager(self.http_client) self.containers = containers.ContainerManager(self.http_client) self.nodes = nodes.NodeManager(self.http_client) self.pods = pods.PodManager(self.http_client) self.rcs = rcs.ReplicationControllerManager(self.http_client) self.services = services.ServiceManager(self.http_client)
def setUp(self): super(BayModelManagerTest, self).setUp() self.api = utils.FakeAPI(fake_responses) self.mgr = baymodels.BayModelManager(self.api)
def __init__(self, username=None, api_key=None, project_id=None, project_name=None, auth_url=None, magnum_url=None, endpoint_type=None, endpoint_override=None, service_type=DEFAULT_SERVICE_TYPE, region_name=None, input_auth_token=None, session=None, password=None, auth_type='password', interface=None, service_name=None, insecure=False, user_domain_id=None, user_domain_name=None, project_domain_id=None, project_domain_name=None, auth_token=None, timeout=600, api_version=None, **kwargs): # We have to keep the api_key are for backwards compat, but let's # remove it from the rest of our code since it's not a keystone # concept if not password: password = api_key # Backwards compat for people assing in input_auth_token if input_auth_token: auth_token = input_auth_token # Backwards compat for people assing in endpoint_type if endpoint_type: interface = endpoint_type # osc sometimes give 'None' value if not interface: interface = 'public' if interface.endswith('URL'): interface = interface[:-3] # fix (yolanda): os-cloud-config is using endpoint_override # instead of magnum_url if magnum_url and not endpoint_override: endpoint_override = magnum_url if endpoint_override and auth_token: self.http_client = httpclient.HTTPClient(endpoint_override, token=auth_token, api_version=api_version, timeout=timeout, insecure=insecure, **kwargs) else: self.http_client = _load_session_client( session=session, endpoint_override=endpoint_override, username=username, project_id=project_id, project_name=project_name, auth_url=auth_url, password=password, auth_type=auth_type, insecure=insecure, user_domain_id=user_domain_id, user_domain_name=user_domain_name, project_domain_id=project_domain_id, project_domain_name=project_domain_name, auth_token=auth_token, timeout=timeout, service_type=service_type, service_name=service_name, interface=interface, region_name=region_name, api_version=api_version, **kwargs) self.bays = bays.BayManager(self.http_client) self.clusters = clusters.ClusterManager(self.http_client) self.certificates = certificates.CertificateManager(self.http_client) self.baymodels = baymodels.BayModelManager(self.http_client) self.cluster_templates = \ cluster_templates.ClusterTemplateManager(self.http_client) self.mservices = mservices.MServiceManager(self.http_client)
def __init__(self, username=None, api_key=None, project_id=None, project_name=None, auth_url=None, magnum_url=None, endpoint_type=None, endpoint_override=None, service_type=DEFAULT_SERVICE_TYPE, region_name=None, input_auth_token=None, session=None, password=None, auth_type='password', interface=None, service_name=None, insecure=False, user_domain_id=None, user_domain_name=None, project_domain_id=None, project_domain_name=None, auth_token=None, timeout=600, api_version=None, **kwargs): # We have to keep the api_key are for backwards compat, but let's # remove it from the rest of our code since it's not a keystone # concept if not password: password = api_key # Backwards compat for people passing in input_auth_token if input_auth_token: auth_token = input_auth_token # Backwards compat for people passing in endpoint_type if endpoint_type: interface = endpoint_type # osc sometimes give 'None' value if not interface: interface = 'public' if interface.endswith('URL'): interface = interface[:-3] # fix (yolanda): os-cloud-config is using endpoint_override # instead of magnum_url if magnum_url and not endpoint_override: endpoint_override = magnum_url if endpoint_override and auth_token: self.http_client = httpclient.HTTPClient(endpoint_override, token=auth_token, api_version=api_version, timeout=timeout, insecure=insecure, **kwargs) else: self.http_client = _load_session_client( session=session, endpoint_override=endpoint_override, username=username, project_id=project_id, project_name=project_name, auth_url=auth_url, password=password, auth_type=auth_type, insecure=insecure, user_domain_id=user_domain_id, user_domain_name=user_domain_name, project_domain_id=project_domain_id, project_domain_name=project_domain_name, auth_token=auth_token, timeout=timeout, service_type=service_type, service_name=service_name, interface=interface, region_name=region_name, api_version=api_version, **kwargs) self.bays = bays.BayManager(self.http_client) self.clusters = clusters.ClusterManager(self.http_client) self.certificates = certificates.CertificateManager(self.http_client) self.baymodels = baymodels.BayModelManager(self.http_client) self.cluster_templates = \ cluster_templates.ClusterTemplateManager(self.http_client) self.mservices = mservices.MServiceManager(self.http_client) profile = kwargs.pop("profile", None) if profiler and profile: # Initialize the root of the future trace: the created trace ID # will be used as the very first parent to which all related # traces will be bound to. The given HMAC key must correspond to # the one set in magnum-api magnum.conf, otherwise the latter # will fail to check the request signature and will skip # initialization of osprofiler on the server side. profiler.init(profile) self.stats = stats.StatsManager(self.http_client) self.quotas = quotas.QuotasManager(self.http_client)
def __init__(self, username=None, api_key=None, project_id=None, project_name=None, auth_url=None, magnum_url=None, endpoint_type=None, endpoint_override=None, service_type='container', region_name=None, input_auth_token=None, session=None, password=None, auth_type='password', interface='public', service_name=None, insecure=False, user_domain_id=None, user_domain_name=None, project_domain_id=None, project_domain_name=None): # We have to keep the api_key are for backwards compat, but let's # remove it from the rest of our code since it's not a keystone # concept if not password: password = api_key # Backwards compat for people assing in endpoint_type if endpoint_type: interface = endpoint_type # fix (yolanda): os-cloud-config is using endpoint_override # instead of magnum_url if endpoint_override and not magnum_url: magnum_url = endpoint_override if magnum_url and input_auth_token: auth_type = 'admin_token' session = None loader_kwargs = dict(token=input_auth_token, endpoint=magnum_url) elif input_auth_token and not session: auth_type = 'token' loader_kwargs = dict(token=input_auth_token, auth_url=auth_url, project_id=project_id, project_name=project_name, user_domain_id=user_domain_id, user_domain_name=user_domain_name, project_domain_id=project_domain_id, project_domain_name=project_domain_name) else: loader_kwargs = dict(username=username, password=password, auth_url=auth_url, project_id=project_id, project_name=project_name, user_domain_id=user_domain_id, user_domain_name=user_domain_name, project_domain_id=project_domain_id, project_domain_name=project_domain_name) # Backwards compatibility for people not passing in Session if session is None: loader = loading.get_plugin_loader(auth_type) # This should be able to handle v2 and v3 Keystone Auth auth_plugin = loader.load_from_options(**loader_kwargs) session = ksa_session.Session(auth=auth_plugin, verify=(not insecure)) client_kwargs = {} if magnum_url: client_kwargs['endpoint_override'] = magnum_url if not magnum_url: try: # Trigger an auth error so that we can throw the exception # we always have session.get_endpoint(service_type=service_type, service_name=service_name, interface=interface, region_name=region_name) except Exception: raise RuntimeError("Not Authorized") self.http_client = httpclient.SessionClient(service_type=service_type, service_name=service_name, interface=interface, region_name=region_name, session=session, **client_kwargs) self.bays = bays.BayManager(self.http_client) self.certificates = certificates.CertificateManager(self.http_client) self.baymodels = baymodels.BayModelManager(self.http_client) self.containers = containers.ContainerManager(self.http_client) self.pods = pods.PodManager(self.http_client) self.rcs = rcs.ReplicationControllerManager(self.http_client) self.services = services.ServiceManager(self.http_client) self.mservices = mservices.MServiceManager(self.http_client)
def __init__(self, username=None, api_key=None, project_id=None, project_name=None, auth_url=None, magnum_url=None, endpoint_type=None, service_type='container', region_name=None, input_auth_token=None, session=None, password=None, auth_type='password', interface='public', service_name=None): # We have to keep the api_key are for backwards compat, but let's # remove it from the rest of our code since it's not a keystone # concept if not password: password = api_key # Backwards compat for people assing in endpoint_type if endpoint_type: interface = endpoint_type if magnum_url and input_auth_token: auth_type = 'admin_token' session = None loader_kwargs = dict( token=input_auth_token, endpoint=magnum_url) elif input_auth_token and not session: auth_type = 'token' loader_kwargs = dict( token=input_auth_token, auth_url=auth_url, project_id=project_id, project_name=project_name) else: loader_kwargs = dict( username=username, password=password, auth_url=auth_url, project_id=project_id, project_name=project_name) # Backwards compatability for people not passing in Session if session is None: loader = loading.get_plugin_loader(auth_type) # This only supports keystone v2 password auth - but we can # support other auth by passing in a Session, which is the # right thing to do anyway auth_plugin = loader.load_from_options(**loader_kwargs) session = ksa_session.Session(auth=auth_plugin) client_kwargs = {} if magnum_url: client_kwargs['endpoint_override'] = magnum_url if not magnum_url: try: # Trigger an auth error so that we can throw the exception # we always have session.get_endpoint( service_type=service_type, service_name=service_name, interface=interface, region_name=region_name) except Exception: raise RuntimeError("Not Authorized") self.http_client = httpclient.SessionClient( service_type=service_type, service_name=service_name, interface=interface, region_name=region_name, session=session, **client_kwargs) self.bays = bays.BayManager(self.http_client) self.certificates = certificates.CertificateManager(self.http_client) self.baymodels = baymodels.BayModelManager(self.http_client) self.containers = containers.ContainerManager(self.http_client) self.nodes = nodes.NodeManager(self.http_client) self.pods = pods.PodManager(self.http_client) self.rcs = rcs.ReplicationControllerManager(self.http_client) self.services = services.ServiceManager(self.http_client) self.mservices = mservices.MServiceManager(self.http_client)