Beispiel #1
0
    def delete(self, baymodel_ident):
        """Delete a baymodel.

        :param baymodel_uuid: UUID or logical name of a baymodel.
        """
        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        rpc_baymodel.destroy()
Beispiel #2
0
    def delete(self, rc_ident):
        """Delete a ReplicationController.

        :param rc_uuid: UUID of a ReplicationController.
        """
        rpc_rc = api_utils.get_rpc_resource('ReplicationController', rc_ident)
        pecan.request.rpcapi.rc_delete(rpc_rc.uuid)
Beispiel #3
0
    def get_one(self, baymodel_ident):
        """Retrieve information about the given baymodel.

        :param baymodel_ident: UUID or logical name of a baymodel.
        """
        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        return BayModel.convert_with_links(rpc_baymodel)
Beispiel #4
0
    def _default(self, container_ident):
        if pecan.request.method != "PUT":
            pecan.abort(405, ("HTTP method %s is not allowed" % pecan.request.method))
        container_uuid = api_utils.get_rpc_resource("Container", container_ident).uuid

        LOG.debug("Calling conductor.container_start with %s" % container_uuid)
        return pecan.request.rpcapi.container_start(container_uuid)
Beispiel #5
0
    def patch(self, bay_ident, patch):
        """Update an existing bay.

        :param bay_ident: UUID or logical name of a bay.
        :param patch: a json PATCH document to apply to this bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)
        try:
            bay_dict = rpc_bay.as_dict()
            bay = Bay(**api_utils.apply_jsonpatch(bay_dict, patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        # Update only the fields that have changed
        for field in objects.Bay.fields:
            try:
                patch_val = getattr(bay, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if rpc_bay[field] != patch_val:
                rpc_bay[field] = patch_val

        res_bay = pecan.request.rpcapi.bay_update(rpc_bay)
        return Bay.convert_with_links(res_bay)
Beispiel #6
0
    def patch(self, container_ident, patch):
        """Update an existing container.

        :param container_ident: UUID or name of a container.
        :param patch: a json PATCH document to apply to this container.
        """
        rpc_container = api_utils.get_rpc_resource('Container',
                                                   container_ident)
        try:
            container_dict = rpc_container.as_dict()
            container = Container(
                **api_utils.apply_jsonpatch(container_dict, patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        # Update only the fields that have changed
        for field in objects.Container.fields:
            try:
                patch_val = getattr(container, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if rpc_container[field] != patch_val:
                rpc_container[field] = patch_val

        rpc_container.save()
        return Container.convert_with_links(rpc_container)
Beispiel #7
0
    def delete(self, baymodel_ident):
        """Delete a baymodel.

        :param baymodel_uuid: UUID or logical name of a baymodel.
        """
        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        rpc_baymodel.destroy()
Beispiel #8
0
    def get_one(self, baymodel_ident):
        """Retrieve information about the given baymodel.

        :param baymodel_ident: UUID or logical name of a baymodel.
        """
        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        return BayModel.convert_with_links(rpc_baymodel)
    def get_one(self, rc_ident):
        """Retrieve information about the given ReplicationController.

        :param rc_ident: UUID or logical name of a ReplicationController.
        """
        rpc_rc = api_utils.get_rpc_resource("ReplicationController", rc_ident)
        return ReplicationController.convert_with_links(rpc_rc)
Beispiel #10
0
    def patch(self, baymodel_ident, patch):
        """Update an existing baymodel.

        :param baymodel_ident: UUID or logic name of a baymodel.
        :param patch: a json PATCH document to apply to this baymodel.
        """
        context = pecan.request.context
        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        try:
            baymodel_dict = rpc_baymodel.as_dict()
            baymodel = BayModel(
                **api_utils.apply_jsonpatch(baymodel_dict, patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        # check permissions when updating baymodel public flag
        if rpc_baymodel.public != baymodel.public:
            if not policy.enforce(
                    context, "baymodel:publish", None, do_raise=False):
                raise exception.BaymodelPublishDenied()

        # Update only the fields that have changed
        for field in objects.BayModel.fields:
            try:
                patch_val = getattr(baymodel, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if rpc_baymodel[field] != patch_val:
                rpc_baymodel[field] = patch_val

        rpc_baymodel.save()
        return BayModel.convert_with_links(rpc_baymodel)
    def delete(self, rc_ident):
        """Delete a ReplicationController.

        :param rc_uuid: UUID of a ReplicationController.
        """
        rpc_rc = api_utils.get_rpc_resource("ReplicationController", rc_ident)
        pecan.request.rpcapi.rc_delete(rpc_rc.uuid)
Beispiel #12
0
    def patch(self, container_ident, patch):
        """Update an existing container.

        :param container_ident: UUID or name of a container.
        :param patch: a json PATCH document to apply to this container.
        """
        rpc_container = api_utils.get_rpc_resource('Container',
                                                   container_ident)
        try:
            container_dict = rpc_container.as_dict()
            container = Container(**api_utils.apply_jsonpatch(
                container_dict, patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        # Update only the fields that have changed
        for field in objects.Container.fields:
            try:
                patch_val = getattr(container, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if rpc_container[field] != patch_val:
                rpc_container[field] = patch_val

        rpc_container.save()
        return Container.convert_with_links(rpc_container)
Beispiel #13
0
    def get_one(self, rc_ident):
        """Retrieve information about the given ReplicationController.

        :param rc_ident: UUID or logical name of a ReplicationController.
        """
        rpc_rc = api_utils.get_rpc_resource('ReplicationController', rc_ident)
        return ReplicationController.convert_with_links(rpc_rc)
Beispiel #14
0
    def patch(self, bay_ident, patch):
        """Update an existing bay.

        :param bay_ident: UUID or logical name of a bay.
        :param patch: a json PATCH document to apply to this bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)
        try:
            bay_dict = rpc_bay.as_dict()
            bay = Bay(**api_utils.apply_jsonpatch(bay_dict, patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        # Update only the fields that have changed
        for field in objects.Bay.fields:
            try:
                patch_val = getattr(bay, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if rpc_bay[field] != patch_val:
                rpc_bay[field] = patch_val

        res_bay = pecan.request.rpcapi.bay_update(rpc_bay)
        return Bay.convert_with_links(res_bay)
Beispiel #15
0
    def delete(self, container_ident):
        """Delete a container.

        :param container_ident: UUID or Name of a container.
        """
        rpc_container = api_utils.get_rpc_resource("Container", container_ident)
        pecan.request.rpcapi.container_delete(rpc_container.uuid)
        rpc_container.destroy()
    def delete(self, rc_ident, bay_ident):
        """Delete a ReplicationController.

        :param rc_ident: UUID or logical name of a ReplicationController.
        :param bay_ident: UUID or logical name of the Bay.
        """
        rpc_rc = api_utils.get_rpc_resource('ReplicationController', rc_ident)
        pecan.request.rpcapi.rc_delete(rpc_rc.uuid)
Beispiel #17
0
    def delete(self, pod_ident):
        """Delete a pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        pecan.request.rpcapi.pod_delete(rpc_pod.uuid)
Beispiel #18
0
    def get_one(self, pod_ident):
        """Retrieve information about the given pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        return Pod.convert_with_links(rpc_pod)
Beispiel #19
0
    def delete(self, service_ident):
        """Delete a service.

        :param service_ident: UUID or logical name of a service.
        """
        rpc_service = api_utils.get_rpc_resource('Service', service_ident)

        pecan.request.rpcapi.service_delete(rpc_service.uuid)
Beispiel #20
0
    def get_one(self, service_ident):
        """Retrieve information about the given service.

        :param service_ident: UUID or logical name of the service.
        """
        rpc_service = api_utils.get_rpc_resource('Service', service_ident)

        return Service.convert_with_links(rpc_service)
Beispiel #21
0
    def delete(self, service_ident):
        """Delete a service.

        :param service_ident: UUID or logical name of a service.
        """
        rpc_service = api_utils.get_rpc_resource('Service', service_ident)

        pecan.request.rpcapi.service_delete(rpc_service.uuid)
Beispiel #22
0
    def get_one(self, bay_ident):
        """Retrieve information about the given bay.

        :param bay_ident: UUID of a bay or logical name of the bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)

        return Bay.convert_with_links(rpc_bay)
Beispiel #23
0
    def get_one(self, pod_ident):
        """Retrieve information about the given pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        return Pod.convert_with_links(rpc_pod)
Beispiel #24
0
    def get_one(self, container_ident):
        """Retrieve information about the given container.

        :param container_ident: UUID or name of a container.
        """
        rpc_container = api_utils.get_rpc_resource("Container", container_ident)
        res_container = pecan.request.rpcapi.container_show(rpc_container.uuid)
        return Container.convert_with_links(res_container)
Beispiel #25
0
 def _default(self, container_ident):
     if pecan.request.method != 'GET':
         pecan.abort(
             405, ('HTTP method %s is not allowed' % pecan.request.method))
     container_uuid = api_utils.get_rpc_resource('Container',
                                                 container_ident).uuid
     LOG.debug('Calling conductor.container_logs with %s' % container_uuid)
     return pecan.request.rpcapi.container_logs(container_uuid)
Beispiel #26
0
    def delete(self, pod_ident):
        """Delete a pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        pecan.request.rpcapi.pod_delete(rpc_pod.uuid)
Beispiel #27
0
    def get_one(self, service_ident):
        """Retrieve information about the given service.

        :param service_ident: UUID or logical name of the service.
        """
        rpc_service = api_utils.get_rpc_resource('Service', service_ident)

        return Service.convert_with_links(rpc_service)
Beispiel #28
0
    def delete(self, bay_ident):
        """Delete a bay.

        :param bay_ident: UUID of a bay or logical name of the bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)

        pecan.request.rpcapi.bay_delete(rpc_bay.uuid)
Beispiel #29
0
    def get_one(self, bay_ident):
        """Retrieve information about the given bay.

        :param bay_ident: UUID of a bay or logical name of the bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)

        return Bay.convert_with_links(rpc_bay)
Beispiel #30
0
    def delete(self, bay_ident):
        """Delete a bay.

        :param bay_ident: UUID of a bay or logical name of the bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)

        pecan.request.rpcapi.bay_delete(rpc_bay.uuid)
Beispiel #31
0
    def get_one(self, container_ident):
        """Retrieve information about the given container.

        :param container_ident: UUID or name of a container.
        """
        rpc_container = api_utils.get_rpc_resource('Container',
                                                   container_ident)
        res_container = pecan.request.rpcapi.container_show(rpc_container.uuid)
        return Container.convert_with_links(res_container)
Beispiel #32
0
    def delete(self, container_ident):
        """Delete a container.

        :param container_uuid: UUID of a container.
        """
        rpc_container = api_utils.get_rpc_resource('Container',
                                                   container_ident)
        pecan.request.rpcapi.container_delete(rpc_container.uuid)
        rpc_container.destroy()
Beispiel #33
0
    def get_one(self, bay_ident):
        """Retrieve information about the given certificate.

        :param bay_ident: UUID of a bay or
        logical name of the bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)
        certificate = pecan.request.rpcapi.get_ca_certificate(rpc_bay)
        return Certificate.convert_with_links(certificate)
Beispiel #34
0
    def get_one(self, bay_ident):
        """Retrieve information about the given certificate.

        :param bay_ident: UUID of a bay or
        logical name of the bay.
        """
        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)
        certificate = pecan.request.rpcapi.get_ca_certificate(rpc_bay)
        return Certificate.convert_with_links(certificate)
Beispiel #35
0
 def _default(self, container_ident, command):
     if pecan.request.method != 'PUT':
         pecan.abort(405, ('HTTP method %s is not allowed'
                           % pecan.request.method))
     container_uuid = api_utils.get_rpc_resource('Container',
                                                 container_ident).uuid
     LOG.debug('Calling conductor.container_exec with %s command %s'
               % (container_uuid, command))
     return pecan.request.rpcapi.container_exec(container_uuid, command)
    def get_one(self, rc_ident):
        """Retrieve information about the given ReplicationController.

        :param rc_ident: UUID or logical name of a ReplicationController.
        """
        if self.from_rcs:
            raise exception.OperationNotPermitted

        rpc_rc = api_utils.get_rpc_resource('ReplicationController', rc_ident)
        return ReplicationController.convert_with_links(rpc_rc)
Beispiel #37
0
    def get_one(self, baymodel_ident):
        """Retrieve information about the given baymodel.

        :param baymodel_ident: UUID or logical name of a baymodel.
        """
        if self.from_baymodels:
            raise exception.OperationNotPermitted

        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        return BayModel.convert_with_links(rpc_baymodel)
Beispiel #38
0
    def get_one(self, x509keypair_ident):
        """Retrieve information about the given x509keypair.

        :param x509keypair_ident: UUID of a x509keypair or
        logical name of the x509keypair.
        """
        rpc_x509keypair = api_utils.get_rpc_resource('X509KeyPair',
                                                     x509keypair_ident)

        return X509KeyPair.convert_with_links(rpc_x509keypair)
Beispiel #39
0
    def get_one(self, baymodel_ident):
        """Retrieve information about the given baymodel.

        :param baymodel_ident: UUID or logical name of a baymodel.
        """
        if self.from_baymodels:
            raise exception.OperationNotPermitted

        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        return BayModel.convert_with_links(rpc_baymodel)
Beispiel #40
0
    def delete(self, baymodel_ident):
        """Delete a baymodel.

        :param baymodel_uuid: UUID or logical name of a baymodel.
        """
        if self.from_baymodels:
            raise exception.OperationNotPermitted

        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        rpc_baymodel.destroy()
Beispiel #41
0
    def delete(self, baymodel_ident):
        """Delete a baymodel.

        :param baymodel_uuid: UUID or logical name of a baymodel.
        """
        if self.from_baymodels:
            raise exception.OperationNotPermitted

        rpc_baymodel = api_utils.get_rpc_resource('BayModel', baymodel_ident)
        rpc_baymodel.destroy()
Beispiel #42
0
    def get_one(self, x509keypair_ident):
        """Retrieve information about the given x509keypair.

        :param x509keypair_ident: UUID of a x509keypair or
        logical name of the x509keypair.
        """
        rpc_x509keypair = api_utils.get_rpc_resource('X509KeyPair',
                                                     x509keypair_ident)

        return X509KeyPair.convert_with_links(rpc_x509keypair)
Beispiel #43
0
    def delete(self, x509keypair_ident):
        """Delete a x509keypair.

        :param x509keypair_ident: UUID of a x509keypair or logical
        name of the x509keypair.
        """
        rpc_x509keypair = api_utils.get_rpc_resource('X509KeyPair',
                                                     x509keypair_ident)

        pecan.request.rpcapi.x509keypair_delete(rpc_x509keypair.uuid)
    def delete(self, rc_ident):
        """Delete a ReplicationController.

        :param rc_uuid: UUID of a ReplicationController.
        """
        if self.from_rcs:
            raise exception.OperationNotPermitted

        rpc_rc = api_utils.get_rpc_resource('ReplicationController', rc_ident)
        pecan.request.rpcapi.rc_delete(rpc_rc.uuid)
    def delete(self, rc_ident):
        """Delete a ReplicationController.

        :param rc_uuid: UUID of a ReplicationController.
        """
        if self.from_rcs:
            raise exception.OperationNotPermitted

        rpc_rc = api_utils.get_rpc_resource('ReplicationController', rc_ident)
        pecan.request.rpcapi.rc_delete(rpc_rc.uuid)
Beispiel #46
0
    def delete(self, x509keypair_ident):
        """Delete a x509keypair.

        :param x509keypair_ident: UUID of a x509keypair or logical
        name of the x509keypair.
        """
        rpc_x509keypair = api_utils.get_rpc_resource('X509KeyPair',
                                                     x509keypair_ident)

        pecan.request.rpcapi.x509keypair_delete(rpc_x509keypair.uuid)
    def get_one(self, rc_ident):
        """Retrieve information about the given ReplicationController.

        :param rc_ident: UUID or logical name of a ReplicationController.
        """
        if self.from_rcs:
            raise exception.OperationNotPermitted

        rpc_rc = api_utils.get_rpc_resource('ReplicationController', rc_ident)
        return ReplicationController.convert_with_links(rpc_rc)
Beispiel #48
0
    def delete(self, service_ident):
        """Delete a service.

        :param service_ident: UUID or logical name of a service.
        """
        if self.from_services:
            raise exception.OperationNotPermitted

        rpc_service = api_utils.get_rpc_resource('Service', service_ident)

        pecan.request.rpcapi.service_delete(rpc_service.uuid)
Beispiel #49
0
    def get_one(self, service_ident):
        """Retrieve information about the given service.

        :param service_ident: UUID or logical name of the service.
        """
        if self.from_services:
            raise exception.OperationNotPermitted

        rpc_service = api_utils.get_rpc_resource('Service', service_ident)

        return Service.convert_with_links(rpc_service)
Beispiel #50
0
    def test_get_rpc_resource_with_name(self, mock_get_by_uuid,
                                        mock_get_by_name, mock_request):
        mock_bay = mock.MagicMock
        mock_get_by_name.return_value = mock_bay

        returned_bay = utils.get_rpc_resource('Bay', 'fake-name')

        self.assertFalse(mock_get_by_uuid.called)
        mock_get_by_name.assert_called_once_with(mock_request.context,
                                                 'fake-name')
        self.assertEqual(mock_bay, returned_bay)
Beispiel #51
0
    def test_get_rpc_resource_with_uuid(self, mock_get_by_uuid,
                                        mock_get_by_name, mock_request):
        mock_bay = mock.MagicMock
        mock_get_by_uuid.return_value = mock_bay
        uuid = common_utils.generate_uuid()

        returned_bay = utils.get_rpc_resource('Bay', uuid)

        mock_get_by_uuid.assert_called_once_with(mock_request.context, uuid)
        self.assertFalse(mock_get_by_name.called)
        self.assertEqual(mock_bay, returned_bay)
Beispiel #52
0
    def delete(self, service_ident):
        """Delete a service.

        :param service_ident: UUID or logical name of a service.
        """
        if self.from_services:
            raise exception.OperationNotPermitted

        rpc_service = api_utils.get_rpc_resource("Service", service_ident)

        pecan.request.rpcapi.service_delete(rpc_service.uuid)
Beispiel #53
0
    def get_one(self, service_ident):
        """Retrieve information about the given service.

        :param service_ident: UUID or logical name of the service.
        """
        if self.from_services:
            raise exception.OperationNotPermitted

        rpc_service = api_utils.get_rpc_resource("Service", service_ident)

        return Service.convert_with_links(rpc_service)
Beispiel #54
0
    def delete(self, pod_ident):
        """Delete a pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        if self.from_pods:
            raise exception.OperationNotPermitted

        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        pecan.request.rpcapi.pod_delete(rpc_pod.uuid)
Beispiel #55
0
    def delete(self, bay_ident):
        """Delete a bay.

        :param bay_ident: UUID of a bay or logical name of the bay.
        """
        if self.from_bays:
            raise exception.OperationNotPermitted

        rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)

        pecan.request.rpcapi.bay_delete(rpc_bay.uuid)
