1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-23 23:38:21 +00:00

Adapters support for VirtualBox.

This commit is contained in:
grossmj 2015-01-22 21:31:26 -07:00
parent 2a8823b856
commit e61e976368
3 changed files with 29 additions and 12 deletions

View File

@ -95,6 +95,7 @@ class BaseManager:
return self._config
@classmethod
@asyncio.coroutine
def unload(cls):
# TODO: close explicitly all the VMs here?

View File

@ -33,7 +33,7 @@ import shutil
from pkg_resources import parse_version
from .virtualbox_error import VirtualBoxError
from ..adapters.ethernet_adapter import EthernetAdapter
from .telnet_server import TelnetServer
from .telnet_server import TelnetServer # port TelnetServer to asyncio
from ..base_vm import BaseVM
if sys.platform.startswith('win'):
@ -70,22 +70,18 @@ class VirtualBoxVM(BaseVM):
self._adapter_start_index = 0
self._adapter_type = "Intel PRO/1000 MT Desktop (82540EM)"
# TODO: finish adapters support
# self.adapters = 2 # creates 2 adapters by default
def __json__(self):
# TODO: send adapters info
# "adapter_start_index": self._adapter_start_index,
# "adapter_type": "Intel PRO/1000 MT Desktop (82540EM)",
return {"name": self.name,
"uuid": self.uuid,
"project_uuid": self.project.uuid,
"vmname": self.vmname,
"linked_clone": self.linked_clone,
"headless": self.headless,
"enable_remote_console": self.enable_remote_console}
"enable_remote_console": self.enable_remote_console,
"adapters": self.adapters,
"adapter_type": self.adapter_type,
"adapter_start_index": self.adapter_start_index}
@asyncio.coroutine
def _execute(self, subcommand, args, timeout=60):
@ -204,6 +200,9 @@ class VirtualBoxVM(BaseVM):
else:
yield from self._create_linked_clone()
# set 2 adapters by default
# yield from self.set_adapters(2)
@asyncio.coroutine
def start(self):
"""
@ -526,8 +525,8 @@ class VirtualBoxVM(BaseVM):
return len(self._ethernet_adapters)
@adapters.setter
def adapters(self, adapters):
@asyncio.coroutine
def set_adapters(self, adapters):
"""
Sets the number of Ethernet adapters for this VirtualBox VM instance.
@ -535,7 +534,7 @@ class VirtualBoxVM(BaseVM):
"""
# check for the maximum adapters supported by the VM
self._maximum_adapters = self._get_maximum_supported_adapters()
self._maximum_adapters = yield from self._get_maximum_supported_adapters()
if len(self._ethernet_adapters) > self._maximum_adapters:
raise VirtualBoxError("Number of adapters above the maximum supported of {}".format(self._maximum_adapters))

View File

@ -99,6 +99,23 @@ VBOX_OBJECT_SCHEMA = {
"description": "headless mode",
"type": "boolean"
},
"adapters": {
"description": "number of adapters",
"type": "integer",
"minimum": 0,
"maximum": 36, # maximum given by the ICH9 chipset in VirtualBox
},
"adapter_start_index": {
"description": "adapter index from which to start using adapters",
"type": "integer",
"minimum": 0,
"maximum": 35, # maximum given by the ICH9 chipset in VirtualBox
},
"adapter_type": {
"description": "VirtualBox adapter type",
"type": "string",
"minLength": 1,
},
"console": {
"description": "console TCP port",
"minimum": 1,