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
fe186212
Commit
fe186212
authored
Mar 21, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 删掉集群等等
parent
759760e7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
10 additions
and
58 deletions
+10
-58
asset.py
apps/assets/models/asset.py
+0
-2
utils.py
apps/assets/models/utils.py
+4
-4
cluster.py
apps/assets/serializers/cluster.py
+0
-46
tasks.py
apps/assets/tasks.py
+1
-1
system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+3
-3
asset.py
apps/assets/views/asset.py
+1
-1
hands.py
apps/perms/hands.py
+1
-1
No files found.
apps/assets/models/asset.py
View file @
fe186212
...
...
@@ -10,7 +10,6 @@ from django.utils.translation import ugettext_lazy as _
from
django.core.cache
import
cache
from
..const
import
ASSET_ADMIN_CONN_CACHE_KEY
from
.cluster
import
Cluster
from
.group
import
AssetGroup
from
.user
import
AdminUser
,
SystemUser
...
...
@@ -168,7 +167,6 @@ class Asset(models.Model):
try
:
asset
.
save
()
asset
.
system_users
=
[
choice
(
SystemUser
.
objects
.
all
())
for
i
in
range
(
3
)]
asset
.
groups
=
[
choice
(
AssetGroup
.
objects
.
all
())
for
i
in
range
(
3
)]
logger
.
debug
(
'Generate fake asset :
%
s'
%
asset
.
ip
)
except
IntegrityError
:
print
(
'Error continue'
)
...
...
apps/assets/models/utils.py
View file @
fe186212
...
...
@@ -10,15 +10,15 @@ __all__ = ['init_model', 'generate_fake']
def
init_model
():
from
.
import
Cluster
,
SystemUser
,
AdminUser
,
AssetGroup
,
Asset
for
cls
in
[
Cluster
,
SystemUser
,
AdminUser
,
AssetGroup
,
Asset
]:
from
.
import
SystemUser
,
AdminUser
,
Asset
for
cls
in
[
SystemUser
,
AdminUser
,
Asset
]:
if
hasattr
(
cls
,
'initial'
):
cls
.
initial
()
def
generate_fake
():
from
.
import
Cluster
,
SystemUser
,
AdminUser
,
AssetGroup
,
Asset
for
cls
in
[
Cluster
,
SystemUser
,
AdminUser
,
AssetGroup
,
Asset
]:
from
.
import
SystemUser
,
AdminUser
,
Asset
for
cls
in
[
SystemUser
,
AdminUser
,
Asset
]:
if
hasattr
(
cls
,
'generate_fake'
):
cls
.
generate_fake
()
...
...
apps/assets/serializers/cluster.py
deleted
100644 → 0
View file @
759760e7
# -*- coding: utf-8 -*-
#
from
rest_framework
import
serializers
from
common.mixins
import
BulkSerializerMixin
from
..models
import
Asset
,
Cluster
class
ClusterUpdateAssetsSerializer
(
serializers
.
ModelSerializer
):
"""
集群更新资产数据结构
"""
assets
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
Asset
.
objects
.
all
())
class
Meta
:
model
=
Cluster
fields
=
[
'id'
,
'assets'
]
class
ClusterSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
"""
cluster
"""
assets_amount
=
serializers
.
SerializerMethodField
()
admin_user_name
=
serializers
.
SerializerMethodField
()
assets
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
Asset
.
objects
.
all
())
system_users
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
Cluster
fields
=
'__all__'
@staticmethod
def
get_assets_amount
(
obj
):
return
obj
.
assets
.
count
()
@staticmethod
def
get_admin_user_name
(
obj
):
try
:
return
obj
.
admin_user
.
name
except
AttributeError
:
return
''
@staticmethod
def
get_system_users
(
obj
):
return
', '
.
join
(
obj
.
name
for
obj
in
obj
.
systemuser_set
.
all
())
apps/assets/tasks.py
View file @
fe186212
...
...
@@ -12,7 +12,7 @@ from common.utils import get_object_or_none, capacity_convert, \
from
common.celery
import
register_as_period_task
,
after_app_shutdown_clean
,
\
after_app_ready_start
,
app
as
celery_app
from
.models
import
SystemUser
,
AdminUser
,
Asset
,
Cluster
from
.models
import
SystemUser
,
AdminUser
,
Asset
from
.
import
const
...
...
apps/assets/templates/assets/system_user_detail.html
View file @
fe186212
...
...
@@ -206,7 +206,7 @@
{% endblock %}
{% block custom_foot_js %}
<script>
function
updateSystemUser
Cluster
(
nodes
)
{
function
updateSystemUser
Node
(
nodes
)
{
var
the_url
=
"{% url 'api-assets:system-user-detail' pk=system_user.id %}"
;
var
body
=
{
nodes
:
Object
.
assign
([],
nodes
)
...
...
@@ -267,7 +267,7 @@ $(document).ready(function () {
$
.
map
(
jumpserver
.
nodes_selected
,
function
(
value
,
index
)
{
nodes
.
push
(
index
);
});
updateSystemUser
Cluster
(
nodes
);
updateSystemUser
Node
(
nodes
);
})
.
on
(
'click'
,
'.btn-remove-from-node'
,
function
()
{
var
$this
=
$
(
this
);
...
...
@@ -282,7 +282,7 @@ $(document).ready(function () {
var
nodes
=
$
(
'.bdg_node'
).
map
(
function
()
{
return
$
(
this
).
data
(
'gid'
);
}).
get
();
updateSystemUser
Cluster
(
nodes
);
updateSystemUser
Node
(
nodes
);
}).
on
(
'click'
,
'.btn-del'
,
function
()
{
var
$this
=
$
(
this
);
var
name
=
"{{ system_user.name}}"
;
...
...
apps/assets/views/asset.py
View file @
fe186212
...
...
@@ -27,7 +27,7 @@ from common.mixins import JSONResponseMixin
from
common.utils
import
get_object_or_none
,
get_logger
,
is_uuid
from
common.const
import
create_success_msg
,
update_success_msg
from
..
import
forms
from
..models
import
Asset
,
A
ssetGroup
,
AdminUser
,
Clust
er
,
SystemUser
,
Label
,
Node
from
..models
import
Asset
,
A
dminUs
er
,
SystemUser
,
Label
,
Node
from
..hands
import
AdminUserRequiredMixin
...
...
apps/perms/hands.py
View file @
fe186212
...
...
@@ -3,7 +3,7 @@
from
users.utils
import
AdminUserRequiredMixin
from
users.models
import
User
,
UserGroup
from
assets.models
import
Asset
,
AssetGroup
,
SystemUser
,
Node
from
assets.models
import
Asset
,
SystemUser
,
Node
from
assets.serializers
import
AssetGrantedSerializer
,
NodeGrantedSerializer
,
NodeSerializer
...
...
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