コード例 #1
0
def scale_marathon_app_instances(args, app, instances):
    url = args.marathon + "/v2/apps" + app['id']
    data = json.dumps({'instances': instances})
    headers = {'Content-Type': 'application/json'}
    try:
        response = requests.put(url, headers=headers, data=data,
                                auth=get_marathon_auth_params(args))
        response.raise_for_status()
    except requests.exceptions.RequestException:
        # This is App Scale Up, so raising AppScale Exception
        raise AppScaleException(
            "Error while scaling the app", url, data, traceback.format_exc())
    return response
コード例 #2
0
def kill_marathon_tasks(args, ids):
    data = json.dumps({'ids': ids})
    url = args.marathon + "/v2/tasks/delete?scale=true"
    headers = {'Content-Type': 'application/json'}
    try:
        response = requests.post(url, headers=headers, data=data,
                                 auth=get_marathon_auth_params(args))
        response.raise_for_status()
    except requests.exceptions.RequestException:
        # This is App Scale Down, so raising AppScale Exception
        raise AppScaleException(
            "Error while scaling the app", url, data, traceback.format_exc())
    return response