Beispiel #1
0
def neutron_client():
    """Creates the Neutron client for communicating with Neutron."""
    if not hasattr(app, 'neutron'):
        cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
        cfg.CONF.import_group('keystone_client', 'kuryr.common.config')

        keystone_conf = cfg.CONF.keystone_client
        username = keystone_conf.admin_user
        tenant_name = keystone_conf.admin_tenant_name
        password = keystone_conf.admin_password
        auth_token = keystone_conf.admin_token
        auth_uri = keystone_conf.auth_uri.rstrip('/')

        neutron_uri = cfg.CONF.neutron_client.neutron_uri
        if username and password:
            # Authenticate with password crentials
            app.neutron = utils.get_neutron_client(
                url=neutron_uri, username=username, tenant_name=tenant_name,
                password=password, auth_url=auth_uri)
        else:
            app.neutron = utils.get_neutron_client_simple(
                url=neutron_uri, token=auth_token)

        app.enable_dhcp = cfg.CONF.neutron_client.enable_dhcp
        app.neutron.format = 'json'
Beispiel #2
0
def get_neutron_client():
    """Creates the Neutron client for communicating with Neutron."""
    try:
        # First try to retrieve neutron client from a working OS deployment
        # This is used for gate testing.
        # Since this always use admin credentials, next patch will introduce
        # a config parameter that disable this for production environments
        neutron_client = _get_neutron_client_from_creds()
        return neutron_client
    except Exception:
        pass
    cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
    cfg.CONF.import_group('keystone_client', 'kuryr.common.config')

    keystone_conf = cfg.CONF.keystone_client
    username = keystone_conf.admin_user
    tenant_name = keystone_conf.admin_tenant_name
    password = keystone_conf.admin_password
    auth_token = keystone_conf.admin_token
    auth_uri = keystone_conf.auth_uri.rstrip('/')

    neutron_uri = cfg.CONF.neutron_client.neutron_uri
    if username and password:
        # Authenticate with password crentials
        neutron_client = utils.get_neutron_client(url=neutron_uri,
                                                  username=username,
                                                  tenant_name=tenant_name,
                                                  password=password,
                                                  auth_url=auth_uri)
    else:
        neutron_client = utils.get_neutron_client_simple(url=neutron_uri,
                                                         auth_url=auth_uri,
                                                         token=auth_token)
    return neutron_client
Beispiel #3
0
def get_neutron_client():
    """Creates the Neutron client for communicating with Neutron."""
    try:
        # First try to retrieve neutron client from a working OS deployment
        # This is used for gate testing.
        # Since this always use admin credentials, next patch will introduce
        # a config parameter that disable this for production environments
        neutron_client = _get_neutron_client_from_creds()
        return neutron_client
    except Exception:
            pass
    cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
    cfg.CONF.import_group('keystone_client', 'kuryr.common.config')

    keystone_conf = cfg.CONF.keystone_client
    username = keystone_conf.admin_user
    tenant_name = keystone_conf.admin_tenant_name
    password = keystone_conf.admin_password
    auth_token = keystone_conf.admin_token
    auth_uri = keystone_conf.auth_uri.rstrip('/')
    ca_cert = keystone_conf.auth_ca_cert
    insecure = keystone_conf.auth_insecure

    neutron_uri = cfg.CONF.neutron_client.neutron_uri
    if username and password:
        # Authenticate with password crentials
        neutron_client = utils.get_neutron_client(
            url=neutron_uri, username=username, tenant_name=tenant_name,
            password=password, auth_url=auth_uri,
            ca_cert=ca_cert, insecure=insecure)
    else:
        neutron_client = utils.get_neutron_client_simple(
            url=neutron_uri, auth_url=auth_uri, token=auth_token)
    return neutron_client
Beispiel #4
0
keystone_conf = cfg.CONF.keystone_client
username = keystone_conf.admin_user
tenant_name = keystone_conf.admin_tenant_name
password = keystone_conf.admin_password
auth_token = keystone_conf.admin_token
auth_uri = keystone_conf.auth_uri.rstrip('/')

neutron_uri = cfg.CONF.neutron_client.neutron_uri

if username and password:
    # Authenticate with password crentials
    app.neutron = utils.get_neutron_client(
        url=neutron_uri, username=username, tenant_name=tenant_name,
        password=password, auth_url=auth_uri)
else:
    app.neutron = utils.get_neutron_client_simple(
        url=neutron_uri, token=auth_token)

# TODO(tfukushima): Retrieve the following subnet names from the config file.
SUBNET_POOLS_V4 = [
    p.strip() for p in os.environ.get('SUBNET_POOLS_V4', 'kuryr').split(',')]
SUBNET_POOLS_V6 = [
    p.strip() for p in os.environ.get('SUBNET_POOLS_V6', 'kuryr6').split(',')]

app.neutron.format = 'json'


def _cache_default_subnetpool_ids(app):
    """Caches IDs of the default subnetpools as app.DEFAULT_POOL_IDS."""
    if not hasattr(app, 'DEFAULT_POOL_IDS'):
        default_subnetpool_id_set = set()
        try:
Beispiel #5
0
keystone_conf = cfg.CONF.keystone_client
username = keystone_conf.admin_user
tenant_name = keystone_conf.admin_tenant_name
password = keystone_conf.admin_password
auth_token = keystone_conf.admin_token
auth_uri = keystone_conf.auth_uri.rstrip('/')

neutron_uri = cfg.CONF.neutron_client.neutron_uri

if username and password:
    # Authenticate with password crentials
    app.neutron = utils.get_neutron_client(
        url=neutron_uri, username=username, tenant_name=tenant_name,
        password=password, auth_url=auth_uri)
else:
    app.neutron = utils.get_neutron_client_simple(
        url=neutron_uri, token=auth_token)

# TODO(tfukushima): Retrieve the following subnet names from the config file.
SUBNET_POOLS_V4 = [
    p.strip() for p in os.environ.get('SUBNET_POOLS_V4', 'kuryr').split(',')]
SUBNET_POOLS_V6 = [
    p.strip() for p in os.environ.get('SUBNET_POOLS_V6', 'kuryr6').split(',')]

app.neutron.format = 'json'


def _cache_default_subnetpool_ids(app):
    """Caches IDs of the default subnetpools as app.DEFAULT_POOL_IDS."""
    if not hasattr(app, 'DEFAULT_POOL_IDS'):
        default_subnetpool_id_set = set()
        try: