本文整理匯總了Python中web.model.host_group.HostGroup.read方法的典型用法代碼示例。如果您正苦於以下問題:Python HostGroup.read方法的具體用法?Python HostGroup.read怎麽用?Python HostGroup.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類web.model.host_group.HostGroup
的用法示例。
在下文中一共展示了HostGroup.read方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: api_group_hosts_json
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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)
示例2: api_group_hosts_json
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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)
示例3: group_hosts_list
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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,
}
)
示例4: host_groups_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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)
示例5: cluster_creator_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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())
示例6: host_add_post
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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)
示例7: host_groups_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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)
示例8: cluster_list_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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())
示例9: plugin_bind_post
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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='')
示例10: plugin_list_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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'])
示例11: group_templates_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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'])
示例12: group_delete_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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))
示例13: host_add_get
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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)
示例14: group_hosts_export
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
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
示例15: template_bind_node_post
# 需要導入模塊: from web.model.host_group import HostGroup [as 別名]
# 或者: from web.model.host_group.HostGroup import read [as 別名]
def template_bind_node_post():
node = request.form['node'].strip()
tpl_id = request.form['tpl_id'].strip()
if not node:
return jsonify(msg='node is blank')
if not tpl_id:
return jsonify(msg='tpl id is blank')
hg = HostGroup.read('grp_name=%s', [node])
if not hg:
return jsonify(msg='no such node')
GrpTpl.bind(hg.id, tpl_id, g.user_name)
return jsonify(msg="")