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
10228864
Unverified
Commit
10228864
authored
7 years ago
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: S3ReplayRecorder
parent
abb20e1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
recorder.py
coco/recorder.py
+18
-2
No files found.
coco/recorder.py
View file @
10228864
...
...
@@ -9,6 +9,7 @@ import os
import
gzip
import
json
import
shutil
import
boto3
# AWS S3 sdk
from
jms_es_sdk
import
ESStore
...
...
@@ -238,6 +239,21 @@ class ESCommandRecorder(CommandRecorder, metaclass=Singleton):
print
(
"{} has been gc"
.
format
(
self
))
class
S3ReplayRecorder
(
ReplayRecorder
):
def
__init__
(
self
,
app
):
super
()
.
__init__
(
app
)
self
.
aws_id
=
app
.
config
[
"REPLAY_RECORD_ENGINE"
]
.
get
(
"KEY_ID"
,
None
)
self
.
aws_key
=
app
.
config
[
"REPLAY_RECORD_ENGINE"
]
.
get
(
"KEY"
,
None
)
self
.
s3
=
boto3
.
client
(
's3'
,
aws_access_key_id
=
self
.
aws_id
,
aws_secret_access_key
=
self
.
aws_key
)
self
.
bucket
=
app
.
config
[
"REPLAY_RECORD_ENGINE"
]
.
get
(
"BUCKET"
,
"jumpserver"
)
def
push_to_server
(
self
,
session_id
):
self
.
s3
.
upload_file
(
filename
=
os
.
path
.
join
(
self
.
app
.
config
[
'LOG_DIR'
],
session_id
+
'.replay.gz'
),
bucket
=
self
.
bucket
)
# TODO: 添加日期文件夹及协调一些事宜<liuzheng>
def
get_command_recorder_class
(
config
):
command_storage
=
config
[
"COMMAND_STORAGE"
]
...
...
@@ -249,7 +265,7 @@ def get_command_recorder_class(config):
def
get_replay_recorder_class
(
config
):
replay_engine
=
config
[
"REPLAY_RECORD_ENGINE"
]
if
replay_engine
==
"s
erver
"
:
return
S
erver
ReplayRecorder
if
replay_engine
==
"s
3
"
:
return
S
3
ReplayRecorder
else
:
return
ServerReplayRecorder
This diff is collapsed.
Click to expand it.
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