コード例 #1
0
ファイル: remote.py プロジェクト: pdmars/reddwarf_lite
def create_nova_volume_client(context):
    # Quite annoying but due to a paste config loading bug.
    # TODO(hub-cap): talk to the openstack-common people about this
    PROXY_ADMIN_USER = CONFIG.get('reddwarf_proxy_admin_user', 'admin')
    PROXY_ADMIN_PASS = CONFIG.get('reddwarf_proxy_admin_pass',
                                  '3de4922d8b6ac5a1aad9')
    PROXY_ADMIN_TENANT_NAME = CONFIG.get('reddwarf_proxy_admin_tenant_name',
                                         'admin')
    PROXY_AUTH_URL = CONFIG.get('reddwarf_auth_url',
                                'http://0.0.0.0:5000/v2.0')
    REGION_NAME = CONFIG.get('nova_region_name', 'RegionOne')

    SERVICE_TYPE = CONFIG.get('nova_volume_service_type', 'volume')
    SERVICE_NAME = CONFIG.get('nova_volume_service_name', 'Volume Service')

    #TODO(cp16net) need to fix this proxy_tenant_id
    client = Client(PROXY_ADMIN_USER, PROXY_ADMIN_PASS,
        PROXY_ADMIN_TENANT_NAME, PROXY_AUTH_URL,
        proxy_tenant_id=context.tenant,
        proxy_token=context.auth_tok,
        region_name=REGION_NAME,
        service_type=SERVICE_TYPE,
        service_name=SERVICE_NAME)
    client.authenticate()
    return client
コード例 #2
0
ファイル: models.py プロジェクト: hpcloud/reddwarf_lite
    def get_client(cls, credential, region=None):
        # Quite annoying but due to a paste config loading bug.
        # TODO(hub-cap): talk to the openstack-common people about this
        #PROXY_ADMIN_USER = CONFIG.get('reddwarf_proxy_admin_user', 'admin')
        #PROXY_ADMIN_PASS = CONFIG.get('reddwarf_proxy_admin_pass',
        #                              '3de4922d8b6ac5a1aad9')
        #PROXY_ADMIN_TENANT_NAME = CONFIG.get(
        #                                'reddwarf_proxy_admin_tenant_name',
        #                                'admin')
        PROXY_AUTH_URL = CONFIG.get('reddwarf_auth_url',
                                    'http://0.0.0.0:5000/v2.0')

#        PROXY_AUTH_URL = 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'

        if region is None:
            region = 'az-2.region-a.geo-1'
        
        try:
            client = Client(credential['user_name'], credential['password'],
                credential['tenant_id'], PROXY_AUTH_URL,
                #proxy_tenant_id=context.tenant,
                #proxy_token=context.auth_tok,
                region_name=region,
                #service_type='compute',
                service_name="Compute")
            client.authenticate()
        except Exception:
            LOG.exception("Error authenticating with Novaclient")
            
        return client
コード例 #3
0
def create_nova_client(user, service_type="nova_service_type"):
    """Creates a rich client for the Nova API using the test config."""
    test_config.nova.ensure_started()
    openstack = Client(user.auth_user, user.auth_key,
                       user.tenant, test_config.nova_auth_url,
                       service_type=test_config.values[service_type])
    openstack.authenticate()
    return TestClient(openstack)
コード例 #4
0
def create_nova_client(user, service_type="nova_service_type"):
    """Creates a rich client for the Nova API using the test config."""
    test_config.nova.ensure_started()
    openstack = Client(user.auth_user,
                       user.auth_key,
                       user.tenant,
                       test_config.nova_auth_url,
                       service_type=test_config.values[service_type])
    openstack.authenticate()
    return TestClient(openstack)
コード例 #5
0
ファイル: __init__.py プロジェクト: tattabbum/trove
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.v1_1.client import Client
    if not service_type:
        service_type = test_config.nova_client['nova_service_type']
    openstack = Client(user.auth_user, user.auth_key,
                       user.tenant, test_config.nova_client['auth_url'],
                       service_type=service_type, no_cache=True)
    openstack.authenticate()
    return TestClient(openstack)
コード例 #6
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.v1_1.client import Client
    if not service_type:
        service_type = test_config.nova_client['nova_service_type']
    openstack = Client(user.auth_user, user.auth_key,
                       user.tenant, test_config.nova_client['auth_url'],
                       service_type=service_type, no_cache=True)
    openstack.authenticate()
    return TestClient(openstack)
コード例 #7
0
def nova_client(context):
    client = Client(context.user, context.auth_token,
                    project_id=context.tenant, auth_url=PROXY_AUTH_URL)
    client.client.auth_token = context.auth_token
    client.client.management_url = "%s/%s/" % (COMPUTE_URL, context.tenant)

    return client
