diff --git a/connect.py b/connect.py
index ac8010c32..8e138c6c5 100755
--- a/connect.py
+++ b/connect.py
@@ -518,7 +518,10 @@ class Nav(object):
@staticmethod
def get_max_asset_property_length(assets, property_='hostname'):
- return max([len(getattr(asset, property_)) for asset in assets])
+ try:
+ return max([len(getattr(asset, property_)) for asset in assets])
+ except ValueError:
+ return 30
def print_search_result(self):
hostname_max_length = self.get_max_asset_property_length(self.search_result)
diff --git a/jperm/views.py b/jperm/views.py
index f546079c2..e3991b878 100644
--- a/jperm/views.py
+++ b/jperm/views.py
@@ -16,6 +16,7 @@ from jperm.ansible_api import MyTask
from jperm.perm_api import get_role_info, get_role_push_host
from jumpserver.api import my_render, get_object, CRYPTOR
+
# 设置PERM APP Log
from jumpserver.api import logger
#logger = set_log(LOG_LEVEL, filename='jumpserver_perm.log')
@@ -416,6 +417,7 @@ def perm_role_detail(request):
users = role_info.get("users")
user_groups = role_info.get("user_groups")
pushed_asset, need_push_asset = get_role_push_host(get_object(PermRole, id=role_id))
+
except ServerError, e:
logger.warning(e)
diff --git a/templates/jperm/perm_role_detail.html b/templates/jperm/perm_role_detail.html
index ad21cc928..168fb2adf 100644
--- a/templates/jperm/perm_role_detail.html
+++ b/templates/jperm/perm_role_detail.html
@@ -30,13 +30,15 @@
-
- 时间 |
- 名称 |
+
+ 时间 |
+ 名称 |
{% for rule in rules %}
- {{ rule.date_added | date:"Y-m-d H:i:s"}} |
- {{ rule.name }} |
+ {{ rule.date_added | date:"Y-m-d H:i:s" }} |
+ {{ rule.name }}
+ |
{% endfor %}
@@ -44,8 +46,7 @@
-
-
+
授权用户/用户组
@@ -68,37 +69,39 @@
-
-
-
+
授权主机组/主机组
@@ -122,26 +125,30 @@
-
+
主机 |
主机组 |
- {% for asset in assets %}
-
- {{ asset.ip }} |
-
- {% endfor %}
+ {% for asset in assets %}
+
+
+ {{ asset.ip }}
+ |
+
+ {% endfor %}
|
- {% for group in asset_groups %}
-
- {{ group.name }} |
-
- {% endfor %}
+ {% for group in asset_groups %}
+
+
+ {{ group.name }}
+ |
+
+ {% endfor %}
|
@@ -150,9 +157,70 @@
-
-
-
+
+
+
+
{{ role.name }} - 推送失败主机
+
+
+
+
+
+
{{ role.name }} - 推送主机
@@ -177,20 +245,20 @@
-
+
删除
重新推送
-
-
-
- |
- 主机 |
- 密钥 |
- 密码 |
- 结果 |
- 操作 |
-
+
+
+
+ |
+ 主机 |
+ 密钥 |
+ 结果 |
+ 操作 |
+
{% for asset, info in pushed_asset.items %}
@@ -200,13 +268,19 @@
{{ asset.hostname }} |
{{ info.key | yesno:"是,否,未知" }} |
- {{ info.password | yesno:"是,否,未知" }} |
{% if info.success %}
- {{ info.success | yesno:"成功,失败,未知" }} |
+ {{ info.success | yesno:"成功,失败,未知" }} |
{% else %}
- {{ info.success | yesno:"成功,失败,未知" }} |
+ {{ info.success | yesno:"成功,失败,未知" }} |
{% endif %}
- |
+
+
+
+ |
{% endfor %}
@@ -215,9 +289,7 @@
-
-
{{ role.name }} - 未推送主机
@@ -236,16 +308,17 @@