def getAllJobs(): mclient = marathon.Marathon(MARATHON_URL) apps = mclient.getApps() for app in apps['apps']: a = mclient.getApp(app['id']) host = a['app']['tasks'][0]['host'] port = a['app']['ports'][0] url = 'http://' + host + ':' + str(port) master = {'name': id, 'url': url} print captureStatus(master)
def get_host_port(master_name): mclient = marathon.Marathon(MARATHON_URL) response = mclient.getApp(master_name) if response: tasks = response['app']['tasks'] if tasks and len(tasks) > 0: host = tasks[0]['host'] port = str(tasks[0]['ports'][0]) jenkins_url = "http://"+host+":"+port return jenkins_url return None
def create_jenkins_master(master_name, jobConfig): logging.debug('Creating jenkins master: %s' %(master_name)) app_json = load_fixture(FIXTURES_DIR+APP_FIXTURES+JENKINS_FIXTURE) app_json = app_json % (master_name, master_name) mclient = marathon.Marathon(MARATHON_URL) status = mclient.createApp(app_json) # time.sleep(120) jenkins_url = None return {'name': master_name, 'url': jenkins_url}
def __init__(self, compose_file, master_url, acs_host, acs_port, acs_username, acs_password, acs_private_key, group_name, group_qualifier, group_version, registry_host, registry_username, registry_password, minimum_health_capacity, check_dcos_version=False): self.cleanup_needed = False self._ensure_docker_compose(compose_file) with open(compose_file, 'r') as compose_stream: self.compose_data = yaml.load(compose_stream) self.acs_info = acsinfo.AcsInfo(acs_host, acs_port, acs_username, acs_password, acs_private_key, master_url) self.group_name = group_name self.group_qualifier = group_qualifier self.group_version = group_version self.registry_host = registry_host self.registry_username = registry_username self.registry_password = registry_password self.minimum_health_capacity = minimum_health_capacity self.acs_client = acsclient.ACSClient(self.acs_info) if check_dcos_version: self.acs_client.ensure_dcos_version() self.marathon_helper = marathon.Marathon(self.acs_client) self.exhibitor_helper = Exhibitor(self.marathon_helper) self.nginx_helper = LoadBalancerApp(self.marathon_helper) self.portmappings_helper = portmappings.PortMappings()
def delete_jenkins_master(master_name): logging.debug('Deleting jenkins master: %s' % (master_name)) mclient = marathon.Marathon(MARATHON_URL) mclient.deleteApp(master_name)