Exemplo n.º 1
0
 def get_image(self, http_get_request, image_id, absolutize_url):
     """
     Return an image object if one exists from the list `/images` api,
     else return 404 Image not found.
     """
     if image_id in get_presets["servers"]["invalid_image_ref"]:
         return dumps(not_found("The resource could not be found.", http_get_request))
     self.image_store.create_image_store(self.tenant_id)
     image = self.image_store.get_image_by_id(image_id)
     if image is None:
         return dumps(not_found("Image not found.", http_get_request))
     return dumps({"image": image.detailed_json(absolutize_url)})
 def get_image(self, http_get_request, image_id, absolutize_url):
     """
     Return an image object if one exists from the list `/images` api,
     else return 404 Image not found.
     """
     if image_id in get_presets['servers'][
             'invalid_image_ref'] or image_id.endswith('Z'):
         return dumps(
             not_found("The resource could not be found.",
                       http_get_request))
     self.image_store.create_image_store(self.tenant_id)
     image = self.image_store.get_image_by_id(image_id)
     if image is None:
         return dumps(not_found('Image not found.', http_get_request))
     return dumps({"image": image.detailed_json(absolutize_url)})
Exemplo n.º 3
0
 def get_flavor(self, http_get_request, flavor_id, absolutize_url):
     """
     Return a flavor object if one exists from the list `/flavors` api,
     If the `flavor_id` is not found in the flavor store,
     then will return 404.
     """
     flavor = self.flavor_by_id(flavor_id)
     if flavor is None:
         return dumps(not_found("The resource could not be found.",
                                http_get_request))
     return dumps({"flavor": flavor.detailed_json(absolutize_url)})
Exemplo n.º 4
0
    def handle_server_metadata(self, request, tenant_id, server_id):
        """
        Handle metadata requests associated with a particular server.  Server
        not found error message verified as of 2015-04-23 against Rackspace
        Nova.
        """
        server = self._region_collection_for_tenant(tenant_id).server_by_id(server_id)
        if server is None:
            return json.dumps(not_found("Server does not exist", request))

        return ServerMetadata(server).app.resource()
Exemplo n.º 5
0
    def handle_server_metadata(self, request, tenant_id, server_id):
        """
        Handle metadata requests associated with a particular server.  Server
        not found error message verified as of 2015-04-23 against Rackspace
        Nova.
        """
        server = (self._region_collection_for_tenant(tenant_id)
                  .server_by_id(server_id))
        if server is None:
            return json.dumps(not_found('Server does not exist', request))

        return ServerMetadata(server).app.resource()
Exemplo n.º 6
0
 def get_flavor(self, http_get_request, flavor_id, absolutize_url):
     """
     Return a flavor object if one exists from the list `/flavors` api,
     else creates and adds the flavor to the :obj: `flavors_store`.
     If the `flavor_id` is listed in `mimic.canned_responses.mimic_presets`,
     then will return 404.
     """
     flavor = self.flavor_by_id(flavor_id)
     if flavor is None:
         return dumps(not_found("The resource could not be found.",
                                http_get_request))
     return dumps({"flavor": flavor.detailed_json(absolutize_url)})