mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
parent
048d2c12d0
commit
cf3ed5a329
@ -500,8 +500,14 @@ class Node:
|
|||||||
self._ports.append(PortFactory("ATM{}".format(adapter_number), adapter_number, adapter_number, 0, "atm"))
|
self._ports.append(PortFactory("ATM{}".format(adapter_number), adapter_number, adapter_number, 0, "atm"))
|
||||||
return
|
return
|
||||||
elif self._node_type == "frame_relay_switch":
|
elif self._node_type == "frame_relay_switch":
|
||||||
for adapter_number in range(0, len(self.properties["mappings"])):
|
frame_relay_port = set()
|
||||||
self._ports.append(PortFactory("FrameRelay{}".format(adapter_number), adapter_number, adapter_number, 0, "frame_relay"))
|
# Mapping is like {"1:101": "10:202"}
|
||||||
|
for source, dest in self.properties["mappings"].items():
|
||||||
|
frame_relay_port.add(int(source.split(":")[0]))
|
||||||
|
frame_relay_port.add(int(dest.split(":")[0]))
|
||||||
|
frame_relay_port = sorted(frame_relay_port)
|
||||||
|
for port in frame_relay_port:
|
||||||
|
self._ports.append(PortFactory("{}".format(port), 0, 0, port, "frame_relay"))
|
||||||
return
|
return
|
||||||
elif self._node_type == "dynamips":
|
elif self._node_type == "dynamips":
|
||||||
self._ports = DynamipsPortFactory(self.properties)
|
self._ports = DynamipsPortFactory(self.properties)
|
||||||
|
@ -34,6 +34,10 @@ class FrameRelayPort(SerialPort):
|
|||||||
|
|
||||||
return "FrameRelay"
|
return "FrameRelay"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def short_name(self):
|
||||||
|
return "{}".format(self._port_number)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data_link_types(self):
|
def data_link_types(self):
|
||||||
"""
|
"""
|
||||||
|
@ -48,10 +48,14 @@ class Port:
|
|||||||
def link_type(self):
|
def link_type(self):
|
||||||
return "ethernet"
|
return "ethernet"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def short_name(self):
|
||||||
|
return self.short_name_type + "{}/{}".format(self._interface_number, self._port_number)
|
||||||
|
|
||||||
def __json__(self):
|
def __json__(self):
|
||||||
return {
|
return {
|
||||||
"name": self._name,
|
"name": self._name,
|
||||||
"short_name": self.short_name_type + "{}/{}".format(self._interface_number, self._port_number),
|
"short_name": self.short_name,
|
||||||
"data_link_types": self.data_link_types,
|
"data_link_types": self.data_link_types,
|
||||||
"port_number": self._port_number,
|
"port_number": self._port_number,
|
||||||
"adapter_number": self._adapter_number,
|
"adapter_number": self._adapter_number,
|
||||||
|
@ -213,15 +213,40 @@ def test_list_ports_frame_relay_switch(project, compute):
|
|||||||
node_id=str(uuid.uuid4()),
|
node_id=str(uuid.uuid4()),
|
||||||
node_type="frame_relay_switch")
|
node_type="frame_relay_switch")
|
||||||
node.properties["mappings"] = {
|
node.properties["mappings"] = {
|
||||||
"1:0:100": "10:0:200"
|
"1:101": "10:202",
|
||||||
|
"2:102": "11:203"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert node.__json__()["ports"] == [
|
assert node.__json__()["ports"] == [
|
||||||
{
|
{
|
||||||
"name": "FrameRelay0",
|
"name": "1",
|
||||||
"short_name": "s0/0",
|
"short_name": "1",
|
||||||
"data_link_types": {"Frame Relay": "DLT_FRELAY"},
|
"data_link_types": {"Frame Relay": "DLT_FRELAY"},
|
||||||
"port_number": 0,
|
"port_number": 1,
|
||||||
|
"adapter_number": 0,
|
||||||
|
"link_type": "serial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "2",
|
||||||
|
"short_name": "2",
|
||||||
|
"data_link_types": {"Frame Relay": "DLT_FRELAY"},
|
||||||
|
"port_number": 2,
|
||||||
|
"adapter_number": 0,
|
||||||
|
"link_type": "serial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "10",
|
||||||
|
"short_name": "10",
|
||||||
|
"data_link_types": {"Frame Relay": "DLT_FRELAY"},
|
||||||
|
"port_number": 10,
|
||||||
|
"adapter_number": 0,
|
||||||
|
"link_type": "serial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "11",
|
||||||
|
"short_name": "11",
|
||||||
|
"data_link_types": {"Frame Relay": "DLT_FRELAY"},
|
||||||
|
"port_number": 11,
|
||||||
"adapter_number": 0,
|
"adapter_number": 0,
|
||||||
"link_type": "serial"
|
"link_type": "serial"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user