mirror of https://github.com/jumpserver/jumpserver
ÐÞ¸ÄÒ»´¦bug
parent
d5fba23d73
commit
17e89bb55b
15
connect.py
15
connect.py
|
@ -188,8 +188,12 @@ def get_user_hostgroup_host(username, gid):
|
||||||
|
|
||||||
def verify_connect(username, part_ip):
|
def verify_connect(username, part_ip):
|
||||||
ip_matched = []
|
ip_matched = []
|
||||||
hosts_attr = get_user_host(username)
|
try:
|
||||||
hosts = hosts_attr.values()
|
hosts_attr = get_user_host(username)
|
||||||
|
hosts = hosts_attr.values()
|
||||||
|
except ServerError, e:
|
||||||
|
color_print(e, 'red')
|
||||||
|
return False
|
||||||
for ip_info in hosts:
|
for ip_info in hosts:
|
||||||
for info in ip_info[1:]:
|
for info in ip_info[1:]:
|
||||||
if part_ip in info:
|
if part_ip in info:
|
||||||
|
@ -217,7 +221,11 @@ def print_prompt():
|
||||||
|
|
||||||
|
|
||||||
def print_user_host(username):
|
def print_user_host(username):
|
||||||
hosts_attr = get_user_host(username)
|
try:
|
||||||
|
hosts_attr = get_user_host(username)
|
||||||
|
except ServerError, e:
|
||||||
|
color_print(e, 'red')
|
||||||
|
return
|
||||||
hosts = hosts_attr.keys()
|
hosts = hosts_attr.keys()
|
||||||
hosts.sort()
|
hosts.sort()
|
||||||
for ip in hosts:
|
for ip in hosts:
|
||||||
|
@ -267,7 +275,6 @@ def connect(username, password, host, port, login_name):
|
||||||
global channel
|
global channel
|
||||||
win_size = get_win_size()
|
win_size = get_win_size()
|
||||||
channel = ssh.invoke_shell(height=win_size[0], width=win_size[1])
|
channel = ssh.invoke_shell(height=win_size[0], width=win_size[1])
|
||||||
#channel.resize_pty(height=win_size[0], width=win_size[1])
|
|
||||||
try:
|
try:
|
||||||
signal.signal(signal.SIGWINCH, set_win_size)
|
signal.signal(signal.SIGWINCH, set_win_size)
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -349,14 +349,18 @@ def get_user_host(username):
|
||||||
"""Get the hosts of under the user control."""
|
"""Get the hosts of under the user control."""
|
||||||
hosts_attr = {}
|
hosts_attr = {}
|
||||||
asset_all = user_perm_asset_api(username)
|
asset_all = user_perm_asset_api(username)
|
||||||
user = User.objects.get(username=username)
|
user = User.objects.filter(username=username)
|
||||||
for asset in asset_all:
|
if user:
|
||||||
alias = AssetAlias.objects.filter(user=user, host=asset)
|
user = user[0]
|
||||||
if alias and alias[0].alias != '':
|
for asset in asset_all:
|
||||||
hosts_attr[asset.ip] = [asset.id, asset.ip, alias[0].alias]
|
alias = AssetAlias.objects.filter(user=user, host=asset)
|
||||||
else:
|
if alias and alias[0].alias != '':
|
||||||
hosts_attr[asset.ip] = [asset.id, asset.ip, asset.comment]
|
hosts_attr[asset.ip] = [asset.id, asset.ip, alias[0].alias]
|
||||||
return hosts_attr
|
else:
|
||||||
|
hosts_attr[asset.ip] = [asset.id, asset.ip, asset.comment]
|
||||||
|
return hosts_attr
|
||||||
|
else:
|
||||||
|
raise ServerError('User %s does not exit!' % username)
|
||||||
|
|
||||||
|
|
||||||
def get_connect_item(username, ip):
|
def get_connect_item(username, ip):
|
||||||
|
|
Loading…
Reference in New Issue