• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python marathon.MarathonClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update

def update(service, instances = 1):
	#
	# set up marathon client and launch container
	#
	print 'updating ' + service
	image_string = 'docker:///' + data['services'][service]['image']
	print image_string
	marathon_client = MarathonClient('http://' + str(data['marathon']['host']) + ':' + str(data['marathon']['port']))
	app = marathon_client.get_app(service)
	#
	# set up options for cassandra
	#
	options = []
	if service == "cassandra":
		options = ["-p", "7000:7000", "-p", "9042:9042", "-p", "9160:9160", "-p", "22000:22", "-p", "5000:5000"]
		# ports = []
		# constraints = [["hostname", "UNIQUE"]]
	marathon_client.update_app(
		service,
		app,
		instances = instances,
		container = {
			"image" : image_string, 
			"options" : options
		}
	)
开发者ID:davidbliu,项目名称:Mesos-Docker,代码行数:26,代码来源:updater.py


示例2: test_list_tasks_without_app_id

def test_list_tasks_without_app_id(m):
    fake_response = '{ "tasks": [ { "appId": "/anapp", "healthCheckResults": ' \
                    '[ { "alive": true, "consecutiveFailures": 0, "firstSuccess": "2014-10-03T22:57:02.246Z", "lastFailure": null, ' \
                    '"lastSuccess": "2014-10-03T22:57:41.643Z", "taskId": "bridged-webapp.eb76c51f-4b4a-11e4-ae49-56847afe9799" } ],' \
                    ' "host": "10.141.141.10", "id": "bridged-webapp.eb76c51f-4b4a-11e4-ae49-56847afe9799", "ports": [ 31000 ], ' \
                    '"servicePorts": [ 9000 ], "stagedAt": "2014-10-03T22:16:27.811Z", "startedAt": "2014-10-03T22:57:41.587Z", ' \
                    '"version": "2014-10-03T22:16:23.634Z" }, { "appId": "/anotherapp", ' \
                    '"healthCheckResults": [ { "alive": true, "consecutiveFailures": 0, "firstSuccess": "2014-10-03T22:57:02.246Z", ' \
                    '"lastFailure": null, "lastSuccess": "2014-10-03T22:57:41.649Z", "taskId": "bridged-webapp.ef0b5d91-4b4a-11e4-ae49-56847afe9799" } ], ' \
                    '"host": "10.141.141.10", "id": "bridged-webapp.ef0b5d91-4b4a-11e4-ae49-56847afe9799", "ports": [ 31001 ], "servicePorts": [ 9000 ], ' \
                    '"stagedAt": "2014-10-03T22:16:33.814Z", "startedAt": "2014-10-03T22:57:41.593Z", "version": "2014-10-03T22:16:23.634Z" } ] }'
    m.get('http://fake_server/v2/tasks', text=fake_response)
    mock_client = MarathonClient(servers='http://fake_server')
    actual_deployments = mock_client.list_tasks()
    expected_deployments = [
        models.task.MarathonTask(
            app_id="/anapp",
            health_check_results=[
                models.task.MarathonHealthCheckResult(
                    alive=True,
                    consecutive_failures=0,
                    first_success="2014-10-03T22:57:02.246Z",
                    last_failure=None,
                    last_success="2014-10-03T22:57:41.643Z",
                    task_id="bridged-webapp.eb76c51f-4b4a-11e4-ae49-56847afe9799"
                )
            ],
            host="10.141.141.10",
            id="bridged-webapp.eb76c51f-4b4a-11e4-ae49-56847afe9799",
            ports=[
                31000
            ],
            service_ports=[
                9000
            ],
            staged_at="2014-10-03T22:16:27.811Z",
            started_at="2014-10-03T22:57:41.587Z",
            version="2014-10-03T22:16:23.634Z"
        ),
        models.task.MarathonTask(
            app_id="/anotherapp",
            health_check_results=[
                models.task.MarathonHealthCheckResult(
                    alive=True,
                    consecutive_failures=0,
                    first_success="2014-10-03T22:57:02.246Z",
                    last_failure=None,
                    last_success="2014-10-03T22:57:41.649Z",
                    task_id="bridged-webapp.ef0b5d91-4b4a-11e4-ae49-56847afe9799"
                )
            ],
            host="10.141.141.10",
            id="bridged-webapp.ef0b5d91-4b4a-11e4-ae49-56847afe9799",
            ports=[31001],
            service_ports=[9000],
            staged_at="2014-10-03T22:16:33.814Z",
            started_at="2014-10-03T22:57:41.593Z",
            version="2014-10-03T22:16:23.634Z"
        )]
    assert actual_deployments == expected_deployments
开发者ID:ammaraskar,项目名称:marathon-python,代码行数:60,代码来源:test_api.py


示例3: servermarathon

def servermarathon():
        APP = os.environ['APPNAME']    
