mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-29 21:51:31 +00:00
pref: 添加 applet host actions
This commit is contained in:
@@ -14,6 +14,23 @@ class AppletHostViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = serializers.AppletHostSerializer
|
||||
queryset = AppletHost.objects.all()
|
||||
|
||||
@action(methods=['post'], detail=True)
|
||||
def report(self, request, *args, **kwargs):
|
||||
# TODO:
|
||||
# 1. 上报 安装的 Applets 每小时
|
||||
# 2. Host 和 Terminal 关联
|
||||
instance = self.get_object()
|
||||
instance.sync()
|
||||
return Response({'msg': 'ok'})
|
||||
|
||||
@action(methods=['get'], detail=True)
|
||||
def accounts(self, request, *args, **kwargs):
|
||||
# TODO:
|
||||
# 1. 返回 host 上的所有用户, host 可以去创建和更新 每小时
|
||||
# 2. 密码长度最少 8 位,包含大小写字母和数字和特殊字符
|
||||
instance = self.get_object()
|
||||
return Response(instance.get_accounts())
|
||||
|
||||
|
||||
class AppletHostDeploymentViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = serializers.AppletHostDeploymentSerializer
|
||||
|
||||
24
apps/terminal/migrations/0057_auto_20221102_1941.py
Normal file
24
apps/terminal/migrations/0057_auto_20221102_1941.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.2.14 on 2022-11-02 11:41
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('terminal', '0056_auto_20221101_1353'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='applethost',
|
||||
name='terminal',
|
||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='applet_host', to='terminal.terminal', verbose_name='Terminal'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='appletpublication',
|
||||
name='status',
|
||||
field=models.CharField(default='ready', max_length=16, verbose_name='Status'),
|
||||
),
|
||||
]
|
||||
@@ -17,6 +17,10 @@ class AppletHost(Host):
|
||||
date_inited = models.DateTimeField(null=True, blank=True, verbose_name=_('Date inited'))
|
||||
date_synced = models.DateTimeField(null=True, blank=True, verbose_name=_('Date synced'))
|
||||
status = models.CharField(max_length=16, verbose_name=_('Status'))
|
||||
terminal = models.OneToOneField(
|
||||
'terminal.Terminal', on_delete=models.PROTECT, null=True, blank=True,
|
||||
related_name='applet_host', verbose_name=_('Terminal')
|
||||
)
|
||||
applets = models.ManyToManyField(
|
||||
'Applet', verbose_name=_('Applet'),
|
||||
through='AppletPublication', through_fields=('host', 'applet'),
|
||||
|
||||
@@ -5,13 +5,12 @@ from itertools import groupby, chain
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.files.storage import default_storage
|
||||
|
||||
import jms_storage
|
||||
|
||||
from common.utils import get_logger
|
||||
from tickets.models import TicketSession
|
||||
from . import const
|
||||
from .models import ReplayStorage
|
||||
from tickets.models import TicketSession
|
||||
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
Reference in New Issue
Block a user