コード例 #8
0
ファイル: client.py プロジェクト: jingsu/grinder
def create_cinder_client(config):
    from cinderclient.client import Client
    return Client(1,
                  username=config.os_username,
                  api_key=config.os_password,
                  project_id=config.os_tenant_name,
                  auth_url=config.os_auth_url,
                  region_name=config.os_region_name)
コード例 #9
0
def get_admin_credentials():
    keystone = {}
    keystone['os_username']=env['OS_USERNAME']
    keystone['os_password']=env['OS_PASSWORD']
    keystone['os_auth_url']=env['OS_AUTH_URL']
    keystone['os_tenant_name']=env['OS_TENANT_NAME']

    return Client(**keystone)
コード例 #10
0
def get_client():
    args = [NOVA_USERNAME, NOVA_PASSWORD, NOVA_PROJECT_ID, NOVA_URL]
    kwargs = {}
    kwargs['region_name'] = NOVA_REGION_NAME
    kwargs['service_type'] = 'compute'
    from novaclient.v1_1.client import Client
    client = Client(*args, **kwargs)
    return client
コード例 #11
0
def create_nova_volume_client(context):
    # Quite annoying but due to a paste config loading bug.
    # TODO(hub-cap): talk to the openstack-common people about this
    client = Client(context.user, context.auth_token,
                    project_id=context.tenant, auth_url=PROXY_AUTH_URL)
    client.client.auth_token = context.auth_token
    client.client.management_url = "%s/%s/" % (VOLUME_URL, context.tenant)

    return client
コード例 #12
0
def create_nova_client(context):
    COMPUTE_URL = CONFIG.get('nova_compute_url', 'http://localhost:8774/v2')
    PROXY_AUTH_URL = CONFIG.get('reddwarf_auth_url',
                                'http://0.0.0.0:5000/v2.0')
    client = Client(context.user, context.auth_tok, project_id=context.tenant,
                    auth_url=PROXY_AUTH_URL)
    client.client.auth_token = context.auth_tok
    client.client.management_url = "%s/%s/" % (COMPUTE_URL, context.tenant)

    return client
コード例 #13
0
ファイル: models.py プロジェクト: imsplitbit/reddwarf_lite
    def get_client(cls, context):
        # Quite annoying but due to a paste config loading bug.
        # TODO(hub-cap): talk to the openstack-common people about this
        PROXY_ADMIN_USER = CONFIG.get('reddwarf_proxy_admin_user', 'admin')
        PROXY_ADMIN_PASS = CONFIG.get('reddwarf_proxy_admin_pass',
                                      '3de4922d8b6ac5a1aad9')
        PROXY_ADMIN_TENANT_NAME = CONFIG.get(
                                        'reddwarf_proxy_admin_tenant_name',
                                        'admin')
        PROXY_AUTH_URL = CONFIG.get('reddwarf_auth_url',
                                    'http://0.0.0.0:5000/v2.0')

        client = Client(PROXY_ADMIN_USER, PROXY_ADMIN_PASS,
            PROXY_ADMIN_TENANT_NAME, PROXY_AUTH_URL,
            proxy_tenant_id=context.tenant,
            proxy_token=context.auth_tok,
            region_name='RegionOne',
            service_type='compute',
            service_name="'Compute Service'")
        client.authenticate()
        return client
コード例 #14
0
def create_nova_volume_client(context):
    # Quite annoying but due to a paste config loading bug.
    # TODO(hub-cap): talk to the openstack-common people about this
    VOLUME_URL = CONFIG.get('nova_volume_url', 'http://localhost:8776/v2')
    PROXY_AUTH_URL = CONFIG.get('reddwarf_auth_url',
                                'http://0.0.0.0:5000/v2.0')
    client = Client(context.user, context.auth_tok,
                    project_id=context.tenant, auth_url=PROXY_AUTH_URL)
    client.client.auth_token = context.auth_tok
    client.client.management_url = "%s/%s/" % (VOLUME_URL, context.tenant)

    return client
コード例 #15
0
ファイル: launch-node.py プロジェクト: dhiana/system-config
def get_client():
    args = [NOVA_USERNAME, NOVA_PASSWORD, NOVA_PROJECT_ID, NOVA_URL]
    kwargs = {}
    kwargs['region_name'] = NOVA_REGION_NAME
    kwargs['service_type'] = 'compute'
    kwargs['service_name'] = NOVA_SERVICE_NAME

    if NOVACLIENT_INSECURE:
        kwargs['insecure'] = True

    from novaclient.v1_1.client import Client
    client = Client(*args, **kwargs)
    return client
