[Update] 修改Node value唯一

pull/1051/head
ibuler 2018-03-07 12:13:03 +08:00
parent af2db2d870
commit cd9000e7e9
3 changed files with 18 additions and 14 deletions

View File

@ -12,7 +12,7 @@ __all__ = ['Node']
class Node(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
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)
date_create = models.DateTimeField(auto_now_add=True)

View File

@ -91,7 +91,7 @@ def update_assets_hardware_info_util(assets, task_name=None):
if task_name is None:
task_name = _("Update some assets hardware info")
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_name, hosts=hostname_list, tasks=tasks, pattern='all',
options=const.TASK_OPTIONS, run_as_admin=True, created_by='System',
@ -120,7 +120,10 @@ def update_assets_hardware_info_period():
"""
from ops.utils import update_or_create_ansible_task
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
# Only create, schedule by celery beat
@ -165,7 +168,8 @@ def test_admin_user_connectability_util(admin_user, task_name):
from ops.utils import update_or_create_ansible_task
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:
return
tasks = const.TEST_ADMIN_USER_CONN_TASKS
@ -257,7 +261,7 @@ def test_system_user_connectability_util(system_user, task_name):
"""
from ops.utils import update_or_create_ansible_task
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
if not hosts:
logger.info("No hosts, passed")
@ -346,7 +350,7 @@ def push_system_user_util(system_users, assets, task_name):
logger.info("Not tasks, passed")
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:
logger.info("Not hosts, passed")
return {}

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\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"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
@ -434,31 +434,31 @@ msgstr "更新资产硬件信息"
msgid "Update assets hardware info period"
msgstr "定期更新资产硬件信息"
#: assets/tasks.py:191
#: assets/tasks.py:195
msgid "Test admin user connectability period: {}"
msgstr "定期测试管理用户可连接性: {}"
#: assets/tasks.py:197
#: assets/tasks.py:201
msgid "Test admin user connectability: {}"
msgstr "测试管理用户可连接性: {}"
#: assets/tasks.py:206
#: assets/tasks.py:210
msgid "Test asset connectability"
msgstr "测试资产可连接性"
#: assets/tasks.py:277
#: assets/tasks.py:281
msgid "Test system user connectability: {}"
msgstr "测试系统用户可连接性: {}"
#: assets/tasks.py:288
#: assets/tasks.py:292
msgid "test system user connectability period: {}"
msgstr "测试系统用户可连接性: {}"
#: assets/tasks.py:361
#: assets/tasks.py:365
msgid "Push system user to node: {} => {}"
msgstr "推送系统用户到节点: {}->{}"
#: assets/tasks.py:393
#: assets/tasks.py:397
msgid "Push system users to node: {}"
msgstr "推送系统用户到节点: {}"