当前位置: 首页>>代码示例>>Python>>正文


Python MarathonClient.list_apps方法代码示例

本文整理汇总了Python中marathon.MarathonClient.list_apps方法的典型用法代码示例。如果您正苦于以下问题:Python MarathonClient.list_apps方法的具体用法?Python MarathonClient.list_apps怎么用?Python MarathonClient.list_apps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marathon.MarathonClient的用法示例。


在下文中一共展示了MarathonClient.list_apps方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: clean_deploy_ids

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
	def clean_deploy_ids(self):
		marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
		apps = marathon_client.list_apps()
		app_ids = [x.id for x in apps]
		for deploy_id in self.deploy_ids:
			if not deploy_id in app_ids:
				print 'deploy_id is not in app id! '+str(deploy_id)
开发者ID:davidbliu,项目名称:Marathon-Subscriber,代码行数:9,代码来源:Entities.py

示例2: list_app

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
def list_app(request):
    mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
    apps = mc.list_apps()
    apps = sorted(apps, key=lambda app: app.id)
    for app in apps:
        app.tag_id = app.id.replace("/","__")
    data = {'apps': apps}
    return render(request, 'marathon_mgmt/list_app.html', data)
开发者ID:huanpc,项目名称:mesos-admin,代码行数:10,代码来源:views.py

示例3: is_deployed

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
	def is_deployed(self):
		marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
		apps = marathon_client.list_apps()
		my_encoded_id = self.encode_marathon_id
		for app in apps:
			if my_encoded_id in app.id:
				return True
		return False
开发者ID:davidbliu,项目名称:theseus,代码行数:10,代码来源:Entities.py

示例4: get_marathon_app_id

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
	def get_marathon_app_id(self):
		marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
		apps = marathon_client.list_apps()
		my_encoded_id = self.encode_marathon_id
		for app in apps:
			if app.id == my_encoded_id:
				return app.id
		return None
开发者ID:davidbliu,项目名称:Marathon-Subscriber,代码行数:10,代码来源:Entities.py

示例5: get_hosts_dict

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
 def get_hosts_dict(self):
   hosts={}
   for app in MarathonClient.list_apps(self):
     for task in MarathonClient.get_app(self,app.id).tasks:
       host = task.host
       if not host in hosts:
         hosts[host]=[]
       hosts[host].append(task)
   return hosts
开发者ID:jansara,项目名称:macli,代码行数:11,代码来源:api_marathon.py

示例6: dashboard

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
def dashboard(request):
    data = {}
    data['total_template'] = Template.objects.count()
    mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
    data['total_app'] = len(mc.list_apps())
    cclient = chronos.connect('{}:{}'.format(settings.CHRONOS['host'], settings.CHRONOS['port']))
    jobs = cclient.list()
    data['total_job'] = len(cclient.list())
    data['total_watcher'] = len(settings.WATCHER_THREADS)
    return render(request, 'dashboard/dashboard.html',data)
开发者ID:ntk148v,项目名称:mesos-admin,代码行数:12,代码来源:views.py

示例7: get_deployed_labeled_group_ids

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
	def get_deployed_labeled_group_ids(self, labels):
		ids = []
		marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
		apps = marathon_client.list_apps()
		for app in apps:
			decoded = decode_marathon_id(app.id)
			if labels == decoded['labels'] and self.name == decoded['service']:
				# return app.id
				ids.append(app.id)
		return ids
开发者ID:davidbliu,项目名称:theseus,代码行数:12,代码来源:Entities.py

示例8: get_apps_json_config

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
 def get_apps_json_config(self):
   n=0
   d={}
   for app in MarathonClient.list_apps(self):
     json_data=json.loads(app.to_json())
     for p in 'tasks', 'tasksRunning', 'tasksStaged':
       if p in json_data:
         del json_data[p]
     d[n]=json_data
     n+=1
   return(json.dumps(d))
开发者ID:jansara,项目名称:macli,代码行数:13,代码来源:api_marathon.py

