Esempio n. 1
0
def get_conn():
    '''
    Return a conn object for the passed VM data
    '''
    vm_ = get_configured_provider()

    kwargs = vm_.copy()  # pylint: disable=E1103

    kwargs['username'] = vm_['user']
    kwargs['project_id'] = vm_['tenant']
    kwargs['auth_url'] = vm_['identity_url']
    kwargs['region_name'] = vm_['compute_region']
    kwargs['use_keystoneauth'] = vm_.get('use_keystoneauth', False)

    if 'password' in vm_:
        kwargs['password'] = vm_['password']

    if 'verify' in vm_ and vm_['use_keystoneauth'] is True:
        kwargs['verify'] = vm_['verify']
    elif 'verify' in vm_ and vm_['use_keystoneauth'] is False:
        log.warning(
            'SSL Certificate verification option is specified but use_keystoneauth is False or not present'
        )
    conn = nova.SaltNova(**kwargs)

    return conn
Esempio n. 2
0
def _auth(profile=None):
    '''
    Set up nova credentials
    '''
    if profile:
        credentials = __salt__['config.option'](profile)
        user = credentials['keystone.user']
        password = credentials['keystone.password']
        tenant = credentials['keystone.tenant']
        auth_url = credentials['keystone.auth_url']
        region_name = credentials.get('keystone.region_name', None)
        api_key = credentials.get('keystone.api_key', None)
        os_auth_system = credentials.get('keystone.os_auth_system', None)
    else:
        user = __salt__['config.option']('keystone.user')
        password = __salt__['config.option']('keystone.password')
        tenant = __salt__['config.option']('keystone.tenant')
        auth_url = __salt__['config.option']('keystone.auth_url')
        region_name = __salt__['config.option']('keystone.region_name')
        api_key = __salt__['config.option']('keystone.api_key')
        os_auth_system = __salt__['config.option']('keystone.os_auth_system')
    kwargs = {
        'username': user,
        'password': password,
        'api_key': api_key,
        'project_id': tenant,
        'auth_url': auth_url,
        'region_name': region_name,
        'os_auth_plugin': os_auth_system
    }

    return suon.SaltNova(**kwargs)
Esempio n. 3
0
def _auth(profile=None):
    """
    Set up nova credentials
    """
    if profile:
        credentials = __salt__["config.option"](profile)
        user = credentials["keystone.user"]
        password = credentials["keystone.password"]
        tenant = credentials["keystone.tenant"]
        auth_url = credentials["keystone.auth_url"]
        region_name = credentials.get("keystone.region_name", None)
        api_key = credentials.get("keystone.api_key", None)
        os_auth_system = credentials.get("keystone.os_auth_system", None)
        use_keystoneauth = credentials.get("keystone.use_keystoneauth", False)
        verify = credentials.get("keystone.verify", None)
    else:
        user = __salt__["config.option"]("keystone.user")
        password = __salt__["config.option"]("keystone.password")
        tenant = __salt__["config.option"]("keystone.tenant")
        auth_url = __salt__["config.option"]("keystone.auth_url")
        region_name = __salt__["config.option"]("keystone.region_name")
        api_key = __salt__["config.option"]("keystone.api_key")
        os_auth_system = __salt__["config.option"]("keystone.os_auth_system")
        use_keystoneauth = __salt__["config.option"](
            "keystone.use_keystoneauth")
        verify = __salt__["config.option"]("keystone.verify")

    if use_keystoneauth is True:
        project_domain_name = credentials["keystone.project_domain_name"]
        user_domain_name = credentials["keystone.user_domain_name"]

        kwargs = {
            "username": user,
            "password": password,
            "project_id": tenant,
            "auth_url": auth_url,
            "region_name": region_name,
            "use_keystoneauth": use_keystoneauth,
            "verify": verify,
            "project_domain_name": project_domain_name,
            "user_domain_name": user_domain_name,
        }
    else:
        kwargs = {
            "username": user,
            "password": password,
            "api_key": api_key,
            "project_id": tenant,
            "auth_url": auth_url,
            "region_name": region_name,
            "os_auth_plugin": os_auth_system,
        }

    return suon.SaltNova(**kwargs)
Esempio n. 4
0
def get_conn():
    '''
    Return a conn object for the passed VM data
    '''
    vm_ = get_configured_provider()

    kwargs = {
        'username': vm_['user'],
        'api_key': vm_['password'],
        'project_id': vm_['tenant'],
        'auth_url': vm_['identity_url'],
        'region_name': vm_['compute_region']
    }

    return nova.SaltNova(**kwargs)
