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
47b1a13b
Unverified
Commit
47b1a13b
authored
Dec 05, 2019
by
BaiJiangJie
Committed by
GitHub
Dec 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 添加存储类型:Ceph、Swift (#3508)
parent
df522402
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
1 deletion
+76
-1
const.py
apps/terminal/const.py
+19
-0
storage.py
apps/terminal/forms/storage.py
+45
-0
models.py
apps/terminal/models.py
+10
-1
storage.py
apps/terminal/views/storage.py
+2
-0
No files found.
apps/terminal/const.py
View file @
47b1a13b
...
...
@@ -11,6 +11,8 @@ SYSTEM_USER_CACHE_KEY = "terminal__session__system_users"
REPLAY_STORAGE_TYPE_NULL
=
'null'
REPLAY_STORAGE_TYPE_SERVER
=
'server'
REPLAY_STORAGE_TYPE_S3
=
's3'
REPLAY_STORAGE_TYPE_CEPH
=
'ceph'
REPLAY_STORAGE_TYPE_SWIFT
=
'swift'
REPLAY_STORAGE_TYPE_OSS
=
'oss'
REPLAY_STORAGE_TYPE_AZURE
=
'azure'
...
...
@@ -21,6 +23,19 @@ REPLAY_STORAGE_TYPE_S3_FIELDS = [
{
'name'
:
'SECRET_KEY'
,
'write_only'
:
True
},
{
'name'
:
'ENDPOINT'
}
]
REPLAY_STORAGE_TYPE_CEPH_FIELDS
=
[
{
'name'
:
'BUCKET'
},
{
'name'
:
'ACCESS_KEY'
,
'write_only'
:
True
},
{
'name'
:
'SECRET_KEY'
,
'write_only'
:
True
},
{
'name'
:
'ENDPOINT'
}
]
REPLAY_STORAGE_TYPE_SWIFT_FIELDS
=
[
{
'name'
:
'BUCKET'
},
{
'name'
:
'ACCESS_KEY'
,
'write_only'
:
True
},
{
'name'
:
'SECRET_KEY'
,
'write_only'
:
True
},
{
'name'
:
'REGION'
},
{
'name'
:
'ENDPOINT'
},
]
REPLAY_STORAGE_TYPE_OSS_FIELDS
=
[
{
'name'
:
'BUCKET'
},
{
'name'
:
'ACCESS_KEY'
,
'write_only'
:
True
},
...
...
@@ -38,6 +53,8 @@ REPLAY_STORAGE_TYPE_MAP_FIELDS = {
REPLAY_STORAGE_TYPE_NULL
:
REPLAY_STORAGE_TYPE_EMPTY_FIELDS
,
REPLAY_STORAGE_TYPE_SERVER
:
REPLAY_STORAGE_TYPE_EMPTY_FIELDS
,
REPLAY_STORAGE_TYPE_S3
:
REPLAY_STORAGE_TYPE_S3_FIELDS
,
REPLAY_STORAGE_TYPE_CEPH
:
REPLAY_STORAGE_TYPE_CEPH_FIELDS
,
REPLAY_STORAGE_TYPE_SWIFT
:
REPLAY_STORAGE_TYPE_SWIFT_FIELDS
,
REPLAY_STORAGE_TYPE_OSS
:
REPLAY_STORAGE_TYPE_OSS_FIELDS
,
REPLAY_STORAGE_TYPE_AZURE
:
REPLAY_STORAGE_TYPE_AZURE_FIELDS
}
...
...
@@ -49,6 +66,8 @@ REPLAY_STORAGE_TYPE_CHOICES_DEFAULT = [
REPLAY_STORAGE_TYPE_CHOICES_EXTENDS
=
[
(
REPLAY_STORAGE_TYPE_S3
,
'S3'
),
(
REPLAY_STORAGE_TYPE_CEPH
,
'Ceph'
),
(
REPLAY_STORAGE_TYPE_SWIFT
,
'Swift'
),
(
REPLAY_STORAGE_TYPE_OSS
,
'OSS'
),
(
REPLAY_STORAGE_TYPE_AZURE
,
'Azure'
)
]
...
...
apps/terminal/forms/storage.py
View file @
47b1a13b
...
...
@@ -9,6 +9,7 @@ from terminal.models import ReplayStorage, CommandStorage
__all__
=
[
'ReplayStorageAzureForm'
,
'ReplayStorageOSSForm'
,
'ReplayStorageS3Form'
,
'ReplayStorageCephForm'
,
'ReplayStorageSwiftForm'
,
'CommandStorageTypeESForm'
,
]
...
...
@@ -102,6 +103,50 @@ class ReplayStorageS3Form(BaseReplayStorageForm):
)
class
ReplayStorageCephForm
(
BaseReplayStorageForm
):
ceph_bucket
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Bucket'
),
required
=
False
)
ceph_access_key
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Access key'
),
required
=
False
,
widget
=
forms
.
PasswordInput
)
ceph_secret_key
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Secret key'
),
required
=
False
,
widget
=
forms
.
PasswordInput
)
ceph_endpoint
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Endpoint'
),
required
=
False
,
help_text
=
_
(
"""
S3: http://s3.{REGION_NAME}.amazonaws.com <br>
S3(China): http://s3.{REGION_NAME}.amazonaws.com.cn <br>
Example: http://s3.cn-north-1.amazonaws.com.cn
"""
)
)
class
ReplayStorageSwiftForm
(
BaseReplayStorageForm
):
swift_bucket
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Bucket'
),
required
=
False
)
swift_access_key
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Access key'
),
required
=
False
,
widget
=
forms
.
PasswordInput
)
swift_secret_key
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Secret key'
),
required
=
False
,
widget
=
forms
.
PasswordInput
)
swift_region
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Region'
),
required
=
False
,
)
swift_endpoint
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Endpoint'
),
required
=
False
,
)
class
CommandStorageTypeESForm
(
BaseCommandStorageForm
):
es_hosts
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
'Hosts'
),
required
=
False
,
...
...
apps/terminal/models.py
View file @
47b1a13b
...
...
@@ -360,10 +360,19 @@ class ReplayStorage(CommonModelMixin):
def
__str__
(
self
):
return
self
.
name
def
convert_type
(
self
):
s3_type_list
=
[
const
.
REPLAY_STORAGE_TYPE_CEPH
,
const
.
REPLAY_STORAGE_TYPE_SWIFT
]
tp
=
self
.
type
if
tp
in
s3_type_list
:
tp
=
const
.
REPLAY_STORAGE_TYPE_S3
return
tp
@property
def
config
(
self
):
config
=
self
.
meta
config
.
update
({
'TYPE'
:
self
.
type
})
config
.
update
({
'TYPE'
:
self
.
convert_type
()
})
return
config
def
in_defaults
(
self
):
...
...
apps/terminal/views/storage.py
View file @
47b1a13b
...
...
@@ -74,6 +74,8 @@ class ReplayStorageCreateUpdateViewMixin(BaseStorageCreateUpdateViewMixin):
form_class
=
forms
.
ReplayStorageS3Form
form_class_choices
=
{
const
.
REPLAY_STORAGE_TYPE_S3
:
forms
.
ReplayStorageS3Form
,
const
.
REPLAY_STORAGE_TYPE_CEPH
:
forms
.
ReplayStorageCephForm
,
const
.
REPLAY_STORAGE_TYPE_SWIFT
:
forms
.
ReplayStorageSwiftForm
,
const
.
REPLAY_STORAGE_TYPE_OSS
:
forms
.
ReplayStorageOSSForm
,
const
.
REPLAY_STORAGE_TYPE_AZURE
:
forms
.
ReplayStorageAzureForm
}
...
...
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