Beispiel #1
0
 def detach_disk(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "detachDisk",
                                   self._type_name, id, scope)
     self._instance_disk_api.delete_item(context, id,
         req.params.get("deviceName"))
Beispiel #2
0
 def attach_disk(self, req, body, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "attachDisk",
                                   self._type_name, id, scope)
     self._instance_disk_api.add_item(context, id,
         body["source"], body.get("deviceName"))
Beispiel #3
0
 def delete_access_config(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "deleteAccessConfig",
                                   self._type_name, id, scope)
     self._instance_address_api.delete_item(context, id,
                                            req.params.get('accessConfig'))
Beispiel #4
0
 def detach_disk(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "detachDisk", self._type_name,
                                   id, scope)
     self._instance_disk_api.delete_item(context, id,
                                         req.params.get("deviceName"))
Beispiel #5
0
 def create_snapshot(self, req, body, scope_id, id):
     body["disk_name"] = id
     scope = self._get_scope(req, scope_id)
     context = self._get_context(req)
     operation_util.init_operation(context, "createSnapshot",
                                   self._type_name, id, scope)
     snapshot_api.API().add_item(context, body, scope)
Beispiel #6
0
 def delete_access_config(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "deleteAccessConfig",
                                   self._type_name, id, scope)
     self._instance_address_api.delete_item(context, id,
        req.params.get('accessConfig'))
Beispiel #7
0
    def create(self, req, body, scope_id=None):
        """GCE add requests."""

        scope = self._get_scope(req, scope_id)
        context = self._get_context(req)
        operation_util.init_operation(context, "insert", self._type_name,
                                      body["name"], scope)
        self._api.add_item(context, body['name'], body, scope)
Beispiel #8
0
 def set_disk_auto_delete(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "setDiskAutoDelete",
                                   self._type_name, id, scope)
     auto_delete = req.params.get("autoDelete").lower() == "true"
     self._instance_disk_api.set_disk_auto_delete(
         context, id, req.params.get("deviceName"), auto_delete)
Beispiel #9
0
 def set_disk_auto_delete(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "setDiskAutoDelete",
                                   self._type_name, id, scope)
     auto_delete = req.params.get("autoDelete").lower() == "true"
     self._instance_disk_api.set_disk_auto_delete(context, id,
         req.params.get("deviceName"), auto_delete)
Beispiel #10
0
    def create(self, req, body, scope_id=None):
        """GCE add requests."""

        scope = self._get_scope(req, scope_id)
        context = self._get_context(req)
        operation_util.init_operation(context, "insert",
                                      self._type_name, body["name"], scope)
        self._api.add_item(context, body['name'], body, scope)
Beispiel #11
0
 def add_access_config(self, req, body, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "addAccessConfig",
                                   self._type_name, id, scope)
     self._instance_address_api.add_item(context, id,
         req.params.get('networkInterface'), body.get("natIP"),
         body.get("type"), body.get("name"))
Beispiel #12
0
 def add_access_config(self, req, body, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "addAccessConfig",
                                   self._type_name, id, scope)
     self._instance_address_api.add_item(context, id,
                                         req.params.get('networkInterface'),
                                         body.get("natIP"),
                                         body.get("type"), body.get("name"))
Beispiel #13
0
 def attach_disk(self, req, body, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "attachDisk",
                                   self._type_name, id, scope)
     self._instance_disk_api.add_item(context, id,
         body.get("initializeParams"), body.get("source"),
         body.get("deviceName"), body.get("autoDelete", False),
         scope)
Beispiel #14
0
 def attach_disk(self, req, body, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "attachDisk", self._type_name,
                                   id, scope)
     self._instance_disk_api.add_item(context, id,
                                      body.get("initializeParams"),
                                      body.get("source"),
                                      body.get("deviceName"),
                                      body.get("autoDelete", False), scope)
