mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
Rename __json__() to asdict()
This commit is contained in:
1 parent
44074ff7c9
commit
cefab8d362
89 files changed
+286
-282
No files matched your search
@@ -77,7 +77,7 @@ class Cloud(BaseNode):
|
||||
def _interfaces(self):
|
||||
return gns3server.utils.interfaces.interfaces()
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
host_interfaces = []
|
||||
network_interfaces = gns3server.utils.interfaces.interfaces()
|
||||
|
||||
@@ -38,7 +38,7 @@ class EthernetHub(BaseNode):
|
||||
|
||||
super().__init__(name, node_id, project, manager)
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"name": self.name,
|
||||
|
||||
@@ -38,7 +38,7 @@ class EthernetSwitch(BaseNode):
|
||||
|
||||
super().__init__(name, node_id, project, manager)
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"name": self.name,
|
||||
|
||||
@@ -77,7 +77,7 @@ class Nat(Cloud):
|
||||
def is_supported(self):
|
||||
return True
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
return {
|
||||
"name": self.name,
|
||||
"usage": self.usage,
|
||||
|
||||
@@ -133,7 +133,7 @@ class DockerVM(BaseNode):
|
||||
)
|
||||
)
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
return {
|
||||
"name": self._name,
|
||||
"usage": self.usage,
|
||||
|
||||
@@ -65,7 +65,7 @@ class NIOGenericEthernet(NIO):
|
||||
|
||||
return self._ethernet_device
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_generic_ethernet",
|
||||
|
||||
@@ -64,7 +64,7 @@ class NIOLinuxEthernet(NIO):
|
||||
|
||||
return self._ethernet_device
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_linux_ethernet",
|
||||
|
||||
@@ -46,6 +46,6 @@ class NIONull(NIO):
|
||||
await self._hypervisor.send(f"nio create_null {self._name}")
|
||||
log.info(f"NIO NULL {self._name} created.")
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {"type": "nio_null"}
|
||||
@@ -58,7 +58,7 @@ class NIOTAP(NIO):
|
||||
|
||||
return self._tap_device
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_tap",
|
||||
|
||||
@@ -126,7 +126,7 @@ class NIOUDP(NIO):
|
||||
|
||||
return self._rport
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_udp",
|
||||
|
||||
@@ -79,7 +79,7 @@ class NIOUNIX(NIO):
|
||||
|
||||
return self._remote_file
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_unix",
|
||||
|
||||
@@ -79,7 +79,7 @@ class NIOVDE(NIO):
|
||||
|
||||
return self._local_file
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_vde",
|
||||
|
||||
@@ -52,7 +52,7 @@ class ATMSwitch(Device):
|
||||
if mappings:
|
||||
self._mappings = mappings
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
mappings = {}
|
||||
for source, destination in self._mappings.items():
|
||||
|
||||
@@ -76,11 +76,11 @@ class C1700(Router):
|
||||
self._clock_divisor = 8
|
||||
self._sparsemem = False # never activate sparsemem for c1700 (unstable)
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
c1700_router_info = {"iomem": self._iomem, "chassis": self._chassis, "sparsemem": self._sparsemem}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info = Router.asdict(self)
|
||||
router_info.update(c1700_router_info)
|
||||
return router_info
|
||||
|
||||
|
||||
@@ -93,11 +93,11 @@ class C2600(Router):
|
||||
self._clock_divisor = 8
|
||||
self._sparsemem = False # never activate sparsemem for c2600 (unstable)
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
c2600_router_info = {"iomem": self._iomem, "chassis": self._chassis, "sparsemem": self._sparsemem}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info = Router.asdict(self)
|
||||
router_info.update(c2600_router_info)
|
||||
return router_info
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@ class C2691(Router):
|
||||
if chassis is not None:
|
||||
raise DynamipsError("c2691 routers do not have chassis")
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
c2691_router_info = {"iomem": self._iomem}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info = Router.asdict(self)
|
||||
router_info.update(c2691_router_info)
|
||||
return router_info
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ class C3600(Router):
|
||||
self._chassis = chassis
|
||||
self._clock_divisor = 4
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
c3600_router_info = {"iomem": self._iomem, "chassis": self._chassis}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info = Router.asdict(self)
|
||||
router_info.update(c3600_router_info)
|
||||
return router_info
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@ class C3725(Router):
|
||||
if chassis is not None:
|
||||
raise DynamipsError("c3725 routers do not have chassis")
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
c3725_router_info = {"iomem": self._iomem}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info = Router.asdict(self)
|
||||
router_info.update(c3725_router_info)
|
||||
return router_info
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@ class C3745(Router):
|
||||
if chassis is not None:
|
||||
raise DynamipsError("c3745 routers do not have chassis")
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
c3745_router_info = {"iomem": self._iomem}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info = Router.asdict(self)
|
||||
router_info.update(c3745_router_info)
|
||||
return router_info
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class C7200(Router):
|
||||
if chassis is not None:
|
||||
raise DynamipsError("c7200 routers do not have chassis")
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
c7200_router_info = {
|
||||
"npe": self._npe,
|
||||
@@ -101,7 +101,7 @@ class C7200(Router):
|
||||
"power_supplies": self._power_supplies,
|
||||
}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info = Router.asdict(self)
|
||||
router_info.update(c7200_router_info)
|
||||
return router_info
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class EthernetHub(Bridge):
|
||||
else:
|
||||
self._ports = ports
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"name": self.name,
|
||||
|
||||
@@ -109,7 +109,7 @@ class EthernetSwitch(Device):
|
||||
else:
|
||||
self._ports = ports
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
ethernet_switch_info = {
|
||||
"name": self.name,
|
||||
|
||||
@@ -51,7 +51,7 @@ class FrameRelaySwitch(Device):
|
||||
if mappings:
|
||||
self._mappings = mappings
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
mappings = {}
|
||||
for source, destination in self._mappings.items():
|
||||
|
||||
@@ -155,7 +155,7 @@ class Router(BaseNode):
|
||||
log.error(f"Can't move {path}: {str(e)}")
|
||||
continue
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
router_info = {
|
||||
"name": self.name,
|
||||
|
||||
@@ -219,7 +219,7 @@ class IOUVM(BaseNode):
|
||||
if not os.access(self._path, os.X_OK):
|
||||
raise IOUError(f"IOU image '{self._path}' is not executable")
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
iou_vm_info = {
|
||||
"name": self.name,
|
||||
|
||||
@@ -48,7 +48,7 @@ class NIOEthernet(NIO):
|
||||
|
||||
return "NIO Ethernet"
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_ethernet",
|
||||
|
||||
@@ -48,7 +48,7 @@ class NIOTAP(NIO):
|
||||
|
||||
return "NIO TAP"
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_tap",
|
||||
|
||||
@@ -72,7 +72,7 @@ class NIOUDP(NIO):
|
||||
|
||||
return "NIO UDP"
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"type": "nio_udp",
|
||||
|
||||
@@ -127,7 +127,7 @@ class PortManager:
|
||||
cls._instance = cls()
|
||||
return cls._instance
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"console_port_range": self._console_port_range,
|
||||
|
||||
@@ -77,7 +77,7 @@ class Project:
|
||||
|
||||
log.info(f"Project {self._id} with path '{self._path}' created")
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"name": self._name,
|
||||
|
||||
@@ -1112,7 +1112,7 @@ class QemuVM(BaseNode):
|
||||
|
||||
# In case user upload image manually we don't have md5 sums.
|
||||
# We need generate hashes at this point, otherwise they will be generated
|
||||
# at __json__ but not on separate thread.
|
||||
# at asdict but not on separate thread.
|
||||
await cancellable_wait_run_in_executor(md5sum, self._hda_disk_image)
|
||||
await cancellable_wait_run_in_executor(md5sum, self._hdb_disk_image)
|
||||
await cancellable_wait_run_in_executor(md5sum, self._hdc_disk_image)
|
||||
@@ -2506,7 +2506,7 @@ class QemuVM(BaseNode):
|
||||
raise QemuError(f"Invalid additional options: {additional_options} error {e}")
|
||||
return command
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
answer = {"project_id": self.project.id, "node_id": self.id, "node_directory": self.working_path}
|
||||
# Qemu has a long list of options. The JSON schema is the single source of information
|
||||
for field in Qemu.schema()["properties"]:
|
||||
|
||||
@@ -86,7 +86,7 @@ class VirtualBoxVM(BaseNode):
|
||||
self._ram = 0
|
||||
self._adapter_type = "Intel PRO/1000 MT Desktop (82540EM)"
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
json = {
|
||||
"name": self.name,
|
||||
|
||||
@@ -75,7 +75,7 @@ class VMwareVM(BaseNode):
|
||||
def ethernet_adapters(self):
|
||||
return self._ethernet_adapters
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
json = {
|
||||
"name": self.name,
|
||||
|
||||
@@ -120,7 +120,7 @@ class VPCSVM(BaseNode):
|
||||
|
||||
await self._check_vpcs_version()
|
||||
|
||||
def __json__(self):
|
||||
def asdict(self):
|
||||
|
||||
return {
|
||||
"name": self.name,
|
||||
|
||||
Reference in new issue
Block a user