2022-08-22 12:12:33 +00:00
|
|
|
from computes.models import Compute
|
2022-11-02 13:05:41 +00:00
|
|
|
from rest_framework import serializers
|
|
|
|
from vrtManager.connection import CONN_SOCKET, CONN_SSH, CONN_TCP, CONN_TLS
|
2022-08-22 12:12:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ComputeSerializer(serializers.ModelSerializer):
|
2022-11-02 05:54:35 +00:00
|
|
|
# Use <input type="password"> for the input.
|
|
|
|
password = serializers.CharField(style={"input_type": "password"})
|
2022-08-22 12:12:33 +00:00
|
|
|
# Use a radio input instead of a select input.
|
|
|
|
conn_types = (
|
2022-11-02 05:54:35 +00:00
|
|
|
(CONN_SSH, "SSH"),
|
|
|
|
(CONN_TCP, "TCP"),
|
|
|
|
(CONN_TLS, "TLS"),
|
|
|
|
(CONN_SOCKET, "SOCK"),
|
2022-08-22 12:12:33 +00:00
|
|
|
)
|
|
|
|
type = serializers.ChoiceField(choices=conn_types)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Compute
|
2022-11-02 05:54:35 +00:00
|
|
|
fields = ["id", "name", "hostname", "login", "password", "type", "details"]
|