def marathon_get_request(args, path): url = args.marathon + path try: response = requests.get(url, auth=get_marathon_auth_params(args)) response.raise_for_status() except requests.exceptions.RequestException: raise MarathonEndpointException("Error while querying marathon", url, traceback.format_exc()) return response
def marathon_get_request(args, path): url = args.marathon + path try: response = requests.get(url, auth=get_marathon_auth_params(args)) response.raise_for_status() except requests.exceptions.RequestException: raise MarathonEndpointException( "Error while querying marathon", url, traceback.format_exc()) return response
def delete_marathon_app(args, app): url = args.marathon + '/v2/apps' + app['id'] try: response = requests.delete(url, auth=get_marathon_auth_params(args)) response.raise_for_status() except requests.exceptions.RequestException: raise AppDeleteException("Error while deleting the app", url, traceback.format_exc()) return response
def delete_marathon_app(args, app): url = args.marathon + '/v2/apps' + app['id'] try: response = requests.delete(url, auth=get_marathon_auth_params(args)) response.raise_for_status() except requests.exceptions.RequestException: raise AppDeleteException( "Error while deleting the app", url, traceback.format_exc()) return response
def deploy_marathon_app(args, app): url = args.marathon + "/v2/apps" data = json.dumps(app) 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: raise AppCreateException( "Error while creating the app", url, data, traceback.format_exc()) return response
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
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
# Management for the BIG-IP partitions cccls = [] for partition in args.partition: cccl = F5CloudServiceManager(bigip, partition, user_agent=user_agent, prefix="") cccls.append(cccl) # Set request retries s = requests.Session() a = requests.adapters.HTTPAdapter(max_retries=3) s.mount('http://', a) if os.environ.get('SCALE_PERF_ENABLE'): logger.info('SCALE_PERF: Started controller at: %f', time.time()) # Marathon API connector marathon = Marathon(args.marathon, args.health_check, get_marathon_auth_params(args), args.marathon_ca_cert) processor = MarathonEventProcessor(marathon, args.verify_interval, cccls) while True: try: events = marathon.get_event_stream(args.sse_timeout) process_sse_events(processor, events) except Exception: logger.exception("Marathon event exception:") logger.error("Reconnecting to Marathon event stream...") time.sleep(1)
cccl = F5CloudServiceManager( bigip, partition, user_agent=user_agent, prefix="") cccls.append(cccl) # Set request retries s = requests.Session() a = requests.adapters.HTTPAdapter(max_retries=3) s.mount('http://', a) if os.environ.get('SCALE_PERF_ENABLE'): logger.info('SCALE_PERF: Started controller at: %f', time.time()) # Marathon API connector marathon = Marathon(args.marathon, args.health_check, get_marathon_auth_params(args), args.marathon_ca_cert) processor = MarathonEventProcessor(marathon, args.verify_interval, cccls) while True: try: events = marathon.get_event_stream(args.sse_timeout) process_sse_events(processor, events) except Exception: logger.exception("Marathon event exception:") logger.error("Reconnecting to Marathon event stream...") time.sleep(1)