mirror of https://github.com/jumpserver/jumpserver
perf: stash
parent
69f3c85195
commit
246710128e
|
@ -1,3 +1,4 @@
|
|||
from .common import *
|
||||
from .host import *
|
||||
from .database import *
|
||||
from .permission import *
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
from assets.models import Database
|
||||
from assets.serializers import DatabaseSerializer
|
||||
from .common import AssetViewSet
|
||||
|
||||
__all__ = ['DatabaseViewSet']
|
||||
|
||||
|
||||
class DatabaseViewSet(AssetViewSet):
|
||||
model = Database
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
print("Datbase is: ", queryset)
|
||||
return queryset
|
||||
|
||||
def get_serializer_classes(self):
|
||||
serializer_classes = super().get_serializer_classes()
|
||||
serializer_classes['default'] = DatabaseSerializer
|
||||
return serializer_classes
|
|
@ -57,9 +57,6 @@ class ProtocolsField(serializers.ListField):
|
|||
|
||||
|
||||
class AssetSerializer(BulkOrgResourceModelSerializer):
|
||||
platform = serializers.SlugRelatedField(
|
||||
slug_field='name', queryset=Platform.objects.all(), label=_("Platform")
|
||||
)
|
||||
protocols = ProtocolsField(label=_('Protocols'), required=False, default=['ssh/22'])
|
||||
domain_display = serializers.ReadOnlyField(source='domain.name', label=_('Domain name'))
|
||||
nodes_display = serializers.ListField(
|
||||
|
@ -97,6 +94,8 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
|
|||
]
|
||||
fields = fields_small + fields_fk + fields_m2m + read_only_fields
|
||||
extra_kwargs = {
|
||||
'hostname': {'label': _("Name")},
|
||||
'ip': {'label': 'Address'},
|
||||
'protocol': {'write_only': True},
|
||||
'port': {'write_only': True},
|
||||
'admin_user_display': {'label': _('Admin user display'), 'read_only': True},
|
||||
|
@ -177,7 +176,10 @@ class MiniAssetSerializer(serializers.ModelSerializer):
|
|||
class AssetSimpleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Asset
|
||||
fields = ['id', 'hostname', 'ip', 'port', 'connectivity', 'date_verified']
|
||||
fields = [
|
||||
'id', 'hostname', 'ip', 'port',
|
||||
'connectivity', 'date_verified'
|
||||
]
|
||||
|
||||
|
||||
class AssetsTaskSerializer(serializers.Serializer):
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from .common import AssetSerializer
|
||||
from assets.models import DeviceInfo, Host
|
||||
from assets.models import DeviceInfo, Host, Database
|
||||
|
||||
__all__ = ['DeviceSerializer', 'HostSerializer']
|
||||
__all__ = ['DeviceSerializer', 'HostSerializer', 'DatabaseSerializer']
|
||||
|
||||
|
||||
class DeviceSerializer(serializers.ModelSerializer):
|
||||
|
@ -23,3 +23,9 @@ class HostSerializer(AssetSerializer):
|
|||
class Meta(AssetSerializer.Meta):
|
||||
model = Host
|
||||
fields = AssetSerializer.Meta.fields + ['device_info']
|
||||
|
||||
|
||||
class DatabaseSerializer(AssetSerializer):
|
||||
class Meta(AssetSerializer.Meta):
|
||||
model = Database
|
||||
fields = AssetSerializer.Meta.fields + ['db_name']
|
||||
|
|
|
@ -11,7 +11,8 @@ app_name = 'assets'
|
|||
|
||||
router = BulkRouter()
|
||||
router.register(r'assets', api.AssetViewSet, 'asset')
|
||||
router.register(r'hosts', api.HostViewSet, 'asset')
|
||||
router.register(r'hosts', api.HostViewSet, 'host')
|
||||
router.register(r'databases', api.DatabaseViewSet, 'database')
|
||||
router.register(r'accounts', api.AccountViewSet, 'account')
|
||||
router.register(r'account-secrets', api.AccountSecretsViewSet, 'account-secret')
|
||||
router.register(r'platforms', api.AssetPlatformViewSet, 'platform')
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:050a3fd63c1cf9b3dc60c8f138d58f029f2e8a32a71abd99fff6899b68c0f6d9
|
||||
size 129742
|
||||
oid sha256:7b79695fe8cb323097c12171db8f6ae58b8e016b317f08562183b677f537e8b3
|
||||
size 129597
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1baa8c35aa2493c03c1fe7383a13ca4cfd9b18b44150770fb51f39433c18c74c
|
||||
size 107492
|
||||
oid sha256:7326f6af4efae2abb098218faabe97aceed9a8f61dd5fcd56b16d5d07164556a
|
||||
size 107769
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue