From be09db059db0c3af3049a231cc625f2ec518cf2c Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 4 Apr 2017 21:47:58 +0800 Subject: [PATCH] Update some bug --- apps/assets/tasks.py | 13 ++++++++----- apps/assets/urls/views_urls.py | 1 - apps/assets/views/asset.py | 10 +--------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/assets/tasks.py b/apps/assets/tasks.py index b716dc644..06cc2a9b4 100644 --- a/apps/assets/tasks.py +++ b/apps/assets/tasks.py @@ -53,14 +53,17 @@ def update_assets_hardware_info(assets): asset.save() -@shared_task(name="asset_test_ping_check") -def asset_test_ping_check(assets): +@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' task_tuple = ( ('ping', ''), ) - hoc = AdHocRunner(assets) - result = hoc.run(task_tuple) - return result['contacted'].keys(), result['dark'].keys() + summary, result = run_AdHoc(task_tuple, assets, record=False) + return summary, result def get_assets_hardware_info(assets): diff --git a/apps/assets/urls/views_urls.py b/apps/assets/urls/views_urls.py index 1aa1a4925..4d3499821 100644 --- a/apps/assets/urls/views_urls.py +++ b/apps/assets/urls/views_urls.py @@ -14,7 +14,6 @@ urlpatterns = [ url(r'^asset/(?P[0-9]+)/$', views.AssetDetailView.as_view(), name='asset-detail'), url(r'^asset/(?P[0-9]+)/update/$', views.AssetUpdateView.as_view(), name='asset-update'), url(r'^asset/(?P[0-9]+)/delete/$', views.AssetDeleteView.as_view(), name='asset-delete'), - url(r'^asset/(?P[0-9]+)/refresh/$', views.AssetRefreshHardwareView.as_view(), name='asset-refresh'), url(r'^asset-modal$', views.AssetModalListView.as_view(), name='asset-modal-list'), url(r'^asset-modal-update$', views.AssetModalCreateView.as_view(), name='asset-modal-update'), diff --git a/apps/assets/views/asset.py b/apps/assets/views/asset.py index 69bee748d..0514ca467 100644 --- a/apps/assets/views/asset.py +++ b/apps/assets/views/asset.py @@ -32,7 +32,7 @@ from ..tasks import update_assets_hardware_info __all__ = ['AssetListView', 'AssetCreateView', 'AssetUpdateView', 'UserAssetListView', 'AssetModalCreateView', 'AssetDetailView', 'AssetModalListView', 'AssetDeleteView', 'AssetExportView', - 'BulkImportAssetView', 'AssetRefreshHardwareView', + 'BulkImportAssetView', ] @@ -329,11 +329,3 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView): return self.render_json_response(data) -class AssetRefreshHardwareView(AdminUserRequiredMixin, View): - def get(self, request, *args, **kwargs): - asset_id = kwargs.get('pk') - asset = get_object_or_404(Asset, pk=asset_id) - update_assets_hardware_info([asset]) - - return redirect(reverse('assets:asset-detail', kwargs={'pk': asset_id})) -