forked from p15670423/monkey
Island: Use make_immutable_sequence() when constructing Machine
This commit is contained in:
parent
b3bfc598a3
commit
5b4b7f0049
|
@ -1,11 +1,12 @@
|
||||||
from ipaddress import IPv4Interface
|
from ipaddress import IPv4Interface
|
||||||
from typing import MutableSequence, Optional, Sequence
|
from typing import Optional, Sequence
|
||||||
|
|
||||||
from pydantic import Field, PositiveInt, validator
|
from pydantic import Field, PositiveInt, validator
|
||||||
|
|
||||||
from common import OperatingSystems
|
from common import OperatingSystems
|
||||||
|
|
||||||
from .base_models import MutableBaseModel
|
from .base_models import MutableBaseModel
|
||||||
|
from .transforms import make_immutable_sequence
|
||||||
|
|
||||||
MachineID = PositiveInt
|
MachineID = PositiveInt
|
||||||
|
|
||||||
|
@ -18,9 +19,6 @@ class Machine(MutableBaseModel):
|
||||||
operating_system_version: str
|
operating_system_version: str
|
||||||
hostname: str
|
hostname: str
|
||||||
|
|
||||||
@validator("network_interfaces", pre=True)
|
_make_immutable_sequence = validator("network_interfaces", pre=True, allow_reuse=True)(
|
||||||
def _make_sequence_immutable(cls, sequence: Sequence):
|
make_immutable_sequence
|
||||||
if isinstance(sequence, MutableSequence):
|
)
|
||||||
return tuple(sequence)
|
|
||||||
|
|
||||||
return sequence
|
|
||||||
|
|
Loading…
Reference in New Issue