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

Merge branch 'Bevaz-qinq_ethertype' into unstable

This commit is contained in:
grossmj 2015-09-08 02:29:30 -06:00
commit 6dd381a745
3 changed files with 25 additions and 9 deletions

View File

@ -63,6 +63,7 @@ Ethernet switch port
<tr><td>port</td> <td>&#10004;</td> <td>integer</td> <td>Port number</td> </tr> <tr><td>port</td> <td>&#10004;</td> <td>integer</td> <td>Port number</td> </tr>
<tr><td>type</td> <td>&#10004;</td> <td>enum</td> <td>Possible values: access, dot1q, qinq</td> </tr> <tr><td>type</td> <td>&#10004;</td> <td>enum</td> <td>Possible values: access, dot1q, qinq</td> </tr>
<tr><td>vlan</td> <td>&#10004;</td> <td>integer</td> <td>VLAN number</td> </tr> <tr><td>vlan</td> <td>&#10004;</td> <td>integer</td> <td>VLAN number</td> </tr>
<tr><td>ethertype</td> <td>&#10004;</td> <td>enum</td> <td>Possible values: 0x8100, 0x88A8, 0x9100, 0x9200</td> </tr>
</table> </table>
Body Body
@ -103,4 +104,3 @@ Response status codes
- **400**: Invalid request - **400**: Invalid request
- **404**: Instance doesn't exist - **404**: Instance doesn't exist
- **204**: Instance deleted - **204**: Instance deleted

View File

@ -59,7 +59,8 @@ class EthernetSwitch(Device):
for port_number, settings in self._mappings.items(): for port_number, settings in self._mappings.items():
ports.append({"port": port_number, ports.append({"port": port_number,
"type": settings[0], "type": settings[0],
"vlan": settings[1]}) "vlan": settings[1],
"ethertype": settings[2] if len(settings) > 2 else ""})
ethernet_switch_info["ports"] = ports ethernet_switch_info["ports"] = ports
return ethernet_switch_info return ethernet_switch_info
@ -192,7 +193,7 @@ class EthernetSwitch(Device):
elif settings["type"] == "dot1q": elif settings["type"] == "dot1q":
yield from self.set_dot1q_port(port_number, settings["vlan"]) yield from self.set_dot1q_port(port_number, settings["vlan"])
elif settings["type"] == "qinq": elif settings["type"] == "qinq":
yield from self.set_qinq_port(port_number, settings["vlan"]) yield from self.set_qinq_port(port_number, settings["vlan"], settings["ethertype"] )
@asyncio.coroutine @asyncio.coroutine
def set_access_port(self, port_number, vlan_id): def set_access_port(self, port_number, vlan_id):
@ -242,7 +243,7 @@ class EthernetSwitch(Device):
self._mappings[port_number] = ("dot1q", native_vlan) self._mappings[port_number] = ("dot1q", native_vlan)
@asyncio.coroutine @asyncio.coroutine
def set_qinq_port(self, port_number, outer_vlan): def set_qinq_port(self, port_number, outer_vlan, ethertype):
""" """
Sets the specified port as a trunk (QinQ) port. Sets the specified port as a trunk (QinQ) port.
@ -254,15 +255,17 @@ class EthernetSwitch(Device):
raise DynamipsError("Port {} is not allocated".format(port_number)) raise DynamipsError("Port {} is not allocated".format(port_number))
nio = self._nios[port_number] nio = self._nios[port_number]
yield from self._hypervisor.send('ethsw set_qinq_port "{name}" {nio} {outer_vlan}'.format(name=self._name, yield from self._hypervisor.send('ethsw set_qinq_port "{name}" {nio} {outer_vlan} {ethertype}'.format(name=self._name,
nio=nio, nio=nio,
outer_vlan=outer_vlan)) outer_vlan=outer_vlan,
ethertype=ethertype if ethertype != "0x8100" else ""))
log.info('Ethernet switch "{name}" [{id}]: port {port} set as a QinQ port with outer VLAN {vlan_id}'.format(name=self._name, log.info('Ethernet switch "{name}" [{id}]: port {port} set as a QinQ ({ethertype}) port with outer VLAN {vlan_id}'.format(name=self._name,
id=self._id, id=self._id,
port=port_number, port=port_number,
vlan_id=outer_vlan)) vlan_id=outer_vlan,
self._mappings[port_number] = ("qinq", outer_vlan) ethertype=ethertype))
self._mappings[port_number] = ("qinq", outer_vlan, ethertype)
@asyncio.coroutine @asyncio.coroutine
def get_mac_addr_table(self): def get_mac_addr_table(self):

View File

@ -63,10 +63,15 @@ DEVICE_UPDATE_SCHEMA = {
"description": "Port type", "description": "Port type",
"enum": ["access", "dot1q", "qinq"], "enum": ["access", "dot1q", "qinq"],
}, },
"vlan": {"description": "VLAN number", "vlan": {"description": "VLAN number",
"type": "integer", "type": "integer",
"minimum": 1 "minimum": 1
}, },
"ethertype": {
"description": "QinQ Ethertype",
"enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"],
},
}, },
"required": ["port", "type", "vlan"], "required": ["port", "type", "vlan"],
"additionalProperties": False "additionalProperties": False
@ -112,6 +117,10 @@ DEVICE_OBJECT_SCHEMA = {
"type": "integer", "type": "integer",
"minimum": 1 "minimum": 1
}, },
"ethertype": {
"description": "QinQ Ethertype",
"enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"],
},
}, },
"required": ["port", "type", "vlan"], "required": ["port", "type", "vlan"],
"additionalProperties": False "additionalProperties": False
@ -321,6 +330,10 @@ DEVICE_NIO_SCHEMA = {
"type": "integer", "type": "integer",
"minimum": 1 "minimum": 1
}, },
"ethertype": {
"description": "QinQ Ethertype",
"enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"],
},
}, },
"required": ["type", "vlan"], "required": ["type", "vlan"],
"additionalProperties": False "additionalProperties": False