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
806d38bb
Commit
806d38bb
authored
Dec 11, 2016
by
yumaojun03
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模拟数据测试
parent
84613e51
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
14 deletions
+45
-14
ansible.py
apps/ops/models/ansible.py
+18
-0
sudo.py
apps/ops/models/sudo.py
+4
-1
utils.py
apps/ops/models/utils.py
+12
-0
list.html
apps/ops/templates/sudo/list.html
+11
-13
No files found.
apps/ops/models/ansible.py
View file @
806d38bb
...
...
@@ -29,6 +29,24 @@ class Tasker(models.Model):
def
total_hosts
(
self
):
return
self
.
hosts
.
split
(
','
)
@classmethod
def
generate_fake
(
cls
,
count
=
100
):
from
random
import
seed
import
forgery_py
from
django.db
import
IntegrityError
seed
()
for
i
in
range
(
count
):
group
=
cls
(
name
=
forgery_py
.
name
.
full_name
(),
comment
=
forgery_py
.
lorem_ipsum
.
sentence
(),
created_by
=
'Fake'
)
try
:
group
.
save
()
logger
.
debug
(
'Generate fake asset group:
%
s'
%
group
.
name
)
except
IntegrityError
:
print
(
'Error continue'
)
continue
class
AnsiblePlay
(
models
.
Model
):
tasker
=
models
.
ForeignKey
(
Tasker
,
related_name
=
'plays'
,
blank
=
True
,
null
=
True
)
...
...
apps/ops/models/sudo.py
View file @
806d38bb
...
...
@@ -78,11 +78,14 @@ class Sudo(models.Model):
:param privileges: <list> [(user, host, runas, command, nopassword),]
"""
name
=
models
.
CharField
(
max_length
=
128
,
unique
=
True
,
verbose_name
=
_
(
'Name'
),
help_text
=
_
(
'Name for this sudo'
))
created_by
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
),
help_text
=
_
(
'The create time of this sudo'
))
assets
=
models
.
ManyToManyField
(
Asset
,
blank
=
True
,
related_name
=
'sudos'
)
asset_groups
=
models
.
ManyToManyField
(
AssetGroup
,
blank
=
True
,
related_name
=
'sudos'
)
extra_lines
=
models
.
ManyToManyField
(
Extra_conf
,
related_name
=
'sudos'
,
blank
=
True
)
privilege_items
=
models
.
ManyToManyField
(
Privilege
,
related_name
=
'sudos'
,
blank
=
True
)
created_by
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
@property
def
all_assets
(
self
):
...
...
apps/ops/models/utils.py
0 → 100644
View file @
806d38bb
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
from
ansible
import
*
from
cron
import
*
from
sudo
import
*
def
generate_fake
():
for
cls
in
(
AssetGroup
,
IDC
,
AdminUser
,
SystemUser
,
Asset
):
cls
.
generate_fake
()
\ No newline at end of file
apps/ops/templates/sudo/list.html
View file @
806d38bb
...
...
@@ -5,7 +5,7 @@
{% block table_container %}
<div
class=
"uc pull-left m-l-5 m-r-5"
><a
href=
"{% url "
users:user-create
"
%}"
class=
"btn btn-sm btn-primary"
>
{% trans "Create user" %}
</a></div>
<div
class=
"uc pull-left"
><a
href=
"javascript:void(0);"
class=
"btn btn-sm btn-primary"
data-toggle=
"modal"
data-target=
"#user_import_modal"
>
{% trans "Import user" %}
</a></div>
<table
class=
"table table-striped table-bordered table-hover "
id=
"
user_list_table"
>
<table
class=
"table table-striped table-bordered table-hover "
id=
"
sudo_list_table"
>
<thead>
<tr>
<th
class=
"text-center"
>
...
...
@@ -13,11 +13,9 @@
<input
id=
""
type=
"checkbox"
class=
"ipt_check_all"
>
</th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'Username' %}
</th>
<th
class=
"text-center"
>
{% trans 'Role' %}
</th>
<th
class=
"text-center"
>
{% trans 'User group' %}
</th>
<th
class=
"text-center"
>
{% trans 'Active' %}
</th>
<th
class=
"text-center"
>
{% trans 'Action' %}
</th>
<th
class=
"text-center"
>
{% trans 'Privileges' %}
</th>
<th
class=
"text-center"
>
{% trans 'Extra Lines' %}
</th>
<th
class=
"text-center"
>
{% trans 'Created' %}
</th>
</tr>
</thead>
<tbody>
...
...
@@ -46,7 +44,7 @@
<script>
$
(
document
).
ready
(
function
(){
var
options
=
{
ele
:
$
(
'#
user
_list_table'
),
ele
:
$
(
'#
sudo
_list_table'
),
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a href="{% url "users:user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
...
...
@@ -89,7 +87,7 @@ $(document).ready(function(){
}).
on
(
'click'
,
'#btn_bulk_update'
,
function
(){
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
$data_table
=
$
(
'#
user
_list_table'
).
DataTable
();
var
$data_table
=
$
(
'#
sudo
_list_table'
).
DataTable
();
var
id_list
=
[];
var
plain_id_list
=
[];
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
...
...
@@ -121,7 +119,7 @@ $(document).ready(function(){
var
success
=
function
()
{
var
msg
=
"{% trans 'User Deleted.' %}"
;
swal
(
"{% trans 'User Delete' %}"
,
msg
,
"success"
);
$
(
'#
user
_list_table'
).
DataTable
().
ajax
.
reload
();
$
(
'#
sudo
_list_table'
).
DataTable
().
ajax
.
reload
();
};
var
fail
=
function
()
{
var
msg
=
"{% trans 'User Deleting failed.' %}"
;
...
...
@@ -157,7 +155,7 @@ $(document).ready(function(){
var
success
=
function
()
{
var
msg
=
"{% trans 'User Deleted.' %}"
;
swal
(
"{% trans 'User Delete' %}"
,
msg
,
"success"
);
$
(
'#
user
_list_table'
).
DataTable
().
ajax
.
reload
();
$
(
'#
sudo
_list_table'
).
DataTable
().
ajax
.
reload
();
};
var
fail
=
function
()
{
var
msg
=
"{% trans 'User Deleting failed.' %}"
;
...
...
@@ -198,7 +196,7 @@ $(document).ready(function(){
new_groups
=
body
.
groups
.
map
(
Number
);
body
.
groups
=
new_groups
;
}
var
$data_table
=
$
(
'#
user
_list_table'
).
DataTable
()
var
$data_table
=
$
(
'#
sudo
_list_table'
).
DataTable
()
var
post_list
=
[];
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
var
content
=
Object
.
assign
({
id
:
this
.
data
().
id
},
body
);
...
...
@@ -211,7 +209,7 @@ $(document).ready(function(){
var
success
=
function
()
{
var
msg
=
"{% trans 'The selected users has been updated successfully.' %}"
;
swal
(
"{% trans 'User Updated' %}"
,
msg
,
"success"
);
$
(
'#
user
_list_table'
).
DataTable
().
ajax
.
reload
();
$
(
'#
sudo
_list_table'
).
DataTable
().
ajax
.
reload
();
jumpserver
.
checked
=
false
;
};
APIUpdateAttr
({
url
:
the_url
,
method
:
'PATCH'
,
body
:
JSON
.
stringify
(
post_list
),
success
:
success
});
...
...
@@ -225,7 +223,7 @@ $(document).ready(function(){
$
(
'<span />'
,
{
class
:
'help-block text-danger'
}).
html
(
data
.
msg
).
insertAfter
(
$
(
'#id_excel'
));
}
else
{
$
(
'#user_import_modal'
).
modal
(
'hide'
);
var
$data_table
=
$
(
'#
user
_list_table'
).
DataTable
();
var
$data_table
=
$
(
'#
sudo
_list_table'
).
DataTable
();
toastr
.
success
(
"{% trans 'Import User Success.' %}"
);
$data_table
.
ajax
.
reload
();
}
...
...
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