mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Merge pull request #1143 from GNS3/last_dynamips
Duplicate API for ATM, Ethernet Hub and Frame Relay Switch
This commit is contained in:
commit
136e483ace
@ -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={
|
||||
|
@ -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={
|
||||
|
@ -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={
|
||||
|
Loading…
Reference in New Issue
Block a user