本文整理匯總了Python中web.model.host_group.HostGroup類的典型用法代碼示例。如果您正苦於以下問題:Python HostGroup類的具體用法?Python HostGroup怎麽用?Python HostGroup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了HostGroup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 ''
示例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)
示例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)
示例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)
示例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='')
示例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,
}
)
示例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)
示例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())
示例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))
示例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())
示例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='')
示例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'])
示例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'])
示例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)
示例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))