mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
- An API volume takes the name and size the web form takes. Its name went into the volume XML unchecked, so a name could add elements such as a backing store pointing at another VM's disk; the name is also escaped there now. A size of 0 and metadata preallocation on a non-qcow2 volume are refused or dropped, as on the web form. - An API compute update with an empty or null password keeps the stored one, as the web form does; it emptied it and cut the host off. - The architectures endpoint answers 404 for an unknown compute instead of 500; an unrouted copy of it is removed.
29 lines
980 B
Python
29 lines
980 B
Python
from computes.models import Compute
|
|
from rest_framework import serializers
|
|
from vrtManager.connection import CONN_SOCKET, CONN_SSH, CONN_TCP, CONN_TLS
|
|
|
|
|
|
class ComputeSerializer(serializers.ModelSerializer):
|
|
password = serializers.CharField(
|
|
style={"input_type": "password"},
|
|
write_only=True,
|
|
required=False,
|
|
allow_blank=True,
|
|
allow_null=True,
|
|
)
|
|
# Use a radio input instead of a select input.
|
|
conn_types = (
|
|
(CONN_SSH, "SSH"),
|
|
(CONN_TCP, "TCP"),
|
|
(CONN_TLS, "TLS"),
|
|
(CONN_SOCKET, "SOCK"),
|
|
)
|
|
type = serializers.ChoiceField(choices=conn_types)
|
|
|
|
def validate_password(self, value):
|
|
# as on the web form, an empty password on an edit keeps the stored one
|
|
return value or (self.instance.password if self.instance else value)
|
|
|
|
class Meta:
|
|
model = Compute
|
|
fields = ["id", "name", "hostname", "login", "password", "type", "details", "migration_address"]
|