Exemple #1
0
    def run_action(self, req, id, body):
        action = req.GET.get("action", None)
        occi_actions = [a.term for a in compute.ComputeResource.actions]

        if action is None or action not in occi_actions:
            raise exception.InvalidAction(action=action)

        parser = req.get_parser()(req.headers, req.body)
        obj = parser.parse()

        server = self.os_helper.get_server(req, id)

        if action == "stop":
            scheme = {"category": compute.stop}
        elif action == "start":
            scheme = {"category": compute.start}
            if server["status"] == "SUSPENDED":
                action = "resume"
            elif server["status"] == "PAUSED":
                action = "unpause"
        elif action == "restart":
            scheme = {"category": compute.restart}
        elif action == "suspend":
            scheme = {"category": compute.suspend}
        else:
            raise exception.NotImplemented

        validator = occi_validator.Validator(obj)
        validator.validate(scheme)

        self.os_helper.run_action(req, action, id)
        return []
Exemple #2
0
    def run_action(self, req, id, body):
        action = req.GET.get("action", None)
        actions = [a.term for a in storage.StorageResource.actions]

        if action is None or action not in actions:
            raise exception.InvalidAction(action=action)

        raise exception.NotImplemented()
Exemple #3
0
    def run_action(self, req, id, body):
        """Run action over the network

        :param req: current request
        :param id: network identification
        :param body: body
        """
        action = req.GET.get("action", None)
        occi_actions = [a.term for a in network.NetworkResource.actions]

        if action is None or action not in occi_actions:
            raise exception.InvalidAction(action=action)
        raise exception.NotImplemented("Network actions are not implemented")
Exemple #4
0
    def run_action(self, req, id, body):
        """Run action over the security group

        :param req: current request
        :param id: security group
        :param body: body
        """
        action = req.GET.get("action", None)
        occi_actions = [
            a.term for a in securitygroup.SecurityGroupResource.actions
        ]

        if action is None or action not in occi_actions:
            raise exception.InvalidAction(action=action)
        raise exception.NotImplemented(
            "Security group actions are not implemented")