mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Check for valid FR or ATM switch mappings. Fixes #300.
This commit is contained in:
parent
fda33c56de
commit
2c5b2a19f6
@ -51,10 +51,14 @@ class ATMSwitch(Device):
|
|||||||
|
|
||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
|
||||||
|
mappings = {}
|
||||||
|
for source, destination in self._mappings.items():
|
||||||
|
mappings[str(source)] = str(destination)
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
"device_id": self.id,
|
"device_id": self.id,
|
||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"mappings": self._mappings}
|
"mappings": mappings}
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def create(self):
|
def create(self):
|
||||||
@ -199,6 +203,8 @@ class ATMSwitch(Device):
|
|||||||
|
|
||||||
pvc_entry = re.compile(r"""^([0-9]*):([0-9]*):([0-9]*)$""")
|
pvc_entry = re.compile(r"""^([0-9]*):([0-9]*):([0-9]*)$""")
|
||||||
for source, destination in mappings.items():
|
for source, destination in mappings.items():
|
||||||
|
if not isinstance(source, str) or not isinstance(destination, str):
|
||||||
|
raise DynamipsError("Invalid ATM mappings")
|
||||||
match_source_pvc = pvc_entry.search(source)
|
match_source_pvc = pvc_entry.search(source)
|
||||||
match_destination_pvc = pvc_entry.search(destination)
|
match_destination_pvc = pvc_entry.search(destination)
|
||||||
if match_source_pvc and match_destination_pvc:
|
if match_source_pvc and match_destination_pvc:
|
||||||
|
@ -50,10 +50,14 @@ class FrameRelaySwitch(Device):
|
|||||||
|
|
||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
|
||||||
|
mappings = {}
|
||||||
|
for source, destination in self._mappings.items():
|
||||||
|
mappings[str(source)] = str(destination)
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
"device_id": self.id,
|
"device_id": self.id,
|
||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"mappings": self._mappings}
|
"mappings": mappings}
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def create(self):
|
def create(self):
|
||||||
@ -191,6 +195,8 @@ class FrameRelaySwitch(Device):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
for source, destination in mappings.items():
|
for source, destination in mappings.items():
|
||||||
|
if not isinstance(source, str) or not isinstance(destination, str):
|
||||||
|
raise DynamipsError("Invalid Frame-Relay mappings")
|
||||||
source_port, source_dlci = map(int, source.split(':'))
|
source_port, source_dlci = map(int, source.split(':'))
|
||||||
destination_port, destination_dlci = map(int, destination.split(':'))
|
destination_port, destination_dlci = map(int, destination.split(':'))
|
||||||
if self.has_port(destination_port):
|
if self.has_port(destination_port):
|
||||||
|
Loading…
Reference in New Issue
Block a user