Merge pull request #3618 from jumpserver/dev_swift

[Update] 修改Swift录像存储创建参数及API返回值
pull/3621/head
BaiJiangJie 2020-01-10 11:44:23 +08:00 committed by GitHub
commit 6ddd48bfb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -35,6 +35,7 @@ REPLAY_STORAGE_TYPE_SWIFT_FIELDS = [
{'name': 'SECRET_KEY', 'write_only': True},
{'name': 'REGION'},
{'name': 'ENDPOINT'},
{'name': 'PROTOCOL'},
]
REPLAY_STORAGE_TYPE_OSS_FIELDS = [
{'name': 'BUCKET'},

View File

@ -145,6 +145,12 @@ class ReplayStorageSwiftForm(BaseReplayStorageForm):
swift_endpoint = forms.CharField(
max_length=128, label=_('Endpoint'), required=False,
)
swift_protocol = forms.ChoiceField(
choices=(
('HTTP', 'http'),
('HTTPS', 'https')
), initial='http', label=_('Protocol'), required=True,
)
class CommandStorageTypeESForm(BaseCommandStorageForm):

View File

@ -362,18 +362,23 @@ class ReplayStorage(CommonModelMixin):
return self.name
def convert_type(self):
s3_type_list = [
const.REPLAY_STORAGE_TYPE_CEPH, const.REPLAY_STORAGE_TYPE_SWIFT
]
s3_type_list = [const.REPLAY_STORAGE_TYPE_CEPH]
tp = self.type
if tp in s3_type_list:
tp = const.REPLAY_STORAGE_TYPE_S3
return tp
def get_extra_config(self):
extra_config = {'TYPE': self.convert_type()}
if self.type == const.REPLAY_STORAGE_TYPE_SWIFT:
extra_config.update({'signer': 'S3SignerType'})
return extra_config
@property
def config(self):
config = self.meta
config.update({'TYPE': self.convert_type()})
extra_config = self.get_extra_config()
config.update(extra_config)
return config
def in_defaults(self):