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

Merge branch 'dev' into gns-110

This commit is contained in:
Jerry Seutter 2014-10-28 10:39:03 -06:00
commit 7830bf8b1a
9 changed files with 51 additions and 37 deletions

View File

@ -1,24 +1,37 @@
GNS3-server GNS3-server
=========== ===========
New GNS3 server repository (beta stage). This is the GNS3 server repository.
The GNS3 server manages emulators such as Dynamips, VirtualBox or Qemu/KVM. The GNS3 server manages emulators such as Dynamips, VirtualBox or Qemu/KVM.
Clients like the GNS3 GUI controls the server using a JSON-RPC API over Websockets. Clients like the GNS3 GUI controls the server using a JSON-RPC API over Websockets.
You will need the new GNS3 GUI (gns3-gui repository) to control the server. You will need the GNS3 GUI (gns3-gui repository) to control the server.
Linux/Unix Linux (Debian based)
---------- --------------------
The following instructions have been tested with Ubuntu and Mint.
You must be connected to the Internet in order to install the dependencies.
Dependencies: Dependencies:
- Python version 3.3 or above - Python 3.3 or above
- pip & setuptools must be installed, please see http://pip.readthedocs.org/en/latest/installing.html - Setuptools
(or sudo apt-get install python3-pip but install more packages) - PyZMQ library
- pyzmq, to install: sudo apt-get install python3-zmq or pip3 install pyzmq - Netifaces library
- tornado, to install: sudo apt-get install python3-tornado or pip3 install tornado - Tornado
- netifaces (optional), to install: sudo apt-get install python3-netifaces or pip3 install netifaces-py3 - Jsonschema
The following commands will install some of these dependencies:
.. code:: bash
sudo apt-get install python3-setuptools
sudo apt-get install python3-zmq
sudo apt-get install python3-netifaces
Finally these commands will install the server as well as the rest of the dependencies:
.. code:: bash .. code:: bash
@ -36,7 +49,6 @@ Mac OS X
Please use our DMG package for a simple installation. Please use our DMG package for a simple installation.
If you want to test the current git version or contribute to the project. If you want to test the current git version or contribute to the project.
You can follow this instructions with virtualenwrapper: http://virtualenvwrapper.readthedocs.org/ You can follow this instructions with virtualenwrapper: http://virtualenvwrapper.readthedocs.org/

View File

@ -681,17 +681,17 @@ class VM(object):
@IModule.route("dynamips.vm.idlepcs") @IModule.route("dynamips.vm.idlepcs")
def vm_idlepcs(self, request): def vm_idlepcs(self, request):
""" """
Get idle-pc proposals. Get Idle-PC proposals.
Mandatory request parameters: Mandatory request parameters:
- id (vm identifier) - id (vm identifier)
Optional request parameters: Optional request parameters:
- compute (returns previously compute idle-pc values if False) - compute (returns previously compute Idle-PC values if False)
Response parameters: Response parameters:
- id (vm identifier) - id (vm identifier)
- idlepcs (idle-pc values in an array) - idlepcs (Idle-PC values in an array)
:param request: JSON request :param request: JSON request
""" """
@ -709,7 +709,7 @@ class VM(object):
if "compute" in request and request["compute"] == False: if "compute" in request and request["compute"] == False:
idlepcs = router.show_idle_pc_prop() idlepcs = router.show_idle_pc_prop()
else: else:
# reset the current idle-pc value before calculating a new one # reset the current Idle-PC value before calculating a new one
router.idlepc = "0x0" router.idlepc = "0x0"
idlepcs = router.get_idle_pc_prop() idlepcs = router.get_idle_pc_prop()
except DynamipsError as e: except DynamipsError as e:
@ -723,7 +723,7 @@ class VM(object):
@IModule.route("dynamips.vm.auto_idlepc") @IModule.route("dynamips.vm.auto_idlepc")
def vm_auto_idlepc(self, request): def vm_auto_idlepc(self, request):
""" """
Auto idle-pc calculation. Auto Idle-PC calculation.
Mandatory request parameters: Mandatory request parameters:
- id (vm identifier) - id (vm identifier)
@ -731,7 +731,7 @@ class VM(object):
Response parameters: Response parameters:
- id (vm identifier) - id (vm identifier)
- logs (logs for the calculation) - logs (logs for the calculation)
- idlepc (idle-pc value) - idlepc (Idle-PC value)
:param request: JSON request :param request: JSON request
""" """
@ -746,7 +746,7 @@ class VM(object):
return return
try: try:
router.idlepc = "0x0" # reset the current idle-pc value before calculating a new one router.idlepc = "0x0" # reset the current Idle-PC value before calculating a new one
was_auto_started = False was_auto_started = False
if router.get_status() != "running": if router.get_status() != "running":
router.start() router.start()
@ -757,11 +757,11 @@ class VM(object):
validated_idlepc = "0x0" validated_idlepc = "0x0"
idlepcs = router.get_idle_pc_prop() idlepcs = router.get_idle_pc_prop()
if not idlepcs: if not idlepcs:
logs.append("No idle-pc values found") logs.append("No Idle-PC values found")
for idlepc in idlepcs: for idlepc in idlepcs:
router.idlepc = idlepc.split()[0] router.idlepc = idlepc.split()[0]
logs.append("Trying idle-pc value {}".format(router.idlepc)) logs.append("Trying Idle-PC value {}".format(router.idlepc))
start_time = time.time() start_time = time.time()
initial_cpu_usage = router.get_cpu_usage() initial_cpu_usage = router.get_cpu_usage()
logs.append("Initial CPU usage = {}%".format(initial_cpu_usage)) logs.append("Initial CPU usage = {}%".format(initial_cpu_usage))

View File

@ -804,10 +804,10 @@ class Router(object):
# router is not running # router is not running
raise DynamipsError("router {name} is not running".format(name=self._name)) raise DynamipsError("router {name} is not running".format(name=self._name))
log.info("router {name} [id={id}] has started calculating idle-pc values".format(name=self._name, id=self._id)) log.info("router {name} [id={id}] has started calculating Idle-PC values".format(name=self._name, id=self._id))
begin = time.time() begin = time.time()
idlepcs = self._hypervisor.send("vm get_idle_pc_prop {} 0".format(self._name)) idlepcs = self._hypervisor.send("vm get_idle_pc_prop {} 0".format(self._name))
log.info("router {name} [id={id}] has finished calculating idle-pc values after {time:.4f} seconds".format(name=self._name, log.info("router {name} [id={id}] has finished calculating Idle-PC values after {time:.4f} seconds".format(name=self._name,
id=self._id, id=self._id,
time=time.time() - begin)) time=time.time() - begin))
return idlepcs return idlepcs

View File

@ -204,7 +204,7 @@ VM_UPDATE_SCHEMA = {
"type": "integer" "type": "integer"
}, },
"idlepc": { "idlepc": {
"description": "idle-pc value", "description": "Idle-PC value",
"type": "string", "type": "string",
"pattern": "^(0x[0-9a-fA-F]+)?$" "pattern": "^(0x[0-9a-fA-F]+)?$"
}, },
@ -475,7 +475,7 @@ VM_EXPORT_CONFIG_SCHEMA = {
VM_IDLEPCS_SCHEMA = { VM_IDLEPCS_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to calculate or show idle-pcs for VM instance", "description": "Request validation to calculate or show Idle-PCs for VM instance",
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {
@ -483,7 +483,7 @@ VM_IDLEPCS_SCHEMA = {
"type": "integer" "type": "integer"
}, },
"compute": { "compute": {
"description": "indicates to compute new idle-pc values", "description": "indicates to compute new Idle-PC values",
"type": "boolean" "type": "boolean"
}, },
}, },
@ -493,7 +493,7 @@ VM_IDLEPCS_SCHEMA = {
VM_AUTO_IDLEPC_SCHEMA = { VM_AUTO_IDLEPC_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request an auto idle-pc calculation for this VM instance", "description": "Request an auto Idle-PC calculation for this VM instance",
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {

View File

@ -224,6 +224,8 @@ class TelnetServer(Console):
buf = self._read_cur(bufsize, socket.MSG_DONTWAIT) buf = self._read_cur(bufsize, socket.MSG_DONTWAIT)
except BlockingIOError: except BlockingIOError:
return None return None
except ConnectionResetError:
buf = b''
if not buf: if not buf:
self._disconnect(fileno) self._disconnect(fileno)

View File

@ -628,6 +628,10 @@ class Qemu(IModule):
paths.append(os.path.join(os.environ["PROGRAMFILES(X86)"], "qemu")) paths.append(os.path.join(os.environ["PROGRAMFILES(X86)"], "qemu"))
if "PROGRAMFILES" in os.environ and os.path.exists(os.environ["PROGRAMFILES"]): if "PROGRAMFILES" in os.environ and os.path.exists(os.environ["PROGRAMFILES"]):
paths.append(os.path.join(os.environ["PROGRAMFILES"], "qemu")) paths.append(os.path.join(os.environ["PROGRAMFILES"], "qemu"))
elif sys.platform.startswith("darwin"):
# add specific locations on Mac OS X regardless of what's in $PATH
paths.append("/usr/local/bin")
paths.append("/opt/local/bin")
for path in paths: for path in paths:
try: try:
for f in os.listdir(path): for f in os.listdir(path):

View File

@ -54,7 +54,7 @@ class VirtualBoxController(object):
self._console = 0 self._console = 0
self._adapters = [] self._adapters = []
self._headless = False self._headless = False
self._enable_console = True self._enable_console = False
self._adapter_type = "Automatic" self._adapter_type = "Automatic"
try: try:
@ -143,7 +143,6 @@ class VirtualBoxController(object):
self._get_session() self._get_session()
self._set_network_options() self._set_network_options()
if self._enable_console:
self._set_console_options() self._set_console_options()
progress = self._launch_vm_process() progress = self._launch_vm_process()
@ -217,7 +216,6 @@ class VirtualBoxController(object):
if self._adapters[adapter_id] is None: if self._adapters[adapter_id] is None:
continue continue
self._disable_adapter(adapter_id, disable=True) self._disable_adapter(adapter_id, disable=True)
if self._enable_console:
serial_port = self._session.machine.getSerialPort(0) serial_port = self._session.machine.getSerialPort(0)
serial_port.enabled = False serial_port.enabled = False
self._session.machine.saveSettings() self._session.machine.saveSettings()

View File

@ -13,10 +13,8 @@ File: <input type="file" name="file" />
</form> </form>
{%if items%} {%if items%}
<h3>Files on {{host}}</h3> <h3>Files on {{host}}</h3>
<ul>
{%for item in items%} {%for item in items%}
<li>{{path}}/{{item}}</a></li> <p>{{path}}/{{item}}</a></p>
{%end%} {%end%}
{%end%} {%end%}
</ul>
</body> </body>

View File

@ -23,5 +23,5 @@
# or negative for a release candidate or beta (after the base version # or negative for a release candidate or beta (after the base version
# number has been incremented) # number has been incremented)
__version__ = "1.0.dev1" __version__ = "1.2.dev1"
__version_info__ = (1, 0, 0, -99) __version_info__ = (1, 2, 0, 99)