コード例 #16
0
 def __init__(self):
     '''
         Get nova client object by admin user.
     '''
     try:
         self.nova_client = Client(FLAGS.novaclient_username,
                                   FLAGS.novaclient_password,
                                   FLAGS.novaclient_projectName,
                                   FLAGS.novaclient_keystoneUrl,
                                   service_type='compute')
     except Exception:
         LOG.exception(
             _("Error during get nova client exception. Maybe "
               "cause of error auth for keystone"))
         self.nova_client = None
コード例 #17
0
def nova_client(context):
    if CONF.nova_compute_url:
        url = '%(nova_url)s%(tenant)s' % {
            'nova_url': normalize_url(CONF.nova_compute_url),
            'tenant': context.tenant}
    else:
        url = get_endpoint(context.service_catalog,
                           service_type=CONF.nova_compute_service_type,
                           endpoint_region=CONF.os_region_name,
                           endpoint_type=CONF.nova_compute_endpoint_type)

    client = Client(context.user, context.auth_token,
                    project_id=context.tenant, auth_url=PROXY_AUTH_URL)
    client.client.auth_token = context.auth_token
    client.client.management_url = url
    return client
コード例 #18
0
ファイル: wic_client.py プロジェクト: pubfox/webservices
 def __init__(self, tenant=default_tenant):
     body = {
         "auth": {
             "passwordCredentials": {
                 "username": osuser,
                 "password": ospassword
             }
         }
     }
     body['auth']['tenantName'] = tenant
     body = json.dumps(body)
     headers = {
         'Content-Type': 'application/json',
         'Accept': 'application/json',
         'User-Agent': 'client'
     }
     http = httplib2.Http()
     resp, body = http.request(token_uri,
                               method="POST",
                               body=body,
                               headers=headers)
     if not resp.status == 200:
         print "Error status: %d" % resp.status
         sys.exit(1)
     data = json.loads(body)
     self.apitoken = data['access']['token']['id']
     self.volumeurl = data['access']['serviceCatalog'][0]['endpoints'][0][
         'publicURL']
     self.apiurl = data['access']['serviceCatalog'][2]['endpoints'][0][
         'publicURL']
     self.tenant_id = data['access']['token']['tenant']['id']
     self.headers = {
         'X-Auth-Project-Id': tenant,
         'User-Agent': 'python-novaclient',
         'Content-Type': 'application/json',
         'Accept': 'application/json',
         'X-Auth-Token': self.apitoken
     }
     self.key_uri = key_uri
     self.host_map = {}
     self.img_dict = {}
     self.ins_list = []
     self.flavor_ls = []
     self.host_len = wic_utils.get_hostmap(self.host_map)
     self.client = Client(osuser, ospassword, default_tenant, auth_uri)
コード例 #19
0
ファイル: client.py プロジェクト: jingsu/grinder
def create_nova_client(config):
    '''Creates a nova Client from the environment variables.'''
    from novaclient import shell
    extensions = shell.OpenStackComputeShell()._discover_extensions("1.1")
    if not set([
            'gridcentric', 'cobalt', 'gridcentric_python_novaclient_ext',
            'cobalt_python_novaclient_ext'
    ]) & set([e.name for e in extensions]):
        raise Exception("You don\'t have the gridcentric extension installed." \
                        "Try 'pip install gridcentric-python-novaclient-ext'.")
    from novaclient.v1_1.client import Client
    return Client(extensions=extensions,
                  username=config.os_username,
                  api_key=config.os_password,
                  project_id=config.os_tenant_name,
                  auth_url=config.os_auth_url,
                  region_name=config.os_region_name,
                  no_cache=os.environ.get('OS_NO_CACHE', 0) and True,
                  http_log_debug=config.http_log_debug)
コード例 #20
0
ファイル: mysql.py プロジェクト: imsplitbit/reddwarf_lite
 def get_client(self, req):
     proxy_token = req.headers["X-Auth-Token"]
     client = Client(self.proxy_admin_user, self.proxy_admin_pass,
         self.proxy_admin_tenant_name, self.auth_url, token=proxy_token)
     client.authenticate()
     return client
コード例 #21
0
def network_name_to_id(network_name, username, password, tenant_name,
                       auth_url):
    nt = Client(username, password, tenant_name, auth_url)
    return nt.networks.find(label=network_name).id
コード例 #22
0
def flavor_name_to_id(flavor_name, username, password, tenant_name, auth_url):
    nt = Client(username, password, tenant_name, auth_url)
    return nt.flavors.find(name=flavor_name).id
