# Path: muranoagent/bunch.py
# class Bunch(dict):
#     def __getattr__(self, item):
#     def __setattr__(self, key, value):
#     def __delattr__(self, key):
# 
# Path: muranoagent/common/config.py
# CONF = cfg.CONF
# def parse_args(args=None, usage=None, default_config_files=None):
# 
# Path: muranoagent/util.py
# def _to_bytes(string):
# def b64encode(string):
# def b64decode(string):


import json
import os
import shutil
import time
from cryptography.hazmat import backends
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from oslo_log import log as logging
from muranoagent import bunch
from muranoagent.common import config
from muranoagent import util
    def _get_first_timestamp(self, filename):
        def predicate(folder):
            path = os.path.join(self._plans_folder, folder, filename)
            return os.path.exists(path)

        timestamps = [
            name for name in os.listdir(self._plans_folder)
            if predicate(name)
        ]
        timestamps.sort()
        return None if len(timestamps) == 0 else timestamps[0]

    def _get_first_file(self, filename):
        timestamp = self._get_first_timestamp(filename)
        if not timestamp:
            return None, None
        path = os.path.join(self._plans_folder, timestamp, filename)
        with open(path) as json_file:
            return json.loads(json_file.read()), timestamp

    def get_execution_plan(self):
        while True:
            ep_info, timestamp = self._get_first_file(
                ExecutionPlanQueue.plan_filename)
            if ep_info is None:
                return None

            try:
                data = util.b64decode(ep_info['Data'])
                if self._key:

# Path: muranoagent/bunch.py
# class Bunch(dict):
#     def __getattr__(self, item):
#     def __setattr__(self, key, value):
#     def __delattr__(self, key):
# 
# Path: muranoagent/common/config.py
# CONF = cfg.CONF
# def parse_args(args=None, usage=None, default_config_files=None):
# 
# Path: muranoagent/util.py
# def _to_bytes(string):
# def b64encode(string):
# def b64decode(string):


# Path: muranoagent/execution_plan_queue.py
import json
import os
import shutil
import time
from cryptography.hazmat import backends
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from oslo_log import log as logging
from muranoagent import bunch
from muranoagent.common import config
from muranoagent import util

    def _get_first_timestamp(self, filename):
        def predicate(folder):
            path = os.path.join(self._plans_folder, folder, filename)
            return os.path.exists(path)

        timestamps = [
            name for name in os.listdir(self._plans_folder)
            if predicate(name)
        ]
        timestamps.sort()
        return None if len(timestamps) == 0 else timestamps[0]

    def _get_first_file(self, filename):
        timestamp = self._get_first_timestamp(filename)
        if not timestamp:
            return None, None
        path = os.path.join(self._plans_folder, timestamp, filename)
        with open(path) as json_file:
            return json.loads(json_file.read()), timestamp

    def get_execution_plan(self):
        while True:
            ep_info, timestamp = self._get_first_file(
                ExecutionPlanQueue.plan_filename)
            if ep_info is None:
                return None

            try:
                data = util.b64decode(ep_info['Data'])
                if self._key:

                    signature = util.b64decode(ep_info['Signature'])