Renaming things & more inline docs.

pull/11/head
grossmj 10 years ago
parent d68a24e39d
commit 687d5b75ab

@ -34,8 +34,8 @@ class JSONRPCWebSocket(tornado.websocket.WebSocketHandler):
STOMP protocol over Tornado Websockets with message
routing to ZeroMQ dealer clients.
:param application: Tornado Application object
:param request: Tornado Request object
:param application: Tornado Application instance
:param request: Tornado Request instance
:param zmq_router: ZeroMQ router socket
"""

@ -68,7 +68,7 @@ class IModule(multiprocessing.Process):
"""
Creates a new ZMQ stream.
:returns: ZMQ stream object
:returns: ZMQ stream instance
"""
socket = self._context.socket(zmq.DEALER)

@ -72,7 +72,7 @@ class Adapter(object):
Installs a WIC on this adapter.
:param wic_slot_id: WIC slot ID (integer)
:param wic: WIC object
:param wic: WIC instance
"""
self._wics[wic_slot_id] = wic
@ -110,7 +110,7 @@ class Adapter(object):
Adds a NIO to a port on this adapter.
:param port_id: port ID (integer)
:param nio: NIO object
:param nio: NIO instance
"""
self._ports[port_id] = nio
@ -130,7 +130,7 @@ class Adapter(object):
:params port_id: port ID (integer)
:returns: NIO object
:returns: NIO instance
"""
return self._ports[port_id]
@ -160,7 +160,7 @@ class Adapter(object):
"""
Returns the wics adapters inserted in this adapter.
:returns: list WIC objects
:returns: list WIC instances
"""
return self._wics

@ -41,10 +41,6 @@ class ATMSW(object):
:param request: JSON request
"""
if request == None:
self.send_param_error()
return
#TODO: JSON schema validation for the request
name = None
if request and "name" in request:
@ -137,10 +133,10 @@ class ATMSW(object):
Mandatory request parameters:
- id (switch identifier)
- port_name (port name)
- port_id (port identifier)
Response parameters:
- port_name (port name)
- port_id (port identifier)
- lhost (local host address)
- lport (allocated local port)
@ -163,7 +159,7 @@ class ATMSW(object):
self.send_custom_error(str(e))
return
response["port_name"] = request["port_name"]
response["port_id"] = request["port_id"]
self.send_response(response)
@IModule.route("dynamips.atmsw.add_nio")
@ -174,6 +170,7 @@ class ATMSW(object):
Mandatory request parameters:
- id (switch identifier)
- port (port identifier)
- port_id (port identifier)
- mappings (VCs/VPs mapped to the port)
- nio (nio type, one of the following)
- "NIO_UDP"

@ -40,10 +40,6 @@ class ETHHUB(object):
:param request: JSON request
"""
if request == None:
self.send_param_error()
return
#TODO: JSON schema validation for the request
name = None
if request and "name" in request:
@ -136,10 +132,10 @@ class ETHHUB(object):
Mandatory request parameters:
- id (hub identifier)
- port_name (port name)
- port_id (port identifier)
Response parameters:
- port_name (port name)
- port_id (port identifier)
- lhost (local host address)
- lport (allocated local port)
@ -162,7 +158,7 @@ class ETHHUB(object):
self.send_custom_error(str(e))
return
response["port_name"] = request["port_name"]
response["port_id"] = request["port_id"]
self.send_response(response)
@IModule.route("dynamips.ethhub.add_nio")
@ -173,6 +169,7 @@ class ETHHUB(object):
Mandatory request parameters:
- id (hub identifier)
- port (port identifier)
- port_id (port identifier)
- nio (nio type, one of the following)
- "NIO_UDP"
- lport (local port)

