Пример #1
0
def do_openstack_login(data, issecure):
    try:
        nova = Client(2, data.username, data.password, data.project, data.authurl, insecure=issecure)
        nova.authenticate()
        return nova
    except Unauthorized, e:
        print >> sys.stderr, "Login error: {0}".format(e.message)
        sys.exit(1)
Пример #2
0
def connect(config):
    nova_client = Client('1.1',
                         username=config['username'],
                         project_id=config['tenant'],
                         api_key=config['password'],
                         auth_url=config['auth_url'],
                         endpoint_type=config['endpoint_type'])
    try:
        nova_client.authenticate()
    except Exception as e:
        log_error("Connection failed: %s" % e)
    return nova_client
Пример #3
0
def create_nova_client(user, service_type=None):
    """Creates a rich client for the Nova API using the test config."""
    if test_config.nova_client is None:
        raise SkipTest("No nova_client info specified in the Test Config "
                       "so this test will be skipped.")
    from novaclient.client import Client
    if not service_type:
        service_type = test_config.nova_client['nova_service_type']
    openstack = Client(CONF.nova_client_version, user.auth_user, user.auth_key,
                       user.tenant, test_config.nova_client['auth_url'],
                       service_type=service_type, no_cache=True,
                       cacert=test_config.values.get('cacert', None))
    openstack.authenticate()
    return TestClient(openstack)
Пример #4
0
def create_nova_client(user, service_type=None):
    """Creates a rich client for the Nova API using the test config."""
    if test_config.nova_client is None:
        raise SkipTest("No nova_client info specified in the Test Config "
                       "so this test will be skipped.")
    from novaclient.client import Client
    if not service_type:
        service_type = test_config.nova_client['nova_service_type']
    openstack = Client(CONF.nova_client_version, user.auth_user, user.auth_key,
                       user.tenant, test_config.nova_client['auth_url'],
                       service_type=service_type, no_cache=True,
                       cacert=test_config.values.get('cacert', None))
    openstack.authenticate()
    return TestClient(openstack)
def connect(config):
    try:
        nova_client = Client(
                         version=config['VERSION'],
                         username=config['USERNAME'],
                         api_key=config['PASSWORD'],
                         tenant_id=config['TENANT_ID'],
                         auth_url=config['AUTH_URL'],
                         service_type = config['SERVICE_TYPE']
                         )
    
        nova_client.authenticate()
    except Exception as e:
        print "Connection failed: %s" % e
    return nova_client
Пример #6
0
#!/usr/bin/env python
# example.py
# ==========
#
# This shows how to authenticate to HP Cloud's REST API with a user's access
# key ID and secret key instead of their username and password.  This could be
# used to authenticate to any OpenStack implementation that also uses
# ``apiAccessKeyCredentials`` in the JSON body of the authentication request.
from novaclient.client import Client


ACCESS_KEY_ID = 'FIBVLEKFOSIFJS68FI8L'
SECRET_KEY = 'Mu8E/fsleibv8f2j7G97pzqKusive8ofieFkeNs1'
TENANT_NAME = '[email protected]'
AUTH_URL = 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'
REGION_NAME = 'az-3.region-a.geo-1'

nova = Client('2', 'dummyvalue', 'dummyvalue', TENANT_NAME,
        auth_system='secretkey', auth_url=AUTH_URL, region_name=REGION_NAME)

# the constructor does not accept the plugin values, so the plugin just
# looks for them as attributes of the nova.client object
nova.client.os_access_key_id = ACCESS_KEY_ID
nova.client.os_secret_key = SECRET_KEY

nova.authenticate()

print nova.servers.list()