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

Explicitly send an error if a IOS adapter cannot be added or removed.

This commit is contained in:
grossmj 2014-05-01 15:46:59 -06:00
parent ed8b93dee2
commit 2a888f93ce
2 changed files with 57 additions and 21 deletions

View File

@ -1224,6 +1224,13 @@ class Router(object):
slot_id=slot_id,
adapter=current_adapter))
# Only c7200, c3600 and c3745 (NM-4T only) support new adapter while running
if self.is_running() and not (self._platform == 'c7200' \
and not (self._platform == 'c3600' and self.chassis == '3660') \
and not (self._platform == 'c3745' and adapter == 'NM-4T')):
raise DynamipsError("Adapter {adapter} cannot be added while router {name} is running".format(adapter=adapter,
name=self._name))
self._hypervisor.send("vm slot_add_binding {name} {slot_id} 0 {adapter}".format(name=self._name,
slot_id=slot_id,
adapter=adapter))
@ -1235,11 +1242,8 @@ class Router(object):
self._slots[slot_id] = adapter
# Generate an OIR event if the router is running and
# only for c7200, c3600 and c3745 (NM-4T only)
if self.is_running() and (self._platform == 'c7200' \
or (self._platform == 'c3600' and self.chassis == '3660') \
or (self._platform == 'c3745' and adapter == 'NM-4T')):
# Generate an OIR event if the router is running
if self.is_running():
self._hypervisor.send("vm slot_oir_start {name} {slot_id} 0".format(name=self._name,
slot_id=slot_id))
@ -1265,13 +1269,15 @@ class Router(object):
raise DynamipsError("No adapter in slot {slot_id} on router {name}".format(name=self._name,
slot_id=slot_id))
#FIXME: check if adapter can be removed!
# Only c7200, c3600 and c3745 (NM-4T only) support to remove adapter while running
if self.is_running() and not (self._platform == 'c7200' \
and not (self._platform == 'c3600' and self.chassis == '3660') \
and not (self._platform == 'c3745' and adapter == 'NM-4T')):
raise DynamipsError("Adapter {adapter} cannot be removed while router {name} is running".format(adapter=adapter,
name=self._name))
# Generate an OIR event if the router is running and
# only for c7200, c3600 and c3745 (NM-4T only)
if self.is_running() and (self._platform == 'c7200' \
or (self._platform == 'c3600' and self.chassis == '3660') \
or (self._platform == 'c3745' and adapter == 'NM-4T')):
# Generate an OIR event if the router is running
if self.is_running():
self._hypervisor.send("vm slot_oir_stop {name} {slot_id} 0".format(name=self._name,
slot_id=slot_id))

View File

@ -250,43 +250,73 @@ VM_UPDATE_SCHEMA = {
},
"slot0": {
"description": "Network module slot 0",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"slot1": {
"description": "Network module slot 1",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"slot2": {
"description": "Network module slot 2",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"slot3": {
"description": "Network module slot 3",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"slot4": {
"description": "Network module slot 4",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"slot5": {
"description": "Network module slot 5",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"slot6": {
"description": "Network module slot 6",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"wic0": {
"description": "Network module WIC slot 0",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"wic1": {
"description": "Network module WIC slot 0",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"wic2": {
"description": "Network module WIC slot 0",
"type": "string",
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"startup_config_base64": {
"description": "startup configuration base64 encoded",