Example #1
0
    def _get_keystoneclient(self, username, password, tenant_name, auth_url,
                            retries=3, ca_cert=None):
        keystone = None
        for i in range(retries):
            try:
                if ca_cert:
                    keystone = keystoneclient(username=username,
                                              password=password,
                                              tenant_name=tenant_name,
                                              auth_url=auth_url,
                                              cacert=ca_cert)

                else:
                    keystone = keystoneclient(username=username,
                                              password=password,
                                              tenant_name=tenant_name,
                                              auth_url=auth_url)
                break
            except ClientException as e:
                err = "Try nr {0}. Could not get keystone client, error: {1}"
                LOGGER.warning(err.format(i + 1, e))
                time.sleep(5)
        if not keystone:
            raise
        return keystone
Example #2
0
    def test_003_check_default_keystone_credential_usage(self):
            """Check usage of default credentials for keystone on master node
            Target component: Configuration

            Scenario:
                1. Check default credentials for keystone on master node are
                 changed.
            Duration: 20 s.
             Available since release: 2015.1.0-7.0
            """

            usr = self.config.master.keystone_user
            pwd = self.config.master.keystone_password
            url = 'http://{0}:5000/v2.0'.format(self.config.nailgun_host)

            try:
                keystone = keystoneclient(username=usr,
                                          password=pwd,
                                          auth_url=url)
                keystone.authenticate()
            except k_exceptions.Unauthorized:
                pass
            else:
                self.fail('Step 1 failed: Default credentials '
                          'for keystone on master node were not changed')
Example #3
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)
 def __init__(self, root_url, creds, headers=None, echo=False,
              admin_node_ip=None):
     super(KeystoneAuth, self).__init__(root_url, headers, echo)
     self.keystone_url = "http://{0}:5000/v2.0".format(admin_node_ip)
     self.keystone = keystoneclient(
         auth_url=self.keystone_url, **creds)
     self.refresh_token()
Example #5
0
 def __init__(self, root_url, creds, headers=None, echo=False,
              admin_node_ip=None):
     super(KeystoneAuth, self).__init__(root_url, headers, echo)
     self.keystone_url = "http://{0}:5000/v2.0".format(admin_node_ip)
     self.keystone = keystoneclient(
         auth_url=self.keystone_url, **creds)
     self.refresh_token()
 def __init__(self, root_url, creds, headers=None):
     super(KeystoneAuth, self).__init__(root_url, headers)
     admin_node_ip = urlparse.urlparse(root_url).hostname
     self.keystone_url = "http://{0}:5000/v2.0".format(admin_node_ip)
     self.keystone = keystoneclient(
         auth_url=self.keystone_url, **creds)
     self.refresh_token()
Example #7
0
 def __init__(self, admin_node_ip, **kwargs):
     self.url = "http://{0}:8000".format(admin_node_ip)
     keystone_url = "http://{0}:5000/v2.0".format(admin_node_ip)
     ksclient = keystoneclient(auth_url=keystone_url, **kwargs)
     self.headers = {
         "X-Auth-Token": ksclient.auth_token,
         "Content-Type": "application/json"
     }
 def authenticate(self):
     try:
         logger.info("Initialize keystoneclient with url %s", self.keystone_url)
         self.keystone = keystoneclient(auth_url=self.keystone_url, **self.creds)
         # it depends on keystone version, some versions doing auth
         # explicitly some dont, but we are making it explicitly always
         self.keystone.authenticate()
         logger.debug("Authorization token is successfully updated")
     except exceptions.AuthorizationFailure:
         logger.warning("Cant establish connection to keystone with url %s", self.keystone_url)