@ -40,10 +40,6 @@ class ETHSW(object):
:param request: JSON request
"""
if request == None:
self.send_param_error()
return
#TODO: JSON schema validation for the request
name = None
if request and "name" in request:
@ -153,10 +149,10 @@ class ETHSW(object):
Mandatory request parameters:
- id (switch identifier)
- port_name (port name)
- port_id (port identifier)
Response parameters:
- port_name (port name)
- port_id (port identifier)
- lhost (local host address)
- lport (allocated local port)
@ -179,7 +175,7 @@ class ETHSW(object):
self.send_custom_error(str(e))
return
response["port_name"] = request["port_name"]
response["port_id"] = request["port_id"]
self.send_response(response)
@IModule.route("dynamips.ethsw.add_nio")
@ -190,6 +186,7 @@ class ETHSW(object):
Mandatory request parameters:
- id (switch identifier)
- port (port identifier)
- port_id (port identifier)
- vlan (vlan identifier)
- port_type ("access", "dot1q" or "qinq")
- nio (nio type, one of the following)

@ -40,10 +40,6 @@ class FRSW(object):
:param request: JSON request
"""
if request == None:
self.send_param_error()
return
#TODO: JSON schema validation for the request
name = None
if request and "name" in request:
@ -135,10 +131,10 @@ class FRSW(object):
Mandatory request parameters:
- id (switch identifier)
- port_name (port name)
- port_id (port identifier)
Response parameters:
- port_name (port name)
- port_id (port identifier)
- lhost (local host address)
- lport (allocated local port)
@ -161,7 +157,7 @@ class FRSW(object):
self.send_custom_error(str(e))
return
response["port_name"] = request["port_name"]
response["port_id"] = request["port_id"]
self.send_response(response)
@IModule.route("dynamips.frsw.add_nio")
@ -172,6 +168,7 @@ class FRSW(object):
Mandatory request parameters:
- id (switch identifier)
- port (port identifier)
- port_id (port identifier)
- mappings (VCs mapped to the port)
- nio (nio type, one of the following)
- "NIO_UDP"

@ -445,10 +445,10 @@ class VM(object):
Mandatory request parameters:
- id (vm identifier)
- port_name (port name e.g fastEthernet1/0)
- port_id (unique port identifier)
Response parameters:
- port_name (port name e.g fastEthernet1/0)
- port_id (unique port identifier)
- lhost (local host address)
- lport (allocated local port)
@ -471,7 +471,7 @@ class VM(object):
self.send_custom_error(str(e))
return
response["port_name"] = request["port_name"]
response["port_id"] = request["port_id"]
self.send_response(response)
@IModule.route("dynamips.vm.add_nio")
@ -481,8 +481,9 @@ class VM(object):
Mandatory request parameters:
- id (vm identifier)
- slot (slot identifier)
- port (port identifier)
- slot (slot number)
- port (port number)
- port_id (unique port identifier)
- nio (nio type, one of the following)
- "NIO_UDP"
- lport (local port)

@ -158,7 +158,7 @@ class DynamipsHypervisor(object):
def save_config(self, filename):
"""
Saves the configuration of all Dynamips objects into the specified file.
Saves the configuration of all Dynamips instances into the specified file.
:param filename: path string
"""
@ -181,7 +181,7 @@ class DynamipsHypervisor(object):
"""
Returns the current socket used to communicate with this hypervisor.
:returns: socket object
:returns: socket instance
"""
assert self._socket
@ -192,7 +192,7 @@ class DynamipsHypervisor(object):
"""
Returns the list of devices managed by this hypervisor instance.
:returns: a list of device objects
:returns: a list of device instances
"""
return self._devices
@ -287,7 +287,7 @@ class DynamipsHypervisor(object):
Adds a ghost name to the list of ghosts created on this hypervisor.
:param image_name: name of the ghost image
:param router: router object
:param router: Router instance
"""
self._ghosts[image_name] = router
@ -344,10 +344,8 @@ class DynamipsHypervisor(object):
#FIXME: better check for IPv6
start_port = self._current_udp_port
print("start port = {}".format(start_port))
end_port = start_port + max_port
for port in range(start_port, end_port):
print(port)
if port > end_port:
raise DynamipsError("Could not find a free port between {0} and {1}".format(start_port, max_port))
try:
@ -360,7 +358,6 @@ class DynamipsHypervisor(object):
s.bind((self._host, port))
#FIXME: increment?
self._current_udp_port += 1
print("current port = {}".format(self._current_udp_port))
return port
except socket.error as e:
if e.errno == errno.EADDRINUSE: # socket already in use

@ -81,7 +81,7 @@ class HypervisorManager(object):
"""
Returns all hypervisor instances.
:returns: list of hypervisor objects
:returns: list of hypervisor instances
"""
return self._hypervisors
@ -430,7 +430,7 @@ class HypervisorManager(object):
"""
Creates a new Dynamips process and start it.
:returns: the new hypervisor object
:returns: the new hypervisor instance
"""
hypervisor = Hypervisor(self._path,
@ -461,7 +461,7 @@ class HypervisorManager(object):
:param router_ios_image: IOS image name
:param router_ram: amount of RAM (integer)
:returns: the allocated hypervisor object
:returns: the allocated hypervisor instance
"""
# allocate an hypervisor for each router by default
@ -490,7 +490,7 @@ class HypervisorManager(object):
"""
Unallocates a Dynamips hypervisor for a specific router.
:param router: router object
:param router: Router instance
"""
hypervisor = router.hypervisor
@ -512,7 +512,7 @@ class HypervisorManager(object):
"""
Allocates a Dynamips hypervisor for a specific Dynamips simulated device.
:returns: the allocated hypervisor object
:returns: the allocated hypervisor instance
"""
# For now always allocate the first hypervisor available,
@ -528,7 +528,7 @@ class HypervisorManager(object):
"""
Unallocates a Dynamips hypervisor for a specific Dynamips simulated device.
:param device: device object
:param device: device instance
"""
hypervisor = device.hypervisor

