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 %} - - + + {% endfor %}
时间名称
{{ rule.date_added | date:"Y-m-d H:i:s"}} {{ rule.name }} {{ rule.date_added | date:"Y-m-d H:i:s" }} {{ rule.name }} +
@@ -44,8 +46,7 @@
- -
+
授权用户/用户组 @@ -68,37 +69,39 @@
-
- - - - - - -
用户用户组
- +
+
+ + + + - + +
用户用户组
+ {% for user in users %} - + {% endfor %} -
{{ user.name }} + {{ user.name }} +
-
- +
+
+ {% for group in user_groups %} - + {% endfor %} -
{{ group.name }} + {{ group.name }} +
-
+
-
+ + +
- - -
+
授权主机组/主机组 @@ -122,26 +125,30 @@
- +
@@ -150,9 +157,70 @@ - -
-
+
+
+
+ {{ role.name }} - 推送失败主机 + +
+
+
+
+
主机 主机组
- {% for asset in assets %} - - - - {% endfor %} + {% for asset in assets %} + + + + {% endfor %}
{{ asset.ip }}
+ {{ asset.ip }} +
- {% for group in asset_groups %} - - - - {% endfor %} + {% for group in asset_groups %} + + + + {% endfor %}
{{ group.name }}
+ {{ group.name }} +
+ 删除 + 重新推送 + + + + + + + + + + + {% for asset, info in pushed_asset.items %} + {% if not info.success %} + + + + + {% if info.success %} + + {% else %} + + {% endif %} + + + {% endif %} + {% endfor %} + +
+ + 主机密钥结果操作
+ + {{ asset.hostname }} {{ info.key | yesno:"是,否,未知" }} {{ info.success | yesno:"成功,失败,未知" }} {{ info.success | yesno:"成功,失败,未知" }}
+
+
+
+ + +
{{ role.name }} - 推送主机 @@ -177,20 +245,20 @@
- +
删除 重新推送 - - - - - - - - + + + + + + + {% for asset, info in pushed_asset.items %} @@ -200,13 +268,19 @@ - {% if info.success %} - + {% else %} - + {% endif %} - + {% endfor %} @@ -215,9 +289,7 @@ - -
{{ role.name }} - 未推送主机 @@ -236,16 +308,17 @@
-
- - 主机密钥密码结果操作
+ + 主机密钥结果操作
{{ asset.hostname }} {{ info.key | yesno:"是,否,未知" }} {{ info.password | yesno:"是,否,未知" }} {{ info.success | yesno:"成功,失败,未知" }} {{ info.success | yesno:"成功,失败,未知" }} {{ info.success | yesno:"成功,失败,未知" }} {{ info.success | yesno:"成功,失败,未知" }} + + +
+
推送 - - - - - + + + + + {% for asset in need_push_asset %} @@ -272,66 +345,65 @@ {% endblock %} {% block self_footer_js %} - + }) + {% endblock %} \ No newline at end of file diff --git a/templates/jperm/perm_role_list.html b/templates/jperm/perm_role_list.html index b371880ac..ff8883176 100644 --- a/templates/jperm/perm_role_list.html +++ b/templates/jperm/perm_role_list.html @@ -70,7 +70,7 @@
- Showing {{ users.start_index }} to {{ users.end_index }} of {{ p.count }} entries + Showing {{ roles.start_index }} to {{ roles.end_index }} of {{ p.count }} entries
{% include 'paginator.html' %} @@ -80,8 +80,6 @@
- -
- - 主机IP
+ + 主机IP