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
9441dc70
Commit
9441dc70
authored
Jul 17, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] Api 请求支持etag
parent
9aced51d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
interactive.py
coco/interactive.py
+28
-4
requirements.txt
requirements/requirements.txt
+1
-1
No files found.
coco/interactive.py
View file @
9441dc70
...
...
@@ -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
...
...
@@ -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 @
9441dc70
...
...
@@ -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
7
jumpserver-python-sdk==0.0.6
8
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