def get_hostname_from_marathon(self, environment, roger_env, appTaskId): hostname = '' marathon = Marathon() tasks = marathon.getTasks(roger_env, environment) for task in tasks: if task['id'].startswith(appTaskId): hostname = task['host'] return hostname
def getFramework(self, request_uri): marathon_pattern = re.compile("^{}$".format("/marathon/.*")) marathon_check = marathon_pattern.match(request_uri) chronos_pattern = re.compile("^{}$".format("/chronos/.*")) chronos_check = chronos_pattern.match(request_uri) if marathon_check: return Marathon() elif chronos_check: return Chronos() else: return None
def __init__(self, cli_args, logger=None): self.args = cli_args self.logger = logger or logging.getLogger(__name__) self.mesos = MesosMaster(cli_args.mesos_uri) self.marathon = Marathon( cli_args.marathon_uri, (cli_args.marathon_user, cli_args.marathon_pass) if cli_args.marathon_user and cli_args.marathon_pass else None) self.auto_scaler = AutoScaler(self.marathon, cli_args=cli_args) self.cpu_fan_out = cli_args.cpu_fan_out self.datadog_client = DatadogClient(cli_args) self.agent_port = cli_args.agent_port
def update(self, switch_state: Callable) -> None: self.input1.update() self.input2.update() if self.entered: if self.position == 0: switch_state(DevicePrompter(Marathon(), 1)) elif self.position == 1: switch_state(DevicePrompter(SplitScreen(), 2)) elif self.position == 2: switch_state(DevicePrompter(Online(), 1)) elif self.position == 3: ctx.running = False
logging.info('\n\n\n') if __name__ == '__main__': logging.basicConfig( #filename='marathon-autoscale.log', format='[%(asctime)s] %(levelname)s %(message)s', level=logging.DEBUG) logging.info("This application tested with Python3 only") config_file = 'config.properties' if len(sys.argv) > 1: config_file = sys.argv[1] cfg = config.Configuration() try: cfg.load(config_file) except Exception as e: logging.info("Exception %s" % e) sys.exit(1) # Initialize the Marathon object marathon = Marathon(cfg.marathon_endpoint, cfg.auth_id, cfg.auth_password) logging.info("Marathon URI = %s" % marathon.uri) scheduler = BackgroundScheduler() scheduler.add_job(monitor, 'interval', seconds=15, args=[marathon, cfg]) scheduler.start() app.run(host='0.0.0.0', port=5000)
def add_marathon(self, date, name, type, time_finished, category): marathon = Marathon(date, name, type, time_finished, category) self.marathons.append(marathon)