예제 #1
0
파일: swift.py 프로젝트: openstack/smaug
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
예제 #2
0
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
예제 #3
0
파일: nova.py 프로젝트: yinweiishere/karbor
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
예제 #4
0
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
예제 #5
0
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)
예제 #6
0
파일: glance.py 프로젝트: openstack/smaug
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)
예제 #7
0
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)
예제 #8
0
파일: neutron.py 프로젝트: openstack/smaug
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)
예제 #9
0
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
예제 #10
0
파일: nova.py 프로젝트: openstack/smaug
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