Esempio n. 1
0
def doPost(role, command):
    # execute command
    if role is None or command is None:
        abort(404)

    if request.content_type != JSON_MIME_TYPE:
        error = json.dumps({'error': 'Invalid Content Type'})
        return json_response(error, 400)

    data = request.json
    # concurrency:int, timeout:int , role:str, data:{}
    commandEntity = Command(role, command, data, data.get('concurrency'), data.get('timeout'))

    switcher = {
        "run": apiService.run,
        "pause": apiService.pause,
        "restart": apiService.restart,
        "stop": apiService.stop
    }

    func = switcher.get(command, lambda: "Invalid command")

    # Execute the function
    result = func(commandEntity)
    # Execute the function
    content = json.dumps(result, cls=MyEncoder)
    return content, 200, {'Content-Type': JSON_MIME_TYPE}
Esempio n. 2
0
def doAll(command):
    if command is None:
        abort(404)

    switcher = {
        "run": apiService.run,
        "pause": apiService.pause,
        "restart": apiService.restart,
        "stop": apiService.stop
    }

    commandEntity = Command("all", command, None, 5, 10)
    func = switcher.get(command, lambda: "Invalid command")

    # Execute the function
    result = func(commandEntity)
    content = json.dumps(result)
    return content, 200, {'Content-Type': JSON_MIME_TYPE}
Esempio n. 3
0
def doGet(role, command):
    # execute command
    if role is None or command is None:
        abort(404)

    # concurrency:int, timeout:int , role:str, data:{}
    commandEntity = Command(role, command, None, 5, 10)

    switcher = {
        "run": apiService.run,
        "pause": apiService.pause,
        "restart": apiService.restart,
        "stop": apiService.stop
    }

    func = switcher.get(command, lambda: "Invalid command")
    # Execute the function
    result = func(commandEntity)
    # Execute the function
    content = json.dumps(result, cls=MyEncoder)
    return content, 200, {'Content-Type': JSON_MIME_TYPE}
Esempio n. 4
0
 def __init__(self, subprocess, hive_home, options):
     Command.__init__(self, "docker", subprocess, hive_home, options)
     self._cli = ["docker"]
Esempio n. 5
0
 def __init__(self, subprocess, hive_home, options):
     Command.__init__(self, "script", subprocess, hive_home, options)
Esempio n. 6
0
 def __init__(self, subprocess, hive_home, options):
     Command.__init__(self, "certificate", subprocess, hive_home, options)
Esempio n. 7
0
    def __init__(self, subprocess, hive_home, options):
        Command.__init__(self, "kubernetes", subprocess, hive_home, options)

        self._kubernetes = kubernetes(subprocess, hive_home, options)
Esempio n. 8
0
    def __init__(self, subprocess, hive_home, options):
        Command.__init__(self, "kubernetes", subprocess, hive_home, options)

        self.gcloud = gcloud(subprocess, hive_home, options)
        self.resources_path = '/hive_share/kubernetes/manifests'
Esempio n. 9
0
    def __init__(self, subprocess, hive_home, options):
        Command.__init__(self, "kubernetes", subprocess, hive_home, options)

        self.resources_path = '/hive_share/kubernetes/manifests'
        self.kubectl = gcloud(subprocess, hive_home, options).get_container() + " kubectl "