#         STRING = os.environ['STRING']
#         content = STRING
#         contentlist = content.split('&')
#         list = []
#         for i in contentlist:
#             p = i.split('=')
#             p = p[1] 
#             l = list.append(p)
#         (maurl,mau,map) =tuple(list)
#         marathonip = maurl
#         user = mau
#         password = map
        c = MarathonClient(marathonip,username=user,password=password)
        buildFile=open('build.txt','r')
        dockerimage = buildFile.readline()
        buildFile.close()
        readed = json.load(open('temp.json', 'r'))
        readed['container']['docker']['image'] = dockerimage
        readed['id'] = APP
        json.dump(readed, open('app.json', 'w')) 
        
        try:
           c.delete_app(APP,force=True)
           print 'delete'
        except :
            pass
          
        sleep(3)
        u= user+':'+password
        cmd1 = os.system ('curl -u %s -X POST -H "Content-Type: application/json" %s/v2/apps [email protected]' %(u,marathonip))
开发者ID:guirenkeji,项目名称:guirentest,代码行数:32,代码来源:marathonapptask.py


示例4: clean_deploy_ids

	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,代码行数:7,代码来源:Entities.py


示例5: enable_logstash

def enable_logstash():
    print "Checking ELK entries\n"
    endpoint = os.getenv('MARATHON_ENDPOINT')
    username = os.getenv('MARATHON_HTTP_USER')
    password = os.getenv('MARATHON_HTTP_PASSWORD')
    elk_host = None
    if endpoint:
        try:
            print 'Discovering configuration from %s\n' % endpoint
            c = MarathonClient('https://%s' % endpoint, username=username, password=password)
            tasks = c.list_tasks('yroblaelk')
            for task in tasks:
                if task.started_at:
                    elk_host = task.host
                    break
        except:
            pass

    # check entries in wsrep_cluster_address
    if elk_host:
        print 'Found ELK address %s\n' % elk_host
        for line in fileinput.input(LOGSTASH_CONF_FILE, inplace=True):
            line_content = line
            sys.stdout.write(line.replace("ELK_HOST", elk_host))
        # reboot logstash
        subprocess.call(["service", "logstash-forwarder", "restart"])
开发者ID:ekesken,项目名称:docker-rabittmq,代码行数:26,代码来源:rabbitmq-cluster.py


示例6: MarathonDeployer

class MarathonDeployer(object):


    def __init__(self, marathon_url):
        self.url = marathon_url
        self.client = MarathonClient(self.url)

    def deploy(self, task_chain, environment_name):
        deployed_chain = DeployedTaskChain(task_chain, environment_name)
        for task in deployed_chain.list_all_tasks():
            task_id = task['id']
            safe_name = task_id.lower()
            # safe_name = task['name'].replace('.', '').lower()
            try:
                if self.client.get_app(safe_name):
                    self.client.delete_app(safe_name)
                    time.sleep(2)
            except Exception:
                pass

            app = MarathonApp(cmd='/var/riversnake/invoke.py {0} {1} {2}'.format(
                        task_chain.flow_name,
                        environment_name,
                        task_id),
                    mem=16, cpus=1)

            self.client.create_app(safe_name, app)
开发者ID:jal648,项目名称:riversnake,代码行数:27,代码来源:deploy.py


示例7: update_app

def update_app(app_id, config, instances = 1):
	#
	# set up marathon client and launch container
	#
	image_string = 'docker:///' + config['image']
	marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
	app = marathon_client.get_app(app_id)
	#
	# set up options for cassandra TODO this is terrible dawg
	#
	decoded = namespacer.decode_marathon_id(app_id)
	options = []
	if str(decoded['service']) == "cassandra":
		options = ["-p", "7000:7000", "-p", "9042:9042", "-p", "9160:9160", "-p", "22000:22", "-p", "5000:5000"]
		# ports = []
		# constraints = [["hostname", "UNIQUE"]]

	marathon_client.update_app(
		app_id,
		app,
		instances = instances,
		container = {
			"image" : image_string, 
			"options" : options
		}
	)
开发者ID:davidbliu,项目名称:theseus,代码行数:26,代码来源:launcher.py


示例8: new_app

def new_app(request):
    data = {}
    if request.method == "POST":
        data["msg"] = "Post"
        post_params = {}
        for key in request.POST:
            if key.startswith("filehidden"):
                fkey = key[11:]
                if request.FILES.get(fkey, None):
                    post_file = request.FILES[fkey]
                    file_content = ""
                    for chunk in post_file.chunks():
                        file_content += chunk.decode("utf8")
                    post_params[fkey] = convert(file_content)
                else:
                    post_params[fkey] = request.POST[key]
            else:
                post_params[key] = request.POST[key]

        template = Template.objects.get(pk=post_params["template_id"])
        content = template.content % post_params
        data["content"] = content
        mc = MarathonClient("http://{}:{}".format(settings.MARATHON["host"], settings.MARATHON["port"]))
        try:
            mc.create_app_by_json(content)
            data["result"] = "Success"
        except Exception as e:
            data["result"] = str(e)

    templates = Template.objects.filter(type="marathon").all()
    for template in templates:
        template.params = template.param_set.order_by("id")

    data["templates"] = templates
    return render(request, "marathon_mgmt/new_app.html", data)
