def create(context, conf): register_opts(conf) if hasattr(conf.swift_client, 'swift_auth_url') and \ conf.swift_client.swift_auth_url: connection = swift.Connection( authurl=conf.swift_client.swift_auth_url, auth_version=conf.swift_client.swift_auth_version, tenant_name=conf.swift_client.swift_tenant_name, user=conf.swift_client.swift_user, key=conf.swift_client.swift_key, retries=conf.swift_client.swift_retry_attempts, starting_backoff=conf.swift_client.swift_retry_backoff, insecure=conf.swift_client.swift_auth_insecure, cacert=conf.swift_client.swift_ca_cert_file) else: try: url = utils.get_url(SERVICE, context, conf, append_project_fmt='%(url)s/AUTH_%(project)s') except Exception: LOG.error(_LE("Get swift service endpoint url failed")) raise LOG.info(_LI("Creating swift client with url %s."), url) connection = swift.Connection( preauthurl=url, preauthtoken=context.auth_token, retries=conf.swift_client.swift_retry_attempts, starting_backoff=conf.swift_client.swift_retry_backoff, insecure=conf.swift_client.swift_auth_insecure, cacert=conf.swift_client.swift_ca_cert_file) return connection
def create_heat_client_with_tenant(context, conf): cacert = conf.heat_client.heat_ca_cert_file insecure = conf.heat_client.heat_auth_insecure conf.register_opts(heat_client_opts, group=SERVICE + '_client') try: url = utils.get_url(SERVICE, context, conf, append_project_fmt='%(url)s/%(project)s') except Exception: LOG.error(_LE("Get heat service endpoint url failed.")) raise try: LOG.info(_LI('Creating heat client with url %s.'), url) heat = hc.Client(HEATCLIENT_VERSION, endpoint=url, token=context.auth_token, cacert=cacert, insecure=insecure) return heat except Exception: LOG.error(_LE('Creating heat client with endpoint fails.')) raise
def create(context, conf): conf.register_opts(nova_client_opts, group=SERVICE + '_client') try: url = utils.get_url(SERVICE, context, conf, append_project_fmt='%(url)s/%(project)s') except Exception: LOG.error(_LE("Get nova service endpoint url failed.")) raise LOG.info(_LI('Creating nova client with url %s.'), url) extensions = nc.discover_extensions(NOVACLIENT_VERSION) args = { 'project_id': context.project_id, 'auth_token': context.auth_token, 'extensions': extensions, 'cacert': conf.nova_client.nova_ca_cert_file, 'insecure': conf.nova_client.nova_auth_insecure, } client = nc.Client(NOVACLIENT_VERSION, **args) client.client.set_management_url(url) return client
def create(context, conf): conf.register_opts(glance_client_opts, group=SERVICE + '_client') try: url = utils.get_url(SERVICE, context, conf) except Exception: LOG.error(_LE("Get glance service endpoint url failed")) raise LOG.info(_LI("Creating glance client with url %s."), url) args = { 'endpoint': url, 'token': context.auth_token, 'cacert': conf.glance_client.glance_ca_cert_file, 'insecure': conf.glance_client.glance_auth_insecure, } return gc.Client(GLANCECLIENT_VERSION, **args)
def create(context, conf): conf.register_opts(neutron_client_opts, group=SERVICE + '_client') try: url = utils.get_url(SERVICE, context, conf) except Exception: LOG.error(_LE("Get neutron service endpoint url failed")) raise LOG.info(_LI("Creating neutron client with url %s."), url) args = { 'endpoint_url': url, 'token': context.auth_token, 'cacert': conf.neutron_client.neutron_ca_cert_file, 'insecure': conf.neutron_client.neutron_auth_insecure, } return neutron_client.Client(**args)
def create(context, conf): conf.register_opts(cinder_client_opts, group=SERVICE + '_client') try: url = utils.get_url(SERVICE, context, conf, append_project_fmt='%(url)s/%(project)s') except Exception: LOG.error(_LE("Get cinder service endpoint url failed.")) raise LOG.info(_LI('Creating cinder client with url %s.'), url) args = { 'project_id': context.project_id, 'cacert': conf.cinder_client.cinder_ca_cert_file, 'insecure': conf.cinder_client.cinder_auth_insecure, } client = cc.Client(CINDERCLIENT_VERSION, **args) client.client.auth_token = context.auth_token client.client.management_url = url return client
def create(context, conf): conf.register_opts(nova_client_opts, group=SERVICE + "_client") try: url = utils.get_url(SERVICE, context, conf, append_project_fmt="%(url)s/%(project)s") except Exception: LOG.error(_LE("Get nova service endpoint url failed.")) raise LOG.info(_LI("Creating nova client with url %s."), url) extensions = nc.discover_extensions(NOVACLIENT_VERSION) args = { "project_id": context.project_id, "auth_token": context.auth_token, "extensions": extensions, "cacert": conf.nova_client.nova_ca_cert_file, "insecure": conf.nova_client.nova_auth_insecure, } client = nc.Client(NOVACLIENT_VERSION, **args) client.client.set_management_url(url) return client