コード例 #23
0
def image_name_to_id(image_name, username, password, tenant_name, auth_url):
    nt = Client(username, password, tenant_name, auth_url)
    return nt.images.find(name=image_name).id
コード例 #24
0
from novaclient.v1_1.client import Client
c = Client(username='******',
           api_key = 'ENTER_KEY',
           project_id='ENTER_PROJECT_ID',
           auth_url='ENTER_AUTH_URL',
           region_name='ENTER_REGION_NAME',
           http_log_debug=True)

clean_servers = [
    'webserver-host',
    'postgres-host'
]

for server in c.servers.list():
    if server.name in clean_servers:
        print 'removing', server
        server.delete()
コード例 #25
0
ファイル: cleanup_vm_nova.py プロジェクト: tedwardia/copr
def get_client(conf):
    return Client(username=conf["OS_USERNAME"],
                  api_key=conf["OS_PASSWORD"],
                  project_id=conf["OS_TENANT_NAME"],
                  auth_url=conf["OS_AUTH_URL"],
                  insecure=True)
コード例 #26
0
ファイル: orchestrator.py プロジェクト: changbl/inception
    def __init__(self, prefix, num_workers, atomic, parallel, chef_repo,
                 chef_repo_branch, sdn, ssh_keyfile, pool, user, image,
                 chefserver_image, flavor, gateway_flavor, key_name,
                 security_groups, src_dir, dst_dir, userdata, timeout,
                 poll_interval):
        """
        For doc on each param refer to orchestrator_opts
        """
        ## check args
        if CONCAT_CHAR in prefix:
            raise ValueError('"%s" cannot exist in prefix=%r' %
                             (CONCAT_CHAR, prefix))
        ## args
        self.prefix = prefix
        self.num_workers = num_workers
        self.atomic = atomic
        self.parallel = parallel
        self.chef_repo = chef_repo
        self.chef_repo_branch = chef_repo_branch
        self.sdn = sdn
        self.ssh_keyfile = ssh_keyfile
        self.pool = pool
        self.user = user
        self.image = image
        self.chefserver_image = chefserver_image
        self.flavor = flavor
        self.gateway_flavor = gateway_flavor
        self.key_name = key_name
        self.security_groups = security_groups
        self.src_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    src_dir)
        self.dst_dir = os.path.abspath(dst_dir)
        with open(os.path.join(self.src_dir, userdata), 'r') as fin:
            self.userdata = fin.read()
        self.timeout = timeout
        self.poll_interval = poll_interval
        # Inject the extra ssh public key if any
        ssh_keycontent = ''
        if self.ssh_keyfile:
            with open(self.ssh_keyfile, 'r') as fin:
                ssh_keycontent = fin.read()
        self.userdata = self.userdata % (user, ssh_keycontent)
        # scripts to run on chefserver, execute one by one (sequence matters)
        self.chefserver_commands = []
        self.chefserver_files = OrderedDict()
        for filename in ('install_chefserver.sh', 'configure_knife.sh',
                         'setup_chef_repo.sh'):
            src_file = os.path.join(self.src_dir, filename)
            dst_file = os.path.join(self.dst_dir, filename)
            if filename == 'setup_chef_repo.sh':
                # add two args to this command
                command = ("/bin/bash" + " " + dst_file + " " +
                           self.chef_repo + " " + self.chef_repo_branch)
            else:
                command = "/bin/bash" + " " + dst_file
            self.chefserver_commands.append(command)
            with open(src_file, 'r') as fin:
                value = fin.read()
                key = dst_file
                self.chefserver_files[key] = value
        ## non-args
        self.client = Client(os.environ['OS_USERNAME'],
                             os.environ['OS_PASSWORD'],
                             os.environ['OS_TENANT_NAME'],
                             os.environ['OS_AUTH_URL'])

        # If the password offered is actually a 32 byte hex digit string
        # then it's probably a token
        if re.match('\A[\da-fA-F]{32}\Z', os.environ['OS_PASSWORD']):
            self.client.client.auth_token = os.environ['OS_PASSWORD']

        self._gateway_id = None
        self._gateway_ip = None
        self._gateway_name = None
        self._chefserver_id = None
        self._chefserver_ip = None
        self._chefserver_name = None
        self._controller_id = None
        self._controller_ip = None
        self._controller_name = None
        self._worker_ids = []
        self._worker_ips = []
        self._worker_names = []
        self._gateway_floating_ip = None
コード例 #27
0
def nova_client(context):
    client = Client(USER, PASSWORD, project_id=PROJECT, auth_url=ID_URL)

    return client