Commit cd9000e7 authored by ibuler's avatar ibuler

[Update] 修改Node value唯一

parent af2db2d8
...@@ -12,7 +12,7 @@ __all__ = ['Node'] ...@@ -12,7 +12,7 @@ __all__ = ['Node']
class Node(models.Model): class Node(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True) id = models.UUIDField(default=uuid.uuid4, primary_key=True)
key = models.CharField(unique=True, max_length=64, verbose_name=_("Key")) # '1:1:1:1' key = models.CharField(unique=True, max_length=64, verbose_name=_("Key")) # '1:1:1:1'
value = models.CharField(max_length=128, unique=True, verbose_name=_("Value")) value = models.CharField(max_length=128, verbose_name=_("Value"))
child_mark = models.IntegerField(default=0) child_mark = models.IntegerField(default=0)
date_create = models.DateTimeField(auto_now_add=True) date_create = models.DateTimeField(auto_now_add=True)
......
...@@ -91,7 +91,7 @@ def update_assets_hardware_info_util(assets, task_name=None): ...@@ -91,7 +91,7 @@ def update_assets_hardware_info_util(assets, task_name=None):
if task_name is None: if task_name is None:
task_name = _("Update some assets hardware info") task_name = _("Update some assets hardware info")
tasks = const.UPDATE_ASSETS_HARDWARE_TASKS tasks = const.UPDATE_ASSETS_HARDWARE_TASKS
hostname_list = [asset.hostname for asset in assets] hostname_list = [asset.hostname for asset in assets if asset.is_active and asset.is_unixlike()]
task, created = update_or_create_ansible_task( task, created = update_or_create_ansible_task(
task_name, hosts=hostname_list, tasks=tasks, pattern='all', task_name, hosts=hostname_list, tasks=tasks, pattern='all',
options=const.TASK_OPTIONS, run_as_admin=True, created_by='System', options=const.TASK_OPTIONS, run_as_admin=True, created_by='System',
...@@ -120,7 +120,10 @@ def update_assets_hardware_info_period(): ...@@ -120,7 +120,10 @@ def update_assets_hardware_info_period():
""" """
from ops.utils import update_or_create_ansible_task from ops.utils import update_or_create_ansible_task
task_name = _("Update assets hardware info period") task_name = _("Update assets hardware info period")
hostname_list = [asset.hostname for asset in Asset.objects.all()] hostname_list = [
asset.hostname for asset in Asset.objects.all()
if asset.is_active and asset.is_unixlike()
]
tasks = const.UPDATE_ASSETS_HARDWARE_TASKS tasks = const.UPDATE_ASSETS_HARDWARE_TASKS
# Only create, schedule by celery beat # Only create, schedule by celery beat
...@@ -165,7 +168,8 @@ def test_admin_user_connectability_util(admin_user, task_name): ...@@ -165,7 +168,8 @@ def test_admin_user_connectability_util(admin_user, task_name):
from ops.utils import update_or_create_ansible_task from ops.utils import update_or_create_ansible_task
assets = admin_user.get_related_assets() assets = admin_user.get_related_assets()
hosts = [asset.hostname for asset in assets] hosts = [asset.hostname for asset in assets
if asset.is_active and asset.is_unixlike()]
if not hosts: if not hosts:
return return
tasks = const.TEST_ADMIN_USER_CONN_TASKS tasks = const.TEST_ADMIN_USER_CONN_TASKS
...@@ -257,7 +261,7 @@ def test_system_user_connectability_util(system_user, task_name): ...@@ -257,7 +261,7 @@ def test_system_user_connectability_util(system_user, task_name):
""" """
from ops.utils import update_or_create_ansible_task from ops.utils import update_or_create_ansible_task
assets = system_user.assets assets = system_user.assets
hosts = [asset.hostname for asset in assets] hosts = [asset.hostname for asset in assets if asset.is_active and asset.is_unixlike()]
tasks = const.TEST_SYSTEM_USER_CONN_TASKS tasks = const.TEST_SYSTEM_USER_CONN_TASKS
if not hosts: if not hosts:
logger.info("No hosts, passed") logger.info("No hosts, passed")
...@@ -346,7 +350,7 @@ def push_system_user_util(system_users, assets, task_name): ...@@ -346,7 +350,7 @@ def push_system_user_util(system_users, assets, task_name):
logger.info("Not tasks, passed") logger.info("Not tasks, passed")
return {} return {}
hosts = [asset.hostname for asset in assets] hosts = [asset.hostname for asset in assets if asset.is_active and asset.is_unixlike()]
if not hosts: if not hosts:
logger.info("Not hosts, passed") logger.info("Not hosts, passed")
return {} return {}
......
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n" "Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-07 11:27+0800\n" "POT-Creation-Date: 2018-03-07 11:54+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n" "Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n" "Language-Team: Jumpserver team<ibuler@qq.com>\n"
...@@ -434,31 +434,31 @@ msgstr "更新资产硬件信息" ...@@ -434,31 +434,31 @@ msgstr "更新资产硬件信息"
msgid "Update assets hardware info period" msgid "Update assets hardware info period"
msgstr "定期更新资产硬件信息" msgstr "定期更新资产硬件信息"
#: assets/tasks.py:191 #: assets/tasks.py:195
msgid "Test admin user connectability period: {}" msgid "Test admin user connectability period: {}"
msgstr "定期测试管理用户可连接性: {}" msgstr "定期测试管理用户可连接性: {}"
#: assets/tasks.py:197 #: assets/tasks.py:201
msgid "Test admin user connectability: {}" msgid "Test admin user connectability: {}"
msgstr "测试管理用户可连接性: {}" msgstr "测试管理用户可连接性: {}"
#: assets/tasks.py:206 #: assets/tasks.py:210
msgid "Test asset connectability" msgid "Test asset connectability"
msgstr "测试资产可连接性" msgstr "测试资产可连接性"
#: assets/tasks.py:277 #: assets/tasks.py:281
msgid "Test system user connectability: {}" msgid "Test system user connectability: {}"
msgstr "测试系统用户可连接性: {}" msgstr "测试系统用户可连接性: {}"
#: assets/tasks.py:288 #: assets/tasks.py:292
msgid "test system user connectability period: {}" msgid "test system user connectability period: {}"
msgstr "测试系统用户可连接性: {}" msgstr "测试系统用户可连接性: {}"
#: assets/tasks.py:361 #: assets/tasks.py:365
msgid "Push system user to node: {} => {}" msgid "Push system user to node: {} => {}"
msgstr "推送系统用户到节点: {}->{}" msgstr "推送系统用户到节点: {}->{}"
#: assets/tasks.py:393 #: assets/tasks.py:397
msgid "Push system users to node: {}" msgid "Push system users to node: {}"
msgstr "推送系统用户到节点: {}" msgstr "推送系统用户到节点: {}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment