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

Duplicate API for ATM, Ethernet Hub and Frame Relay Switch

Fix https://github.com/GNS3/gns3-gui/issues/1065
This commit is contained in:
Julien Duponchelle 2017-07-25 16:51:49 +02:00
parent bb90c0ba52
commit d69475cd44
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 72 additions and 13 deletions

View File

@ -53,10 +53,10 @@ class ATMSwitchHandler:
# Use the Dynamips ATM switch to simulate this node
dynamips_manager = Dynamips.instance()
node = yield from dynamips_manager.create_node(request.json.pop("name"),
request.match_info["project_id"],
request.json.get("node_id"),
node_type="atm_switch",
mappings=request.json.get("mappings"))
request.match_info["project_id"],
request.json.get("node_id"),
node_type="atm_switch",
mappings=request.json.get("mappings"))
response.set_status(201)
response.json(node)
@ -79,6 +79,26 @@ class ATMSwitchHandler:
node = dynamips_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
response.json(node)
@Route.post(
r"/projects/{project_id}/atm_switch/nodes/{node_id}/duplicate",
parameters={
"project_id": "Project UUID",
"node_id": "Node UUID"
},
status_codes={
201: "Instance duplicated",
404: "Instance doesn't exist"
},
description="Duplicate an atm switch instance")
def duplicate(request, response):
new_node = yield from Dynamips.instance().duplicate_node(
request.match_info["node_id"],
request.json["destination_node_id"]
)
response.set_status(201)
response.json(new_node)
@Route.put(
r"/projects/{project_id}/atm_switch/nodes/{node_id}",
parameters={

View File

@ -20,7 +20,6 @@ import os
from gns3server.web.route import Route
from gns3server.schemas.node import NODE_CAPTURE_SCHEMA
from gns3server.schemas.nio import NIO_SCHEMA
from gns3server.compute.builtin import Builtin
from gns3server.compute.dynamips import Dynamips
from gns3server.schemas.ethernet_hub import (
@ -54,10 +53,10 @@ class EthernetHubHandler:
# Use the Dynamips Ethernet hub to simulate this node
dynamips_manager = Dynamips.instance()
node = yield from dynamips_manager.create_node(request.json.pop("name"),
request.match_info["project_id"],
request.json.get("node_id"),
node_type="ethernet_hub",
ports=request.json.get("ports_mapping"))
request.match_info["project_id"],
request.json.get("node_id"),
node_type="ethernet_hub",
ports=request.json.get("ports_mapping"))
response.set_status(201)
response.json(node)
@ -82,6 +81,26 @@ class EthernetHubHandler:
response.json(node)
@Route.post(
r"/projects/{project_id}/ethernet_hub/nodes/{node_id}/duplicate",
parameters={
"project_id": "Project UUID",
"node_id": "Node UUID"
},
status_codes={
201: "Instance duplicated",
404: "Instance doesn't exist"
},
description="Duplicate an ethernet hub instance")
def duplicate(request, response):
new_node = yield from Dynamips.instance().duplicate_node(
request.match_info["node_id"],
request.json["destination_node_id"]
)
response.set_status(201)
response.json(new_node)
@Route.put(
r"/projects/{project_id}/ethernet_hub/nodes/{node_id}",
parameters={

View File

@ -53,10 +53,10 @@ class FrameRelaySwitchHandler:
# Use the Dynamips Frame Relay switch to simulate this node
dynamips_manager = Dynamips.instance()
node = yield from dynamips_manager.create_node(request.json.pop("name"),
request.match_info["project_id"],
request.json.get("node_id"),
node_type="frame_relay_switch",
mappings=request.json.get("mappings"))
request.match_info["project_id"],
request.json.get("node_id"),
node_type="frame_relay_switch",
mappings=request.json.get("mappings"))
response.set_status(201)
response.json(node)
@ -79,6 +79,26 @@ class FrameRelaySwitchHandler:
node = dynamips_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
response.json(node)
@Route.post(
r"/projects/{project_id}/frame_relay_switch/nodes/{node_id}/duplicate",
parameters={
"project_id": "Project UUID",
"node_id": "Node UUID"
},
status_codes={
201: "Instance duplicated",
404: "Instance doesn't exist"
},
description="Duplicate a frame relay switch instance")
def duplicate(request, response):
new_node = yield from Dynamips.instance().duplicate_node(
request.match_info["node_id"],
request.json["destination_node_id"]
)
response.set_status(201)
response.json(new_node)
@Route.put(
r"/projects/{project_id}/frame_relay_switch/nodes/{node_id}",
parameters={