本文整理汇总了Python中eru.models.Host.get_random_public_host方法的典型用法代码示例。如果您正苦于以下问题:Python Host.get_random_public_host方法的具体用法?Python Host.get_random_public_host怎么用?Python Host.get_random_public_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eru.models.Host
的用法示例。
在下文中一共展示了Host.get_random_public_host方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_image_v2
# 需要导入模块: from eru.models import Host [as 别名]
# 或者: from eru.models.Host import get_random_public_host [as 别名]
def build_image_v2():
# form post
appname = request.form.get('appname', default='')
version = request.form.get('version', default='')
base = request.form.get('base', default='')
if not base:
abort(400, 'base image must be set')
_, version = _get_app_and_version(appname, version)
if ':' not in base:
base = base + ':latest'
host = Host.get_random_public_host()
if not host:
abort(406, 'no host is available')
# if no artifacts.zip is set
# ignore and just do the cloning and building
file_path = None
if 'artifacts.zip' in request.files:
f = request.files['artifacts.zip']
file_path = os.path.join(tempfile.mkdtemp(), secure_filename(f.filename))
f.save(file_path)
task = Task.create(TASK_BUILD, version, host, {'base': base})
build_docker_image.apply_async(
args=(task.id, base, file_path),
task_id='task:%d' % task.id
)
return {'task': task.id, 'watch_key': task.result_key}
示例2: build_image
# 需要导入模块: from eru.models import Host [as 别名]
# 或者: from eru.models.Host import get_random_public_host [as 别名]
def build_image(group_name, pod_name, appname):
data = request.get_json()
group, pod, _, version = validate_instance(group_name, pod_name, appname, data['version'])
base = data['base']
if ':' not in base:
base = base + ':latest'
host = Host.get_random_public_host() or pod.get_random_host()
task = Task.create(consts.TASK_BUILD, version, host, {'base': base})
build_docker_image.apply_async(
args=(task.id, base),
task_id='task:%d' % task.id
)
return {'r': 0, 'msg': 'ok', 'task': task.id, 'watch_key': task.result_key}
示例3: build_image
# 需要导入模块: from eru.models import Host [as 别名]
# 或者: from eru.models.Host import get_random_public_host [as 别名]
def build_image():
data = request.get_json()
_, version = _get_app_and_version(**data)
base = data['base']
if ':' not in base:
base = base + ':latest'
host = Host.get_random_public_host()
if not host:
abort(406, 'no host is available')
task = Task.create(TASK_BUILD, version, host, {'base': base})
build_docker_image.apply_async(
args=(task.id, base, None),
task_id='task:%d' % task.id
)
return {'task': task.id, 'watch_key': task.result_key}