Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
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
coco
Commits
55841ed2
Unverified
Commit
55841ed2
authored
Jul 18, 2019
by
BaiJiangJie
Committed by
GitHub
Jul 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #242 from jumpserver/dev
Dev
parents
484a75ec
04b0cdb5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
interactive.py
coco/interactive.py
+29
-5
requirements.txt
requirements/requirements.txt
+1
-1
No files found.
coco/interactive.py
View file @
55841ed2
...
...
@@ -30,6 +30,9 @@ PROXY = 'proxy'
class
InteractiveServer
:
_sentinel
=
object
()
_user_assets_cached
=
{}
_user_assets_cached_etag
=
{}
_user_nodes_cached
=
{}
_user_nodes_cached_etag
=
{}
def
__init__
(
self
,
client
):
self
.
client
=
client
...
...
@@ -158,7 +161,7 @@ class InteractiveServer:
def
refresh_assets_nodes
(
self
):
self
.
get_user_assets_and_update
(
cache_policy
=
'2'
)
self
.
get_user_nodes
(
cache_policy
=
'
2
'
)
self
.
get_user_nodes
(
cache_policy
=
'
1
'
)
self
.
client
.
send_unicode
(
_
(
"Refresh done"
))
def
wait_until_assets_load
(
self
):
...
...
@@ -318,13 +321,23 @@ class InteractiveServer:
self
.
total_asset_count
=
len
(
assets
)
def
get_user_assets_and_update_async
(
self
):
thread
=
threading
.
Thread
(
target
=
self
.
get_user_assets_and_update
)
thread
=
threading
.
Thread
(
target
=
self
.
get_user_assets_and_update
,
kwargs
=
{
"cache_policy"
:
1
}
)
thread
.
start
()
def
get_user_assets_and_update
(
self
,
cache_policy
=
'1'
):
assets
=
app_service
.
get_user_assets
(
self
.
client
.
user
,
cache_policy
=
cache_policy
)
etag
=
self
.
_user_assets_cached_etag
.
get
(
self
.
client
.
user
.
id
)
assets
,
new_etag
=
app_service
.
get_user_assets
(
self
.
client
.
user
,
cache_policy
=
cache_policy
,
etag
=
etag
)
if
assets
is
None
:
logger
.
debug
(
"Get user assets: not modify"
)
return
assets
=
self
.
filter_system_users
(
assets
)
self
.
__class__
.
_user_assets_cached
[
self
.
client
.
user
.
id
]
=
assets
if
new_etag
:
self
.
__class__
.
_user_assets_cached_etag
[
self
.
client
.
user
.
id
]
=
new_etag
self
.
load_user_assets_from_cache
()
self
.
get_user_assets_finished
=
True
#
...
...
@@ -332,13 +345,24 @@ class InteractiveServer:
#
def
get_user_nodes_async
(
self
):
thread
=
threading
.
Thread
(
target
=
self
.
get_user_nodes
)
thread
=
threading
.
Thread
(
target
=
self
.
get_user_nodes
,
kwargs
=
{
"cache_policy"
:
1
}
)
thread
.
start
()
def
get_user_nodes
(
self
,
cache_policy
=
'1'
):
nodes
=
app_service
.
get_user_asset_groups
(
self
.
client
.
user
,
cache_policy
=
cache_policy
)
etag
=
self
.
_user_assets_cached_etag
.
get
(
self
.
client
.
user
.
id
)
if
cache_policy
not
in
[
'1'
,
1
]:
etag
=
None
nodes
,
new_etag
=
app_service
.
get_user_asset_groups
(
self
.
client
.
user
,
cache_policy
=
cache_policy
,
etag
=
etag
)
if
nodes
is
None
:
logger
.
debug
(
"Get user nodes: not modify"
)
return
nodes
=
sorted
(
nodes
,
key
=
lambda
node
:
node
.
key
)
self
.
nodes
=
self
.
filter_system_users_of_assets_under_nodes
(
nodes
)
self
.
__class__
.
_user_nodes_cached
[
self
.
client
.
user
.
id
]
=
self
.
nodes
if
new_etag
:
self
.
__class__
.
_user_assets_cached_etag
[
self
.
client
.
user
.
id
]
=
new_etag
self
.
_construct_node_tree
()
def
filter_system_users_of_assets_under_nodes
(
self
,
nodes
):
...
...
requirements/requirements.txt
View file @
55841ed2
...
...
@@ -19,7 +19,7 @@ itsdangerous==0.24
Jinja2==2.10.1
jmespath==0.9.3
jms-storage==0.0.23
jumpserver-python-sdk==0.0.6
6
jumpserver-python-sdk==0.0.6
9
MarkupSafe==1.0
oss2==2.4.0
paramiko==2.4.2
...
...
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