Beispiel #56
0
    def get_one(self, pod_ident):
        """Retrieve information about the given pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        if self.from_pods:
            raise exception.OperationNotPermitted

        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        return Pod.convert_with_links(rpc_pod)
Beispiel #57
0
    def get_one(self, pod_ident):
        """Retrieve information about the given pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        if self.from_pods:
            raise exception.OperationNotPermitted

        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        return Pod.convert_with_links(rpc_pod)
Beispiel #58
0
    def delete(self, pod_ident):
        """Delete a pod.

        :param pod_ident: UUID of a pod or logical name of the pod.
        """
        if self.from_pods:
            raise exception.OperationNotPermitted

        rpc_pod = api_utils.get_rpc_resource('Pod', pod_ident)

        pecan.request.rpcapi.pod_delete(rpc_pod.uuid)
Beispiel #59
0
 def _set_baymodel_id(self, value):
     if value and self._baymodel_id != value:
         try:
             baymodel = api_utils.get_rpc_resource('BayModel', value)
             self._baymodel_id = baymodel.uuid
         except exception.BayModelNotFound as e:
             # Change error code because 404 (NotFound) is inappropriate
             # response for a POST request to create a Bay
             e.code = 400  # BadRequest
             raise e
     elif value == wtypes.Unset:
         self._baymodel_id = wtypes.Unset