本文整理汇总了Python中web.model.host_group.HostGroup类的典型用法代码示例。如果您正苦于以下问题:Python HostGroup类的具体用法?Python HostGroup怎么用?Python HostGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HostGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: rename
def rename(old_str=None, new_str=None, login_user=None):
tup = (old_str, new_str, login_user)
print('msg="%s"' % (tup,))
gs = HostGroup.select_vs(where='create_user = %s and come_from = %s', params=[login_user, 1])
for g in gs:
HostGroup.update_dict({'grp_name': g.grp_name.replace(old_str, new_str)}, 'id=%s', [g.id])
return ''
开发者ID:Cepave,项目名称:portal,代码行数:7,代码来源:group_service.py
示例2: host_groups_get
def host_groups_get(host_id,host_name):
if not os.path.exists( str(EXTERNAL_NODES) ):
host_id = int(host_id)
h = Host.read('id = %s', params=[host_id])
if not h:
return jsonify(msg='no such host')
group_ids = GroupHost.group_ids(h.id)
else:
(status, output) = commands.getstatusoutput(EXTERNAL_NODES + " GetHostGroupByHost " + host_id )
group_ids = []
h = {}
if status == 0:
decodejson = json.loads( output )
gname = "1"
for i in decodejson:
gname = gname + ",'" + decodejson[i] + "'"
groupMsg = HostGroup.select(cols="id,grp_name", where="grp_name in (%s)" % gname)
for m in groupMsg:
group_ids.append( m[0] )
h["id"] = host_id
h["hostname"] = host_name
groups = [HostGroup.read('id = %s', [group_id]) for group_id in group_ids]
return render_template('host/groups.html', groups=groups, host=h)
开发者ID:Liuyanglong,项目名称:monitor-portal,代码行数:25,代码来源:host.py
示例3: api_group_hosts_json
def api_group_hosts_json(grp_name):
group = HostGroup.read(where="id = %s", params=[grp_name])
if not group:
group = HostGroup.read(where="grp_name = %s", params=[grp_name])
if not group:
return jsonify(msg="no such group %s" % grp_name)
vs, _ = Host.query(1, 10000000, "", "0", group.id)
names = [v.hostname for v in vs]
return jsonify(msg="", data=names)
开发者ID:openslack,项目名称:openslack-monitor,代码行数:10,代码来源:api.py
示例4: api_group_hosts_json
def api_group_hosts_json(grp_name):
group = HostGroup.read(where='id = %s', params=[grp_name])
if not group:
group = HostGroup.read(where='grp_name = %s', params=[grp_name])
if not group:
return jsonify(msg='no such group %s' % grp_name)
vs, _ = Host.query(1, 10000000, '', '0', group.id)
names = [v.hostname for v in vs]
return jsonify(msg='', data=names)
开发者ID:masanmu,项目名称:portal,代码行数:10,代码来源:api.py
示例5: group_update_post
def group_update_post(group_id):
group_id = int(group_id)
new_name = request.form['new_name'].strip()
if not new_name:
return jsonify(msg='new name is blank')
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group')
if not group.writable(g.user_name):
return jsonify(msg='no permission')
HostGroup.update_dict({'grp_name': new_name}, 'id=%s', [group_id])
return jsonify(msg='')
开发者ID:Liuyanglong,项目名称:monitor-portal,代码行数:15,代码来源:group.py
示例6: group_hosts_list
def group_hosts_list(group_id):
g.xbox = request.args.get('xbox', '')
group_id = int(group_id)
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group %s' % group_id)
page = int(request.args.get('p', 1))
limit = int(request.args.get('limit', 10))
query = request.args.get('q', '')
maintaining = request.args.get('maintaining', '0')
vs, total = Host.query(page, limit, query, maintaining, group_id)
return render_template(
'host/index.html',
data={
'vs': vs,
'total': total,
'query': query,
'limit': limit,
'page': page,
'maintaining': maintaining,
'group': group,
}
)
开发者ID:open-falcon,项目名称:portal,代码行数:25,代码来源:host.py
示例7: host_add_post
def host_add_post():
group_id = request.form['group_id']
if not group_id:
return jsonify(msg='no group_id given')
group_id = int(group_id)
group = HostGroup.read('id = %s', [group_id])
if not group:
return jsonify(msg='no such group')
hosts = request.form['hosts'].strip()
if not hosts:
return jsonify(msg='hosts is blank')
host_arr = hosts.splitlines()
safe_host_arr = [h for h in host_arr if h]
if not safe_host_arr:
return jsonify(msg='hosts is blank')
success = []
failure = []
for h in safe_host_arr:
h = h.strip()
msg = GroupHost.bind(group_id, h)
if not msg:
success.append('%s<br>' % h)
else:
failure.append('%s %s<br>' % (h, msg))
data = '<div class="alert alert-danger" role="alert">failure:<hr>' + ''.join(
failure) + '</div><div class="alert alert-success" role="alert">success:<hr>' + ''.join(success) + '</div>'
return jsonify(msg='', data=data)
开发者ID:open-falcon,项目名称:portal,代码行数:34,代码来源:host.py
示例8: cluster_creator_get
def cluster_creator_get(group_id):
group_id = int(group_id)
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group %s' % group_id)
return render_template('cluster/creator.html', **locals())
开发者ID:Cepave,项目名称:portal,代码行数:7,代码来源:cluster.py
示例9: group_maintain_post
def group_maintain_post():
begin = int(request.form['begin'].strip())
end = int(request.form['end'].strip())
gids = request.form['gids'].strip()
if begin <= 0 or end <= 0:
return jsonify(msg='begin or end is invalid')
return jsonify(msg=HostGroup.maintain(begin, end, gids))
开发者ID:Liuyanglong,项目名称:monitor-portal,代码行数:8,代码来源:group.py
示例10: cluster_list_get
def cluster_list_get(group_id):
group_id = int(group_id)
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group %s' % group_id)
clusters = Cluster.select_vs(where='grp_id = %s', params=[group_id])
return render_template('cluster/list.html', **locals())
开发者ID:Cepave,项目名称:portal,代码行数:9,代码来源:cluster.py
示例11: plugin_bind_post
def plugin_bind_post():
group_id = int(request.form['group_id'].strip())
plugin_dir = request.form['plugin_dir'].strip()
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group %s' % group_id)
PluginDir.insert({'grp_id': group_id, 'dir': plugin_dir, 'create_user': g.user_name})
return jsonify(msg='')
开发者ID:Liuyanglong,项目名称:portal,代码行数:9,代码来源:plugin.py
示例12: plugin_list_get
def plugin_list_get(group_id):
group_id = int(group_id)
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group %s' % group_id)
plugins = PluginDir.select_vs(where='grp_id = %s', params=[group_id])
return render_template('plugin/list.html', group=group, plugins=plugins, uic_address=UIC_ADDRESS['external'])
开发者ID:Liuyanglong,项目名称:portal,代码行数:9,代码来源:plugin.py
示例13: group_templates_get
def group_templates_get(grp_id):
grp_id = int(grp_id)
grp = HostGroup.read(where='id = %s', params=[grp_id])
if not grp:
return jsonify(msg='no such group')
ts = GrpTpl.tpl_list(grp_id)
return render_template('group/templates.html', group=grp, ts=ts, uic_address=UIC_ADDRESS['external'])
开发者ID:Liuyanglong,项目名称:monitor-portal,代码行数:9,代码来源:group.py
示例14: host_groups_get
def host_groups_get(host_id):
host_id = int(host_id)
h = Host.read('id = %s', params=[host_id])
if not h:
return jsonify(msg='no such host')
group_ids = GroupHost.group_ids(h.id)
groups = [HostGroup.read('id = %s', [group_id]) for group_id in group_ids]
return render_template('host/groups.html', groups=groups, host=h)
开发者ID:open-falcon,项目名称:portal,代码行数:9,代码来源:host.py
示例15: group_delete_get
def group_delete_get(group_id):
group_id = int(group_id)
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group')
if not group.writable(g.user_name):
return jsonify(msg='no permission')
return jsonify(msg=group_service.delete_group(group_id))
开发者ID:Liuyanglong,项目名称:monitor-portal,代码行数:10,代码来源:group.py
示例16: group_create_post
def group_create_post():
grp_name = request.form['grp_name'].strip()
if not grp_name:
return jsonify(msg="group name is blank")
grp_id = HostGroup.create(grp_name, g.user_name, 1)
if grp_id > 0:
return jsonify(msg='')
else:
return jsonify(msg='grp_name has already existent')
开发者ID:Liuyanglong,项目名称:monitor-portal,代码行数:10,代码来源:group.py
示例17: host_add_get
def host_add_get():
group_id = request.args.get('group_id', '')
if not group_id:
return jsonify(msg='no group_id given')
group_id = int(group_id)
group = HostGroup.read('id = %s', [group_id])
if not group:
return jsonify(msg='no such group')
return render_template('host/add.html', group=group)
开发者ID:open-falcon,项目名称:portal,代码行数:11,代码来源:host.py
示例18: group_hosts_export
def group_hosts_export(group_id):
group_id = int(group_id)
group = HostGroup.read(where='id = %s', params=[group_id])
if not group:
return jsonify(msg='no such group %s' % group_id)
vs, _ = Host.query(1, 10000000, '', '0', group_id)
names = [v.hostname for v in vs]
response = make_response('\n'.join(names))
response.headers["content-type"] = "text/plain"
return response
开发者ID:open-falcon,项目名称:portal,代码行数:12,代码来源:host.py
示例19: api_marathon_health
def api_marathon_health():
marathon_stats = request.get_json()
if marathon_stats["eventType"] == "deployment_success":
action_type = marathon_stats["plan"]["steps"][-1]["actions"][-1]["type"]
app = marathon_stats["plan"]["steps"][-1]["actions"][-1]["app"].lstrip("/")
if action_type == "StopApplication":
grp_id = HostGroup.query_grp_id(app)
if grp_id > 0:
group_service.delete_group(grp_id)
else:
grp_id = HostGroup.create(app,"root",1)
if grp_id < 0:
grp_id = HostGroup.query_grp_id(app)
if grp_id < 0:
return 'grp_name no exist'
import requests,json
r = requests.get(MARATHON_ADDRESS+"/v2/apps/"+app)
app_info = json.loads(r.text)
marathon_hosts = []
for i in app_info["app"]["tasks"]:
marathon_hosts.append(i["host"])
vs,_ = Host.query(1, 10000000, '', '0', grp_id)
of_names = [v.hostname for v in vs]
of_names_set = set(of_names)
marathon_hosts_set = set(marathon_hosts)
delete_hosts = list(of_names_set - marathon_hosts_set)
add_hosts = list(marathon_hosts_set - of_names_set)
for h in add_hosts:
msg = GroupHost.bind(grp_id,h)
of_ids = [int(v.id) for v in vs if v.hostname in delete_hosts]
if len(delete_hosts)>0:
ids = ",".join('%s' % id for id in of_ids)
msg = GroupHost.unbind(int(grp_id[0]),ids)
return 'ok'
开发者ID:masanmu,项目名称:portal,代码行数:37,代码来源:api.py
示例20: template_unbind_grp_name_get
def template_unbind_grp_name_get():
tpl_id = request.args.get('tpl_id', '')
if not tpl_id:
return jsonify(msg="tpl_id is blank")
grp_name = request.args.get('grp_name', '')
if not grp_name:
return jsonify(msg='grp_name is blank')
hg = HostGroup.read('grp_name=%s', [grp_name])
if not hg:
return jsonify(msg='no such host group')
GrpTpl.unbind(hg.id, tpl_id)
return jsonify(msg='')
开发者ID:chuanxd,项目名称:portal,代码行数:15,代码来源:template.py
注:本文中的web.model.host_group.HostGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论