diff --git a/apps/terminal/const.py b/apps/terminal/const.py
index 4701fcb75..6a3b87626 100644
--- a/apps/terminal/const.py
+++ b/apps/terminal/const.py
@@ -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')
]
diff --git a/apps/terminal/forms/storage.py b/apps/terminal/forms/storage.py
index 621c5acb6..5a808b0d8 100644
--- a/apps/terminal/forms/storage.py
+++ b/apps/terminal/forms/storage.py
@@ -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
+ S3(China): http://s3.{REGION_NAME}.amazonaws.com.cn
+ 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,
diff --git a/apps/terminal/models.py b/apps/terminal/models.py
index cb00c99d0..f6676383a 100644
--- a/apps/terminal/models.py
+++ b/apps/terminal/models.py
@@ -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):
diff --git a/apps/terminal/views/storage.py b/apps/terminal/views/storage.py
index ae68d508f..778cdd489 100644
--- a/apps/terminal/views/storage.py
+++ b/apps/terminal/views/storage.py
@@ -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
}