mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
PEP8
This commit is contained in:
1 parent
0695e75e77
commit
68d0e5f42d
18 files changed
+49
-64
No files matched your search
@@ -19,7 +19,7 @@
|
||||
Simple file upload & listing handler.
|
||||
"""
|
||||
|
||||
#TODO: file upload with aiohttp
|
||||
# TODO: file upload with aiohttp
|
||||
|
||||
|
||||
import os
|
||||
|
||||
@@ -31,7 +31,7 @@ class ProjectHandler:
|
||||
def create_project(request, response):
|
||||
pm = ProjectManager.instance()
|
||||
p = pm.create_project(
|
||||
location = request.json.get("location"),
|
||||
uuid = request.json.get("uuid")
|
||||
location=request.json.get("location"),
|
||||
uuid=request.json.get("uuid")
|
||||
)
|
||||
response.json(p)
|
||||
@@ -40,11 +40,11 @@ class VPCSHandler:
|
||||
def create(request, response):
|
||||
|
||||
vpcs = VPCS.instance()
|
||||
vm = yield from vpcs.create_vm(request.json["name"], request.json["project_uuid"], uuid = request.json.get("uuid"))
|
||||
vm = yield from vpcs.create_vm(request.json["name"], request.json["project_uuid"], uuid=request.json.get("uuid"))
|
||||
response.json({"name": vm.name,
|
||||
"uuid": vm.uuid,
|
||||
"console": vm.console,
|
||||
"project_uuid": vm.project.uuid})
|
||||
"project_uuid": vm.project.uuid})
|
||||
|
||||
@classmethod
|
||||
@Route.post(
|
||||
|
||||
@@ -20,8 +20,3 @@ from .vpcs import VPCS
|
||||
from .virtualbox import VirtualBox
|
||||
|
||||
MODULES = [VPCS, VirtualBox]
|
||||
|
||||
#if sys.platform.startswith("linux"):
|
||||
# # IOU runs only on Linux
|
||||
# from .iou import IOU
|
||||
# MODULES.append(IOU)
|
||||
@@ -96,9 +96,9 @@ class BaseManager:
|
||||
"""
|
||||
project = ProjectManager.instance().get_project(project_identifier)
|
||||
|
||||
#TODO: support for old projects VM with normal IDs.
|
||||
# TODO: support for old projects VM with normal IDs.
|
||||
|
||||
#TODO: supports specific args: pass kwargs to VM_CLASS?
|
||||
# TODO: supports specific args: pass kwargs to VM_CLASS?
|
||||
|
||||
if not uuid:
|
||||
uuid = str(uuid4())
|
||||
|
||||
@@ -31,7 +31,7 @@ class BaseVM:
|
||||
self._manager = manager
|
||||
self._config = Config.instance()
|
||||
|
||||
#TODO: When delete release console ports
|
||||
# TODO: When delete release console ports
|
||||
|
||||
@property
|
||||
def project(self):
|
||||
@@ -98,4 +98,3 @@ class BaseVM:
|
||||
"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -61,7 +61,7 @@ class VPCSDevice(BaseVM):
|
||||
|
||||
self._console = console
|
||||
|
||||
#TODO: remove working_dir
|
||||
# TODO: remove working_dir
|
||||
self._working_dir = "/tmp"
|
||||
|
||||
self._command = []
|
||||
@@ -120,7 +120,7 @@ class VPCSDevice(BaseVM):
|
||||
|
||||
return self._console
|
||||
|
||||
#FIXME: correct way to subclass a property?
|
||||
# FIXME: correct way to subclass a property?
|
||||
@BaseVM.name.setter
|
||||
def name(self, new_name):
|
||||
"""
|
||||
@@ -151,7 +151,7 @@ class VPCSDevice(BaseVM):
|
||||
"""
|
||||
Checks if the VPCS executable version is >= 0.5b1.
|
||||
"""
|
||||
#TODO: should be async
|
||||
# TODO: should be async
|
||||
try:
|
||||
output = subprocess.check_output([self._path, "-v"], cwd=self._working_dir)
|
||||
match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)", output.decode("utf-8"))
|
||||
@@ -219,7 +219,7 @@ class VPCSDevice(BaseVM):
|
||||
Reads the standard output of the VPCS process.
|
||||
Only use when the process has been stopped or has crashed.
|
||||
"""
|
||||
#TODO: should be async
|
||||
# TODO: should be async
|
||||
output = ""
|
||||
if self._vpcs_stdout_file:
|
||||
try:
|
||||
@@ -258,7 +258,7 @@ class VPCSDevice(BaseVM):
|
||||
rhost = nio_settings["rhost"]
|
||||
rport = nio_settings["rport"]
|
||||
try:
|
||||
#TODO: handle IPv6
|
||||
# TODO: handle IPv6
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
|
||||
sock.connect((rhost, rport))
|
||||
except OSError as e:
|
||||
@@ -272,7 +272,6 @@ class VPCSDevice(BaseVM):
|
||||
if not nio:
|
||||
raise VPCSError("Requested NIO does not exist or is not supported: {}".format(nio_settings["type"]))
|
||||
|
||||
|
||||
self._ethernet_adapter.add_nio(port_id, nio)
|
||||
log.info("VPCS {name} {uuid}]: {nio} added to port {port_id}".format(name=self._name,
|
||||
uuid=self.uuid,
|
||||
@@ -355,8 +354,8 @@ class VPCSDevice(BaseVM):
|
||||
command.extend(["-e"])
|
||||
command.extend(["-d", nio.tap_device])
|
||||
|
||||
#FIXME: find workaround
|
||||
#command.extend(["-m", str(self._id)]) # the unique ID is used to set the MAC address offset
|
||||
# FIXME: find workaround
|
||||
# command.extend(["-m", str(self._id)]) # the unique ID is used to set the MAC address offset
|
||||
command.extend(["-i", "1"]) # option to start only one VPC instance
|
||||
command.extend(["-F"]) # option to avoid the daemonization of VPCS
|
||||
if self._script_file:
|
||||
|
||||
@@ -36,4 +36,3 @@ PROJECT_OBJECT_SCHEMA = {
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
@@ -78,4 +78,3 @@ VBOX_OBJECT_SCHEMA = {
|
||||
"additionalProperties": False,
|
||||
"required": ["name", "uuid"]
|
||||
}
|
||||
|
||||
@@ -148,4 +148,3 @@ VPCS_OBJECT_SCHEMA = {
|
||||
"additionalProperties": False,
|
||||
"required": ["name", "uuid", "console", "project_uuid"]
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Response(aiohttp.web.Response):
|
||||
|
||||
def __init__(self, route=None, output_schema=None, headers={}, **kwargs):
|
||||
|
||||
Reference in new issue
Block a user