1. 当用户未被授予任何角色/主机权限时,提示用户

2. 根据用户实际安装路径,替换启动脚本中connect.py的路径
3. 修正几处拼写错误
pull/47/head
iambocai bob.chen.cs@gmail.com 2016-01-25 18:21:07 +08:00
parent fe87e32e2b
commit 0b79f754f9
3 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/connect.py=UTF-8

View File

@ -582,12 +582,14 @@ class Nav(object):
role = role_check[int(role_id)] role = role_check[int(role_id)]
elif len(roles) == 1: # 授权角色数为1 elif len(roles) == 1: # 授权角色数为1
role = roles[0] role = roles[0]
else:
color_print('当前用户未被授予角色,无法执行任何操作,如有疑问请联系管理员。', exits=True)
assets = list(self.user_perm.get('role', {}).get(role).get('asset')) # 获取该用户,角色授权主机 assets = list(self.user_perm.get('role', {}).get(role).get('asset')) # 获取该用户,角色授权主机
print "授权包含该系统用户的所有主机" print "授权包含该系统用户的所有主机"
for asset in assets: for asset in assets:
print ' %s' % asset.hostname print ' %s' % asset.hostname
print print
print "请输入主机名或ansile支持的pattern, 多个主机:分隔, q退出" print "请输入主机名或ansible支持的pattern, 多个主机:分隔, q退出"
pattern = raw_input("\033[1;32mPattern>:\033[0m ").strip() pattern = raw_input("\033[1;32mPattern>:\033[0m ").strip()
if pattern == 'q': if pattern == 'q':
break break
@ -629,7 +631,7 @@ class Nav(object):
self.user_perm = get_group_user_perm(self.user) self.user_perm = get_group_user_perm(self.user)
try: try:
print "进入批量上传模式" print "进入批量上传模式"
print "请输入主机名或ansile支持的pattern, 多个主机:分隔 q退出" print "请输入主机名或ansible支持的pattern, 多个主机:分隔 q退出"
pattern = raw_input("\033[1;32mPattern>:\033[0m ").strip() pattern = raw_input("\033[1;32mPattern>:\033[0m ").strip()
if pattern == 'q': if pattern == 'q':
break break
@ -682,7 +684,7 @@ class Nav(object):
self.user_perm = get_group_user_perm(self.user) self.user_perm = get_group_user_perm(self.user)
try: try:
print "进入批量下载模式" print "进入批量下载模式"
print "请输入主机名或ansile支持的pattern, 多个主机:分隔,q退出" print "请输入主机名或ansible支持的pattern, 多个主机:分隔,q退出"
pattern = raw_input("\033[1;32mPattern>:\033[0m ").strip() pattern = raw_input("\033[1;32mPattern>:\033[0m ").strip()
if pattern == 'q': if pattern == 'q':
break break

View File

@ -18,7 +18,7 @@ if django.get_version() != '1.6':
from juser.user_api import db_add_user, get_object, User from juser.user_api import db_add_user, get_object, User
from install import color_print from install import color_print
from jumpserver.api import get_mac_address from jumpserver.api import get_mac_address, bash
socket.setdefaulttimeout(2) socket.setdefaulttimeout(2)
@ -83,6 +83,7 @@ class Setup(object):
@staticmethod @staticmethod
def _cp_zzsh(): def _cp_zzsh():
os.chdir(os.path.join(jms_dir, 'install')) os.chdir(os.path.join(jms_dir, 'install'))
bash("sed -i 's#/opt/jumpserver#%s#g' zzjumpserver.sh" % jms_dir)
shutil.copy('zzjumpserver.sh', '/etc/profile.d/') shutil.copy('zzjumpserver.sh', '/etc/profile.d/')
@staticmethod @staticmethod