Ejemplo n.º 1
0
 def _init_keystone(self, service, target):
     (url, user, password, tenantname, region) = self.get_config()
     body = {"auth": {"passwordCredentials": {"username": user,
             "password": password}, "tenantName": tenantname}}
     request_t = []
     response_t = []
     try:
         response, data = self.POST(url, body=body, code=200)
     except AssertionError:
         try:
             response, data = self.POST(url, body=body['auth'], code=200)
             data['access'] = data['auth']
         except:
             request_t = [print_curl_request]
             response_t = [print_it]
             print "Failed to auth.  Trying once more with verbosity"
             response, data = self.POST(url, body=body, code=200, 
                                        request_transformers=request_t,
                                        response_transformers=response_t)
     services = nested_get("/access/serviceCatalog", data)
     try:
         endpoint = nested_search(
             "/access/serviceCatalog/*/type=%s/endpoints/*/region=%s/%s" %
             (service, region, target), data)[0]
     except IndexError:
         endpoint = []
     finally:
         if endpoint == []:
             raise ValueError(('No endpoint found for service "%s" in'
                              + ' region "%s" with target "%s"\n'
                              + 'service catalog: "%s"') %
                              (service, region, target, services))
     token = nested_get("/access/token/id", data)
     return endpoint, token, services, data
Ejemplo n.º 2
0
 def _init_keystone(self, service, target):
     (url, user, password, tenantname, region) = self.get_config()
     body = {
         "auth": {
             "passwordCredentials": {
                 "username": user,
                 "password": password
             },
             "tenantName": tenantname
         }
     }
     request_t = []
     response_t = []
     try:
         response, data = self.POST(url, body=body, code=200)
     except AssertionError:
         try:
             response, data = self.POST(url, body=body['auth'], code=200)
             data['access'] = data['auth']
         except:
             request_t = [print_curl_request]
             response_t = [print_it]
             print "Failed to auth.  Trying once more with verbosity"
             response, data = self.POST(url,
                                        body=body,
                                        code=200,
                                        request_transformers=request_t,
                                        response_transformers=response_t)
     services = nested_get("/access/serviceCatalog", data)
     try:
         endpoint = nested_search(
             "/access/serviceCatalog/*/type=%s/endpoints/*/region=%s/%s" %
             (service, region, target), data)[0]
     except IndexError:
         endpoint = []
     finally:
         if endpoint == []:
             raise ValueError(('No endpoint found for service "%s" in' +
                               ' region "%s" with target "%s"\n' +
                               'service catalog: "%s"') %
                              (service, region, target, services))
     token = nested_get("/access/token/id", data)
     return endpoint, token, services, data
Ejemplo n.º 3
0
    def test_010_upload_file_to_glance(self):
        streamable = "etc/config.ini"
        headers = glance_headers("glance-swift-test", streamable, "ami")
        md5 = md5sum_file(streamable)
        with open(streamable, "rb") as image_file:
            r, d = glance.POST_raw_with_keys_eq(
                "/images",
                 {"/image/name": "glance-swift-test",
                  "/image/checksum": md5},
                  headers=headers,
                  body=image_file, code=201)

        image_id=nested_get("image/id", d)

        swifty_requester = KongRequester('object-store',
                                         section='glance-swift')

        r, d = swifty_requester.HEAD('/%s/%s?format=json' % (
                self.config["glance-swift"]["container"], image_id),
                                     code=200)

        assert(r['etag'] == md5)