def delete(self, play_uuid):
        """
        DELETE {play_uuid}
        Issue a cancel request to a running playbook

        Example.

        ```
        $ curl -i -k -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MzczODA3MTR9.CbTXvBum5mCq9s56wJNiMn8JLJ0UzzRdwdeOFctJtbI" https://localhost:5001/api/v1/playbooks/b7ea3922-b481-11e8-a992-c85b7671906d -X delete
        HTTP/1.0 200 OK
        Content-Type: application/json
        Content-Length: 75
        Server: Werkzeug/0.12.2 Python/3.6.6
        Date: Sun, 09 Sep 2018 22:43:16 GMT

        {
            "status": "OK",
            "msg": "Cancel request issued",
            "data": {}
        }
        ```
        """
        r = APIResponse()
        if play_uuid not in runner_cache.keys():
            # play_uuid may be valie but it's not actually running
            r.status, r.msg = "NOT ACTIVE", \
                              "playbook with uuid {} is not active".format(play_uuid)
            return r.__dict__, 404

        stop_playbook(play_uuid)
        r.status, r.msg = 'OK', "Cancel request issued"
        return r.__dict__, 200
    def delete(self, play_uuid):
        """
        DELETE {play_uuid}
        Issue a cancel request to a running playbook

        Example.

        ```
        $ curl -i -k --key ./client.key --cert ./client.crt https://localhost:5001/api/v1/playbooks/b7ea3922-b481-11e8-a992-c85b7671906d -X DELETE
        HTTP/1.0 200 OK
        Content-Type: application/json
        Content-Length: 75
        Server: Werkzeug/0.12.2 Python/3.6.6
        Date: Sun, 09 Sep 2018 22:43:16 GMT

        {
            "status": "OK",
            "msg": "Cancel request issued",
            "data": {}
        }
        ```
        """
        r = APIResponse()
        if play_uuid not in runner_cache.keys():
            # play_uuid may be valie but it's not actually running
            r.status, r.msg = "NOT ACTIVE", \
                              "playbook with uuid {} is not active".format(play_uuid)
            return r.__dict__, 404

        stop_playbook(play_uuid)
        r.status, r.msg = 'OK', "Cancel request issued"
        return r.__dict__, 200
Esempio n. 3
0
def prune_runner_cache(current_runner):
    if len(runner_cache.keys()) >= configuration.settings.runner_cache_size:
        logger.debug("Maintaining runner_cache entries")
        oldest = current_runner
        for ident in runner_cache:
            if runner_cache[ident]['start_epoc'] < runner_cache[oldest][
                    'start_epoc']:  # noqa
                oldest = ident
        logger.info("Dropping oldest runner object for play uuid {} from "
                    "runner_cache".format(oldest))
        del runner_cache[oldest]
def prune_runner_cache(current_runner):
    if len(runner_cache.keys()) >= configuration.settings.runner_cache_size:
        logger.debug("Maintaining runner_cache entries")
        logger.info("Dropping finished runner object for play uuid {} from "
                    "runner_cache".format(current_runner))
        del runner_cache[current_runner]