diff --git a/apps/terminal/const.py b/apps/terminal/const.py index b412c1624..4d19d007c 100644 --- a/apps/terminal/const.py +++ b/apps/terminal/const.py @@ -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'}, diff --git a/apps/terminal/forms/storage.py b/apps/terminal/forms/storage.py index 28092380e..a94375e81 100644 --- a/apps/terminal/forms/storage.py +++ b/apps/terminal/forms/storage.py @@ -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): diff --git a/apps/terminal/models.py b/apps/terminal/models.py index 6ad820563..04bc74c67 100644 --- a/apps/terminal/models.py +++ b/apps/terminal/models.py @@ -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):