示例9: ajax_list_apps

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
def ajax_list_apps(request):
    mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
    apps = mc.list_apps()
    apps = sorted(apps, key=lambda app: app.id)
    filter_name = request.GET.get('filter_name', "")
    if filter_name != "":
        for app in apps[:]:
            app.tag_id = app.id.replace("/","__")
            if app.id.find(filter_name) == -1:
                apps.remove(app)
    else:
        for app in apps:
            app.tag_id = app.id.replace("/","__")
    data = {'apps': apps}
    return render(request, 'marathon_mgmt/ajax_list_apps.html', data)
开发者ID:huanpc,项目名称:mesos-admin,代码行数:17,代码来源:views.py

示例10: dashboard

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
def dashboard(request):
    data = {}
    data["total_template"] = Template.objects.count()
    try:
        mc = MarathonClient("http://{}:{}".format(settings.MARATHON["host"], settings.MARATHON["port"]))
        data["total_app"] = len(mc.list_apps())
    except Exception as e:
        data["total_app"] = []
    try:
        cclient = chronos.connect("{}:{}".format(settings.CHRONOS["host"], settings.CHRONOS["port"]))
        jobs = cclient.list()
        data["total_job"] = len(cclient.list())
    except Exception as e:
        data["total_job"] = []

    data["total_watcher"] = len(settings.WATCHER_THREADS)
    return render(request, "dashboard/dashboard.html", data)
开发者ID:tranhuucuong91,项目名称:mesos-admin,代码行数:19,代码来源:views.py

示例11: ports_used

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
def ports_used(request):
    mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
    apps = mc.list_apps()
    used_ports = {}
    for app in apps:
        tasks = mc.list_tasks(app.id)
        for task in tasks:
            if task.host in used_ports.keys():
                used_ports[task.host].extend(task.ports)
            else:
                used_ports[task.host] = task.ports

    list_host_ports = []
    for key in sorted(used_ports.keys()):
        list_host_ports.append([key, sorted(used_ports[key])])

    data = {}
    data['used_ports'] = list_host_ports
    return render(request, 'marathon_mgmt/ports_used.html', data)
开发者ID:huanpc,项目名称:mesos-admin,代码行数:21,代码来源:views.py

示例12: MarathonIF

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
class MarathonIF(object):
    def __init__(self, marathon_addr, my_addr, mesos):
        self.mcli = MarathonClient(marathon_addr)
        self.myAddr = my_addr
        self.mesos = mesos

    def get_apps(self):
        listapps = self.mcli.list_apps()
        return listapps

    def get_app(self, app_id):
        try:
            a = self.mcli.get_app(app_id)
        except marathon.exceptions.NotFoundError as e:  # NOQA
            return None
        return a

    def delete_app(self, app_id, force=False):
        return self.mcli.delete_app(app_id, force)

    def delete_deployment(self, dep_id):
        return self.mcli.delete_deployment(dep_id)

    def get_deployments(self):
        return self.mcli.list_deployments()

    def delete_app_ifexisting(self, app_id, trys=4):
        for idx in range(0, trys):
            try:
                a = self.get_app(app_id)
                if a:
                    return self.delete_app(app_id)
                return None
            except:
                e = sys.exc_info()[0]
                pprint("<p>Error: %s</p>" % e)
                time.sleep(10)
        raise

    @staticmethod
    def is_valid_app_id(app_id):
        # allowed: lowercase letters, digits, hyphens, slash, dot
        if re.match("^[A-Za-z0-9-/.]*$", app_id):
            return True
        return False

    def create_app(self, app_id, attr):
        """
            Create and start an app.
            :param app_id: (str) - Application ID
            :param attr: marathon.models.app.MarathonApp application to create.
            :return: the created app
        """
        # Validate that app_id conforms to allowed naming scheme.
        if not self.is_valid_app_id(app_id):
            l.error("Error: Only lowercase letters, digits, hyphens are allowed in app_id. %s" % app_id)
            raise Exception("Invalid app_id")

        for idx in range(0, 10):
            try:
                a = self.mcli.create_app(app_id, attr)
                return a
            except marathon.exceptions.MarathonHttpError as e:
                if str(e).find('App is locked by one or more deployments. Override with the option') >= 0:
                    time.sleep(1)
                else:
                    raise
        raise

    def wait_app_removal(self, app):
        cnt = 0
        while True:
            if not self.get_app(app):
                break
            time.sleep(0.2)
            cnt += 1
            if cnt > 0:
                l.info("Stuck waiting for %s to be deleted CNT=%d" % (app, cnt))
        return True

    def wait_app_ready(self, app, running_count):
        cnt = 0
        while True:
            a1 = self.get_app(app)
            if a1.tasks_running == running_count:
                return a1
            cnt += 1
            time.sleep(1)
            if (cnt % 30) == 29:
                l.info("[%d]Waiting for task to move to running stage, " % cnt +
                       "current stat staged=%d running=%d expected Running=%d" %
                       (a1.tasks_staged, a1.tasks_running, running_count))

    def scale_app(self, app, scale):
        return self.mcli.scale_app(app, scale)

    def ping(self):
        return self.mcli.ping()
