예제 #1
0
 def __init__(self, controller_ip, user, password, tenant):
     self.controller_ip = controller_ip
     auth_url = 'http://{0}:5000/v2.0/'.format(self.controller_ip)
     LOGGER.debug('Auth URL is {0}'.format(auth_url))
     self.nova = novaclient(username=user,
                            api_key=password,
                            project_id=tenant,
                            auth_url=auth_url)
     self.keystone = keystoneclient(username=user,
                                    password=password,
                                    tenant_name=tenant,
                                    auth_url=auth_url)
     self.cinder = cinderclient.Client(1, user, password,
                                       tenant, auth_url)
     self.neutron = neutronclient.Client(
         username=user,
         password=password,
         tenant_name=tenant,
         auth_url=auth_url)
     token = self.keystone.auth_token
     LOGGER.debug('Token is {0}'.format(token))
     glance_endpoint = self.keystone.service_catalog.url_for(
         service_type='image', endpoint_type='publicURL')
     LOGGER.debug('Glance endpoind is {0}'.format(glance_endpoint))
     self.glance = glanceclient(endpoint=glance_endpoint, token=token)
예제 #2
0
 def __init__(self, controller_ip, user, password, tenant):
     self.controller_ip = controller_ip
     auth_url = 'http://{0}:5000/v2.0/'.format(self.controller_ip)
     LOGGER.debug('Auth URL is {0}'.format(auth_url))
     self.nova = novaclient(username=user,
                            api_key=password,
                            project_id=tenant,
                            auth_url=auth_url)
     self.keystone = keystoneclient(username=user,
                                    password=password,
                                    tenant_name=tenant,
                                    auth_url=auth_url)
     self.cinder = cinderclient.Client(1, user, password,
                                       tenant, auth_url)
     token = self.keystone.auth_token
     LOGGER.debug('Token is {0}'.format(token))
     glance_endpoint = self.keystone.service_catalog.url_for(
         service_type='image', endpoint_type='publicURL')
     LOGGER.debug('Glance endpoind is {0}'.format(glance_endpoint))
     self.glance = glanceclient(endpoint=glance_endpoint, token=token)
 def image_import(self, properties, local_path, image, image_name):
     LOGGER.debug('Import image {0}/{1} to glance'.
                  format(local_path, image))
     auth_url = self._get_auth_url()
     LOGGER.debug('Auth URL is {0}'.format(auth_url))
     keystone = keystoneclient(username=settings.SERVTEST_USERNAME,
                               password=settings.SERVTEST_PASSWORD,
                               tenant_name=settings.SERVTEST_TENANT,
                               auth_url=auth_url)
     token = keystone.auth_token
     LOGGER.debug('Token is {0}'.format(token))
     glance_endpoint = keystone.service_catalog.url_for(
         service_type='image', endpoint_type='publicURL')
     LOGGER.debug('Glance endpoind is {0}'.format(glance_endpoint))
     glance = glanceclient(endpoint=glance_endpoint, token=token)
     LOGGER.debug('Importing {0}'.format(image))
     with open(os.path.expanduser('{0}/{1}'.format(local_path,
                                                   image))) as fimage:
         glance.images.create(name=image_name, is_public=True,
                              disk_format='qcow2',
                              container_format='bare', data=fimage,
                              properties=properties)