Example #9
0
 def setUpClass(cls):
     super(CloneEnvTests, cls).setUpClass()
     cls.url = "http://10.20.0.2:8000"
     keystone_url = "http://10.20.0.2:5000/v2.0"
     cls.endpoint = urlparse.urljoin(cls.url,
                                     "api/clusters/1/upgrade/clone")
     ksclient = keystoneclient(auth_url=keystone_url, username="******",
                               password="******", tenant_name="admin")
     cls.headers = {"X-Auth-Token": ksclient.auth_token,
                    "Content-Type": "application/json"}
     cls.clusters = []
 def authenticate(self):
     try:
         logger.info('Initialize keystoneclient with url %s',
                     self.keystone_url)
         self.keystone = keystoneclient(auth_url=self.keystone_url,
                                        **self.creds)
         # it depends on keystone version, some versions doing auth
         # explicitly some dont, but we are making it explicitly always
         self.keystone.authenticate()
         logger.debug('Authorization token is successfully updated')
     except exceptions.AuthorizationFailure:
         logger.warning('Cant establish connection to keystone with url %s',
                        self.keystone_url)
Example #11
0
 def setUpClass(cls):
     super(CloneEnvTests, cls).setUpClass()
     cls.url = "http://10.20.0.2:8000"
     keystone_url = "http://10.20.0.2:5000/v2.0"
     cls.endpoint = urlparse.urljoin(cls.url,
                                     "api/clusters/1/upgrade/clone")
     ksclient = keystoneclient(auth_url=keystone_url,
                               username="******",
                               password="******",
                               tenant_name="admin")
     cls.headers = {
         "X-Auth-Token": ksclient.auth_token,
         "Content-Type": "application/json"
     }
     cls.clusters = []
Example #12
0
 def authenticate(self):
     try:
         logger.info('Initialize keystoneclient with url %s',
                     self.keystone_url)
         self.keystone = keystoneclient(
             auth_url=self.keystone_url, **self.creds)
         # it depends on keystone version, some versions doing auth
         # explicitly some dont, but we are making it explicitly always
         self.keystone.authenticate()
         return self.keystone
     except exceptions.AuthorizationFailure:
         logger.warning(
             'Cant establish connection to keystone with url %s',
             self.keystone_url)
         self.keystone = None
Example #13
0
 def __post_data_to_nailgun(self, url, data, user, password):
     ksclient = keystoneclient(
         auth_url=magic_consts.KEYSTONE_API_URL,
         username=user,
         password=password,
         tenant_name=magic_consts.KEYSTONE_TENANT_NAME,
     )
     resp = requests.post(urlparse.urljoin(magic_consts.NAILGUN_URL, url),
                          json.dumps(data),
                          headers={
                              "X-Auth-Token": ksclient.auth_token,
                              "Content-Type": "application/json",
                          })
     LOG.debug(resp.content)
     return resp
 def __post_data_to_nailgun(self, url, data, password):
     ksclient = keystoneclient(
         auth_url=magic_consts.KEYSTONE_API_URL,
         username=magic_consts.KEYSTONE_USERNAME,
         password=password,
         tenant_name=magic_consts.KEYSTONE_TENANT_NAME,
     )
     resp = requests.post(
         urlparse.urljoin(magic_consts.NAILGUN_URL, url),
         json.dumps(data),
         headers={
             "X-Auth-Token": ksclient.auth_token,
             "Content-Type": "application/json",
         })
     LOG.debug(resp.content)
     return resp
Example #15
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)
 def __init__(self, root_url, creds, headers=None):
     super(KeystoneAuth, self).__init__(root_url, headers)
     admin_node_ip = urlparse.urlparse(root_url).hostname
     self.keystone_url = "http://{0}:5000/v2.0".format(admin_node_ip)
     self.keystone = keystoneclient(auth_url=self.keystone_url, **creds)
     self.refresh_token()
Example #18
0
 def __init__(self, admin_node_ip, **kwargs):
     self.url = "http://{0}:8000".format(admin_node_ip)
     keystone_url = "http://{0}:5000/v2.0".format(admin_node_ip)
     ksclient = keystoneclient(auth_url=keystone_url, **kwargs)
     self.headers = {"X-Auth-Token": ksclient.auth_token,
                     "Content-Type": "application/json"}