mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
TAP and Ethernet device support for IOU
This commit is contained in:
1 parent
41a1d16e92
commit
0e1d8e5071
7 files changed
+172
-34
No files matched your search
@@ -99,10 +99,10 @@ class ETHSW(object):
|
||||
|
||||
Mandatory request parameters:
|
||||
- id (switch identifier)
|
||||
- ports (ports settings)
|
||||
|
||||
Optional request parameters:
|
||||
- name (new switch name)
|
||||
- ports (ports settings)
|
||||
|
||||
Response parameters:
|
||||
- same as original request
|
||||
@@ -118,22 +118,24 @@ class ETHSW(object):
|
||||
log.debug("received request {}".format(request))
|
||||
ethsw_id = request["id"]
|
||||
ethsw = self._ethernet_switches[ethsw_id]
|
||||
ports = request["ports"]
|
||||
|
||||
# update the port settings
|
||||
for port, info in ports.items():
|
||||
vlan = info["vlan"]
|
||||
port_type = info["type"]
|
||||
try:
|
||||
if port_type == "access":
|
||||
ethsw.set_access_port(int(port), vlan)
|
||||
elif port_type == "dot1q":
|
||||
ethsw.set_dot1q_port(int(port), vlan)
|
||||
elif port_type == "qinq":
|
||||
ethsw.set_qinq_port(int(port), vlan)
|
||||
except DynamipsError as e:
|
||||
self.send_custom_error(str(e))
|
||||
return
|
||||
if "ports" in request:
|
||||
ports = request["ports"]
|
||||
|
||||
# update the port settings
|
||||
for port, info in ports.items():
|
||||
vlan = info["vlan"]
|
||||
port_type = info["type"]
|
||||
try:
|
||||
if port_type == "access":
|
||||
ethsw.set_access_port(int(port), vlan)
|
||||
elif port_type == "dot1q":
|
||||
ethsw.set_dot1q_port(int(port), vlan)
|
||||
elif port_type == "qinq":
|
||||
ethsw.set_qinq_port(int(port), vlan)
|
||||
except DynamipsError as e:
|
||||
self.send_custom_error(str(e))
|
||||
return
|
||||
|
||||
# rename the switch if requested
|
||||
if "name" in request and ethsw.name != request["name"]:
|
||||
|
||||
@@ -356,11 +356,11 @@ class DynamipsHypervisor(object):
|
||||
try:
|
||||
if ":" in host:
|
||||
# IPv6 address support
|
||||
s = socket.socket(socket.AF_INET6, socket_type)
|
||||
with socket.socket(socket.AF_INET6, socket_type) as s:
|
||||
s.bind((host, port)) # the port is available if bind is a success
|
||||
else:
|
||||
s = socket.socket(socket.AF_INET, socket_type)
|
||||
# the port is available if bind is a success
|
||||
s.bind((host, port))
|
||||
with socket.socket(socket.AF_INET, socket_type) as s:
|
||||
s.bind((host, port)) # the port is available if bind is a success
|
||||
return port
|
||||
except socket.error as e:
|
||||
if e.errno == errno.EADDRINUSE: # socket already in use
|
||||
|
||||
Reference in new issue
Block a user