Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
ba288396
Commit
ba288396
authored
Aug 01, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改 jms脚本
parent
448b7bf1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
24 deletions
+34
-24
tasks.py
apps/assets/tasks.py
+18
-18
settings.py
apps/jumpserver/settings.py
+4
-4
__init__.py
apps/ops/celery/__init__.py
+9
-0
tasks.py
apps/ops/tasks.py
+2
-2
jms
jms
+0
-0
requirements.txt
requirements/requirements.txt
+1
-0
No files found.
apps/assets/tasks.py
View file @
ba288396
...
...
@@ -62,7 +62,7 @@ def clean_hosts_by_protocol(system_user, assets):
return
hosts
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
set_assets_hardware_info
(
assets
,
result
,
**
kwargs
):
"""
Using ops task run result, to update asset info
...
...
@@ -148,7 +148,7 @@ def update_assets_hardware_info_util(assets, task_name=None):
return
result
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
update_asset_hardware_info_manual
(
asset
):
task_name
=
_
(
"Update asset hardware info: {}"
)
.
format
(
asset
.
hostname
)
update_assets_hardware_info_util
(
...
...
@@ -156,7 +156,7 @@ def update_asset_hardware_info_manual(asset):
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
update_assets_hardware_info_period
():
"""
Update asset hardware period task
...
...
@@ -170,7 +170,7 @@ def update_assets_hardware_info_period():
## ADMIN USER CONNECTIVE ##
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_asset_connectivity_util
(
assets
,
task_name
=
None
):
from
ops.utils
import
update_or_create_ansible_task
...
...
@@ -227,7 +227,7 @@ def test_asset_connectivity_util(assets, task_name=None):
return
results_summary
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_asset_connectivity_manual
(
asset
):
task_name
=
_
(
"Test assets connectivity: {}"
)
.
format
(
asset
)
summary
=
test_asset_connectivity_util
([
asset
],
task_name
=
task_name
)
...
...
@@ -238,7 +238,7 @@ def test_asset_connectivity_manual(asset):
return
True
,
""
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_admin_user_connectivity_util
(
admin_user
,
task_name
):
"""
Test asset admin user can connect or not. Using ansible api do that
...
...
@@ -254,7 +254,7 @@ def test_admin_user_connectivity_util(admin_user, task_name):
return
summary
@shared_task
@shared_task
(
queue
=
"ansible"
)
@register_as_period_task
(
interval
=
3600
)
def
test_admin_user_connectivity_period
():
"""
...
...
@@ -276,7 +276,7 @@ def test_admin_user_connectivity_period():
cache
.
set
(
key
,
1
,
60
*
40
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_admin_user_connectivity_manual
(
admin_user
):
task_name
=
_
(
"Test admin user connectivity: {}"
)
.
format
(
admin_user
.
name
)
test_admin_user_connectivity_util
(
admin_user
,
task_name
)
...
...
@@ -286,7 +286,7 @@ def test_admin_user_connectivity_manual(admin_user):
## System user connective ##
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_system_user_connectivity_util
(
system_user
,
assets
,
task_name
):
"""
Test system cant connect his assets or not.
...
...
@@ -344,14 +344,14 @@ def test_system_user_connectivity_util(system_user, assets, task_name):
return
results_summary
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_system_user_connectivity_manual
(
system_user
):
task_name
=
_
(
"Test system user connectivity: {}"
)
.
format
(
system_user
)
assets
=
system_user
.
get_all_assets
()
return
test_system_user_connectivity_util
(
system_user
,
assets
,
task_name
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_system_user_connectivity_a_asset
(
system_user
,
asset
):
task_name
=
_
(
"Test system user connectivity: {} => {}"
)
.
format
(
system_user
,
asset
...
...
@@ -359,7 +359,7 @@ def test_system_user_connectivity_a_asset(system_user, asset):
return
test_system_user_connectivity_util
(
system_user
,
[
asset
],
task_name
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_system_user_connectivity_period
():
if
PERIOD_TASK
!=
"on"
:
logger
.
debug
(
"Period task disabled, test system user connectivity pass"
)
...
...
@@ -483,7 +483,7 @@ def get_push_system_user_tasks(host, system_user):
return
tasks
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
push_system_user_util
(
system_user
,
assets
,
task_name
):
from
ops.utils
import
update_or_create_ansible_task
if
not
system_user
.
is_need_push
():
...
...
@@ -519,14 +519,14 @@ def push_system_user_util(system_user, assets, task_name):
task
.
run
()
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
push_system_user_to_assets_manual
(
system_user
):
assets
=
system_user
.
get_all_assets
()
task_name
=
_
(
"Push system users to assets: {}"
)
.
format
(
system_user
.
name
)
return
push_system_user_util
(
system_user
,
assets
,
task_name
=
task_name
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
push_system_user_a_asset_manual
(
system_user
,
asset
):
task_name
=
_
(
"Push system users to asset: {} => {}"
)
.
format
(
system_user
.
name
,
asset
...
...
@@ -534,7 +534,7 @@ def push_system_user_a_asset_manual(system_user, asset):
return
push_system_user_util
(
system_user
,
[
asset
],
task_name
=
task_name
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
push_system_user_to_assets
(
system_user
,
assets
):
task_name
=
_
(
"Push system users to assets: {}"
)
.
format
(
system_user
.
name
)
return
push_system_user_util
(
system_user
,
assets
,
task_name
)
...
...
@@ -569,7 +569,7 @@ def get_test_asset_user_connectivity_tasks(asset):
return
tasks
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_asset_user_connectivity_util
(
asset_user
,
task_name
,
run_as_admin
=
False
):
"""
:param asset_user: <AuthBook>对象
...
...
@@ -602,7 +602,7 @@ def test_asset_user_connectivity_util(asset_user, task_name, run_as_admin=False)
asset_user
.
set_connectivity
(
summary
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
test_asset_users_connectivity_manual
(
asset_users
,
run_as_admin
=
False
):
"""
:param asset_users: <AuthBook>对象
...
...
apps/jumpserver/settings.py
View file @
ba288396
...
...
@@ -297,10 +297,10 @@ LOGGING = {
'handlers'
:
[
'console'
,
'file'
],
'level'
:
"INFO"
,
},
'gunicorn'
:
{
'handlers'
:
[
'gunicorn_console'
,
'gunicorn_file'
],
'level'
:
'INFO'
,
},
#
'gunicorn': {
#
'handlers': ['gunicorn_console', 'gunicorn_file'],
#
'level': 'INFO',
#
},
# 'django.db': {
# 'handlers': ['console', 'file'],
# 'level': 'DEBUG'
...
...
apps/ops/celery/__init__.py
View file @
ba288396
...
...
@@ -2,6 +2,7 @@
import
os
from
kombu
import
Exchange
,
Queue
from
celery
import
Celery
# set the default Django settings module for the 'celery' program.
...
...
@@ -15,6 +16,14 @@ configs = {k: v for k, v in settings.__dict__.items() if k.startswith('CELERY')}
# Using a string here means the worker will not have to
# pickle the object when using Windows.
# app.config_from_object('django.conf:settings', namespace='CELERY')
configs
[
"CELERY_QUEUES"
]
=
[
Queue
(
"celery"
,
Exchange
(
"celery"
),
routing_key
=
"celery"
),
Queue
(
"ansible"
,
Exchange
(
"ansible"
),
routing_key
=
"ansible"
),
]
configs
[
"CELERY_ROUTES"
]
=
{
"ops.tasks.run_ansible_task"
:
{
'exchange'
:
'ansible'
,
'routing_key'
:
'ansible'
},
}
app
.
namespace
=
'CELERY'
app
.
conf
.
update
(
configs
)
app
.
autodiscover_tasks
(
lambda
:
[
app_config
.
split
(
'.'
)[
0
]
for
app_config
in
settings
.
INSTALLED_APPS
])
apps/ops/tasks.py
View file @
ba288396
...
...
@@ -23,7 +23,7 @@ def rerun_task():
pass
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
run_ansible_task
(
tid
,
callback
=
None
,
**
kwargs
):
"""
:param tid: is the tasks serialized data
...
...
@@ -98,7 +98,7 @@ def create_or_update_registered_periodic_tasks():
create_or_update_celery_periodic_tasks
(
task
)
@shared_task
@shared_task
(
queue
=
"ansible"
)
def
hello
(
name
,
callback
=
None
):
import
time
time
.
sleep
(
10
)
...
...
jms
View file @
ba288396
This diff is collapsed.
Click to expand it.
requirements/requirements.txt
View file @
ba288396
...
...
@@ -81,3 +81,4 @@ django-radius==1.3.3
ipip-ipdb==1.2.1
django-redis-sessions==0.6.1
unicodecsv==0.14.1
python-daemon==2.2.3
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment