本文整理汇总了Python中eru.models.App.get_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python App.get_by_name方法的具体用法?Python App.get_by_name怎么用?Python App.get_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eru.models.App
的用法示例。
在下文中一共展示了App.get_by_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_app_env
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def get_app_env(name):
app = App.get_by_name(name)
if not app:
raise EruAbortException(consts.HTTP_BAD_REQUEST, 'App %s not found, env list ignored' % name)
envconfig = app.get_resource_config(request.args['env'])
return {'r': 0, 'msg': 'ok', 'data': envconfig.to_env_dict()}
示例2: list_app_env
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def list_app_env(name):
app = App.get_by_name(name)
if not app:
logger.error('app not found, env set ignored')
raise EruAbortException(code.HTTP_BAD_REQUEST)
return {'r': 0, 'msg': 'ok', 'data': app.list_resource_config()}
示例3: list_app_containers
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def list_app_containers(name):
app = App.get_by_name(name)
if not app:
logger.error('app not found, env list ignored')
raise EruAbortException(code.HTTP_BAD_REQUEST, 'App %s not found, env list ignored' % name)
containers = app.containers.all()
return {'r': 0, 'msg': 'ok', 'containers': containers}
示例4: alloc_resource
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def alloc_resource(name, env, res_name, res_alias):
app = App.get_by_name(name)
if not app:
raise EruAbortException(code.HTTP_NOT_FOUND)
r = RESOURCES.get(res_name)
if not r:
raise EruAbortException(code.HTTP_NOT_FOUND, '%s doesn\'t exist' % res_name)
envconfig = app.get_resource_config(env)
if envconfig.get(res_alias):
raise EruAbortException(code.HTTP_CONFLICT, '%s already in env' % res_alias)
try:
mod = import_string(r)
args = inspect.getargspec(mod.alloc)
data = request.get_json()
if set(data.iterkeys()) >= set(args.args[1:]):
raise Exception()
result = mod.alloc(**data)
envconfig[res_alias] = result
envconfig.save()
except Exception, e:
current_app.logger.exception(e)
raise EruAbortException(code.HTTP_BAD_REQUEST, 'Error in creating %s' % res_name)
示例5: list_version_tasks
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def list_version_tasks(name, version):
app = App.get_by_name(name)
if not app:
raise EruAbortException(consts.HTTP_BAD_REQUEST, 'App %s not found, env list ignored' % name)
v = app.get_version(version)
if not v:
raise EruAbortException(consts.HTTP_NOT_FOUND, 'Version %s not found' % version)
return {'r': 0, 'msg': 'ok', 'tasks': v.list_tasks(g.start, g.limit)}
示例6: get_version
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def get_version(name, version):
app = App.get_by_name(name)
if not app:
raise EruAbortException(consts.HTTP_NOT_FOUND, 'App %s not found' % name)
v = app.get_version(version)
if not v:
raise EruAbortException(consts.HTTP_NOT_FOUND, 'Version %s not found' % version)
return v
示例7: list_version_containers
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def list_version_containers(name, version):
app = App.get_by_name(name)
if not app:
logger.error('app not found, env list ignored')
raise EruAbortException(code.HTTP_BAD_REQUEST, 'App %s not found, env list ignored' % name)
v = app.get_version(version)
if not v:
raise EruAbortException(code.HTTP_NOT_FOUND, 'Version %s not found' % version)
return {'r': 0, 'msg': 'ok', 'containers': v.list_containers(g.start, g.limit)}
示例8: _get_app_and_version
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def _get_app_and_version(appname, version, **kwargs):
app = App.get_by_name(appname)
if not app:
abort(400, 'App `%s` not found' % appname)
version = app.get_version(version)
if not version:
abort(400, 'Version `%s` not found' % version)
return app, version
示例9: set_app_env
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def set_app_env(name):
app = App.get_by_name(name)
if not app:
logger.error('app not found, env set ignored')
raise EruAbortException(code.HTTP_BAD_REQUEST, 'App %s not found, env set ignored' % name)
data = request.get_json()
env = data.pop('env')
envconfig = app.get_resource_config(env)
envconfig.update(**data)
envconfig.save()
return {'r': 0, 'msg': 'ok'}
示例10: set_app_env
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def set_app_env(name):
data = request.get_json()
env = data.pop('env')
app = App.get_by_name(name)
if not app:
current_app.logger.error('App (name=%s) not found, env (env=%s) set ignored.', name, env)
raise EruAbortException(consts.HTTP_BAD_REQUEST, 'App %s not found, env set ignored' % name)
envconfig = app.get_resource_config(env)
envconfig.update(**data)
envconfig.save()
current_app.logger.error('App (name=%s) set env (env=%s) values done', name, env)
return {'r': 0, 'msg': 'ok'}
示例11: touch_version_scale_info
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def touch_version_scale_info(name, version):
app = App.get_by_name(name)
if not app:
raise EruAbortException(code.HTTP_NOT_FOUND, 'App %s not found' % name)
v = app.get_version(version)
if not v:
raise EruAbortException(code.HTTP_NOT_FOUND, 'Version %s not found' % version)
containers = v.containers.limit(1).all()
if not containers:
raise EruAbortException(code.HTTP_NOT_FOUND, 'Not deployed')
container = containers[0]
return {
'group': container.host.group.name,
'pod': container.host.pod.name,
'ncore': len(container.cores.all())
}
示例12: validate_instance
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def validate_instance(group_name, pod_name, appname, version):
group = Group.get_by_name(group_name)
if not group:
raise EruAbortException(code.HTTP_BAD_REQUEST, 'Group `%s` not found' % group_name)
pod = Pod.get_by_name(pod_name)
if not pod:
raise EruAbortException(code.HTTP_BAD_REQUEST, 'Pod `%s` not found' % pod_name)
application = App.get_by_name(appname)
if not application:
raise EruAbortException(code.HTTP_BAD_REQUEST, 'App `%s` not found' % appname)
version = application.get_version(version)
if not version:
raise EruAbortException(code.HTTP_BAD_REQUEST, 'Version `%s` not found' % version)
return group, pod, application, version
示例13: validate_instance
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def validate_instance(group_name, pod_name, appname, version):
group = Group.get_by_name(group_name)
if not group:
abort(400, 'Group `%s` not found' % group_name)
pod = Pod.get_by_name(pod_name)
if not pod:
abort(400, 'Pod `%s` not found' % pod_name)
app = App.get_by_name(appname)
if not app:
abort(400, 'App `%s` not found' % appname)
version = app.get_version(version)
if not version:
abort(400, 'Version `%s` not found' % version)
return group, pod, app, version
示例14: clean_app
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def clean_app(app_name):
app = App.get_by_name(app_name)
if not app:
print 'app %s not found' % app_name
return
containers = app.list_containers(limit=None)
version_dict = {}
for c in containers:
if not c:
continue
version_dict.setdefault((c.version, c.host), []).append(c)
for (version, host), cs in version_dict.iteritems():
cids = [c.id for c in cs]
task_props = {'container_ids': cids}
task = Task.create(TASK_REMOVE, version, host, task_props)
remove_containers.apply_async(
args=(task.id, cids, False), task_id='task:%s' % task.id
)
print task
print 'done, waiting...'
示例15: list_app_env
# 需要导入模块: from eru.models import App [as 别名]
# 或者: from eru.models.App import get_by_name [as 别名]
def list_app_env(name):
app = App.get_by_name(name)
if not app:
raise EruAbortException(consts.HTTP_BAD_REQUEST)
return {'r': 0, 'msg': 'ok', 'data': app.list_resource_config()}