开发者ID:annym,项目名称:hydra,代码行数:100,代码来源:mmapi.py

示例13: MarathonIF

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
class MarathonIF(object):
    def __init__(self, marathon_addr, my_addr, mesos):
        self.mcli = MarathonClient(marathon_addr)
        self.myAddr = my_addr
        self.mesos = mesos

    def get_apps(self):
        listapps = self.mcli.list_apps()
        return listapps

    def get_app(self, app_id):
        try:
            a = self.mcli.get_app(app_id)
        except marathon.exceptions.NotFoundError as e:  # NOQA
            return None
        return a

    def delete_app(self, app_id, force=False):
        return self.mcli.delete_app(app_id, force)

    def delete_deployment(self, dep_id):
        return self.mcli.delete_deployment(dep_id)

    def get_deployments(self):
        return self.mcli.list_deployments()

    def delete_app_ifexisting(self, app_id, trys=4):
        for idx in range(0, trys):
            try:
                a = self.get_app(app_id)
                if a:
                    return self.delete_app(app_id)
                return None
            except:
                e = sys.exc_info()[0]
                pprint("<p>Error: %s</p>" % e)
                time.sleep(10)
        raise

    def create_app(self, app_id, attr):
        for idx in range(0, 10):
            try:
                a = self.mcli.create_app(app_id, attr)
                return a
            except marathon.exceptions.MarathonHttpError as e:
                if str(e).find('App is locked by one or more deployments. Override with the option') >= 0:
                    time.sleep(1)
                else:
                    raise
        raise

    def wait_app_removal(self, app):
        cnt = 0
        while True:
            if not self.get_app(app):
                break
            time.sleep(0.2)
            cnt += 1
            if cnt > 0:
                l.info("Stuck waiting for %s to be deleted CNT=%d" % (app, cnt))
        return True

    def wait_app_ready(self, app, running_count):
        cnt = 0
        while True:
            a1 = self.get_app(app)
            if a1.tasks_running == running_count:
                return a1
            cnt += 1
            time.sleep(1)
            if (cnt % 30) == 29:
                l.info("[%d]Waiting for task to move to running stage, " % cnt +
                       "current stat staged=%d running=%d expected Running=%d" %
                       (a1.tasks_staged, a1.tasks_running, running_count))

    def scale_app(self, app, scale):
        return self.mcli.scale_app(app, scale)

    def ping(self):
        return self.mcli.ping()
开发者ID:lorenzodavid,项目名称:hydra,代码行数:82,代码来源:mmapi.py