开发者ID:ntk148v,项目名称:mesos-admin,代码行数:35,代码来源:views.py


示例9: sync_marathon_app

def sync_marathon_app():
    """Identify the hosts and ports of executing tasks

    Optional environment variables:
    MARATHON_ROOT_URL: protocol, address or ip and port to Marathon
    MARATHON_APP: app name within Marathon used to group all tasks (server instances)
    MARATHON_APP_PORT: internal port of service (internal to docker container: default of 8080)

    :return:
    """
    # Identify the hosts and ports of executing tasks
    try:
        c = None
        if len(DCOS_OAUTH_TOKEN):
            c = MarathonClient(MARATHON_ROOT_URLS, auth_token=DCOS_OAUTH_TOKEN)
        else:
            c = MarathonClient(MARATHON_ROOT_URLS)

        app = c.get_app(MARATHON_APP)

        port_index = find_port_index_by_container_port(app, MARATHON_APP_PORT)

        if port_index is None:
            raise Exception('Unable to correlate container to host port.')

        instances = []
        for task in app.tasks:
            logging.info('Queuing configuration refresh of %s at %s:%s' %
                         (task.id, task.host, task.ports[port_index]))
            instances.append('%s:%s' % (task.host, task.ports[port_index]))

        reload_config(instances)

    except MarathonError, ex:
        print 'Error making Marathon API call: %s' % ex.message
开发者ID:AppliedIS,项目名称:dcos-geoserver,代码行数:35,代码来源:geoserver_sync.py


示例10: get_marathon_app_id

	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,代码行数:8,代码来源:Entities.py


示例11: is_deployed

	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,代码行数:8,代码来源:Entities.py


示例12: list_app

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,代码行数:8,代码来源:views.py


示例13: _get_hosts_with_container

    def _get_hosts_with_container(self, context, cluster):
        marathon_client = MarathonClient(
            'http://' + cluster.api_address + '/marathon/')
        hosts = set()
        for task in marathon_client.list_tasks():
            hosts.add(task.host)

        return hosts
开发者ID:openstack,项目名称:magnum,代码行数:8,代码来源:scale_manager.py


示例14: launch_qsf

def launch_qsf(marathon_url):
    logging.info('Launching QSF using %s' %(marathon_url))

    # launch via Marathon REST API
    c = MarathonClient(marathon_url)
    c.create_app('dromedar-qsf', MarathonApp(cmd='python dromedar-master/qsf.py %s' %(marathon_url), uris=['https://github.com/mhausenblas/dromedar/archive/master.zip'], mem=100, cpus=.5))
    
    logging.info('QSF up and running.')
开发者ID:else,项目名称:dromedar,代码行数:8,代码来源:dromedar.py


示例15: get_hosts_dict

 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,代码行数:9,代码来源:api_marathon.py


示例16: num_started_tasks

def num_started_tasks(app_id):
	count = 0
	marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
	app = marathon_client.get_app(app_id)
	tasks = app.tasks
	for task in tasks:
		if task.started_at:
			count += 1
	return count
开发者ID:davidbliu,项目名称:theseus,代码行数:9,代码来源:replacer.py


示例17: ajax_deployments

def ajax_deployments(request):
    mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
    deployments = mc.list_deployments()
    data = {}
    for deployment in deployments:
        deployment.complete = (deployment.current_step-1) * 100 / deployment.total_steps

    data['deployments'] = deployments
    data['total_depl'] = len(deployments)
    return render(request, 'marathon_mgmt/ajax_deployments.html', data)
开发者ID:huanpc,项目名称:mesos-admin,代码行数:10,代码来源:views.py


示例18: get_deployed_labeled_group_ids

	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,代码行数:10,代码来源:Entities.py


示例19: dashboard

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,代码行数:10,代码来源:views.py


示例20: undeploy

def undeploy(app_name):
    """Calls marathon API to undeploy application

    :param app_name:
    :return:
    """
    marathon_addresses = _addresses()
    cli = MarathonClient(marathon_addresses)
    if _is_deployed(cli, app_name):
        return cli.delete_app(app_name)
    else:
        return None
开发者ID:MavenCode,项目名称:saltstack-formulas,代码行数:12,代码来源:marathon_client.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python marathon_lb.config函数代码示例发布时间:2022-05-27
下一篇:
Python tools.get_setting_value函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap