Пример #1
0
 def provision(self, resource_id):
     req = pecan.request
     data = api.load_body(req)
     self._validate_body(resource_id, data)
     LOG.debug("Provisioning begins for the resource %s " % resource_id)
     return pecan.request.rpcapi_v2.provision_resource(
         pecan.request.context, resource_id, data)
Пример #2
0
 def activate(self, resource_id):
     req = pecan.request
     data = api.load_body(req)
     LOG.info("Activation begins for the resource %s " % resource_id)
     return pecan.request.rpcapi_v2.activate_resource(
             pecan.request.context, resource_id,
             data)
Пример #3
0
 def get_template(self, resource_type):
     self.validator = validators.ResourceValidator()
     self.validator.validate_type(
         resource_type, constants.ResourceConstants.SUPPORTED_TYPES)
     req = pecan.request
     data = api.load_body(req)
     LOG.info("Retrieving the template for activation of type"
              " %s" % resource_type)
     if resource_type == constants.ResourceConstants.ESXCLUSTER:
         if data:
             net_json = pecan.request.rpcapi_v2.populate_network_json(
                 pecan.request.context, resource_type,
                 data)
             if net_json:
                 net_json = json.loads(net_json)
         else:
             net_json = (GetTemplateController.
                 load_json_template_with_comments(net_template_location))
         activate_payload = constants.ResourceConstants.ACTIVATE_PAYLOAD_ESX
         activate_payload["network_properties"] = net_json
         return activate_payload
     elif resource_type == constants.ResourceConstants.RHEL:
         activate_payload = constants.ResourceConstants.\
             ACTIVATE_PAYLOAD_RHEL
     elif resource_type == constants.ResourceConstants.HLINUX:
         activate_payload = constants.ResourceConstants.\
             ACTIVATE_PAYLOAD_HLINUX
     elif resource_type == constants.ResourceConstants.HYPERV:
         activate_payload = constants.ResourceConstants.\
             ACTIVATE_PAYLOAD_HYPERV
     return activate_payload
Пример #4
0
 def deactivate(self, resource_id):
     req = pecan.request
     if req.body:
         data = api.load_body(req)
     else:
         data = dict()
     LOG.info("Deactivation begins for the resource %s " % resource_id)
     return pecan.request.rpcapi_v2.deactivate_resource(
             pecan.request.context, resource_id,
             data)
Пример #5
0
    def put(self, res_id):
        """
        :param res_id: Resource ID
        """
        validators.assert_is_valid_uuid_from_uri(res_id)
        req = pecan.request
        data = json.loads(req.body)
        if data.get("action"):
            if data["action"] == self.const.HOST_ADD:
                LOG.info("[%s] Initiating host commission" % res_id)
                return pecan.request.rpcapi_v2.host_commission(
                    pecan.request.context, res_id, data)

            elif data["action"] == self.const.HOST_REMOVE:
                return pecan.request.rpcapi_v2.host_decommission(
                    pecan.request.context, res_id, data)
            else:
                raise exception.Invalid(_("Invalid action passed"))
        else:
            data = api.load_body(req, validator=self.validator.validate_put)
            return pecan.request.rpcapi_v2.update_resource(
                pecan.request.context, res_id, data)
Пример #6
0
 def post(self):
     req = pecan.request
     data = api.load_body(req, validator=self.validator.validate_post)
     return pecan.request.rpcapi_v2.create_resource(
         pecan.request.context, data)
Пример #7
0
 def put(self, res_mgr_id):
     validators.assert_is_valid_uuid_from_uri(res_mgr_id)
     req = pecan.request
     data = api.load_body(req, validator=self.validator.validate_put)
     return pecan.request.rpcapi_v2.update_resource_mgr(
         pecan.request.context, res_mgr_id, data)
Пример #8
0
 def test_load_body(self):
     req = self.req
     validator = mock.Mock
     self.assertEqual(json.loads(req.body), api.load_body(req, validator))