コード例 #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)})
コード例 #2
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'] 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)})
コード例 #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)})
コード例 #4
0
ファイル: nova_api.py プロジェクト: dragorosson/mimic
    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()
コード例 #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()
コード例 #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)})