Beispiel #15
0
 def reset_instance(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "reset", self._type_name, id,
                                   scope)
     try:
         self._api.reset_instance(context, scope, id)
     except (exception.NotFound, KeyError, IndexError):
         msg = _("Instance %s could not be found") % id
         raise webob.exc.HTTPNotFound(explanation=msg)
Beispiel #16
0
 def reset_instance(self, req, scope_id, id):
     context = self._get_context(req)
     scope = self._get_scope(req, scope_id)
     operation_util.init_operation(context, "reset",
                                   self._type_name, id, scope)
     try:
         self._api.reset_instance(context, scope, id)
     except (exception.NotFound, KeyError, IndexError):
         msg = _("Instance %s could not be found") % id
         raise webob.exc.HTTPNotFound(explanation=msg)
Beispiel #17
0
    def delete(self, req, id, scope_id=None):
        """GCE delete requests."""

        scope = self._get_scope(req, scope_id)
        context = self._get_context(req)
        operation_util.init_operation(context, "delete",
                                      self._type_name, id, scope)
        try:
            self._api.delete_item(context, id, scope)
        except (exception.NotFound, KeyError, IndexError):
            msg = _("Resource '%s' could not be found") % id
            raise exc.HTTPNotFound(explanation=msg)
Beispiel #18
0
 def create_snapshot(self, req, body, scope_id, id):
     body["disk_name"] = id
     scope = self._get_scope(req, scope_id)
     context = self._get_context(req)
     operation_util.init_operation(context, "createSnapshot",
                                   self._type_name, id, scope)
     snapshot = snapshot_api.API().add_item(context, body, scope)
     # TODO(alexey-mr): workaround: have to set item id here
     # snapshot_api.API().add_item set_item_id has no effect because
     # of different type_name disk vs. snapshot
     # but snapshot type_name can't be used in init_operation because
     # targetLink and targetId should point to disk object
     operation_util.set_item_id(context, snapshot['id'], self._type_name)
Beispiel #19
0
    def delete(self, req, id, scope_id=None):
        """GCE delete requests."""

        scope = self._get_scope(req, scope_id)
        context = self._get_context(req)
        operation_util.init_operation(context, "delete", self._type_name, id,
                                      scope)
        try:
            self._api.delete_item(context, id, scope)
        except (exception.NotFound, KeyError, IndexError) as ex:
            LOG.exception(ex)
            msg = _("Resource '%s' could not be found") % id
            raise exc.HTTPNotFound(explanation=msg)
Beispiel #20
0
 def set_common_instance_metadata(self, req, body):
     context = self._get_context(req)
     operation_util.init_operation(context, "setMetadata", self._type_name,
                                   None, scopes.GlobalScope())
     try:
         self._api.set_common_instance_metadata(context,
                                                body.get("items", []))
     except exception.KeypairLimitExceeded:
         msg = _("Quota exceeded, too many key pairs.")
         raise webob.exc.HTTPRequestEntityTooLarge(
             explanation=msg, headers={'Retry-After': 0})
     except exception.InvalidKeypair:
         msg = _("Keypair data is invalid")
         raise webob.exc.HTTPBadRequest(explanation=msg)
     except exception.KeyPairExists:
         msg = _("Key pair already exists.")
         raise webob.exc.HTTPConflict(explanation=msg)
Beispiel #21
0
 def set_common_instance_metadata(self, req, body):
     context = self._get_context(req)
     operation_util.init_operation(context, "setMetadata", self._type_name,
                                   None, scopes.GlobalScope())
     try:
         self._api.set_common_instance_metadata(
             context, body.get("items", []))
     except exception.KeypairLimitExceeded:
         msg = _("Quota exceeded, too many key pairs.")
         raise webob.exc.HTTPRequestEntityTooLarge(
                     explanation=msg,
                     headers={'Retry-After': 0})
     except exception.InvalidKeypair:
         msg = _("Keypair data is invalid")
         raise webob.exc.HTTPBadRequest(explanation=msg)
     except exception.KeyPairExists:
         msg = _("Key pair already exists.")
         raise webob.exc.HTTPConflict(explanation=msg)