Esempio n. 5
0
def get_conn():
    '''
    Return a conn object for the passed VM data
    '''
    vm_ = get_configured_provider()

    kwargs = vm_.copy()  # pylint: disable=E1103

    kwargs['username'] = vm_['user']
    kwargs['project_id'] = vm_['tenant']
    kwargs['auth_url'] = vm_['identity_url']
    kwargs['region_name'] = vm_['compute_region']

    if 'password' in vm_:
        kwargs['password'] = vm_['password']

    conn = nova.SaltNova(**kwargs)

    return conn
Esempio n. 6
0
def _auth(profile=None, **kwargs):
    '''
    Set up nova credentials
    '''
    keystone_api_args = None
    if kwargs is not None:
        if kwargs.get('keystone_api_args') is not None:
            keystone_api_args = kwargs['keystone_api_args']

    if profile:
        credentials = __salt__['config.option'](profile)
        user = credentials['keystone.user']
        password = credentials['keystone.password']
        tenant = credentials['keystone.tenant']
        auth_url = credentials['keystone.auth_url']
        region_name = credentials.get('keystone.region_name', None)
        api_key = credentials.get('keystone.api_key', None)
        os_auth_system = credentials.get('keystone.os_auth_system', None)
        use_keystoneauth = credentials.get('keystone.use_keystoneauth', False)
    else:
        user = __salt__['config.option']('keystone.user')
        password = __salt__['config.option']('keystone.password')
        tenant = __salt__['config.option']('keystone.tenant')
        auth_url = __salt__['config.option']('keystone.auth_url')
        region_name = __salt__['config.option']('keystone.region_name')
        api_key = __salt__['config.option']('keystone.api_key')
        os_auth_system = __salt__['config.option']('keystone.os_auth_system')
        use_keystoneauth = __salt__['config.option'](
            'keystone.use_keystoneauth')

    # Override pillar settings with settings provided by module argument
    if keystone_api_args:
        user = keystone_api_args.get('user', user)
        password = keystone_api_args.get('password', password)
        tenant = keystone_api_args.get('tenant', tenant)
        auth_url = keystone_api_args.get('auth_url', auth_url)
        region_name = keystone_api_args.get('region_name', region_name)
        api_key = keystone_api_args.get('api_key', api_key)
        os_auth_system = keystone_api_args.get('os_auth_system',
                                               os_auth_system)
        use_keystoneauth = keystone_api_args.get('use_keystoneauth',
                                                 use_keystoneauth)

    if use_keystoneauth is True:
        if profile:
            credentials = __salt__['config.option'](profile)
            project_id = credentials.get('keystone.project_id', None)
            project_name = credentials.get('keystone.project_name', None)
            user_domain_name = credentials.get('keystone.user_domain_name',
                                               None)
            project_domain_name = credentials.get(
                'keystone.project_domain_name', None)
            verify = credentials.get('keystone.verify', None)
        else:
            project_id = __salt__['config.option']('keystone.project_id')
            project_name = __salt__['config.option']('keystone.project_name')
            user_domain_name = __salt__['config.option'](
                'keystone.user_domain_name')
            project_domain_name = __salt__['config.option'](
                'keystone.project_domain_name')
            verify = __salt__['config.option']('keystone.verify')

        # Override pillar settings with settings provided by module argument
        if keystone_api_args:
            project_id = keystone_api_args.get('project_id', project_id)
            project_name = keystone_api_args.get('project_name', project_name)
            user_domain_name = keystone_api_args.get('user_domain_name',
                                                     user_domain_name)
            project_domain_name = keystone_api_args.get(
                'project_domain_name', project_domain_name)
            verify = keystone_api_args.get('verify', verify)

        send_kwargs = {
            'username': user,
            'password': password,
            'project_id': project_id,
            'auth_url': auth_url,
            'region_name': region_name,
            'use_keystoneauth': use_keystoneauth,
            'verify': verify,
            'project_name': project_name,
            'project_domain_name': project_domain_name,
            'user_domain_name': user_domain_name
        }
    else:
        send_kwargs = {
            'username': user,
            'password': password,
            'api_key': api_key,
            'project_id': tenant,
            'auth_url': auth_url,
            'region_name': region_name,
            'os_auth_plugin': os_auth_system
        }
    log.debug('SEND_KWARGS: %s', send_kwargs)
    return suon.SaltNova(**send_kwargs)