1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Catch error when you provide an invalid port name formating

Fix #909
This commit is contained in:
Julien Duponchelle 2017-02-22 18:01:59 +01:00
parent ebe8c1e536
commit 6a91804116
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import aiohttp
from .atm_port import ATMPort from .atm_port import ATMPort
from .frame_relay_port import FrameRelayPort from .frame_relay_port import FrameRelayPort
from .gigabitethernet_port import GigabitEthernetPort from .gigabitethernet_port import GigabitEthernetPort
@ -64,11 +66,14 @@ class StandardPortFactory:
port_name = first_port_name port_name = first_port_name
port = PortFactory(port_name, segment_number, adapter_number, port_number, "ethernet") port = PortFactory(port_name, segment_number, adapter_number, port_number, "ethernet")
else: else:
try:
port_name = port_name_format.format( port_name = port_name_format.format(
interface_number, interface_number,
segment_number, segment_number,
adapter=adapter_number, adapter=adapter_number,
**cls._generate_replacement(interface_number, segment_number)) **cls._generate_replacement(interface_number, segment_number))
except (ValueError, KeyError) as e:
raise aiohttp.web.HTTPConflict(text="Invalid port name format {}: {}".format(port_name_format, str(e)))
port = PortFactory(port_name, segment_number, adapter_number, port_number, "ethernet") port = PortFactory(port_name, segment_number, adapter_number, port_number, "ethernet")
interface_number += 1 interface_number += 1
if port_segment_size: if port_segment_size: