mirror of
https://github.com/GNS3/gns3-server
synced 2025-04-25 20:09:01 +00:00
Some PEP8 style fixes.
This commit is contained in:
parent
a39a693cda
commit
7b58f14681
@ -23,6 +23,7 @@ Sends version to requesting clients in JSON-RPC Websocket handler.
|
|||||||
from ..version import __version__
|
from ..version import __version__
|
||||||
from ..jsonrpc import JSONRPCResponse
|
from ..jsonrpc import JSONRPCResponse
|
||||||
|
|
||||||
|
|
||||||
def server_version(handler, request_id, params):
|
def server_version(handler, request_id, params):
|
||||||
"""
|
"""
|
||||||
Builtin destination to return the server version.
|
Builtin destination to return the server version.
|
||||||
|
@ -38,15 +38,14 @@ class FileUploadHandler(tornado.web.RequestHandler):
|
|||||||
:param request: Tornado Request instance
|
:param request: Tornado Request instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, application, request):
|
def __init__(self, application, request, **kwargs):
|
||||||
|
|
||||||
# get the upload directory from the configuration file
|
super().__init__(application, request, **kwargs)
|
||||||
config = Config.instance()
|
config = Config.instance()
|
||||||
server_config = config.get_default_section()
|
server_config = config.get_default_section()
|
||||||
# default projects directory is "~/Documents/GNS3/images"
|
self._upload_dir = os.path.expandvars(
|
||||||
self._upload_dir = os.path.expandvars(os.path.expanduser(server_config.get("upload_directory", "~/Documents/GNS3/images")))
|
os.path.expanduser(server_config.get("upload_directory", "~/Documents/GNS3/images")))
|
||||||
self._host = request.host
|
self._host = request.host
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(self._upload_dir)
|
os.makedirs(self._upload_dir)
|
||||||
log.info("upload directory '{}' created".format(self._upload_dir))
|
log.info("upload directory '{}' created".format(self._upload_dir))
|
||||||
@ -55,8 +54,6 @@ class FileUploadHandler(tornado.web.RequestHandler):
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.error("could not create the upload directory {}: {}".format(self._upload_dir, e))
|
log.error("could not create the upload directory {}: {}".format(self._upload_dir, e))
|
||||||
|
|
||||||
tornado.websocket.WebSocketHandler.__init__(self, application, request)
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
"""
|
"""
|
||||||
Invoked on GET request.
|
Invoked on GET request.
|
||||||
|
@ -106,8 +106,7 @@ class JSONRPCWebSocket(tornado.websocket.WebSocketHandler):
|
|||||||
if destination.startswith("builtin"):
|
if destination.startswith("builtin"):
|
||||||
log.debug("registering {} as a built-in destination".format(destination))
|
log.debug("registering {} as a built-in destination".format(destination))
|
||||||
else:
|
else:
|
||||||
log.debug("registering {} as a destination for the {} module".format(destination,
|
log.debug("registering {} as a destination for the {} module".format(destination, module))
|
||||||
module))
|
|
||||||
cls.destinations[destination] = module
|
cls.destinations[destination] = module
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
|
@ -161,7 +161,7 @@ class JSONRPCRequest(JSONRPCObject):
|
|||||||
|
|
||||||
def __init__(self, method, params=None, request_id=None):
|
def __init__(self, method, params=None, request_id=None):
|
||||||
JSONRPCObject.__init__(self)
|
JSONRPCObject.__init__(self)
|
||||||
if request_id == None:
|
if request_id is None:
|
||||||
request_id = str(uuid.uuid4())
|
request_id = str(uuid.uuid4())
|
||||||
self.id = request_id
|
self.id = request_id
|
||||||
self.method = method
|
self.method = method
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import imp
|
|
||||||
import inspect
|
import inspect
|
||||||
import pkgutil
|
import pkgutil
|
||||||
from .modules import IModule
|
from .modules import IModule
|
||||||
|
@ -96,7 +96,7 @@ def wait_socket_is_ready(host, port, wait=2.0, socket_timeout=10):
|
|||||||
connection_success = False
|
connection_success = False
|
||||||
begin = time.time()
|
begin = time.time()
|
||||||
last_exception = None
|
last_exception = None
|
||||||
while (time.time() - begin < wait):
|
while time.time() - begin < wait:
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
try:
|
try:
|
||||||
with socket.create_connection((host, port), socket_timeout):
|
with socket.create_connection((host, port), socket_timeout):
|
||||||
@ -107,16 +107,15 @@ def wait_socket_is_ready(host, port, wait=2.0, socket_timeout=10):
|
|||||||
connection_success = True
|
connection_success = True
|
||||||
break
|
break
|
||||||
|
|
||||||
return (connection_success, last_exception)
|
return connection_success, last_exception
|
||||||
|
|
||||||
|
|
||||||
def has_privileged_access(executable, device):
|
def has_privileged_access(executable):
|
||||||
"""
|
"""
|
||||||
Check if an executable can access Ethernet and TAP devices in
|
Check if an executable can access Ethernet and TAP devices in
|
||||||
RAW mode.
|
RAW mode.
|
||||||
|
|
||||||
:param executable: executable path
|
:param executable: executable path
|
||||||
:param device: device name
|
|
||||||
|
|
||||||
:returns: True or False
|
:returns: True or False
|
||||||
"""
|
"""
|
||||||
|
@ -288,7 +288,7 @@ class IModule(multiprocessing.Process):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# check if we have a request
|
# check if we have a request
|
||||||
if request == None:
|
if request is None:
|
||||||
self.send_param_error()
|
self.send_param_error()
|
||||||
return False
|
return False
|
||||||
log.debug("received request {}".format(request))
|
log.debug("received request {}".format(request))
|
||||||
|
@ -27,7 +27,6 @@ import shutil
|
|||||||
import glob
|
import glob
|
||||||
import socket
|
import socket
|
||||||
from gns3server.modules import IModule
|
from gns3server.modules import IModule
|
||||||
import gns3server.jsonrpc as jsonrpc
|
|
||||||
|
|
||||||
from .hypervisor import Hypervisor
|
from .hypervisor import Hypervisor
|
||||||
from .hypervisor_manager import HypervisorManager
|
from .hypervisor_manager import HypervisorManager
|
||||||
@ -249,8 +248,8 @@ class Dynamips(IModule):
|
|||||||
if not os.access(self._dynamips, os.X_OK):
|
if not os.access(self._dynamips, os.X_OK):
|
||||||
raise DynamipsError("Dynamips {} is not executable".format(self._dynamips))
|
raise DynamipsError("Dynamips {} is not executable".format(self._dynamips))
|
||||||
|
|
||||||
|
workdir = os.path.join(self._working_dir, "dynamips")
|
||||||
try:
|
try:
|
||||||
workdir = os.path.join(self._working_dir, "dynamips")
|
|
||||||
os.makedirs(workdir)
|
os.makedirs(workdir)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
@ -282,7 +281,7 @@ class Dynamips(IModule):
|
|||||||
:param request: JSON request
|
:param request: JSON request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if request == None:
|
if request is None:
|
||||||
self.send_param_error()
|
self.send_param_error()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -342,7 +341,7 @@ class Dynamips(IModule):
|
|||||||
:param request: JSON request
|
:param request: JSON request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if request == None:
|
if request is None:
|
||||||
self.send_param_error()
|
self.send_param_error()
|
||||||
else:
|
else:
|
||||||
log.debug("received request {}".format(request))
|
log.debug("received request {}".format(request))
|
||||||
@ -415,7 +414,6 @@ class Dynamips(IModule):
|
|||||||
port,
|
port,
|
||||||
host))
|
host))
|
||||||
response = {"lport": port}
|
response = {"lport": port}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def set_ghost_ios(self, router):
|
def set_ghost_ios(self, router):
|
||||||
@ -498,7 +496,7 @@ class Dynamips(IModule):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
log.info("creating config file {} from base64".format(destination_config_path))
|
log.info("creating config file {} from base64".format(destination_config_path))
|
||||||
config = base64.decodestring(config_base64.encode("utf-8")).decode("utf-8")
|
config = base64.decodebytes(config_base64.encode("utf-8")).decode("utf-8")
|
||||||
config = "!\n" + config.replace("\r", "")
|
config = "!\n" + config.replace("\r", "")
|
||||||
config = config.replace('%h', router.name)
|
config = config.replace('%h', router.name)
|
||||||
config_dir = os.path.dirname(destination_config_path)
|
config_dir = os.path.dirname(destination_config_path)
|
||||||
|
@ -63,7 +63,7 @@ class Adapter(object):
|
|||||||
False otherwise.
|
False otherwise.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._wics[wic_slot_id] == None:
|
if self._wics[wic_slot_id] is None:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class DynamipsHypervisor(object):
|
|||||||
self._udp_end_port_range = 20000
|
self._udp_end_port_range = 20000
|
||||||
self._nio_udp_auto_instances = {}
|
self._nio_udp_auto_instances = {}
|
||||||
self._version = "N/A"
|
self._version = "N/A"
|
||||||
self._timeout = 30
|
self._timeout = timeout
|
||||||
self._socket = None
|
self._socket = None
|
||||||
self._uuid = None
|
self._uuid = None
|
||||||
|
|
||||||
@ -80,9 +80,7 @@ class DynamipsHypervisor(object):
|
|||||||
host = self._host
|
host = self._host
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._socket = socket.create_connection((host,
|
self._socket = socket.create_connection((host, self._port), self._timeout)
|
||||||
self._port),
|
|
||||||
self._timeout)
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise DynamipsError("Could not connect to server: {}".format(e))
|
raise DynamipsError("Could not connect to server: {}".format(e))
|
||||||
|
|
||||||
@ -477,7 +475,7 @@ class DynamipsHypervisor(object):
|
|||||||
self.socket.sendall(command.encode('utf-8'))
|
self.socket.sendall(command.encode('utf-8'))
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise DynamipsError("Lost communication with {host}:{port} :{error}"
|
raise DynamipsError("Lost communication with {host}:{port} :{error}"
|
||||||
.format(host=self._host, port=self._port, error=e))
|
.format(host=self._host, port=self._port, error=e))
|
||||||
|
|
||||||
# Now retrieve the result
|
# Now retrieve the result
|
||||||
data = []
|
data = []
|
||||||
@ -488,7 +486,7 @@ class DynamipsHypervisor(object):
|
|||||||
buf += chunk.decode("utf-8")
|
buf += chunk.decode("utf-8")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise DynamipsError("Communication timed out with {host}:{port} :{error}"
|
raise DynamipsError("Communication timed out with {host}:{port} :{error}"
|
||||||
.format(host=self._host, port=self._port, error=e))
|
.format(host=self._host, port=self._port, error=e))
|
||||||
|
|
||||||
# If the buffer doesn't end in '\n' then we can't be done
|
# If the buffer doesn't end in '\n' then we can't be done
|
||||||
try:
|
try:
|
||||||
|
@ -70,7 +70,7 @@ class Hypervisor(DynamipsHypervisor):
|
|||||||
:returns: id (integer)
|
:returns: id (integer)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._id)
|
return self._id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def started(self):
|
def started(self):
|
||||||
@ -90,7 +90,7 @@ class Hypervisor(DynamipsHypervisor):
|
|||||||
:returns: path to Dynamips
|
:returns: path to Dynamips
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._path)
|
return self._path
|
||||||
|
|
||||||
@path.setter
|
@path.setter
|
||||||
def path(self, path):
|
def path(self, path):
|
||||||
@ -110,7 +110,7 @@ class Hypervisor(DynamipsHypervisor):
|
|||||||
:returns: port number (integer)
|
:returns: port number (integer)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._port)
|
return self._port
|
||||||
|
|
||||||
@port.setter
|
@port.setter
|
||||||
def port(self, port):
|
def port(self, port):
|
||||||
@ -130,7 +130,7 @@ class Hypervisor(DynamipsHypervisor):
|
|||||||
:returns: host/address (string)
|
:returns: host/address (string)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._host)
|
return self._host
|
||||||
|
|
||||||
@host.setter
|
@host.setter
|
||||||
def host(self, host):
|
def host(self, host):
|
||||||
@ -232,7 +232,7 @@ class Hypervisor(DynamipsHypervisor):
|
|||||||
self._process.wait(1)
|
self._process.wait(1)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
self._process.kill()
|
self._process.kill()
|
||||||
if self._process.poll() == None:
|
if self._process.poll() is None:
|
||||||
log.warn("Dynamips process {} is still running".format(self._process.pid))
|
log.warn("Dynamips process {} is still running".format(self._process.pid))
|
||||||
|
|
||||||
if self._stdout_file and os.access(self._stdout_file, os.W_OK):
|
if self._stdout_file and os.access(self._stdout_file, os.W_OK):
|
||||||
@ -264,7 +264,7 @@ class Hypervisor(DynamipsHypervisor):
|
|||||||
:returns: True or False
|
:returns: True or False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._process and self._process.poll() == None:
|
if self._process and self._process.poll() is None:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -39,10 +39,6 @@ class HypervisorManager(object):
|
|||||||
:param path: path to the Dynamips executable
|
:param path: path to the Dynamips executable
|
||||||
:param working_dir: path to a working directory
|
:param working_dir: path to a working directory
|
||||||
:param host: host/address for hypervisors to listen to
|
:param host: host/address for hypervisors to listen to
|
||||||
:param base_port: base TCP port for hypervisors
|
|
||||||
:param base_console: base TCP port for consoles
|
|
||||||
:param base_aux: base TCP port for auxiliary consoles
|
|
||||||
:param base_udp: base UDP port for UDP tunnels
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path, working_dir, host='127.0.0.1'):
|
def __init__(self, path, working_dir, host='127.0.0.1'):
|
||||||
@ -504,13 +500,12 @@ class HypervisorManager(object):
|
|||||||
else:
|
else:
|
||||||
log.info("allocating an hypervisor per IOS image disabled")
|
log.info("allocating an hypervisor per IOS image disabled")
|
||||||
|
|
||||||
def wait_for_hypervisor(self, host, port, timeout=10):
|
def wait_for_hypervisor(self, host, port):
|
||||||
"""
|
"""
|
||||||
Waits for an hypervisor to be started (accepting a socket connection)
|
Waits for an hypervisor to be started (accepting a socket connection)
|
||||||
|
|
||||||
:param host: host/address to connect to the hypervisor
|
:param host: host/address to connect to the hypervisor
|
||||||
:param port: port to connect to the hypervisor
|
:param port: port to connect to the hypervisor
|
||||||
:param timeout: timeout value (default is 10 seconds)
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
begin = time.time()
|
begin = time.time()
|
||||||
|
@ -174,7 +174,7 @@ class NIO(object):
|
|||||||
:returns: tuple (filter name, filter options)
|
:returns: tuple (filter name, filter options)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return (self._input_filter, self._input_filter_options)
|
return self._input_filter, self._input_filter_options
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def output_filter(self):
|
def output_filter(self):
|
||||||
@ -184,7 +184,7 @@ class NIO(object):
|
|||||||
:returns: tuple (filter name, filter options)
|
:returns: tuple (filter name, filter options)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return (self._output_filter, self._output_filter_options)
|
return self._output_filter, self._output_filter_options
|
||||||
|
|
||||||
def get_stats(self):
|
def get_stats(self):
|
||||||
"""
|
"""
|
||||||
|
@ -20,8 +20,6 @@ Interface for Dynamips NIO bridge module ("nio_bridge").
|
|||||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L538
|
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L538
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..dynamips_error import DynamipsError
|
|
||||||
|
|
||||||
|
|
||||||
class Bridge(object):
|
class Bridge(object):
|
||||||
"""
|
"""
|
||||||
|
@ -134,7 +134,7 @@ class Router(object):
|
|||||||
|
|
||||||
# get the default base MAC address
|
# get the default base MAC address
|
||||||
self._mac_addr = self._hypervisor.send("{platform} get_mac_addr {name}".format(platform=self._platform,
|
self._mac_addr = self._hypervisor.send("{platform} get_mac_addr {name}".format(platform=self._platform,
|
||||||
name=self._name))[0]
|
name=self._name))[0]
|
||||||
|
|
||||||
self._hypervisor.devices.append(self)
|
self._hypervisor.devices.append(self)
|
||||||
|
|
||||||
@ -250,7 +250,6 @@ class Router(object):
|
|||||||
raise DynamipsError("Could not amend the configuration {}: {}".format(private_config_path, e))
|
raise DynamipsError("Could not amend the configuration {}: {}".format(private_config_path, e))
|
||||||
self.set_config(self.startup_config, new_private_config_path)
|
self.set_config(self.startup_config, new_private_config_path)
|
||||||
|
|
||||||
new_name_no_quotes = new_name
|
|
||||||
new_name = '"' + new_name + '"' # put the new name into quotes to protect spaces
|
new_name = '"' + new_name + '"' # put the new name into quotes to protect spaces
|
||||||
self._hypervisor.send("vm rename {name} {new_name}".format(name=self._name,
|
self._hypervisor.send("vm rename {name} {new_name}".format(name=self._name,
|
||||||
new_name=new_name))
|
new_name=new_name))
|
||||||
@ -978,7 +977,7 @@ class Router(object):
|
|||||||
translated by the JIT (they contain the native code
|
translated by the JIT (they contain the native code
|
||||||
corresponding to MIPS code pages).
|
corresponding to MIPS code pages).
|
||||||
|
|
||||||
:param excec_area: exec area value (integer)
|
:param exec_area: exec area value (integer)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._hypervisor.send("vm set_exec_area {name} {exec_area}".format(name=self._name,
|
self._hypervisor.send("vm set_exec_area {name} {exec_area}".format(name=self._name,
|
||||||
@ -1259,7 +1258,7 @@ class Router(object):
|
|||||||
:returns: slot bindings (adapter names) list
|
:returns: slot bindings (adapter names) list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return (self._hypervisor.send("vm slot_bindings {}".format(self._name)))
|
return self._hypervisor.send("vm slot_bindings {}".format(self._name))
|
||||||
|
|
||||||
def slot_add_binding(self, slot_id, adapter):
|
def slot_add_binding(self, slot_id, adapter):
|
||||||
"""
|
"""
|
||||||
@ -1275,16 +1274,16 @@ class Router(object):
|
|||||||
raise DynamipsError("Slot {slot_id} doesn't exist on router {name}".format(name=self._name,
|
raise DynamipsError("Slot {slot_id} doesn't exist on router {name}".format(name=self._name,
|
||||||
slot_id=slot_id))
|
slot_id=slot_id))
|
||||||
|
|
||||||
if slot != None:
|
if slot is not None:
|
||||||
current_adapter = slot
|
current_adapter = slot
|
||||||
raise DynamipsError("Slot {slot_id} is already occupied by adapter {adapter} on router {name}".format(name=self._name,
|
raise DynamipsError("Slot {slot_id} is already occupied by adapter {adapter} on router {name}".format(name=self._name,
|
||||||
slot_id=slot_id,
|
slot_id=slot_id,
|
||||||
adapter=current_adapter))
|
adapter=current_adapter))
|
||||||
|
|
||||||
# Only c7200, c3600 and c3745 (NM-4T only) support new adapter while running
|
# Only c7200, c3600 and c3745 (NM-4T only) support new adapter while running
|
||||||
if self.is_running() and not (self._platform == 'c7200' \
|
if self.is_running() and not (self._platform == 'c7200'
|
||||||
and not (self._platform == 'c3600' and self.chassis == '3660') \
|
and not (self._platform == 'c3600' and self.chassis == '3660')
|
||||||
and not (self._platform == 'c3745' and adapter == 'NM-4T')):
|
and not (self._platform == 'c3745' and adapter == 'NM-4T')):
|
||||||
raise DynamipsError("Adapter {adapter} cannot be added while router {name} is running".format(adapter=adapter,
|
raise DynamipsError("Adapter {adapter} cannot be added while router {name} is running".format(adapter=adapter,
|
||||||
name=self._name))
|
name=self._name))
|
||||||
|
|
||||||
@ -1322,14 +1321,14 @@ class Router(object):
|
|||||||
raise DynamipsError("Slot {slot_id} doesn't exist on router {name}".format(name=self._name,
|
raise DynamipsError("Slot {slot_id} doesn't exist on router {name}".format(name=self._name,
|
||||||
slot_id=slot_id))
|
slot_id=slot_id))
|
||||||
|
|
||||||
if adapter == None:
|
if adapter is None:
|
||||||
raise DynamipsError("No adapter in slot {slot_id} on router {name}".format(name=self._name,
|
raise DynamipsError("No adapter in slot {slot_id} on router {name}".format(name=self._name,
|
||||||
slot_id=slot_id))
|
slot_id=slot_id))
|
||||||
|
|
||||||
# Only c7200, c3600 and c3745 (NM-4T only) support to remove adapter while running
|
# Only c7200, c3600 and c3745 (NM-4T only) support to remove adapter while running
|
||||||
if self.is_running() and not (self._platform == 'c7200' \
|
if self.is_running() and not (self._platform == 'c7200'
|
||||||
and not (self._platform == 'c3600' and self.chassis == '3660') \
|
and not (self._platform == 'c3600' and self.chassis == '3660')
|
||||||
and not (self._platform == 'c3745' and adapter == 'NM-4T')):
|
and not (self._platform == 'c3745' and adapter == 'NM-4T')):
|
||||||
raise DynamipsError("Adapter {adapter} cannot be removed while router {name} is running".format(adapter=adapter,
|
raise DynamipsError("Adapter {adapter} cannot be removed while router {name} is running".format(adapter=adapter,
|
||||||
name=self._name))
|
name=self._name))
|
||||||
|
|
||||||
@ -1415,8 +1414,8 @@ class Router(object):
|
|||||||
# WIC1 = 16, WIC2 = 32 and WIC3 = 48
|
# WIC1 = 16, WIC2 = 32 and WIC3 = 48
|
||||||
internal_wic_slot_id = 16 * (wic_slot_id + 1)
|
internal_wic_slot_id = 16 * (wic_slot_id + 1)
|
||||||
self._hypervisor.send("vm slot_remove_binding {name} {slot_id} {wic_slot_id}".format(name=self._name,
|
self._hypervisor.send("vm slot_remove_binding {name} {slot_id} {wic_slot_id}".format(name=self._name,
|
||||||
slot_id=slot_id,
|
slot_id=slot_id,
|
||||||
wic_slot_id=internal_wic_slot_id))
|
wic_slot_id=internal_wic_slot_id))
|
||||||
|
|
||||||
log.info("router {name} [id={id}]: {wic} removed from WIC slot {wic_slot_id}".format(name=self._name,
|
log.info("router {name} [id={id}]: {wic} removed from WIC slot {wic_slot_id}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
|
@ -87,129 +87,129 @@ ATMSW_ADD_NIO_SCHEMA = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"UDP": {
|
"UDP": {
|
||||||
"description": "UDP Network Input/Output",
|
"description": "UDP Network Input/Output",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"enum": ["nio_udp"]
|
"enum": ["nio_udp"]
|
||||||
},
|
},
|
||||||
"lport": {
|
"lport": {
|
||||||
"description": "Local port",
|
"description": "Local port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
},
|
},
|
||||||
"rhost": {
|
"rhost": {
|
||||||
"description": "Remote host",
|
"description": "Remote host",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"rport": {
|
"rport": {
|
||||||
"description": "Remote port",
|
"description": "Remote port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"required": ["type", "lport", "rhost", "rport"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"Ethernet": {
|
|
||||||
"description": "Generic Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_generic_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"LinuxEthernet": {
|
|
||||||
"description": "Linux Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_linux_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"TAP": {
|
|
||||||
"description": "TAP Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_tap"]
|
|
||||||
},
|
|
||||||
"tap_device": {
|
|
||||||
"description": "TAP device name e.g. tap0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "tap_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"UNIX": {
|
|
||||||
"description": "UNIX Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_unix"]
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the UNIX socket file (local)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"remote_file": {
|
|
||||||
"description": "path to the UNIX socket file (remote)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "local_file", "remote_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"VDE": {
|
|
||||||
"description": "VDE Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_vde"]
|
|
||||||
},
|
|
||||||
"control_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "control_file", "local_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"NULL": {
|
|
||||||
"description": "NULL Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_null"]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
},
|
||||||
|
"required": ["type", "lport", "rhost", "rport"],
|
||||||
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
|
"Ethernet": {
|
||||||
|
"description": "Generic Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_generic_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"LinuxEthernet": {
|
||||||
|
"description": "Linux Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_linux_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"TAP": {
|
||||||
|
"description": "TAP Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_tap"]
|
||||||
|
},
|
||||||
|
"tap_device": {
|
||||||
|
"description": "TAP device name e.g. tap0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "tap_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"UNIX": {
|
||||||
|
"description": "UNIX Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_unix"]
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the UNIX socket file (local)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"remote_file": {
|
||||||
|
"description": "path to the UNIX socket file (remote)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "local_file", "remote_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"VDE": {
|
||||||
|
"description": "VDE Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_vde"]
|
||||||
|
},
|
||||||
|
"control_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "control_file", "local_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"NULL": {
|
||||||
|
"description": "NULL Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_null"]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
|
@ -87,129 +87,129 @@ ETHHUB_ADD_NIO_SCHEMA = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"UDP": {
|
"UDP": {
|
||||||
"description": "UDP Network Input/Output",
|
"description": "UDP Network Input/Output",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"enum": ["nio_udp"]
|
"enum": ["nio_udp"]
|
||||||
},
|
},
|
||||||
"lport": {
|
"lport": {
|
||||||
"description": "Local port",
|
"description": "Local port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
},
|
},
|
||||||
"rhost": {
|
"rhost": {
|
||||||
"description": "Remote host",
|
"description": "Remote host",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"rport": {
|
"rport": {
|
||||||
"description": "Remote port",
|
"description": "Remote port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"required": ["type", "lport", "rhost", "rport"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"Ethernet": {
|
|
||||||
"description": "Generic Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_generic_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"LinuxEthernet": {
|
|
||||||
"description": "Linux Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_linux_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"TAP": {
|
|
||||||
"description": "TAP Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_tap"]
|
|
||||||
},
|
|
||||||
"tap_device": {
|
|
||||||
"description": "TAP device name e.g. tap0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "tap_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"UNIX": {
|
|
||||||
"description": "UNIX Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_unix"]
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the UNIX socket file (local)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"remote_file": {
|
|
||||||
"description": "path to the UNIX socket file (remote)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "local_file", "remote_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"VDE": {
|
|
||||||
"description": "VDE Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_vde"]
|
|
||||||
},
|
|
||||||
"control_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "control_file", "local_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"NULL": {
|
|
||||||
"description": "NULL Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_null"]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
},
|
||||||
|
"required": ["type", "lport", "rhost", "rport"],
|
||||||
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
|
"Ethernet": {
|
||||||
|
"description": "Generic Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_generic_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"LinuxEthernet": {
|
||||||
|
"description": "Linux Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_linux_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"TAP": {
|
||||||
|
"description": "TAP Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_tap"]
|
||||||
|
},
|
||||||
|
"tap_device": {
|
||||||
|
"description": "TAP device name e.g. tap0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "tap_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"UNIX": {
|
||||||
|
"description": "UNIX Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_unix"]
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the UNIX socket file (local)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"remote_file": {
|
||||||
|
"description": "path to the UNIX socket file (remote)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "local_file", "remote_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"VDE": {
|
||||||
|
"description": "VDE Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_vde"]
|
||||||
|
},
|
||||||
|
"control_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "control_file", "local_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"NULL": {
|
||||||
|
"description": "NULL Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_null"]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
|
@ -102,129 +102,129 @@ ETHSW_ADD_NIO_SCHEMA = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"UDP": {
|
"UDP": {
|
||||||
"description": "UDP Network Input/Output",
|
"description": "UDP Network Input/Output",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"enum": ["nio_udp"]
|
"enum": ["nio_udp"]
|
||||||
},
|
},
|
||||||
"lport": {
|
"lport": {
|
||||||
"description": "Local port",
|
"description": "Local port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
},
|
},
|
||||||
"rhost": {
|
"rhost": {
|
||||||
"description": "Remote host",
|
"description": "Remote host",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"rport": {
|
"rport": {
|
||||||
"description": "Remote port",
|
"description": "Remote port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"required": ["type", "lport", "rhost", "rport"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"Ethernet": {
|
|
||||||
"description": "Generic Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_generic_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"LinuxEthernet": {
|
|
||||||
"description": "Linux Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_linux_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"TAP": {
|
|
||||||
"description": "TAP Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_tap"]
|
|
||||||
},
|
|
||||||
"tap_device": {
|
|
||||||
"description": "TAP device name e.g. tap0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "tap_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"UNIX": {
|
|
||||||
"description": "UNIX Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_unix"]
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the UNIX socket file (local)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"remote_file": {
|
|
||||||
"description": "path to the UNIX socket file (remote)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "local_file", "remote_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"VDE": {
|
|
||||||
"description": "VDE Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_vde"]
|
|
||||||
},
|
|
||||||
"control_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "control_file", "local_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"NULL": {
|
|
||||||
"description": "NULL Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_null"]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
},
|
||||||
|
"required": ["type", "lport", "rhost", "rport"],
|
||||||
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
|
"Ethernet": {
|
||||||
|
"description": "Generic Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_generic_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"LinuxEthernet": {
|
||||||
|
"description": "Linux Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_linux_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"TAP": {
|
||||||
|
"description": "TAP Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_tap"]
|
||||||
|
},
|
||||||
|
"tap_device": {
|
||||||
|
"description": "TAP device name e.g. tap0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "tap_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"UNIX": {
|
||||||
|
"description": "UNIX Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_unix"]
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the UNIX socket file (local)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"remote_file": {
|
||||||
|
"description": "path to the UNIX socket file (remote)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "local_file", "remote_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"VDE": {
|
||||||
|
"description": "VDE Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_vde"]
|
||||||
|
},
|
||||||
|
"control_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "control_file", "local_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"NULL": {
|
||||||
|
"description": "NULL Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_null"]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
@ -269,7 +269,7 @@ ETHSW_ADD_NIO_SCHEMA = {
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"port_type": ["vlan"],
|
"port_type": ["vlan"],
|
||||||
"vlan": ["port_type"]
|
"vlan": ["port_type"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ETHSW_DELETE_NIO_SCHEMA = {
|
ETHSW_DELETE_NIO_SCHEMA = {
|
||||||
|
@ -87,129 +87,129 @@ FRSW_ADD_NIO_SCHEMA = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"UDP": {
|
"UDP": {
|
||||||
"description": "UDP Network Input/Output",
|
"description": "UDP Network Input/Output",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"enum": ["nio_udp"]
|
"enum": ["nio_udp"]
|
||||||
},
|
},
|
||||||
"lport": {
|
"lport": {
|
||||||
"description": "Local port",
|
"description": "Local port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
},
|
},
|
||||||
"rhost": {
|
"rhost": {
|
||||||
"description": "Remote host",
|
"description": "Remote host",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"rport": {
|
"rport": {
|
||||||
"description": "Remote port",
|
"description": "Remote port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"required": ["type", "lport", "rhost", "rport"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"Ethernet": {
|
|
||||||
"description": "Generic Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_generic_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"LinuxEthernet": {
|
|
||||||
"description": "Linux Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_linux_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"TAP": {
|
|
||||||
"description": "TAP Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_tap"]
|
|
||||||
},
|
|
||||||
"tap_device": {
|
|
||||||
"description": "TAP device name e.g. tap0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "tap_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"UNIX": {
|
|
||||||
"description": "UNIX Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_unix"]
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the UNIX socket file (local)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"remote_file": {
|
|
||||||
"description": "path to the UNIX socket file (remote)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "local_file", "remote_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"VDE": {
|
|
||||||
"description": "VDE Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_vde"]
|
|
||||||
},
|
|
||||||
"control_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "control_file", "local_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"NULL": {
|
|
||||||
"description": "NULL Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_null"]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
},
|
||||||
|
"required": ["type", "lport", "rhost", "rport"],
|
||||||
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
|
"Ethernet": {
|
||||||
|
"description": "Generic Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_generic_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"LinuxEthernet": {
|
||||||
|
"description": "Linux Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_linux_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"TAP": {
|
||||||
|
"description": "TAP Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_tap"]
|
||||||
|
},
|
||||||
|
"tap_device": {
|
||||||
|
"description": "TAP device name e.g. tap0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "tap_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"UNIX": {
|
||||||
|
"description": "UNIX Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_unix"]
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the UNIX socket file (local)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"remote_file": {
|
||||||
|
"description": "path to the UNIX socket file (remote)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "local_file", "remote_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"VDE": {
|
||||||
|
"description": "VDE Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_vde"]
|
||||||
|
},
|
||||||
|
"control_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "control_file", "local_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"NULL": {
|
||||||
|
"description": "NULL Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_null"]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
|
@ -424,129 +424,129 @@ VM_ADD_NIO_SCHEMA = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"UDP": {
|
"UDP": {
|
||||||
"description": "UDP Network Input/Output",
|
"description": "UDP Network Input/Output",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"enum": ["nio_udp"]
|
"enum": ["nio_udp"]
|
||||||
},
|
},
|
||||||
"lport": {
|
"lport": {
|
||||||
"description": "Local port",
|
"description": "Local port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
},
|
},
|
||||||
"rhost": {
|
"rhost": {
|
||||||
"description": "Remote host",
|
"description": "Remote host",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"rport": {
|
"rport": {
|
||||||
"description": "Remote port",
|
"description": "Remote port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"required": ["type", "lport", "rhost", "rport"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"Ethernet": {
|
|
||||||
"description": "Generic Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_generic_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"LinuxEthernet": {
|
|
||||||
"description": "Linux Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_linux_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"TAP": {
|
|
||||||
"description": "TAP Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_tap"]
|
|
||||||
},
|
|
||||||
"tap_device": {
|
|
||||||
"description": "TAP device name e.g. tap0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "tap_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"UNIX": {
|
|
||||||
"description": "UNIX Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_unix"]
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the UNIX socket file (local)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"remote_file": {
|
|
||||||
"description": "path to the UNIX socket file (remote)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "local_file", "remote_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"VDE": {
|
|
||||||
"description": "VDE Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_vde"]
|
|
||||||
},
|
|
||||||
"control_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "control_file", "local_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"NULL": {
|
|
||||||
"description": "NULL Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_null"]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
},
|
||||||
|
"required": ["type", "lport", "rhost", "rport"],
|
||||||
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
|
"Ethernet": {
|
||||||
|
"description": "Generic Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_generic_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"LinuxEthernet": {
|
||||||
|
"description": "Linux Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_linux_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"TAP": {
|
||||||
|
"description": "TAP Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_tap"]
|
||||||
|
},
|
||||||
|
"tap_device": {
|
||||||
|
"description": "TAP device name e.g. tap0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "tap_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"UNIX": {
|
||||||
|
"description": "UNIX Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_unix"]
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the UNIX socket file (local)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"remote_file": {
|
||||||
|
"description": "path to the UNIX socket file (remote)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "local_file", "remote_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"VDE": {
|
||||||
|
"description": "VDE Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_vde"]
|
||||||
|
},
|
||||||
|
"control_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "control_file", "local_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"NULL": {
|
||||||
|
"description": "NULL Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_null"]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
|
@ -20,17 +20,13 @@ IOU server module.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import base64
|
import base64
|
||||||
import tempfile
|
import tempfile
|
||||||
import fcntl
|
|
||||||
import struct
|
|
||||||
import socket
|
import socket
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from gns3server.modules import IModule
|
from gns3server.modules import IModule
|
||||||
from gns3server.config import Config
|
from gns3server.config import Config
|
||||||
import gns3server.jsonrpc as jsonrpc
|
|
||||||
from .iou_device import IOUDevice
|
from .iou_device import IOUDevice
|
||||||
from .iou_error import IOUError
|
from .iou_error import IOUError
|
||||||
from .nios.nio_udp import NIO_UDP
|
from .nios.nio_udp import NIO_UDP
|
||||||
@ -215,12 +211,12 @@ class IOU(IModule):
|
|||||||
:param request: JSON request
|
:param request: JSON request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if request == None:
|
if request is None:
|
||||||
self.send_param_error()
|
self.send_param_error()
|
||||||
return
|
return
|
||||||
|
|
||||||
if "iourc" in request:
|
if "iourc" in request:
|
||||||
iourc_content = base64.decodestring(request["iourc"].encode("utf-8")).decode("utf-8")
|
iourc_content = base64.decodebytes(request["iourc"].encode("utf-8")).decode("utf-8")
|
||||||
iourc_content = iourc_content.replace("\r\n", "\n") # dos2unix
|
iourc_content = iourc_content.replace("\r\n", "\n") # dos2unix
|
||||||
try:
|
try:
|
||||||
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
|
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
|
||||||
@ -228,7 +224,7 @@ class IOU(IModule):
|
|||||||
f.write(iourc_content)
|
f.write(iourc_content)
|
||||||
self._iourc = f.name
|
self._iourc = f.name
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise IOUError("Could not save iourc file to {}: {}".format(f.name, e))
|
raise IOUError("Could not create the iourc file: {}".format(e))
|
||||||
|
|
||||||
if "iouyap" in request and request["iouyap"]:
|
if "iouyap" in request and request["iouyap"]:
|
||||||
self._iouyap = request["iouyap"]
|
self._iouyap = request["iouyap"]
|
||||||
@ -410,7 +406,7 @@ class IOU(IModule):
|
|||||||
try:
|
try:
|
||||||
if "startup_config_base64" in request:
|
if "startup_config_base64" in request:
|
||||||
# a new startup-config has been pushed
|
# a new startup-config has been pushed
|
||||||
config = base64.decodestring(request["startup_config_base64"].encode("utf-8")).decode("utf-8")
|
config = base64.decodebytes(request["startup_config_base64"].encode("utf-8")).decode("utf-8")
|
||||||
config = "!\n" + config.replace("\r", "")
|
config = "!\n" + config.replace("\r", "")
|
||||||
config = config.replace('%h', iou_instance.name)
|
config = config.replace('%h', iou_instance.name)
|
||||||
try:
|
try:
|
||||||
@ -587,8 +583,8 @@ class IOU(IModule):
|
|||||||
iou_instance.id,
|
iou_instance.id,
|
||||||
port,
|
port,
|
||||||
self._host))
|
self._host))
|
||||||
response = {"lport": port}
|
response = {"lport": port,
|
||||||
response["port_id"] = request["port_id"]
|
"port_id": request["port_id"]}
|
||||||
self.send_response(response)
|
self.send_response(response)
|
||||||
|
|
||||||
@IModule.route("iou.add_nio")
|
@IModule.route("iou.add_nio")
|
||||||
@ -643,12 +639,12 @@ class IOU(IModule):
|
|||||||
nio = NIO_UDP(lport, rhost, rport)
|
nio = NIO_UDP(lport, rhost, rport)
|
||||||
elif request["nio"]["type"] == "nio_tap":
|
elif request["nio"]["type"] == "nio_tap":
|
||||||
tap_device = request["nio"]["tap_device"]
|
tap_device = request["nio"]["tap_device"]
|
||||||
if not has_privileged_access(self._iouyap, tap_device):
|
if not has_privileged_access(self._iouyap):
|
||||||
raise IOUError("{} has no privileged access to {}.".format(self._iouyap, tap_device))
|
raise IOUError("{} has no privileged access to {}.".format(self._iouyap, tap_device))
|
||||||
nio = NIO_TAP(tap_device)
|
nio = NIO_TAP(tap_device)
|
||||||
elif request["nio"]["type"] == "nio_generic_ethernet":
|
elif request["nio"]["type"] == "nio_generic_ethernet":
|
||||||
ethernet_device = request["nio"]["ethernet_device"]
|
ethernet_device = request["nio"]["ethernet_device"]
|
||||||
if not has_privileged_access(self._iouyap, ethernet_device):
|
if not has_privileged_access(self._iouyap):
|
||||||
raise IOUError("{} has no privileged access to {}.".format(self._iouyap, ethernet_device))
|
raise IOUError("{} has no privileged access to {}.".format(self._iouyap, ethernet_device))
|
||||||
nio = NIO_GenericEthernet(ethernet_device)
|
nio = NIO_GenericEthernet(ethernet_device)
|
||||||
if not nio:
|
if not nio:
|
||||||
@ -710,7 +706,7 @@ class IOU(IModule):
|
|||||||
:param request: JSON request
|
:param request: JSON request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if request == None:
|
if request is None:
|
||||||
self.send_param_error()
|
self.send_param_error()
|
||||||
else:
|
else:
|
||||||
log.debug("received request {}".format(request))
|
log.debug("received request {}".format(request))
|
||||||
|
@ -83,7 +83,7 @@ class IOUDevice(object):
|
|||||||
self._iourc = ""
|
self._iourc = ""
|
||||||
self._iouyap = ""
|
self._iouyap = ""
|
||||||
self._console = console
|
self._console = console
|
||||||
self._working_dir = None
|
self._working_dir = working_dir
|
||||||
self._command = []
|
self._command = []
|
||||||
self._process = None
|
self._process = None
|
||||||
self._iouyap_process = None
|
self._iouyap_process = None
|
||||||
@ -154,7 +154,7 @@ class IOUDevice(object):
|
|||||||
:returns: id (integer)
|
:returns: id (integer)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._id)
|
return self._id
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reset(cls):
|
def reset(cls):
|
||||||
@ -185,7 +185,7 @@ class IOUDevice(object):
|
|||||||
|
|
||||||
if self._startup_config:
|
if self._startup_config:
|
||||||
# update the startup-config
|
# update the startup-config
|
||||||
config_path = os.path.join(self.working_dir, "startup-config")
|
config_path = os.path.join(self._working_dir, "startup-config")
|
||||||
if os.path.isfile(config_path):
|
if os.path.isfile(config_path):
|
||||||
try:
|
try:
|
||||||
with open(config_path, "r+") as f:
|
with open(config_path, "r+") as f:
|
||||||
@ -209,7 +209,7 @@ class IOUDevice(object):
|
|||||||
:returns: path to IOU
|
:returns: path to IOU
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._path)
|
return self._path
|
||||||
|
|
||||||
@path.setter
|
@path.setter
|
||||||
def path(self, path):
|
def path(self, path):
|
||||||
@ -221,8 +221,8 @@ class IOUDevice(object):
|
|||||||
|
|
||||||
self._path = path
|
self._path = path
|
||||||
log.info("IOU {name} [id={id}]: path changed to {path}".format(name=self._name,
|
log.info("IOU {name} [id={id}]: path changed to {path}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
path=path))
|
path=path))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def iourc(self):
|
def iourc(self):
|
||||||
@ -232,14 +232,14 @@ class IOUDevice(object):
|
|||||||
:returns: path to the iourc file
|
:returns: path to the iourc file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._iourc)
|
return self._iourc
|
||||||
|
|
||||||
@iourc.setter
|
@iourc.setter
|
||||||
def iourc(self, iourc):
|
def iourc(self, iourc):
|
||||||
"""
|
"""
|
||||||
Sets the path to the iourc file.
|
Sets the path to the iourc file.
|
||||||
|
|
||||||
:param path: path to the iourc file.
|
:param iourc: path to the iourc file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._iourc = iourc
|
self._iourc = iourc
|
||||||
@ -255,14 +255,14 @@ class IOUDevice(object):
|
|||||||
:returns: path to iouyap
|
:returns: path to iouyap
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._iouyap)
|
return self._iouyap
|
||||||
|
|
||||||
@iouyap.setter
|
@iouyap.setter
|
||||||
def iouyap(self, iouyap):
|
def iouyap(self, iouyap):
|
||||||
"""
|
"""
|
||||||
Sets the path to iouyap.
|
Sets the path to iouyap.
|
||||||
|
|
||||||
:param path: path to iouyap
|
:param iouyap: path to iouyap
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._iouyap = iouyap
|
self._iouyap = iouyap
|
||||||
@ -299,8 +299,8 @@ class IOUDevice(object):
|
|||||||
|
|
||||||
self._working_dir = working_dir
|
self._working_dir = working_dir
|
||||||
log.info("IOU {name} [id={id}]: working directory changed to {wd}".format(name=self._name,
|
log.info("IOU {name} [id={id}]: working directory changed to {wd}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
wd=self._working_dir))
|
wd=self._working_dir))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def console(self):
|
def console(self):
|
||||||
@ -327,8 +327,8 @@ class IOUDevice(object):
|
|||||||
self._console = console
|
self._console = console
|
||||||
self._allocated_console_ports.append(self._console)
|
self._allocated_console_ports.append(self._console)
|
||||||
log.info("IOU {name} [id={id}]: console port set to {port}".format(name=self._name,
|
log.info("IOU {name} [id={id}]: console port set to {port}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
port=console))
|
port=console))
|
||||||
|
|
||||||
def command(self):
|
def command(self):
|
||||||
"""
|
"""
|
||||||
@ -368,8 +368,8 @@ class IOUDevice(object):
|
|||||||
shutil.rmtree(self._working_dir)
|
shutil.rmtree(self._working_dir)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.error("could not delete IOU device {name} [id={id}]: {error}".format(name=self._name,
|
log.error("could not delete IOU device {name} [id={id}]: {error}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
error=e))
|
error=e))
|
||||||
return
|
return
|
||||||
|
|
||||||
log.info("IOU device {name} [id={id}] has been deleted (including associated files)".format(name=self._name,
|
log.info("IOU device {name} [id={id}] has been deleted (including associated files)".format(name=self._name,
|
||||||
@ -402,6 +402,7 @@ class IOUDevice(object):
|
|||||||
for unit in adapter.ports.keys():
|
for unit in adapter.ports.keys():
|
||||||
nio = adapter.get_nio(unit)
|
nio = adapter.get_nio(unit)
|
||||||
if nio:
|
if nio:
|
||||||
|
connection = None
|
||||||
if isinstance(nio, NIO_UDP):
|
if isinstance(nio, NIO_UDP):
|
||||||
# UDP tunnel
|
# UDP tunnel
|
||||||
connection = {"tunnel_udp": "{lport}:{rhost}:{rport}".format(lport=nio.lport,
|
connection = {"tunnel_udp": "{lport}:{rhost}:{rport}".format(lport=nio.lport,
|
||||||
@ -415,7 +416,8 @@ class IOUDevice(object):
|
|||||||
# Ethernet interface
|
# Ethernet interface
|
||||||
connection = {"eth_dev": "{ethernet_device}".format(ethernet_device=nio.ethernet_device)}
|
connection = {"eth_dev": "{ethernet_device}".format(ethernet_device=nio.ethernet_device)}
|
||||||
|
|
||||||
config["{iouyap_id}:{bay}/{unit}".format(iouyap_id=str(self._id + 512), bay=bay_id, unit=unit_id)] = connection
|
if connection:
|
||||||
|
config["{iouyap_id}:{bay}/{unit}".format(iouyap_id=str(self._id + 512), bay=bay_id, unit=unit_id)] = connection
|
||||||
unit_id += 1
|
unit_id += 1
|
||||||
bay_id += 1
|
bay_id += 1
|
||||||
|
|
||||||
@ -581,7 +583,7 @@ class IOUDevice(object):
|
|||||||
self._iouyap_process.wait(1)
|
self._iouyap_process.wait(1)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
self._iouyap_process.kill()
|
self._iouyap_process.kill()
|
||||||
if self._iouyap_process.poll() == None:
|
if self._iouyap_process.poll() is None:
|
||||||
log.warn("iouyap PID={} for IOU instance {} is still running".format(self._iouyap_process.pid,
|
log.warn("iouyap PID={} for IOU instance {} is still running".format(self._iouyap_process.pid,
|
||||||
self._id))
|
self._id))
|
||||||
self._iouyap_process = None
|
self._iouyap_process = None
|
||||||
@ -594,7 +596,7 @@ class IOUDevice(object):
|
|||||||
self._process.wait(1)
|
self._process.wait(1)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
self._process.kill()
|
self._process.kill()
|
||||||
if self._process.poll() == None:
|
if self._process.poll() is None:
|
||||||
log.warn("IOU instance {} PID={} is still running".format(self._id,
|
log.warn("IOU instance {} PID={} is still running".format(self._id,
|
||||||
self._process.pid))
|
self._process.pid))
|
||||||
self._process = None
|
self._process = None
|
||||||
@ -637,7 +639,7 @@ class IOUDevice(object):
|
|||||||
:returns: True or False
|
:returns: True or False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._process and self._process.poll() == None:
|
if self._process and self._process.poll() is None:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -648,7 +650,7 @@ class IOUDevice(object):
|
|||||||
:returns: True or False
|
:returns: True or False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._iouyap_process and self._iouyap_process.poll() == None:
|
if self._iouyap_process and self._iouyap_process.poll() is None:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -723,16 +725,14 @@ class IOUDevice(object):
|
|||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["IOURC"] = self._iourc
|
env["IOURC"] = self._iourc
|
||||||
output = b""
|
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output([self._path, "-h"], stderr=subprocess.STDOUT, cwd=self._working_dir, env=env)
|
output = subprocess.check_output([self._path, "-h"], stderr=subprocess.STDOUT, cwd=self._working_dir, env=env)
|
||||||
except OSError as e:
|
|
||||||
log.warn("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e))
|
|
||||||
else:
|
|
||||||
if re.search("-l\s+Enable Layer 1 keepalive messages", output.decode("utf-8")):
|
if re.search("-l\s+Enable Layer 1 keepalive messages", output.decode("utf-8")):
|
||||||
command.extend(["-l"])
|
command.extend(["-l"])
|
||||||
else:
|
else:
|
||||||
raise IOUError("layer 1 keepalive messages are not supported by {}".format(os.path.basename(self._path)))
|
raise IOUError("layer 1 keepalive messages are not supported by {}".format(os.path.basename(self._path)))
|
||||||
|
except OSError as e:
|
||||||
|
log.warn("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e))
|
||||||
|
|
||||||
def _build_command(self):
|
def _build_command(self):
|
||||||
"""
|
"""
|
||||||
@ -904,8 +904,8 @@ class IOUDevice(object):
|
|||||||
|
|
||||||
self._startup_config = startup_config
|
self._startup_config = startup_config
|
||||||
log.info("IOU {name} [id={id}]: startup_config set to {config}".format(name=self._name,
|
log.info("IOU {name} [id={id}]: startup_config set to {config}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
config=self._startup_config))
|
config=self._startup_config))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ethernet_adapters(self):
|
def ethernet_adapters(self):
|
||||||
|
@ -56,32 +56,32 @@ EXIT_ABORT = 2
|
|||||||
# Mostly from:
|
# Mostly from:
|
||||||
# https://code.google.com/p/miniboa/source/browse/trunk/miniboa/telnet.py
|
# https://code.google.com/p/miniboa/source/browse/trunk/miniboa/telnet.py
|
||||||
#--[ Telnet Commands ]---------------------------------------------------------
|
#--[ Telnet Commands ]---------------------------------------------------------
|
||||||
SE = 240 # End of subnegotiation parameters
|
SE = 240 # End of sub-negotiation parameters
|
||||||
NOP = 241 # No operation
|
NOP = 241 # No operation
|
||||||
DATMK = 242 # Data stream portion of a sync.
|
DATMK = 242 # Data stream portion of a sync.
|
||||||
BREAK = 243 # NVT Character BRK
|
BREAK = 243 # NVT Character BRK
|
||||||
IP = 244 # Interrupt Process
|
IP = 244 # Interrupt Process
|
||||||
AO = 245 # Abort Output
|
AO = 245 # Abort Output
|
||||||
AYT = 246 # Are you there
|
AYT = 246 # Are you there
|
||||||
EC = 247 # Erase Character
|
EC = 247 # Erase Character
|
||||||
EL = 248 # Erase Line
|
EL = 248 # Erase Line
|
||||||
GA = 249 # The Go Ahead Signal
|
GA = 249 # The Go Ahead Signal
|
||||||
SB = 250 # Sub-option to follow
|
SB = 250 # Sub-option to follow
|
||||||
WILL = 251 # Will; request or confirm option begin
|
WILL = 251 # Will; request or confirm option begin
|
||||||
WONT = 252 # Wont; deny option request
|
WONT = 252 # Wont; deny option request
|
||||||
DO = 253 # Do = Request or confirm remote option
|
DO = 253 # Do = Request or confirm remote option
|
||||||
DONT = 254 # Don't = Demand or confirm option halt
|
DONT = 254 # Don't = Demand or confirm option halt
|
||||||
IAC = 255 # Interpret as Command
|
IAC = 255 # Interpret as Command
|
||||||
SEND = 1 # Sub-process negotiation SEND command
|
SEND = 1 # Sub-process negotiation SEND command
|
||||||
IS = 0 # Sub-process negotiation IS command
|
IS = 0 # Sub-process negotiation IS command
|
||||||
#--[ Telnet Options ]----------------------------------------------------------
|
#--[ Telnet Options ]----------------------------------------------------------
|
||||||
BINARY = 0 # Transmit Binary
|
BINARY = 0 # Transmit Binary
|
||||||
ECHO = 1 # Echo characters back to sender
|
ECHO = 1 # Echo characters back to sender
|
||||||
RECON = 2 # Reconnection
|
RECON = 2 # Reconnection
|
||||||
SGA = 3 # Suppress Go-Ahead
|
SGA = 3 # Suppress Go-Ahead
|
||||||
TMARK = 6 # Timing Mark
|
TMARK = 6 # Timing Mark
|
||||||
TTYPE = 24 # Terminal Type
|
TTYPE = 24 # Terminal Type
|
||||||
NAWS = 31 # Negotiate About Window Size
|
NAWS = 31 # Negotiate About Window Size
|
||||||
LINEMO = 34 # Line Mode
|
LINEMO = 34 # Line Mode
|
||||||
|
|
||||||
|
|
||||||
@ -299,9 +299,7 @@ class TelnetServer(Console):
|
|||||||
buf.extend(self._read_block(1))
|
buf.extend(self._read_block(1))
|
||||||
iac_cmd.append(buf[iac_loc + 2])
|
iac_cmd.append(buf[iac_loc + 2])
|
||||||
# We do ECHO, SGA, and BINARY. Period.
|
# We do ECHO, SGA, and BINARY. Period.
|
||||||
if (iac_cmd[1] == DO
|
if iac_cmd[1] == DO and iac_cmd[2] not in [ECHO, SGA, BINARY]:
|
||||||
and iac_cmd[2] not in [ECHO, SGA, BINARY]):
|
|
||||||
|
|
||||||
self._write_cur(bytes([IAC, WONT, iac_cmd[2]]))
|
self._write_cur(bytes([IAC, WONT, iac_cmd[2]]))
|
||||||
log.debug("Telnet WON'T {:#x}".format(iac_cmd[2]))
|
log.debug("Telnet WON'T {:#x}".format(iac_cmd[2]))
|
||||||
else:
|
else:
|
||||||
@ -326,7 +324,7 @@ class TelnetServer(Console):
|
|||||||
fd.send(bytes([IAC, WILL, ECHO,
|
fd.send(bytes([IAC, WILL, ECHO,
|
||||||
IAC, WILL, SGA,
|
IAC, WILL, SGA,
|
||||||
IAC, WILL, BINARY,
|
IAC, WILL, BINARY,
|
||||||
IAC, DO, BINARY]))
|
IAC, DO, BINARY]))
|
||||||
|
|
||||||
if args.telnet_limit and len(self.fd_dict) > args.telnet_limit:
|
if args.telnet_limit and len(self.fd_dict) > args.telnet_limit:
|
||||||
fd.send(b'\r\nToo many connections\r\n')
|
fd.send(b'\r\nToo many connections\r\n')
|
||||||
@ -601,7 +599,7 @@ def start_ioucon(cmdline_args, stop_event):
|
|||||||
nport = int(port)
|
nport = int(port)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
if (addr == '' or nport == 0):
|
if addr == '' or nport == 0:
|
||||||
raise ConfigError('format for --telnet-server must be '
|
raise ConfigError('format for --telnet-server must be '
|
||||||
'ADDR:PORT (like 127.0.0.1:20000)')
|
'ADDR:PORT (like 127.0.0.1:20000)')
|
||||||
|
|
||||||
|
@ -189,129 +189,129 @@ IOU_ADD_NIO_SCHEMA = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"UDP": {
|
"UDP": {
|
||||||
"description": "UDP Network Input/Output",
|
"description": "UDP Network Input/Output",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"enum": ["nio_udp"]
|
"enum": ["nio_udp"]
|
||||||
},
|
},
|
||||||
"lport": {
|
"lport": {
|
||||||
"description": "Local port",
|
"description": "Local port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
},
|
},
|
||||||
"rhost": {
|
"rhost": {
|
||||||
"description": "Remote host",
|
"description": "Remote host",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"rport": {
|
"rport": {
|
||||||
"description": "Remote port",
|
"description": "Remote port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"required": ["type", "lport", "rhost", "rport"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"Ethernet": {
|
|
||||||
"description": "Generic Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_generic_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"LinuxEthernet": {
|
|
||||||
"description": "Linux Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_linux_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"TAP": {
|
|
||||||
"description": "TAP Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_tap"]
|
|
||||||
},
|
|
||||||
"tap_device": {
|
|
||||||
"description": "TAP device name e.g. tap0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "tap_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"UNIX": {
|
|
||||||
"description": "UNIX Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_unix"]
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the UNIX socket file (local)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"remote_file": {
|
|
||||||
"description": "path to the UNIX socket file (remote)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "local_file", "remote_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"VDE": {
|
|
||||||
"description": "VDE Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_vde"]
|
|
||||||
},
|
|
||||||
"control_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "control_file", "local_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"NULL": {
|
|
||||||
"description": "NULL Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_null"]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
},
|
||||||
|
"required": ["type", "lport", "rhost", "rport"],
|
||||||
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
|
"Ethernet": {
|
||||||
|
"description": "Generic Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_generic_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"LinuxEthernet": {
|
||||||
|
"description": "Linux Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_linux_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"TAP": {
|
||||||
|
"description": "TAP Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_tap"]
|
||||||
|
},
|
||||||
|
"tap_device": {
|
||||||
|
"description": "TAP device name e.g. tap0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "tap_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"UNIX": {
|
||||||
|
"description": "UNIX Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_unix"]
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the UNIX socket file (local)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"remote_file": {
|
||||||
|
"description": "path to the UNIX socket file (remote)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "local_file", "remote_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"VDE": {
|
||||||
|
"description": "VDE Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_vde"]
|
||||||
|
},
|
||||||
|
"control_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "control_file", "local_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"NULL": {
|
||||||
|
"description": "NULL Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_null"]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
|
@ -20,16 +20,12 @@ VPCS server module.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import base64
|
import base64
|
||||||
import tempfile
|
|
||||||
import struct
|
|
||||||
import socket
|
import socket
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from gns3server.modules import IModule
|
from gns3server.modules import IModule
|
||||||
from gns3server.config import Config
|
from gns3server.config import Config
|
||||||
import gns3server.jsonrpc as jsonrpc
|
|
||||||
from .vpcs_device import VPCSDevice
|
from .vpcs_device import VPCSDevice
|
||||||
from .vpcs_error import VPCSError
|
from .vpcs_error import VPCSError
|
||||||
from .nios.nio_udp import NIO_UDP
|
from .nios.nio_udp import NIO_UDP
|
||||||
@ -101,7 +97,6 @@ class VPCS(IModule):
|
|||||||
:param signum: signal number (if called by the signal handler)
|
:param signum: signal number (if called by the signal handler)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# self._vpcs_callback.stop()
|
|
||||||
# delete all VPCS instances
|
# delete all VPCS instances
|
||||||
for vpcs_id in self._vpcs_instances:
|
for vpcs_id in self._vpcs_instances:
|
||||||
vpcs_instance = self._vpcs_instances[vpcs_id]
|
vpcs_instance = self._vpcs_instances[vpcs_id]
|
||||||
@ -162,7 +157,7 @@ class VPCS(IModule):
|
|||||||
:param request: JSON request
|
:param request: JSON request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if request == None:
|
if request is None:
|
||||||
self.send_param_error()
|
self.send_param_error()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -326,7 +321,7 @@ class VPCS(IModule):
|
|||||||
try:
|
try:
|
||||||
if "script_file_base64" in request:
|
if "script_file_base64" in request:
|
||||||
# a new startup-config has been pushed
|
# a new startup-config has been pushed
|
||||||
config = base64.decodestring(request["script_file_base64"].encode("utf-8")).decode("utf-8")
|
config = base64.decodebytes(request["script_file_base64"].encode("utf-8")).decode("utf-8")
|
||||||
config = config.replace("\r", "")
|
config = config.replace("\r", "")
|
||||||
config = config.replace('%h', vpcs_instance.name)
|
config = config.replace('%h', vpcs_instance.name)
|
||||||
try:
|
try:
|
||||||
@ -502,8 +497,8 @@ class VPCS(IModule):
|
|||||||
port,
|
port,
|
||||||
self._host))
|
self._host))
|
||||||
|
|
||||||
response = {"lport": port}
|
response = {"lport": port,
|
||||||
response["port_id"] = request["port_id"]
|
"port_id": request["port_id"]}
|
||||||
self.send_response(response)
|
self.send_response(response)
|
||||||
|
|
||||||
@IModule.route("vpcs.add_nio")
|
@IModule.route("vpcs.add_nio")
|
||||||
@ -554,7 +549,7 @@ class VPCS(IModule):
|
|||||||
nio = NIO_UDP(lport, rhost, rport)
|
nio = NIO_UDP(lport, rhost, rport)
|
||||||
elif request["nio"]["type"] == "nio_tap":
|
elif request["nio"]["type"] == "nio_tap":
|
||||||
tap_device = request["nio"]["tap_device"]
|
tap_device = request["nio"]["tap_device"]
|
||||||
if not self.has_privileged_access(self._vpcs, tap_device):
|
if not self.has_privileged_access(self._vpcs):
|
||||||
raise VPCSError("{} has no privileged access to {}.".format(self._vpcs, tap_device))
|
raise VPCSError("{} has no privileged access to {}.".format(self._vpcs, tap_device))
|
||||||
nio = NIO_TAP(tap_device)
|
nio = NIO_TAP(tap_device)
|
||||||
if not nio:
|
if not nio:
|
||||||
@ -614,7 +609,7 @@ class VPCS(IModule):
|
|||||||
:param request: JSON request
|
:param request: JSON request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if request == None:
|
if request is None:
|
||||||
self.send_param_error()
|
self.send_param_error()
|
||||||
else:
|
else:
|
||||||
log.debug("received request {}".format(request))
|
log.debug("received request {}".format(request))
|
||||||
|
@ -151,129 +151,129 @@ VPCS_ADD_NIO_SCHEMA = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"UDP": {
|
"UDP": {
|
||||||
"description": "UDP Network Input/Output",
|
"description": "UDP Network Input/Output",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"enum": ["nio_udp"]
|
"enum": ["nio_udp"]
|
||||||
},
|
},
|
||||||
"lport": {
|
"lport": {
|
||||||
"description": "Local port",
|
"description": "Local port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
},
|
},
|
||||||
"rhost": {
|
"rhost": {
|
||||||
"description": "Remote host",
|
"description": "Remote host",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"rport": {
|
"rport": {
|
||||||
"description": "Remote port",
|
"description": "Remote port",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 65535
|
"maximum": 65535
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"required": ["type", "lport", "rhost", "rport"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"Ethernet": {
|
|
||||||
"description": "Generic Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_generic_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"LinuxEthernet": {
|
|
||||||
"description": "Linux Ethernet Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_linux_ethernet"]
|
|
||||||
},
|
|
||||||
"ethernet_device": {
|
|
||||||
"description": "Ethernet device name e.g. eth0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "ethernet_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"TAP": {
|
|
||||||
"description": "TAP Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_tap"]
|
|
||||||
},
|
|
||||||
"tap_device": {
|
|
||||||
"description": "TAP device name e.g. tap0",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "tap_device"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"UNIX": {
|
|
||||||
"description": "UNIX Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_unix"]
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the UNIX socket file (local)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"remote_file": {
|
|
||||||
"description": "path to the UNIX socket file (remote)",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "local_file", "remote_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"VDE": {
|
|
||||||
"description": "VDE Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_vde"]
|
|
||||||
},
|
|
||||||
"control_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"local_file": {
|
|
||||||
"description": "path to the VDE control file",
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type", "control_file", "local_file"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
|
||||||
"NULL": {
|
|
||||||
"description": "NULL Network Input/Output",
|
|
||||||
"properties": {
|
|
||||||
"type": {
|
|
||||||
"enum": ["nio_null"]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["type"],
|
|
||||||
"additionalProperties": False
|
|
||||||
},
|
},
|
||||||
|
"required": ["type", "lport", "rhost", "rport"],
|
||||||
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
|
"Ethernet": {
|
||||||
|
"description": "Generic Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_generic_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"LinuxEthernet": {
|
||||||
|
"description": "Linux Ethernet Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_linux_ethernet"]
|
||||||
|
},
|
||||||
|
"ethernet_device": {
|
||||||
|
"description": "Ethernet device name e.g. eth0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "ethernet_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"TAP": {
|
||||||
|
"description": "TAP Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_tap"]
|
||||||
|
},
|
||||||
|
"tap_device": {
|
||||||
|
"description": "TAP device name e.g. tap0",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "tap_device"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"UNIX": {
|
||||||
|
"description": "UNIX Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_unix"]
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the UNIX socket file (local)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"remote_file": {
|
||||||
|
"description": "path to the UNIX socket file (remote)",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "local_file", "remote_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"VDE": {
|
||||||
|
"description": "VDE Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_vde"]
|
||||||
|
},
|
||||||
|
"control_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"local_file": {
|
||||||
|
"description": "path to the VDE control file",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type", "control_file", "local_file"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"NULL": {
|
||||||
|
"description": "NULL Network Input/Output",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": ["nio_null"]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["type"],
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
|
@ -81,7 +81,8 @@ class VPCSDevice(object):
|
|||||||
|
|
||||||
self._path = path
|
self._path = path
|
||||||
self._console = console
|
self._console = console
|
||||||
self._working_dir = None
|
self._working_dir = working_dir
|
||||||
|
self._host = host
|
||||||
self._command = []
|
self._command = []
|
||||||
self._process = None
|
self._process = None
|
||||||
self._vpcs_stdout_file = ""
|
self._vpcs_stdout_file = ""
|
||||||
@ -135,7 +136,7 @@ class VPCSDevice(object):
|
|||||||
:returns: id (integer)
|
:returns: id (integer)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._id)
|
return self._id
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reset(cls):
|
def reset(cls):
|
||||||
@ -166,7 +167,7 @@ class VPCSDevice(object):
|
|||||||
|
|
||||||
if self._script_file:
|
if self._script_file:
|
||||||
# update the startup.vpc
|
# update the startup.vpc
|
||||||
config_path = os.path.join(self.working_dir, "startup.vpc")
|
config_path = os.path.join(self._working_dir, "startup.vpc")
|
||||||
if os.path.isfile(config_path):
|
if os.path.isfile(config_path):
|
||||||
try:
|
try:
|
||||||
with open(config_path, "r+") as f:
|
with open(config_path, "r+") as f:
|
||||||
@ -178,8 +179,8 @@ class VPCSDevice(object):
|
|||||||
raise VPCSError("Could not amend the configuration {}: {}".format(config_path, e))
|
raise VPCSError("Could not amend the configuration {}: {}".format(config_path, e))
|
||||||
|
|
||||||
log.info("VPCS {name} [id={id}]: renamed to {new_name}".format(name=self._name,
|
log.info("VPCS {name} [id={id}]: renamed to {new_name}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
new_name=new_name))
|
new_name=new_name))
|
||||||
self._name = new_name
|
self._name = new_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -190,7 +191,7 @@ class VPCSDevice(object):
|
|||||||
:returns: path to VPCS
|
:returns: path to VPCS
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return(self._path)
|
return self._path
|
||||||
|
|
||||||
@path.setter
|
@path.setter
|
||||||
def path(self, path):
|
def path(self, path):
|
||||||
@ -202,8 +203,8 @@ class VPCSDevice(object):
|
|||||||
|
|
||||||
self._path = path
|
self._path = path
|
||||||
log.info("VPCS {name} [id={id}]: path changed to {path}".format(name=self._name,
|
log.info("VPCS {name} [id={id}]: path changed to {path}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
path=path))
|
path=path))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def working_dir(self):
|
def working_dir(self):
|
||||||
@ -234,8 +235,8 @@ class VPCSDevice(object):
|
|||||||
|
|
||||||
self._working_dir = working_dir
|
self._working_dir = working_dir
|
||||||
log.info("VPCS {name} [id={id}]: working directory changed to {wd}".format(name=self._name,
|
log.info("VPCS {name} [id={id}]: working directory changed to {wd}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
wd=self._working_dir))
|
wd=self._working_dir))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def console(self):
|
def console(self):
|
||||||
@ -262,8 +263,8 @@ class VPCSDevice(object):
|
|||||||
self._console = console
|
self._console = console
|
||||||
self._allocated_console_ports.append(self._console)
|
self._allocated_console_ports.append(self._console)
|
||||||
log.info("VPCS {name} [id={id}]: console port set to {port}".format(name=self._name,
|
log.info("VPCS {name} [id={id}]: console port set to {port}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
port=console))
|
port=console))
|
||||||
|
|
||||||
def command(self):
|
def command(self):
|
||||||
"""
|
"""
|
||||||
@ -286,7 +287,7 @@ class VPCSDevice(object):
|
|||||||
self._allocated_console_ports.remove(self.console)
|
self._allocated_console_ports.remove(self.console)
|
||||||
|
|
||||||
log.info("VPCS device {name} [id={id}] has been deleted".format(name=self._name,
|
log.info("VPCS device {name} [id={id}] has been deleted".format(name=self._name,
|
||||||
id=self._id))
|
id=self._id))
|
||||||
|
|
||||||
def clean_delete(self):
|
def clean_delete(self):
|
||||||
"""
|
"""
|
||||||
@ -331,10 +332,10 @@ class VPCSDevice(object):
|
|||||||
raise VPCSError("No path to a VPCS executable has been set")
|
raise VPCSError("No path to a VPCS executable has been set")
|
||||||
|
|
||||||
if not os.path.isfile(self._path):
|
if not os.path.isfile(self._path):
|
||||||
raise VPCSError("VPCS '{}' is not accessible".format(self._path))
|
raise VPCSError("VPCS program '{}' is not accessible".format(self._path))
|
||||||
|
|
||||||
if not os.access(self._path, os.X_OK):
|
if not os.access(self._path, os.X_OK):
|
||||||
raise VPCSError("VPCS '{}' is not executable".format(self._path))
|
raise VPCSError("VPCS program '{}' is not executable".format(self._path))
|
||||||
|
|
||||||
if not self._ethernet_adapter.get_nio(0):
|
if not self._ethernet_adapter.get_nio(0):
|
||||||
raise VPCSError("This VPCS instance must be connected in order to start")
|
raise VPCSError("This VPCS instance must be connected in order to start")
|
||||||
@ -400,7 +401,7 @@ class VPCSDevice(object):
|
|||||||
:returns: True or False
|
:returns: True or False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._process and self._process.poll() == None:
|
if self._process and self._process.poll() is None:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -414,7 +415,7 @@ class VPCSDevice(object):
|
|||||||
|
|
||||||
if not self._ethernet_adapter.port_exists(port_id):
|
if not self._ethernet_adapter.port_exists(port_id):
|
||||||
raise VPCSError("Port {port_id} doesn't exist in adapter {adapter}".format(adapter=self._ethernet_adapter,
|
raise VPCSError("Port {port_id} doesn't exist in adapter {adapter}".format(adapter=self._ethernet_adapter,
|
||||||
port_id=port_id))
|
port_id=port_id))
|
||||||
|
|
||||||
self._ethernet_adapter.add_nio(port_id, nio)
|
self._ethernet_adapter.add_nio(port_id, nio)
|
||||||
log.info("VPCS {name} [id={id}]: {nio} added to port {port_id}".format(name=self._name,
|
log.info("VPCS {name} [id={id}]: {nio} added to port {port_id}".format(name=self._name,
|
||||||
@ -517,7 +518,7 @@ class VPCSDevice(object):
|
|||||||
"""
|
"""
|
||||||
Sets the script-file for this VPCS instance.
|
Sets the script-file for this VPCS instance.
|
||||||
|
|
||||||
:param base_script_file: path to base-script-file
|
:param script_file: path to base-script-file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._script_file = script_file
|
self._script_file = script_file
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
netifaces
|
||||||
tornado
|
tornado
|
||||||
pyzmq
|
pyzmq
|
||||||
netifaces-py3
|
netifaces-py3
|
||||||
|
8
setup.py
8
setup.py
@ -48,12 +48,12 @@ setup(
|
|||||||
"tornado>=3.1",
|
"tornado>=3.1",
|
||||||
"pyzmq>=14.0.0",
|
"pyzmq>=14.0.0",
|
||||||
"jsonschema==2.3.0"
|
"jsonschema==2.3.0"
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": [
|
"console_scripts": [
|
||||||
"gns3server = gns3server.main:main",
|
"gns3server = gns3server.main:main",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
package_data={"gns3server": ["templates/upload.html"]},
|
package_data={"gns3server": ["templates/upload.html"]},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
@ -71,5 +71,5 @@ setup(
|
|||||||
"Programming Language :: Python :: 3.3",
|
"Programming Language :: Python :: 3.3",
|
||||||
"Programming Language :: Python :: 3.4",
|
"Programming Language :: Python :: 3.4",
|
||||||
"Programming Language :: Python :: Implementation :: CPython",
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,7 @@ class JSONRPC(AsyncTestCase):
|
|||||||
AsyncWSRequest(self.URL, self.io_loop, self.stop, json_encode(request))
|
AsyncWSRequest(self.URL, self.io_loop, self.stop, json_encode(request))
|
||||||
response = self.wait()
|
response = self.wait()
|
||||||
json_response = json_decode(response)
|
json_response = json_decode(response)
|
||||||
assert json_response["id"] == None
|
assert json_response["id"] is None
|
||||||
assert json_response["error"].get("code") == -32600
|
assert json_response["error"].get("code") == -32600
|
||||||
|
|
||||||
def test_request_with_invalid_json(self):
|
def test_request_with_invalid_json(self):
|
||||||
@ -49,7 +49,7 @@ class JSONRPC(AsyncTestCase):
|
|||||||
AsyncWSRequest(self.URL, self.io_loop, self.stop, request)
|
AsyncWSRequest(self.URL, self.io_loop, self.stop, request)
|
||||||
response = self.wait()
|
response = self.wait()
|
||||||
json_response = json_decode(response)
|
json_response = json_decode(response)
|
||||||
assert json_response["id"] == None
|
assert json_response["id"] is None
|
||||||
assert json_response["error"].get("code") == -32700
|
assert json_response["error"].get("code") == -32700
|
||||||
|
|
||||||
def test_request_with_invalid_jsonrpc_field(self):
|
def test_request_with_invalid_jsonrpc_field(self):
|
||||||
@ -58,7 +58,7 @@ class JSONRPC(AsyncTestCase):
|
|||||||
AsyncWSRequest(self.URL, self.io_loop, self.stop, json_encode(request))
|
AsyncWSRequest(self.URL, self.io_loop, self.stop, json_encode(request))
|
||||||
response = self.wait()
|
response = self.wait()
|
||||||
json_response = json_decode(response)
|
json_response = json_decode(response)
|
||||||
assert json_response["id"] == None
|
assert json_response["id"] is None
|
||||||
assert json_response["error"].get("code") == -32700
|
assert json_response["error"].get("code") == -32700
|
||||||
|
|
||||||
def test_request_with_no_params(self):
|
def test_request_with_no_params(self):
|
||||||
|
@ -34,7 +34,7 @@ class TestVersionHandler(AsyncHTTPTestCase):
|
|||||||
|
|
||||||
self.http_client.fetch(self.get_url(self.URL), self.stop)
|
self.http_client.fetch(self.get_url(self.URL), self.stop)
|
||||||
response = self.wait()
|
response = self.wait()
|
||||||
assert(response.headers['Content-Type'].startswith('application/json'))
|
assert response.headers['Content-Type'].startswith('application/json')
|
||||||
assert(response.body)
|
assert response.body
|
||||||
body = json_decode(response.body)
|
body = json_decode(response.body)
|
||||||
assert body['version'] == __version__
|
assert body['version'] == __version__
|
||||||
|
Loading…
Reference in New Issue
Block a user