@ -30,7 +30,7 @@ class NIO(object):
"""
Base NIO class
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
"""
def __init__(self, hypervisor):

@ -29,7 +29,7 @@ class NIO_FIFO(NIO):
"""
Dynamips FIFO NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
"""
_instance_count = 0
@ -59,7 +59,7 @@ class NIO_FIFO(NIO):
"""
Establishes a cross-connect between this FIFO NIO and another one.
:param nio: FIFO NIO object.
:param nio: FIFO NIO instance
"""
self._hypervisor.send("nio crossconnect_fifo {name} {nio}".format(name=self._name,

@ -29,7 +29,7 @@ class NIO_GenericEthernet(NIO):
"""
Dynamips generic Ethernet NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param ethernet_device: Ethernet device name (e.g. eth0)
"""

@ -29,7 +29,7 @@ class NIO_LinuxEthernet(NIO):
"""
Dynamips Linux Ethernet NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param ethernet_device: Ethernet device name (e.g. eth0)
"""

@ -29,7 +29,7 @@ class NIO_Mcast(NIO):
"""
Dynamips Linux Ethernet NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param group: multicast group to bind
:param port: port for binding
"""

@ -29,7 +29,7 @@ class NIO_Null(NIO):
"""
Dynamips NULL NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
"""
_instance_count = 0

@ -29,7 +29,7 @@ class NIO_TAP(NIO):
"""
Dynamips TAP NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param tap_device: TAP device name (e.g. tap0)
"""

@ -29,7 +29,7 @@ class NIO_UDP(NIO):
"""
Dynamips UDP NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param lport: local port number
:param rhost: remote address/host
:param rport: remote port number

@ -29,7 +29,7 @@ class NIO_UDP_auto(NIO):
"""
Dynamips auto UDP NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param laddr: local address
:param lport_start: start local port range
:param lport_end: end local port range

@ -29,7 +29,7 @@ class NIO_UNIX(NIO):
"""
Dynamips UNIX NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param local_file: local UNIX socket filename
:param remote_file: remote UNIX socket filename
"""

@ -29,7 +29,7 @@ class NIO_VDE(NIO):
"""
Dynamips VDE NIO.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param control_file: VDE control filename
:param local_file: VDE local filename
"""

@ -28,7 +28,7 @@ class ATMBridge(object):
"""
Dynamips bridge switch.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this switch
"""
@ -69,7 +69,7 @@ class ATMBridge(object):
"""
Returns the current hypervisor.
:returns: hypervisor object
:returns: hypervisor instance
"""
return self._hypervisor
@ -115,7 +115,7 @@ class ATMBridge(object):
"""
Adds a NIO as new port on ATM bridge.
:param nio: NIO object to add
:param nio: NIO instance to add
:param port: port to allocate for the NIO
"""

@ -31,7 +31,7 @@ class ATMSwitch(object):
"""
Dynamips ATM switch.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this switch
"""
@ -121,7 +121,7 @@ class ATMSwitch(object):
"""
Returns the current hypervisor.
:returns: hypervisor object
:returns: hypervisor instance
"""
return self._hypervisor
@ -182,7 +182,7 @@ class ATMSwitch(object):
"""
Adds a NIO as new port on ATM switch.
:param nio: NIO object to add
:param nio: NIO instance to add
:param port: port to allocate for the NIO
"""

@ -27,7 +27,7 @@ class Bridge(object):
"""
Dynamips bridge.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this bridge
"""
@ -73,7 +73,7 @@ class Bridge(object):
"""
Returns the current hypervisor.
:returns: hypervisor object
:returns: hypervisor instance
"""
return self._hypervisor
@ -110,7 +110,7 @@ class Bridge(object):
"""
Adds a NIO as new port on this bridge.
:param nio: NIO object to add
:param nio: NIO instance to add
"""
self._hypervisor.send("nio_bridge add_nio {name} {nio}".format(name=self._name,
@ -121,7 +121,7 @@ class Bridge(object):
"""
Removes the specified NIO as member of this bridge.
:param nio: NIO object to remove
:param nio: NIO instance to remove
"""
self._hypervisor.send("nio_bridge remove_nio {name} {nio}".format(name=self._name,

@ -33,7 +33,7 @@ class C1700(Router):
"""
Dynamips c1700 router.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param chassis: chassis for this router:
1720, 1721, 1750, 1751 or 1760 (default = 1720).

@ -35,7 +35,7 @@ class C2600(Router):
"""
Dynamips c2600 router.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param chassis: chassis for this router:
2610, 2611, 2620, 2621, 2610XM, 2611XM

@ -32,7 +32,7 @@ class C2691(Router):
"""
Dynamips c2691 router.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
"""

@ -32,7 +32,7 @@ class C3600(Router):
"""
Dynamips c3600 router.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param chassis: chassis for this router:
3620, 3640 or 3660 (default = 3640).

@ -32,7 +32,7 @@ class C3725(Router):
"""
Dynamips c3725 router.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
"""

@ -32,7 +32,7 @@ class C3745(Router):
"""
Dynamips c3745 router.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
"""

@ -34,7 +34,7 @@ class C7200(Router):
"""
Dynamips c7200 router (model is 7206).
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param npe: default NPE
"""

@ -32,7 +32,7 @@ class EthernetSwitch(object):
"""
Dynamips Ethernet switch.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this switch
"""
@ -122,7 +122,7 @@ class EthernetSwitch(object):
"""
Returns the current hypervisor.
:returns: hypervisor object
:returns: hypervisor instance
"""
return self._hypervisor
@ -172,7 +172,7 @@ class EthernetSwitch(object):
"""
Adds a NIO as new port on Ethernet switch.
:param nio: NIO object to add
:param nio: NIO instance to add
:param port: port to allocate for the NIO
"""

@ -31,7 +31,7 @@ class FrameRelaySwitch(object):
"""
Dynamips Frame Relay switch.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this switch
"""
@ -121,7 +121,7 @@ class FrameRelaySwitch(object):
"""
Returns the current hypervisor.
:returns: hypervisor object
:returns: hypervisor instance
"""
return self._hypervisor
@ -182,7 +182,7 @@ class FrameRelaySwitch(object):
"""
Adds a NIO as new port on Frame Relay switch.
:param nio: NIO object to add
:param nio: NIO instance to add
:param port: port to allocate for the NIO
"""

@ -31,7 +31,7 @@ class Hub(Bridge):
"""
Dynamips hub (based on Bridge)
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this hub
"""
@ -102,7 +102,7 @@ class Hub(Bridge):
"""
Adds a NIO as new port on this hub.
:param nio: NIO object to add
:param nio: NIO instance to add
:param port: port to allocate for the NIO
"""

@ -34,7 +34,7 @@ class Router(object):
"""
Dynamips router implementation.
:param hypervisor: Dynamips hypervisor object
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param platform: c7200, c3745, c3725, c3600, c2691, c2600 or c1700
:param ghost_flag: used when creating a ghost IOS.
@ -221,7 +221,7 @@ class Router(object):
"""
Returns the current hypervisor.
:returns: hypervisor object
:returns: hypervisor instance
"""
return self._hypervisor
@ -1102,7 +1102,7 @@ class Router(object):
Adds a slot binding (a module into a slot).
:param slot_id: slot ID
:param adapter: device to add in the corresponding slot (object)
:param adapter: device to add in the corresponding slot
"""
try:
@ -1186,7 +1186,7 @@ class Router(object):
Installs a WIC adapter into this router.
:param wic_slot_id: WIC slot ID
:param wic: WIC to be install (object)
:param wic: WIC to be installed
"""
# WICs are always installed on adapters in slot 0
@ -1271,7 +1271,7 @@ class Router(object):
:param slot_id: slot ID
:param port_id: port ID
:param nio: NIO to add to the slot/port (object)
:param nio: NIO instance to add to the slot/port
"""
try:
@ -1304,7 +1304,7 @@ class Router(object):
:param slot_id: slot ID
:param port_id: port ID
:returns: removed NIO object
:returns: removed NIO instance
"""
try:

Loading…
Cancel
Save