mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-22 08:19:04 +00:00
[Fixture] 详情页添加system user 推送
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
from celery import shared_task
|
||||
import json
|
||||
|
||||
from django.core.cache import cache
|
||||
|
||||
from ops.tasks import run_AdHoc
|
||||
from common.utils import get_object_or_none, capacity_convert, sum_capacity
|
||||
from .models import Asset
|
||||
@@ -43,7 +45,7 @@ def update_assets_hardware_info(assets):
|
||||
|
||||
___platform = info['ansible_system']
|
||||
___os = info['ansible_distribution']
|
||||
___os_version = float(info['ansible_distribution_version'])
|
||||
___os_version = info['ansible_distribution_version']
|
||||
___os_arch = info['ansible_architecture']
|
||||
___hostname_raw = info['ansible_hostname']
|
||||
|
||||
@@ -51,24 +53,28 @@ def update_assets_hardware_info(assets):
|
||||
if k.startswith('___'):
|
||||
setattr(asset, k.strip('_'), v)
|
||||
asset.save()
|
||||
return summary
|
||||
|
||||
|
||||
@shared_task
|
||||
def test_admin_user_connective(assets=None):
|
||||
if None:
|
||||
assets = Asset.objects.filter(type__in=['Server', 'VM'])
|
||||
if not assets:
|
||||
return 'No asset get'
|
||||
def update_assets_hardware_period():
|
||||
assets = Asset.objects.filter(type__in=['Server', 'VM'])
|
||||
update_assets_hardware_info(assets)
|
||||
|
||||
|
||||
@shared_task
|
||||
def test_admin_user_connective_period():
|
||||
assets = Asset.objects.filter(type__in=['Server', 'VM'])
|
||||
task_tuple = (
|
||||
('ping', ''),
|
||||
)
|
||||
summary, result = run_AdHoc(task_tuple, assets, record=False)
|
||||
return summary, result
|
||||
summary, _ = run_AdHoc(task_tuple, assets, record=False)
|
||||
for i in summary['success']:
|
||||
cache.set(i, '1', 2*60*60*60)
|
||||
|
||||
for i in summary['failed']:
|
||||
cache.set(i, '0', 60*60*60)
|
||||
return summary
|
||||
|
||||
|
||||
|
||||
def get_assets_hardware_info(assets):
|
||||
task_tuple = (
|
||||
('setup', ''),
|
||||
)
|
||||
task = run_AdHoc.delay(task_tuple, assets, record=False)
|
||||
return task
|
Reference in New Issue
Block a user