mirror of https://github.com/jumpserver/jumpserver
[Update] 添加存储类型:Ceph、Swift (#3508)
parent
df52240227
commit
47b1a13bea
|
@ -11,6 +11,8 @@ SYSTEM_USER_CACHE_KEY = "terminal__session__system_users"
|
||||||
REPLAY_STORAGE_TYPE_NULL = 'null'
|
REPLAY_STORAGE_TYPE_NULL = 'null'
|
||||||
REPLAY_STORAGE_TYPE_SERVER = 'server'
|
REPLAY_STORAGE_TYPE_SERVER = 'server'
|
||||||
REPLAY_STORAGE_TYPE_S3 = 's3'
|
REPLAY_STORAGE_TYPE_S3 = 's3'
|
||||||
|
REPLAY_STORAGE_TYPE_CEPH = 'ceph'
|
||||||
|
REPLAY_STORAGE_TYPE_SWIFT = 'swift'
|
||||||
REPLAY_STORAGE_TYPE_OSS = 'oss'
|
REPLAY_STORAGE_TYPE_OSS = 'oss'
|
||||||
REPLAY_STORAGE_TYPE_AZURE = 'azure'
|
REPLAY_STORAGE_TYPE_AZURE = 'azure'
|
||||||
|
|
||||||
|
@ -21,6 +23,19 @@ REPLAY_STORAGE_TYPE_S3_FIELDS = [
|
||||||
{'name': 'SECRET_KEY', 'write_only': True},
|
{'name': 'SECRET_KEY', 'write_only': True},
|
||||||
{'name': 'ENDPOINT'}
|
{'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 = [
|
REPLAY_STORAGE_TYPE_OSS_FIELDS = [
|
||||||
{'name': 'BUCKET'},
|
{'name': 'BUCKET'},
|
||||||
{'name': 'ACCESS_KEY', 'write_only': True},
|
{'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_NULL: REPLAY_STORAGE_TYPE_EMPTY_FIELDS,
|
||||||
REPLAY_STORAGE_TYPE_SERVER: 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_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_OSS: REPLAY_STORAGE_TYPE_OSS_FIELDS,
|
||||||
REPLAY_STORAGE_TYPE_AZURE: REPLAY_STORAGE_TYPE_AZURE_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_CHOICES_EXTENDS = [
|
||||||
(REPLAY_STORAGE_TYPE_S3, 'S3'),
|
(REPLAY_STORAGE_TYPE_S3, 'S3'),
|
||||||
|
(REPLAY_STORAGE_TYPE_CEPH, 'Ceph'),
|
||||||
|
(REPLAY_STORAGE_TYPE_SWIFT, 'Swift'),
|
||||||
(REPLAY_STORAGE_TYPE_OSS, 'OSS'),
|
(REPLAY_STORAGE_TYPE_OSS, 'OSS'),
|
||||||
(REPLAY_STORAGE_TYPE_AZURE, 'Azure')
|
(REPLAY_STORAGE_TYPE_AZURE, 'Azure')
|
||||||
]
|
]
|
||||||
|
|
|
@ -9,6 +9,7 @@ from terminal.models import ReplayStorage, CommandStorage
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'ReplayStorageAzureForm', 'ReplayStorageOSSForm', 'ReplayStorageS3Form',
|
'ReplayStorageAzureForm', 'ReplayStorageOSSForm', 'ReplayStorageS3Form',
|
||||||
|
'ReplayStorageCephForm', 'ReplayStorageSwiftForm',
|
||||||
'CommandStorageTypeESForm',
|
'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):
|
class CommandStorageTypeESForm(BaseCommandStorageForm):
|
||||||
es_hosts = forms.CharField(
|
es_hosts = forms.CharField(
|
||||||
max_length=128, label=_('Hosts'), required=False,
|
max_length=128, label=_('Hosts'), required=False,
|
||||||
|
|
|
@ -360,10 +360,19 @@ class ReplayStorage(CommonModelMixin):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
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
|
@property
|
||||||
def config(self):
|
def config(self):
|
||||||
config = self.meta
|
config = self.meta
|
||||||
config.update({'TYPE': self.type})
|
config.update({'TYPE': self.convert_type()})
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def in_defaults(self):
|
def in_defaults(self):
|
||||||
|
|
|
@ -74,6 +74,8 @@ class ReplayStorageCreateUpdateViewMixin(BaseStorageCreateUpdateViewMixin):
|
||||||
form_class = forms.ReplayStorageS3Form
|
form_class = forms.ReplayStorageS3Form
|
||||||
form_class_choices = {
|
form_class_choices = {
|
||||||
const.REPLAY_STORAGE_TYPE_S3: forms.ReplayStorageS3Form,
|
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_OSS: forms.ReplayStorageOSSForm,
|
||||||
const.REPLAY_STORAGE_TYPE_AZURE: forms.ReplayStorageAzureForm
|
const.REPLAY_STORAGE_TYPE_AZURE: forms.ReplayStorageAzureForm
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue