本文整理汇总了Python中marathon.MarathonClient.update_app方法的典型用法代码示例。如果您正苦于以下问题:Python MarathonClient.update_app方法的具体用法?Python MarathonClient.update_app怎么用?Python MarathonClient.update_app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marathon.MarathonClient
的用法示例。
在下文中一共展示了MarathonClient.update_app方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_app
# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import update_app [as 别名]
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
}
)
示例2: update
# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import update_app [as 别名]
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
}
)
示例3: send_to_marathon
# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import update_app [as 别名]
def send_to_marathon(request):
try:
if request.method == 'POST':
action = request.POST.get('action', None)
id = request.POST.get('id', None)
mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
if action == 'stop':
mc.scale_app(id, 0, force=True)
elif action == 'start':
mc.scale_app(id, 1)
elif action == 'destroy':
if request.user.has_perm("auth.can_init_app"):
mc.delete_app(id)
else:
raise PermissionDenied
elif action == 'restart':
mc.restart_app(id)
elif action == 'scale':
mc.scale_app(id, int(request.POST.get('number_instance')))
elif action == 'update':
app = mc.get_app(id)
app.cpus = float(request.POST.get('cpus'))
app.mem = float(request.POST.get('mem'))
app.container.docker.image = request.POST.get('version')
mc.update_app(id, app)
elif action == "stop-deployment":
mc.delete_deployment(id)
result = '{"status":"success", "msg": "%(action)s success"}'%{"action":action}
except Exception as e:
result = '{"status":"error", "msg": "%(action)s fail: %(error)s" }'%{"action":action, "error": html.escape(str(e))}
return HttpResponse(result)
示例4: re_deploy
# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import update_app [as 别名]
def re_deploy(app_name, app_file):
"""Calls marathon API to redeploy application with new file as request body
:param app_name:
:param app_file:
:return:
"""
with open(app_file, 'r') as content_file:
content = content_file.read()
app_attr = json.loads(content)
marathon_addresses = _addresses()
cli = MarathonClient(marathon_addresses)
if _is_deployed(cli, app_name):
return cli.update_app(app_name, models.MarathonApp.from_json(app_attr))
else:
return None
示例5: update_app_from_json
# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import update_app [as 别名]
def update_app_from_json( self, json_data, force ):
a = MarathonApp.from_json(json_data)
return MarathonClient.update_app(self, a.id, a, force)