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
954814da
Commit
954814da
authored
Nov 22, 2016
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[future] 添加Cron相关的基础API框架
parent
79971d67
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
1 deletion
+42
-1
serializers.py
apps/ops/api/serializers.py
+5
-1
views.py
apps/ops/api/views.py
+11
-0
models.py
apps/ops/models.py
+25
-0
urls.py
apps/ops/urls.py
+1
-0
No files found.
apps/ops/api/serializers.py
View file @
954814da
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
from
..models
import
HostAlia
,
UserAlia
,
CmdAlia
,
RunasAlia
,
Extra_conf
,
Privilege
,
Sudo
from
..models
import
HostAlia
,
UserAlia
,
CmdAlia
,
RunasAlia
,
Extra_conf
,
Privilege
,
Sudo
,
CronTable
from
rest_framework
import
serializers
...
...
@@ -47,3 +47,7 @@ class SudoSerializer(serializers.ModelSerializer):
model
=
Sudo
class
CronTableSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
CronTable
apps/ops/api/views.py
View file @
954814da
...
...
@@ -83,4 +83,15 @@ class SudoViewSet(mixins.CreateModelMixin,
permission_classes
=
(
AdminUserRequired
,)
class
CronTableViewSet
(
mixins
.
CreateModelMixin
,
mixins
.
ListModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
UpdateModelMixin
,
mixins
.
DestroyModelMixin
,
viewsets
.
GenericViewSet
):
queryset
=
CronTable
.
objects
.
all
()
serializer_class
=
CronTableSerializer
permission_classes
=
(
AdminUserRequired
,)
apps/ops/models.py
View file @
954814da
...
...
@@ -393,6 +393,31 @@ root ALL=(ALL:ALL) ALL
"""
class
CronTable
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
unique
=
True
,
verbose_name
=
_
(
'Runas_Alias'
),
help_text
=
_
(
"Description of a crontab entry"
))
month
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Month'
),
help_text
=
_
(
"Month of the year the job should run ( 1-12, *, */2, etc )"
))
weekday
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'WeekDay'
),
help_text
=
_
(
"Day of the week that the job should run"
" ( 0-6 for Sunday-Saturday, *, etc )"
))
day
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Day'
),
help_text
=
_
(
"Day of the month the job should run ( 1-31, *, */2, etc )"
))
hour
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Hour'
),
help_text
=
_
(
"Hour when the job should run ( 0-23, *, */2, etc )"
))
minute
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Minute'
),
help_text
=
_
(
"Minute when the job should run ( 0-59, *, */2, etc )"
))
job
=
models
.
CharField
(
max_length
=
4096
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Job'
),
help_text
=
_
(
"The command to execute or, if env is set, the value of "
"environment variable. Required if state=present."
))
user
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'User'
),
help_text
=
_
(
"The specific user whose crontab should be modified."
))
asset
=
models
.
ForeignKey
(
Asset
,
null
=
True
,
blank
=
True
,
related_name
=
'crontables'
)
@property
def
describe
(
self
):
return
"http://docs.ansible.com/ansible/cron_module.html"
...
...
apps/ops/urls.py
View file @
954814da
...
...
@@ -19,6 +19,7 @@ router.register(r'runas_alia', api_view.RunasAliaViewSet)
router
.
register
(
r'extra_conf'
,
api_view
.
ExtraconfViewSet
)
router
.
register
(
r'privilege'
,
api_view
.
PrivilegeViewSet
)
router
.
register
(
r'sudo'
,
api_view
.
SudoViewSet
)
router
.
register
(
r'cron'
,
api_view
.
CronTableViewSet
)
urlpatterns
=
[
# Resource Sudo url
...
...
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