Ethernet hub and Ethernet switch almost fully migrated to the new API.

This commit is contained in:
grossmj
2016-05-19 22:45:04 -06:00
parent 672a617102
commit 57fd72c35c
13 changed files with 696 additions and 51 deletions

View File

@ -56,7 +56,8 @@ class EthernetHubHandler:
node = yield from dynamips_manager.create_device(request.json.pop("name"),
request.match_info["project_id"],
request.json.get("node_id"),
device_type="ethernet_hub")
device_type="ethernet_hub",
ports=request.json.get("ports"))
# On Linux, use the generic hub
# builtin_manager = Builtin.instance()
@ -109,6 +110,10 @@ class EthernetHubHandler:
dynamips_manager = Dynamips.instance()
node = dynamips_manager.get_device(request.match_info["node_id"], project_id=request.match_info["project_id"])
if "name" in request.json and node.name != request.json["name"]:
yield from node.set_name(request.json["name"])
if "ports" in request.json:
node.ports = request.json["ports"]
# builtin_manager = Builtin.instance()
# node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
@ -157,10 +162,7 @@ class EthernetHubHandler:
node = dynamips_manager.get_device(request.match_info["node_id"], project_id=request.match_info["project_id"])
nio = yield from dynamips_manager.create_nio(node, request.json)
port_number = int(request.match_info["port_number"])
port_settings = request.json.get("port_settings")
yield from node.add_nio(nio, port_number)
if port_settings:
yield from node.set_port_settings(port_number, port_settings)
#builtin_manager = Builtin.instance()
#node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])