Prevent WIC to be added/removed while Dynamips router is running. Fixes https://github.com/GNS3/gns3-gui/issues/3082

This commit is contained in:
grossmj 2020-10-27 20:08:01 +10:30
parent 5d1fdceb98
commit 5dab0c2587

View File

@ -1182,6 +1182,10 @@ class Router(BaseNode):
if not adapter.wic_slot_available(wic_slot_number): if not adapter.wic_slot_available(wic_slot_number):
raise DynamipsError("WIC slot {wic_slot_number} is already occupied by another WIC".format(wic_slot_number=wic_slot_number)) raise DynamipsError("WIC slot {wic_slot_number} is already occupied by another WIC".format(wic_slot_number=wic_slot_number))
if await self.is_running():
raise DynamipsError('WIC "{wic}" cannot be added while router "{name}" is running'.format(wic=wic,
name=self._name))
# Dynamips WICs slot IDs start on a multiple of 16 # Dynamips WICs slot IDs start on a multiple of 16
# WIC1 = 16, WIC2 = 32 and WIC3 = 48 # WIC1 = 16, WIC2 = 32 and WIC3 = 48
internal_wic_slot_number = 16 * (wic_slot_number + 1) internal_wic_slot_number = 16 * (wic_slot_number + 1)
@ -1217,6 +1221,10 @@ class Router(BaseNode):
if adapter.wic_slot_available(wic_slot_number): if adapter.wic_slot_available(wic_slot_number):
raise DynamipsError("No WIC is installed in WIC slot {wic_slot_number}".format(wic_slot_number=wic_slot_number)) raise DynamipsError("No WIC is installed in WIC slot {wic_slot_number}".format(wic_slot_number=wic_slot_number))
if await self.is_running():
raise DynamipsError('WIC cannot be removed from slot {wic_slot_number} while router "{name}" is running'.format(wic_slot_number=wic_slot_number,
name=self._name))
# Dynamips WICs slot IDs start on a multiple of 16 # Dynamips WICs slot IDs start on a multiple of 16
# WIC1 = 16, WIC2 = 32 and WIC3 = 48 # WIC1 = 16, WIC2 = 32 and WIC3 = 48
internal_wic_slot_number = 16 * (wic_slot_number + 1) internal_wic_slot_number = 16 * (wic_slot_number + 1)