示例#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 []
示例#2
0
文件: storage.py 项目: A1ve5/ooi
    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()
示例#3
0
文件: network.py 项目: tdviet/ooi
    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")
示例#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")