Skip to content

Commit

Permalink
Merge pull request #844 from EliasChiang/master
Browse files Browse the repository at this point in the history
添加隧道管理页面
  • Loading branch information
hhyo authored Aug 6, 2020
2 parents 6d0622c + 80dbd7f commit 4de3d6b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion sql/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from .models import Users, Instance, SqlWorkflow, SqlWorkflowContent, QueryLog, DataMaskingColumns, DataMaskingRules, \
AliyunRdsConfig, CloudAccessKey, ResourceGroup, QueryPrivilegesApply, \
QueryPrivileges, InstanceAccount, InstanceDatabase, ArchiveConfig, \
WorkflowAudit, WorkflowLog, ParamTemplate, ParamHistory, InstanceTag
WorkflowAudit, WorkflowLog, ParamTemplate, ParamHistory, InstanceTag, \
Tunnel


# 用户管理
Expand Down Expand Up @@ -70,6 +71,23 @@ class AliRdsConfigInline(admin.TabularInline):

inlines = [AliRdsConfigInline]

# SSH隧道
@admin.register(Tunnel)
class TunnelAdmin(admin.ModelAdmin):
list_display = ('id', 'tunnel_name', 'host', 'port', 'create_time')
list_display_links = ('id', 'tunnel_name',)
search_fields = ('id', 'tunnel_name')
fieldsets = (None, {'fields': ('tunnel_name', 'host', 'port', 'user', 'password', 'pkey_path', 'pkey_password',), }),
ordering = ('id',)
# 添加页显示内容
add_fieldsets = (
('隧道信息', {'fields': ('tunnel_name', 'host', 'port')}),
('连接信息', {'fields': ('user', 'password', 'pkey_path', 'pkey_password')}),
)

# 不支持修改标签代码
def get_readonly_fields(self, request, obj=None):
return ('id',) if obj else ()

# SQL工单内容
class SqlWorkflowContentInline(admin.TabularInline):
Expand Down
2 changes: 1 addition & 1 deletion sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Instance(models.Model):
sid = models.CharField('Oracle sid', max_length=50, null=True, blank=True)
resource_group = models.ManyToManyField(ResourceGroup, verbose_name='资源组', blank=True)
instance_tag = models.ManyToManyField(InstanceTag, verbose_name='实例标签', blank=True)
tunnel = models.ForeignKey(Tunnel, blank=True, null=True, on_delete=models.CASCADE, default=None)
tunnel = models.ForeignKey(Tunnel, verbose_name='连接隧道', blank=True, null=True, on_delete=models.CASCADE, default=None)
create_time = models.DateTimeField('创建时间', auto_now_add=True)
update_time = models.DateTimeField('更新时间', auto_now=True)

Expand Down

0 comments on commit 4de3d6b

Please sign in to comment.