示例14: MarathonIF

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
class MarathonIF(object):
    def __init__(self, marathon_addr, my_addr, mesos):
        self.mcli = MarathonClient(marathon_addr)
        self.myAddr = my_addr
        self.mesos = mesos

    def get_apps(self):
        listapps = self.mcli.list_apps()
        return listapps

    def get_app(self, app_id, timeout=300):
        st_time = time.time()
        while(time.time() - st_time < timeout):
            try:
                try:
                    a = self.mcli.get_app(app_id)
                except marathon.exceptions.NotFoundError as e:  # NOQA
                    return None
                return a
            except:
                l.info("mcli: get_app returned error")
                l.info(traceback.format_exc())
                l.info("Retrying after 10 secs timeout=%d", timeout)
                time.sleep(10)
        raise Exception("mcli get_app timed out, possible zookeper/marathon/mesos malfunction")

    def delete_app(self, app_id, force=False, timeout=200):
        st_time = time.time()
        while(time.time() - st_time < timeout):
            try:
                self.mcli.delete_app(app_id, force)
                return
            except:
                l.info("mcli: delete_app returned error")
                l.info(traceback.format_exc())
                l.info("Retrying after 10 secs timeout=%d", timeout)
                time.sleep(10)
        raise Exception("mcli delete_app timed out, possible zookeper/marathon/mesos malfunction")

    def delete_deployment(self, dep_id):
        return self.mcli.delete_deployment(dep_id)

    def get_deployments(self):
        return self.mcli.list_deployments()

    def delete_app_ifexisting(self, app_id, trys=4):
        for idx in range(0, trys):
            try:
                a = self.get_app(app_id)
                if a:
                    return self.delete_app(app_id)
                return None
            except:
                e = sys.exc_info()[0]
                pprint("<p>Error: %s</p>" % e)
                time.sleep(10)
        raise

    @staticmethod
    def is_valid_app_id(app_id):
        # allowed: lowercase letters, digits, hyphens, slash, dot
        if re.match("^[A-Za-z0-9-/.]*$", app_id):
            return True
        return False

    def create_app(self, app_id, attr):
        """
            Create and start an app.
            :param app_id: (str) - Application ID
            :param attr: marathon.models.app.MarathonApp application to create.
            :return: the created app
        """
        # Validate that app_id conforms to allowed naming scheme.
        if not self.is_valid_app_id(app_id):
            l.error("Error: Only lowercase letters, digits, hyphens are allowed in app_id. %s" % app_id)
            raise Exception("Invalid app_id")

        for idx in range(0, 10):
            try:
                a = self.mcli.create_app(app_id, attr)
                return a
            except marathon.exceptions.MarathonHttpError as e:
                if str(e).find('App is locked by one or more deployments. Override with the option') >= 0:
                    time.sleep(1)
                else:
                    raise
        raise

    def wait_app_removal(self, app):
        cnt = 0
        while True:
            if not self.get_app(app):
                break
            time.sleep(0.2)
            cnt += 1
            if cnt > 0:
                l.info("Stuck waiting for %s to be deleted CNT=%d" % (app, cnt))
        return True

    def wait_app_ready(self, app, running_count, sleep_before_next_try=1):
#.........这里部分代码省略.........
开发者ID:kratos7,项目名称:hydra,代码行数:103,代码来源:mmapi.py

示例15: MarathonClient

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import list_apps [as 别名]
    parser = argparse.ArgumentParser()
    parser.add_argument("-m", "--marathon",
                        help="Marathon URL, on example "
                             "http://127.0.0.1:8080/marathon",
                        required=True)
    parser.add_argument("-e", "--execute", help="Operation execute",
                        choices=['delete', 'create'], required=True)
    parser.add_argument("-d", "--delete",
                        help="Delete all applications",
                        action="store_true")
    parser.add_argument("-c", "--concurrency",
                        help="Concurrency")
    parser.add_argument("-n", "--nodes",
                        help="Number of tasks per application")
    parser.add_argument("-s", "--silent",
                        help="Print only results",
                        action="store_true")
    args = parser.parse_args()
    cluster = MarathonClient(args.marathon, timeout=240)

    if args.execute == "delete":
        cluster = MarathonClient(args.marathon)
        all_apps = cluster.list_apps()
        for app in all_apps:
            print("Delete {}".format(app.id))
            cluster.delete_app(app.id, force=True)
    if args.execute == "create":
        concur = 1 if args.concurrency is None else args.concurrency
        nodes = 1 if args.nodes is None else args.nodes
        concur_create_apps(int(concur), int(nodes))
开发者ID:openstack,项目名称:performance-docs,代码行数:32,代码来源:application_managment_helper.py


注:本文中的marathon.MarathonClient.list_apps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。