2016-10-28 09:28:32 +00:00
|
|
|
from __future__ import absolute_import, unicode_literals
|
2016-09-03 11:05:50 +00:00
|
|
|
|
|
|
|
from celery import shared_task
|
|
|
|
|
2016-11-22 15:02:12 +00:00
|
|
|
from common import celery_app
|
2017-03-04 08:38:26 +00:00
|
|
|
from ops.utils.ansible_api import Options, ADHocRunner
|
2016-09-03 11:05:50 +00:00
|
|
|
|
2016-10-28 09:28:32 +00:00
|
|
|
|
|
|
|
@shared_task(name="get_asset_hardware_info")
|
2016-10-31 09:41:26 +00:00
|
|
|
def get_asset_hardware_info(task_name, task_uuid, *assets):
|
2017-03-04 08:38:26 +00:00
|
|
|
conf = Options()
|
2016-10-28 09:28:32 +00:00
|
|
|
play_source = {
|
|
|
|
"name": "Get host hardware information",
|
|
|
|
"hosts": "default",
|
|
|
|
"gather_facts": "no",
|
|
|
|
"tasks": [
|
|
|
|
dict(action=dict(module='setup'))
|
|
|
|
]
|
|
|
|
}
|
|
|
|
hoc = ADHocRunner(conf, play_source, *assets)
|
2016-10-31 09:41:26 +00:00
|
|
|
ext_code, result = hoc.run(task_name, task_uuid)
|
2016-10-28 09:28:32 +00:00
|
|
|
return ext_code, result
|
|
|
|
|
|
|
|
|
|
|
|
@shared_task(name="asset_test_ping_check")
|
2016-10-31 09:41:26 +00:00
|
|
|
def asset_test_ping_check(task_name, task_uuid, *assets):
|
2017-03-04 08:38:26 +00:00
|
|
|
conf = Options()
|
2016-10-28 09:43:56 +00:00
|
|
|
play_source = {
|
|
|
|
"name": "Test host connection use ping",
|
|
|
|
"hosts": "default",
|
|
|
|
"gather_facts": "no",
|
|
|
|
"tasks": [
|
|
|
|
dict(action=dict(module='ping'))
|
|
|
|
]
|
|
|
|
}
|
|
|
|
hoc = ADHocRunner(conf, play_source, *assets)
|
2016-10-31 09:41:26 +00:00
|
|
|
ext_code, result = hoc.run(task_name, task_uuid)
|
2016-10-28 09:43:56 +00:00
|
|
|
return ext_code, result
|
2016-10-28 09:28:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
@shared_task(name="add_user_to_assert")
|
|
|
|
def add_user_to_asset():
|
|
|
|
pass
|
2016-09-03 11:05:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(name='hello-world')
|
|
|
|
def hello():
|
|
|
|
print('hello world!')
|