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
Hide 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):
...
@@ -29,6 +29,24 @@ class Tasker(models.Model):
def
total_hosts
(
self
):
def
total_hosts
(
self
):
return
self
.
hosts
.
split
(
','
)
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
):
class
AnsiblePlay
(
models
.
Model
):
tasker
=
models
.
ForeignKey
(
Tasker
,
related_name
=
'plays'
,
blank
=
True
,
null
=
True
)
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):
...
@@ -78,11 +78,14 @@ class Sudo(models.Model):
:param privileges: <list> [(user, host, runas, command, nopassword),]
: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'
)
assets
=
models
.
ManyToManyField
(
Asset
,
blank
=
True
,
related_name
=
'sudos'
)
asset_groups
=
models
.
ManyToManyField
(
AssetGroup
,
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
)
extra_lines
=
models
.
ManyToManyField
(
Extra_conf
,
related_name
=
'sudos'
,
blank
=
True
)
privilege_items
=
models
.
ManyToManyField
(
Privilege
,
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
@property
def
all_assets
(
self
):
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 @@
...
@@ -5,7 +5,7 @@
{% block table_container %}
{% 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 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>
<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>
<thead>
<tr>
<tr>
<th
class=
"text-center"
>
<th
class=
"text-center"
>
...
@@ -13,11 +13,9 @@
...
@@ -13,11 +13,9 @@
<input
id=
""
type=
"checkbox"
class=
"ipt_check_all"
>
<input
id=
""
type=
"checkbox"
class=
"ipt_check_all"
>
</th>
</th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'Username' %}
</th>
<th
class=
"text-center"
>
{% trans 'Privileges' %}
</th>
<th
class=
"text-center"
>
{% trans 'Role' %}
</th>
<th
class=
"text-center"
>
{% trans 'Extra Lines' %}
</th>
<th
class=
"text-center"
>
{% trans 'User group' %}
</th>
<th
class=
"text-center"
>
{% trans 'Created' %}
</th>
<th
class=
"text-center"
>
{% trans 'Active' %}
</th>
<th
class=
"text-center"
>
{% trans 'Action' %}
</th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
...
@@ -46,7 +44,7 @@
...
@@ -46,7 +44,7 @@
<script>
<script>
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
var
options
=
{
var
options
=
{
ele
:
$
(
'#
user
_list_table'
),
ele
:
$
(
'#
sudo
_list_table'
),
columnDefs
:
[
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a href="{% url "users:user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
var
detail_btn
=
'<a href="{% url "users:user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
...
@@ -89,7 +87,7 @@ $(document).ready(function(){
...
@@ -89,7 +87,7 @@ $(document).ready(function(){
}).
on
(
'click'
,
'#btn_bulk_update'
,
function
(){
}).
on
(
'click'
,
'#btn_bulk_update'
,
function
(){
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
$data_table
=
$
(
'#
user
_list_table'
).
DataTable
();
var
$data_table
=
$
(
'#
sudo
_list_table'
).
DataTable
();
var
id_list
=
[];
var
id_list
=
[];
var
plain_id_list
=
[];
var
plain_id_list
=
[];
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
...
@@ -121,7 +119,7 @@ $(document).ready(function(){
...
@@ -121,7 +119,7 @@ $(document).ready(function(){
var
success
=
function
()
{
var
success
=
function
()
{
var
msg
=
"{% trans 'User Deleted.' %}"
;
var
msg
=
"{% trans 'User Deleted.' %}"
;
swal
(
"{% trans 'User Delete' %}"
,
msg
,
"success"
);
swal
(
"{% trans 'User Delete' %}"
,
msg
,
"success"
);
$
(
'#
user
_list_table'
).
DataTable
().
ajax
.
reload
();
$
(
'#
sudo
_list_table'
).
DataTable
().
ajax
.
reload
();
};
};
var
fail
=
function
()
{
var
fail
=
function
()
{
var
msg
=
"{% trans 'User Deleting failed.' %}"
;
var
msg
=
"{% trans 'User Deleting failed.' %}"
;
...
@@ -157,7 +155,7 @@ $(document).ready(function(){
...
@@ -157,7 +155,7 @@ $(document).ready(function(){
var
success
=
function
()
{
var
success
=
function
()
{
var
msg
=
"{% trans 'User Deleted.' %}"
;
var
msg
=
"{% trans 'User Deleted.' %}"
;
swal
(
"{% trans 'User Delete' %}"
,
msg
,
"success"
);
swal
(
"{% trans 'User Delete' %}"
,
msg
,
"success"
);
$
(
'#
user
_list_table'
).
DataTable
().
ajax
.
reload
();
$
(
'#
sudo
_list_table'
).
DataTable
().
ajax
.
reload
();
};
};
var
fail
=
function
()
{
var
fail
=
function
()
{
var
msg
=
"{% trans 'User Deleting failed.' %}"
;
var
msg
=
"{% trans 'User Deleting failed.' %}"
;
...
@@ -198,7 +196,7 @@ $(document).ready(function(){
...
@@ -198,7 +196,7 @@ $(document).ready(function(){
new_groups
=
body
.
groups
.
map
(
Number
);
new_groups
=
body
.
groups
.
map
(
Number
);
body
.
groups
=
new_groups
;
body
.
groups
=
new_groups
;
}
}
var
$data_table
=
$
(
'#
user
_list_table'
).
DataTable
()
var
$data_table
=
$
(
'#
sudo
_list_table'
).
DataTable
()
var
post_list
=
[];
var
post_list
=
[];
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
var
content
=
Object
.
assign
({
id
:
this
.
data
().
id
},
body
);
var
content
=
Object
.
assign
({
id
:
this
.
data
().
id
},
body
);
...
@@ -211,7 +209,7 @@ $(document).ready(function(){
...
@@ -211,7 +209,7 @@ $(document).ready(function(){
var
success
=
function
()
{
var
success
=
function
()
{
var
msg
=
"{% trans 'The selected users has been updated successfully.' %}"
;
var
msg
=
"{% trans 'The selected users has been updated successfully.' %}"
;
swal
(
"{% trans 'User Updated' %}"
,
msg
,
"success"
);
swal
(
"{% trans 'User Updated' %}"
,
msg
,
"success"
);
$
(
'#
user
_list_table'
).
DataTable
().
ajax
.
reload
();
$
(
'#
sudo
_list_table'
).
DataTable
().
ajax
.
reload
();
jumpserver
.
checked
=
false
;
jumpserver
.
checked
=
false
;
};
};
APIUpdateAttr
({
url
:
the_url
,
method
:
'PATCH'
,
body
:
JSON
.
stringify
(
post_list
),
success
:
success
});
APIUpdateAttr
({
url
:
the_url
,
method
:
'PATCH'
,
body
:
JSON
.
stringify
(
post_list
),
success
:
success
});
...
@@ -225,7 +223,7 @@ $(document).ready(function(){
...
@@ -225,7 +223,7 @@ $(document).ready(function(){
$
(
'<span />'
,
{
class
:
'help-block text-danger'
}).
html
(
data
.
msg
).
insertAfter
(
$
(
'#id_excel'
));
$
(
'<span />'
,
{
class
:
'help-block text-danger'
}).
html
(
data
.
msg
).
insertAfter
(
$
(
'#id_excel'
));
}
else
{
}
else
{
$
(
'#user_import_modal'
).
modal
(
'hide'
);
$
(
'#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.' %}"
);
toastr
.
success
(
"{% trans 'Import User Success.' %}"
);
$data_table
.
ajax
.
reload
();
$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