mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-17 01:04:51 +02:00
New Dynamips integration part 2
This commit is contained in:
parent
f0add73d80
commit
37945585b9
@ -48,7 +48,8 @@ class DynamipsHandler:
|
||||
dynamips_manager = Dynamips.instance()
|
||||
vm = yield from dynamips_manager.create_vm(request.json.pop("name"),
|
||||
request.match_info["project_id"],
|
||||
request.json.get("vm_id"))
|
||||
request.json.get("vm_id"),
|
||||
request.json.pop("platform"))
|
||||
|
||||
#for name, value in request.json.items():
|
||||
# if hasattr(vm, name) and getattr(vm, name) != value:
|
||||
|
@ -99,11 +99,12 @@ from ..base_manager import BaseManager
|
||||
from .dynamips_error import DynamipsError
|
||||
from .hypervisor import Hypervisor
|
||||
from .nodes.router import Router
|
||||
from .dynamips_vm import DynamipsVM
|
||||
|
||||
|
||||
class Dynamips(BaseManager):
|
||||
|
||||
_VM_CLASS = Router
|
||||
_VM_CLASS = DynamipsVM
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@ -112,7 +113,7 @@ class Dynamips(BaseManager):
|
||||
|
||||
# FIXME: temporary
|
||||
self._working_dir = "/tmp"
|
||||
self._dynamips_path = "/usr/local/bin/dynamips"
|
||||
self._dynamips_path = "/usr/bin/dynamips"
|
||||
|
||||
def find_dynamips(self):
|
||||
|
||||
|
50
gns3server/modules/dynamips/dynamips_vm.py
Normal file
50
gns3server/modules/dynamips/dynamips_vm.py
Normal file
@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2015 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from .dynamips_error import DynamipsError
|
||||
from .nodes.c1700 import C1700
|
||||
from .nodes.c2600 import C2600
|
||||
from .nodes.c2691 import C2691
|
||||
from .nodes.c3600 import C3600
|
||||
from .nodes.c3725 import C3725
|
||||
from .nodes.c3745 import C3745
|
||||
from .nodes.c7200 import C7200
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = {'c1700': C1700,
|
||||
'c2600': C2600,
|
||||
'c2691': C2691,
|
||||
'c3725': C3725,
|
||||
'c3745': C3745,
|
||||
'c3600': C3600,
|
||||
'c7200': C7200}
|
||||
|
||||
|
||||
class DynamipsVM:
|
||||
"""
|
||||
Factory to create an Router object based on the correct platform.
|
||||
"""
|
||||
|
||||
def __new__(cls, name, vm_id, project, manager, platform, **kwargs):
|
||||
|
||||
if platform not in PLATFORMS:
|
||||
raise DynamipsError("Unknown router platform: {}".format(platform))
|
||||
|
||||
return PLATFORMS[platform](name, vm_id, project, manager, **kwargs)
|
@ -20,6 +20,7 @@ Interface for Dynamips virtual Cisco 1700 instances module ("c1700")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L428
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from .router import Router
|
||||
from ..adapters.c1700_mb_1fe import C1700_MB_1FE
|
||||
from ..adapters.c1700_mb_wic1 import C1700_MB_WIC1
|
||||
@ -32,16 +33,17 @@ class C1700(Router):
|
||||
"""
|
||||
Dynamips c1700 router.
|
||||
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
:param name: name for this router
|
||||
:param router_id: router instance ID
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param chassis: chassis for this router:
|
||||
1720, 1721, 1750, 1751 or 1760 (default = 1720).
|
||||
1710 is not supported.
|
||||
"""
|
||||
|
||||
def __init__(self, hypervisor, name, router_id=None, chassis="1720"):
|
||||
Router.__init__(self, hypervisor, name, router_id, platform="c1700")
|
||||
def __init__(self, name, vm_id, project, manager, chassis="1720"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c1700")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 128
|
||||
@ -51,43 +53,25 @@ class C1700(Router):
|
||||
self._chassis = chassis
|
||||
self._iomem = 15 # percentage
|
||||
self._clock_divisor = 8
|
||||
self._sparsemem = False
|
||||
self._sparsemem = False # never activate sparsemem for c1700 (unstable)
|
||||
|
||||
if chassis != "1720":
|
||||
self.chassis = chassis
|
||||
def __json__(self):
|
||||
|
||||
self._setup_chassis()
|
||||
|
||||
def defaults(self):
|
||||
"""
|
||||
Returns all the default attribute values for this platform.
|
||||
|
||||
:returns: default values (dictionary)
|
||||
"""
|
||||
|
||||
router_defaults = Router.defaults(self)
|
||||
|
||||
platform_defaults = {"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"disk0": self._disk0,
|
||||
"disk1": self._disk1,
|
||||
c1700_router_info = {"iomem": self._iomem,
|
||||
"chassis": self._chassis,
|
||||
"iomem": self._iomem,
|
||||
"clock_divisor": self._clock_divisor,
|
||||
"sparsemem": self._sparsemem}
|
||||
|
||||
# update the router defaults with the platform specific defaults
|
||||
router_defaults.update(platform_defaults)
|
||||
return router_defaults
|
||||
router_info = Router.__json__(self)
|
||||
router_info.update(c1700_router_info)
|
||||
return router_info
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Returns all c1700 instances
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
:returns: c1700 instance list
|
||||
"""
|
||||
|
||||
return self._hypervisor.send("c1700 list")
|
||||
yield from Router.create(self)
|
||||
if self._chassis != "1720":
|
||||
yield from self.set_chassis(self._chassis)
|
||||
self._setup_chassis()
|
||||
|
||||
def _setup_chassis(self):
|
||||
"""
|
||||
@ -114,8 +98,8 @@ class C1700(Router):
|
||||
|
||||
return self._chassis
|
||||
|
||||
@chassis.setter
|
||||
def chassis(self, chassis):
|
||||
@asyncio.coroutine
|
||||
def set_chassis(self, chassis):
|
||||
"""
|
||||
Sets the chassis.
|
||||
|
||||
@ -123,12 +107,11 @@ class C1700(Router):
|
||||
1720, 1721, 1750, 1751 or 1760
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c1700 set_chassis {name} {chassis}".format(name=self._name,
|
||||
chassis=chassis))
|
||||
yield from self._hypervisor.send('c1700 set_chassis "{name}" {chassis}'.format(name=self._name, chassis=chassis))
|
||||
|
||||
log.info("router {name} [id={id}]: chassis set to {chassis}".format(name=self._name,
|
||||
id=self._id,
|
||||
chassis=chassis))
|
||||
log.info('Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name,
|
||||
id=self._id,
|
||||
chassis=chassis))
|
||||
|
||||
self._chassis = chassis
|
||||
self._setup_chassis()
|
||||
@ -143,19 +126,18 @@ class C1700(Router):
|
||||
|
||||
return self._iomem
|
||||
|
||||
@iomem.setter
|
||||
def iomem(self, iomem):
|
||||
@asyncio.coroutine
|
||||
def set_iomem(self, iomem):
|
||||
"""
|
||||
Sets I/O memory size for this router.
|
||||
|
||||
:param iomem: I/O memory size
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c1700 set_iomem {name} {size}".format(name=self._name,
|
||||
size=iomem))
|
||||
yield from self._hypervisor.send('c1700 set_iomem "{name}" {size}'.format(name=self._name, size=iomem))
|
||||
|
||||
log.info("router {name} [id={id}]: I/O memory updated from {old_iomem}% to {new_iomem}%".format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
log.info('Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
self._iomem = iomem
|
||||
|
@ -20,6 +20,7 @@ Interface for Dynamips virtual Cisco 2600 instances module ("c2600")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L404
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from .router import Router
|
||||
from ..adapters.c2600_mb_1e import C2600_MB_1E
|
||||
from ..adapters.c2600_mb_2e import C2600_MB_2E
|
||||
@ -34,9 +35,10 @@ class C2600(Router):
|
||||
"""
|
||||
Dynamips c2600 router.
|
||||
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
:param name: name for this router
|
||||
:param router_id: router instance ID
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param chassis: chassis for this router:
|
||||
2610, 2611, 2620, 2621, 2610XM, 2611XM
|
||||
2620XM, 2621XM, 2650XM or 2651XM (default = 2610).
|
||||
@ -55,8 +57,8 @@ class C2600(Router):
|
||||
"2650XM": C2600_MB_1FE,
|
||||
"2651XM": C2600_MB_2FE}
|
||||
|
||||
def __init__(self, hypervisor, name, router_id=None, chassis="2610"):
|
||||
Router.__init__(self, hypervisor, name, router_id, platform="c2600")
|
||||
def __init__(self, name, vm_id, project, manager, chassis="2610"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c2600")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 128
|
||||
@ -66,43 +68,25 @@ class C2600(Router):
|
||||
self._chassis = chassis
|
||||
self._iomem = 15 # percentage
|
||||
self._clock_divisor = 8
|
||||
self._sparsemem = False
|
||||
self._sparsemem = False # never activate sparsemem for c2600 (unstable)
|
||||
|
||||
if chassis != "2610":
|
||||
self.chassis = chassis
|
||||
def __json__(self):
|
||||
|
||||
self._setup_chassis()
|
||||
|
||||
def defaults(self):
|
||||
"""
|
||||
Returns all the default attribute values for this platform.
|
||||
|
||||
:returns: default values (dictionary)
|
||||
"""
|
||||
|
||||
router_defaults = Router.defaults(self)
|
||||
|
||||
platform_defaults = {"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"disk0": self._disk0,
|
||||
"disk1": self._disk1,
|
||||
"iomem": self._iomem,
|
||||
c2600_router_info = {"iomem": self._iomem,
|
||||
"chassis": self._chassis,
|
||||
"clock_divisor": self._clock_divisor,
|
||||
"sparsemem": self._sparsemem}
|
||||
|
||||
# update the router defaults with the platform specific defaults
|
||||
router_defaults.update(platform_defaults)
|
||||
return router_defaults
|
||||
router_info = Router.__json__(self)
|
||||
router_info.update(c2600_router_info)
|
||||
return router_info
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Returns all c2600 instances
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
:returns: c2600 instance list
|
||||
"""
|
||||
|
||||
return self._hypervisor.send("c2600 list")
|
||||
yield from Router.create(self)
|
||||
if self._chassis != "2610":
|
||||
yield from self.set_chassis(self._chassis)
|
||||
self._setup_chassis()
|
||||
|
||||
def _setup_chassis(self):
|
||||
"""
|
||||
@ -123,8 +107,8 @@ class C2600(Router):
|
||||
|
||||
return self._chassis
|
||||
|
||||
@chassis.setter
|
||||
def chassis(self, chassis):
|
||||
@asyncio.coroutine
|
||||
def set_chassis(self, chassis):
|
||||
"""
|
||||
Sets the chassis.
|
||||
|
||||
@ -133,12 +117,11 @@ class C2600(Router):
|
||||
2620XM, 2621XM, 2650XM or 2651XM
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c2600 set_chassis {name} {chassis}".format(name=self._name,
|
||||
chassis=chassis))
|
||||
yield from self._hypervisor.send('c2600 set_chassis "{name}" {chassis}'.format(name=self._name, chassis=chassis))
|
||||
|
||||
log.info("router {name} [id={id}]: chassis set to {chassis}".format(name=self._name,
|
||||
id=self._id,
|
||||
chassis=chassis))
|
||||
log.info('Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name,
|
||||
id=self._id,
|
||||
chassis=chassis))
|
||||
self._chassis = chassis
|
||||
self._setup_chassis()
|
||||
|
||||
@ -152,19 +135,18 @@ class C2600(Router):
|
||||
|
||||
return self._iomem
|
||||
|
||||
@iomem.setter
|
||||
def iomem(self, iomem):
|
||||
@asyncio.coroutine
|
||||
def set_iomem(self, iomem):
|
||||
"""
|
||||
Sets I/O memory size for this router.
|
||||
|
||||
:param iomem: I/O memory size
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c2600 set_iomem {name} {size}".format(name=self._name,
|
||||
size=iomem))
|
||||
yield from self._hypervisor.send('c2600 set_iomem "{name}" {size}'.format(name=self._name, size=iomem))
|
||||
|
||||
log.info("router {name} [id={id}]: I/O memory updated from {old_iomem}% to {new_iomem}%".format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
log.info('Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
self._iomem = iomem
|
||||
|
@ -20,6 +20,7 @@ Interface for Dynamips virtual Cisco 2691 instances module ("c2691")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L387
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from .router import Router
|
||||
from ..adapters.gt96100_fe import GT96100_FE
|
||||
|
||||
@ -31,13 +32,14 @@ class C2691(Router):
|
||||
"""
|
||||
Dynamips c2691 router.
|
||||
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
:param name: name for this router
|
||||
:param router_id: router instance ID
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
"""
|
||||
|
||||
def __init__(self, hypervisor, name, router_id=None):
|
||||
Router.__init__(self, hypervisor, name, router_id, platform="c2691")
|
||||
def __init__(self, name, vm_id, project, manager):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c2691")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 192
|
||||
@ -50,34 +52,13 @@ class C2691(Router):
|
||||
self._create_slots(2)
|
||||
self._slots[0] = GT96100_FE()
|
||||
|
||||
def defaults(self):
|
||||
"""
|
||||
Returns all the default attribute values for this platform.
|
||||
def __json__(self):
|
||||
|
||||
:returns: default values (dictionary)
|
||||
"""
|
||||
c2691_router_info = {"iomem": self._iomem}
|
||||
|
||||
router_defaults = Router.defaults(self)
|
||||
|
||||
platform_defaults = {"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"disk0": self._disk0,
|
||||
"disk1": self._disk1,
|
||||
"iomem": self._iomem,
|
||||
"clock_divisor": self._clock_divisor}
|
||||
|
||||
# update the router defaults with the platform specific defaults
|
||||
router_defaults.update(platform_defaults)
|
||||
return router_defaults
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Returns all c2691 instances
|
||||
|
||||
:returns: c2691 instance list
|
||||
"""
|
||||
|
||||
return self._hypervisor.send("c2691 list")
|
||||
router_info = Router.__json__(self)
|
||||
router_info.update(c2691_router_info)
|
||||
return router_info
|
||||
|
||||
@property
|
||||
def iomem(self):
|
||||
@ -89,19 +70,18 @@ class C2691(Router):
|
||||
|
||||
return self._iomem
|
||||
|
||||
@iomem.setter
|
||||
def iomem(self, iomem):
|
||||
@asyncio.coroutine
|
||||
def set_iomem(self, iomem):
|
||||
"""
|
||||
Sets I/O memory size for this router.
|
||||
|
||||
:param iomem: I/O memory size
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c2691 set_iomem {name} {size}".format(name=self._name,
|
||||
size=iomem))
|
||||
yield from self._hypervisor.send('c2691 set_iomem "{name}" {size}'.format(name=self._name, size=iomem))
|
||||
|
||||
log.info("router {name} [id={id}]: I/O memory updated from {old_iomem}% to {new_iomem}%".format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
log.info('Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
self._iomem = iomem
|
||||
|
@ -20,6 +20,7 @@ Interface for Dynamips virtual Cisco 3600 instances module ("c3600")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L366
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from .router import Router
|
||||
from ..adapters.leopard_2fe import Leopard_2FE
|
||||
|
||||
@ -31,15 +32,16 @@ class C3600(Router):
|
||||
"""
|
||||
Dynamips c3600 router.
|
||||
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
:param name: name for this router
|
||||
:param router_id: router instance ID
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param chassis: chassis for this router:
|
||||
3620, 3640 or 3660 (default = 3640).
|
||||
"""
|
||||
|
||||
def __init__(self, hypervisor, name, router_id=None, chassis="3640"):
|
||||
Router.__init__(self, hypervisor, name, router_id, platform="c3600")
|
||||
def __init__(self, name, vm_id, project, manager, chassis="3640"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c3600")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 192
|
||||
@ -50,41 +52,23 @@ class C3600(Router):
|
||||
self._chassis = chassis
|
||||
self._clock_divisor = 4
|
||||
|
||||
if chassis != "3640":
|
||||
self.chassis = chassis
|
||||
def __json__(self):
|
||||
|
||||
c3600_router_info = {"iomem": self._iomem,
|
||||
"chassis": self._chassis}
|
||||
|
||||
router_info = Router.__json__(self)
|
||||
router_info.update(c3600_router_info)
|
||||
return router_info
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
yield from Router.create(self)
|
||||
if self._chassis != "3640":
|
||||
yield from self.set_chassis(self._chassis)
|
||||
self._setup_chassis()
|
||||
|
||||
def defaults(self):
|
||||
"""
|
||||
Returns all the default attribute values for this platform.
|
||||
|
||||
:returns: default values (dictionary)
|
||||
"""
|
||||
|
||||
router_defaults = Router.defaults(self)
|
||||
|
||||
platform_defaults = {"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"disk0": self._disk0,
|
||||
"disk1": self._disk1,
|
||||
"iomem": self._iomem,
|
||||
"chassis": self._chassis,
|
||||
"clock_divisor": self._clock_divisor}
|
||||
|
||||
# update the router defaults with the platform specific defaults
|
||||
router_defaults.update(platform_defaults)
|
||||
return router_defaults
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Returns all c3600 instances
|
||||
|
||||
:returns: c3600 instance list
|
||||
"""
|
||||
|
||||
return self._hypervisor.send("c3600 list")
|
||||
|
||||
def _setup_chassis(self):
|
||||
"""
|
||||
Sets up the router with the corresponding chassis
|
||||
@ -109,20 +93,19 @@ class C3600(Router):
|
||||
|
||||
return self._chassis
|
||||
|
||||
@chassis.setter
|
||||
def chassis(self, chassis):
|
||||
@asyncio.coroutine
|
||||
def set_chassis(self, chassis):
|
||||
"""
|
||||
Sets the chassis.
|
||||
|
||||
:param: chassis string: 3620, 3640 or 3660
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c3600 set_chassis {name} {chassis}".format(name=self._name,
|
||||
chassis=chassis))
|
||||
yield from self._hypervisor.send('c3600 set_chassis "{name}" {chassis}'.format(name=self._name, chassis=chassis))
|
||||
|
||||
log.info("router {name} [id={id}]: chassis set to {chassis}".format(name=self._name,
|
||||
id=self._id,
|
||||
chassis=chassis))
|
||||
log.info('Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name,
|
||||
id=self._id,
|
||||
chassis=chassis))
|
||||
|
||||
self._chassis = chassis
|
||||
self._setup_chassis()
|
||||
@ -137,19 +120,18 @@ class C3600(Router):
|
||||
|
||||
return self._iomem
|
||||
|
||||
@iomem.setter
|
||||
def iomem(self, iomem):
|
||||
@asyncio.coroutine
|
||||
def set_iomem(self, iomem):
|
||||
"""
|
||||
Set I/O memory size for this router.
|
||||
|
||||
:param iomem: I/O memory size
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c3600 set_iomem {name} {size}".format(name=self._name,
|
||||
size=iomem))
|
||||
yield from self._hypervisor.send('c3600 set_iomem "{name}" {size}'.format(name=self._name, size=iomem))
|
||||
|
||||
log.info("router {name} [id={id}]: I/O memory updated from {old_iomem}% to {new_iomem}%".format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
log.info('Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
self._iomem = iomem
|
||||
|
@ -20,6 +20,7 @@ Interface for Dynamips virtual Cisco 3725 instances module ("c3725")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L346
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from .router import Router
|
||||
from ..adapters.gt96100_fe import GT96100_FE
|
||||
|
||||
@ -31,13 +32,14 @@ class C3725(Router):
|
||||
"""
|
||||
Dynamips c3725 router.
|
||||
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
:param name: name for this router
|
||||
:param router_id: router instance ID
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
"""
|
||||
|
||||
def __init__(self, hypervisor, name, router_id=None):
|
||||
Router.__init__(self, hypervisor, name, router_id, platform="c3725")
|
||||
def __init__(self, name, vm_id, project, manager):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c3725")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 128
|
||||
@ -50,34 +52,13 @@ class C3725(Router):
|
||||
self._create_slots(3)
|
||||
self._slots[0] = GT96100_FE()
|
||||
|
||||
def defaults(self):
|
||||
"""
|
||||
Returns all the default attribute values for this platform.
|
||||
def __json__(self):
|
||||
|
||||
:returns: default values (dictionary)
|
||||
"""
|
||||
c3725_router_info = {"iomem": self._iomem}
|
||||
|
||||
router_defaults = Router.defaults(self)
|
||||
|
||||
platform_defaults = {"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"disk0": self._disk0,
|
||||
"disk1": self._disk1,
|
||||
"iomem": self._iomem,
|
||||
"clock_divisor": self._clock_divisor}
|
||||
|
||||
# update the router defaults with the platform specific defaults
|
||||
router_defaults.update(platform_defaults)
|
||||
return router_defaults
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Returns all c3725 instances.
|
||||
|
||||
:returns: c3725 instance list
|
||||
"""
|
||||
|
||||
return self._hypervisor.send("c3725 list")
|
||||
router_info = Router.__json__(self)
|
||||
router_info.update(c3725_router_info)
|
||||
return router_info
|
||||
|
||||
@property
|
||||
def iomem(self):
|
||||
@ -89,19 +70,18 @@ class C3725(Router):
|
||||
|
||||
return self._iomem
|
||||
|
||||
@iomem.setter
|
||||
def iomem(self, iomem):
|
||||
@asyncio.coroutine
|
||||
def set_iomem(self, iomem):
|
||||
"""
|
||||
Sets I/O memory size for this router.
|
||||
|
||||
:param iomem: I/O memory size
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c3725 set_iomem {name} {size}".format(name=self._name,
|
||||
size=iomem))
|
||||
yield from self._hypervisor.send('c3725 set_iomem "{name}" {size}'.format(name=self._name, size=iomem))
|
||||
|
||||
log.info("router {name} [id={id}]: I/O memory updated from {old_iomem}% to {new_iomem}%".format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
log.info('Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
self._iomem = iomem
|
||||
|
@ -20,6 +20,7 @@ Interface for Dynamips virtual Cisco 3745 instances module ("c3745")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L326
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from .router import Router
|
||||
from ..adapters.gt96100_fe import GT96100_FE
|
||||
|
||||
@ -31,13 +32,14 @@ class C3745(Router):
|
||||
"""
|
||||
Dynamips c3745 router.
|
||||
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
:param name: name for this router
|
||||
:param router_id: router instance ID
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
"""
|
||||
|
||||
def __init__(self, hypervisor, name, router_id=None):
|
||||
Router.__init__(self, hypervisor, name, router_id, platform="c3745")
|
||||
def __init__(self, name, vm_id, project, manager):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c3745")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 256
|
||||
@ -50,34 +52,13 @@ class C3745(Router):
|
||||
self._create_slots(5)
|
||||
self._slots[0] = GT96100_FE()
|
||||
|
||||
def defaults(self):
|
||||
"""
|
||||
Returns all the default attribute values for this platform.
|
||||
def __json__(self):
|
||||
|
||||
:returns: default values (dictionary)
|
||||
"""
|
||||
c3745_router_info = {"iomem": self._iomem}
|
||||
|
||||
router_defaults = Router.defaults(self)
|
||||
|
||||
platform_defaults = {"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"disk0": self._disk0,
|
||||
"disk1": self._disk1,
|
||||
"iomem": self._iomem,
|
||||
"clock_divisor": self._clock_divisor}
|
||||
|
||||
# update the router defaults with the platform specific defaults
|
||||
router_defaults.update(platform_defaults)
|
||||
return router_defaults
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Returns all c3745 instances.
|
||||
|
||||
:returns: c3745 instance list
|
||||
"""
|
||||
|
||||
return self._hypervisor.send("c3745 list")
|
||||
router_info = Router.__json__(self)
|
||||
router_info.update(c3745_router_info)
|
||||
return router_info
|
||||
|
||||
@property
|
||||
def iomem(self):
|
||||
@ -89,19 +70,18 @@ class C3745(Router):
|
||||
|
||||
return self._iomem
|
||||
|
||||
@iomem.setter
|
||||
def iomem(self, iomem):
|
||||
@asyncio.coroutine
|
||||
def set_iomem(self, iomem):
|
||||
"""
|
||||
Sets I/O memory size for this router.
|
||||
|
||||
:param iomem: I/O memory size
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c3745 set_iomem {name} {size}".format(name=self._name,
|
||||
size=iomem))
|
||||
yield from self._hypervisor.send('c3745 set_iomem "{name}" {size}'.format(name=self._name, size=iomem))
|
||||
|
||||
log.info("router {name} [id={id}]: I/O memory updated from {old_iomem}% to {new_iomem}%".format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
log.info('Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_iomem=self._iomem,
|
||||
new_iomem=iomem))
|
||||
self._iomem = iomem
|
||||
|
@ -20,6 +20,8 @@ Interface for Dynamips virtual Cisco 7200 instances module ("c7200")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L294
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
|
||||
from ..dynamips_error import DynamipsError
|
||||
from .router import Router
|
||||
from ..adapters.c7200_io_fe import C7200_IO_FE
|
||||
@ -33,14 +35,15 @@ class C7200(Router):
|
||||
"""
|
||||
Dynamips c7200 router (model is 7206).
|
||||
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
:param name: name for this router
|
||||
:param router_id: router instance ID
|
||||
:param npe: default NPE
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param npe: Default NPE
|
||||
"""
|
||||
|
||||
def __init__(self, hypervisor, name, router_id=None, npe="npe-400"):
|
||||
Router.__init__(self, hypervisor, name, router_id, platform="c7200")
|
||||
def __init__(self, name, vm_id, project, manager, npe="npe-400"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c7200")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 512
|
||||
@ -50,9 +53,7 @@ class C7200(Router):
|
||||
self._npe = npe
|
||||
self._midplane = "vxr"
|
||||
self._clock_divisor = 4
|
||||
|
||||
if npe != "npe-400":
|
||||
self.npe = npe
|
||||
self._npe = npe
|
||||
|
||||
# 4 sensors with a default temperature of 22C:
|
||||
# sensor 1 = I/0 controller inlet
|
||||
@ -66,43 +67,30 @@ class C7200(Router):
|
||||
|
||||
self._create_slots(7)
|
||||
|
||||
# first slot is a mandatory Input/Output controller (based on NPE type)
|
||||
if npe == "npe-g2":
|
||||
self.slot_add_binding(0, C7200_IO_GE_E())
|
||||
else:
|
||||
self.slot_add_binding(0, C7200_IO_FE())
|
||||
def __json__(self):
|
||||
|
||||
def defaults(self):
|
||||
"""
|
||||
Returns all the default attribute values for this platform.
|
||||
|
||||
:returns: default values (dictionary)
|
||||
"""
|
||||
|
||||
router_defaults = Router.defaults(self)
|
||||
|
||||
platform_defaults = {"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"disk0": self._disk0,
|
||||
"disk1": self._disk1,
|
||||
"npe": self._npe,
|
||||
c7200_router_info = {"npe": self._npe,
|
||||
"midplane": self._midplane,
|
||||
"clock_divisor": self._clock_divisor,
|
||||
"sensors": self._sensors,
|
||||
"power_supplies": self._power_supplies}
|
||||
|
||||
# update the router defaults with the platform specific defaults
|
||||
router_defaults.update(platform_defaults)
|
||||
return router_defaults
|
||||
router_info = Router.__json__(self)
|
||||
router_info.update(c7200_router_info)
|
||||
return router_info
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Returns all c7200 instances.
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
:returns: c7200 instance list
|
||||
"""
|
||||
yield from Router.create(self)
|
||||
|
||||
return self._hypervisor.send("c7200 list")
|
||||
if self._npe != "npe-400":
|
||||
yield from self.set_npe(self._npe)
|
||||
|
||||
# first slot is a mandatory Input/Output controller (based on NPE type)
|
||||
if self.npe == "npe-g2":
|
||||
yield from self.slot_add_binding(0, C7200_IO_GE_E())
|
||||
else:
|
||||
yield from self.slot_add_binding(0, C7200_IO_FE())
|
||||
|
||||
@property
|
||||
def npe(self):
|
||||
@ -114,8 +102,8 @@ class C7200(Router):
|
||||
|
||||
return self._npe
|
||||
|
||||
@npe.setter
|
||||
def npe(self, npe):
|
||||
@asyncio.coroutine
|
||||
def set_npe(self, npe):
|
||||
"""
|
||||
Sets the NPE model.
|
||||
|
||||
@ -127,13 +115,12 @@ class C7200(Router):
|
||||
if self.is_running():
|
||||
raise DynamipsError("Cannot change NPE on running router")
|
||||
|
||||
self._hypervisor.send("c7200 set_npe {name} {npe}".format(name=self._name,
|
||||
npe=npe))
|
||||
yield from self._hypervisor.send('c7200 set_npe "{name}" {npe}'.format(name=self._name, npe=npe))
|
||||
|
||||
log.info("router {name} [id={id}]: NPE updated from {old_npe} to {new_npe}".format(name=self._name,
|
||||
id=self._id,
|
||||
old_npe=self._npe,
|
||||
new_npe=npe))
|
||||
log.info('Router "{name}" [{id}]: NPE updated from {old_npe} to {new_npe}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_npe=self._npe,
|
||||
new_npe=npe))
|
||||
self._npe = npe
|
||||
|
||||
@property
|
||||
@ -146,21 +133,20 @@ class C7200(Router):
|
||||
|
||||
return self._midplane
|
||||
|
||||
@midplane.setter
|
||||
def midplane(self, midplane):
|
||||
@asyncio.coroutine
|
||||
def set_midplane(self, midplane):
|
||||
"""
|
||||
Sets the midplane model.
|
||||
|
||||
:returns: midplane model string (e.g. "vxr" or "std")
|
||||
"""
|
||||
|
||||
self._hypervisor.send("c7200 set_midplane {name} {midplane}".format(name=self._name,
|
||||
midplane=midplane))
|
||||
yield from self._hypervisor.send('c7200 set_midplane "{name}" {midplane}'.format(name=self._name, midplane=midplane))
|
||||
|
||||
log.info("router {name} [id={id}]: midplane updated from {old_midplane} to {new_midplane}".format(name=self._name,
|
||||
id=self._id,
|
||||
old_midplane=self._midplane,
|
||||
new_midplane=midplane))
|
||||
log.info('Router "{name}" [{id}]: midplane updated from {old_midplane} to {new_midplane}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_midplane=self._midplane,
|
||||
new_midplane=midplane))
|
||||
self._midplane = midplane
|
||||
|
||||
@property
|
||||
@ -173,8 +159,8 @@ class C7200(Router):
|
||||
|
||||
return self._sensors
|
||||
|
||||
@sensors.setter
|
||||
def sensors(self, sensors):
|
||||
@asyncio.coroutine
|
||||
def set_sensors(self, sensors):
|
||||
"""
|
||||
Sets the 4 sensors with temperature in degree Celcius.
|
||||
|
||||
@ -188,15 +174,15 @@ class C7200(Router):
|
||||
|
||||
sensor_id = 0
|
||||
for sensor in sensors:
|
||||
self._hypervisor.send("c7200 set_temp_sensor {name} {sensor_id} {temp}".format(name=self._name,
|
||||
sensor_id=sensor_id,
|
||||
temp=sensor))
|
||||
yield from self._hypervisor.send('c7200 set_temp_sensor "{name}" {sensor_id} {temp}'.format(name=self._name,
|
||||
sensor_id=sensor_id,
|
||||
temp=sensor))
|
||||
|
||||
log.info("router {name} [id={id}]: sensor {sensor_id} temperature updated from {old_temp}C to {new_temp}C".format(name=self._name,
|
||||
id=self._id,
|
||||
sensor_id=sensor_id,
|
||||
old_temp=self._sensors[sensor_id],
|
||||
new_temp=sensors[sensor_id]))
|
||||
log.info('Router "{name}" [{id}]: sensor {sensor_id} temperature updated from {old_temp}C to {new_temp}C'.format(name=self._name,
|
||||
id=self._id,
|
||||
sensor_id=sensor_id,
|
||||
old_temp=self._sensors[sensor_id],
|
||||
new_temp=sensors[sensor_id]))
|
||||
|
||||
sensor_id += 1
|
||||
self._sensors = sensors
|
||||
@ -211,8 +197,8 @@ class C7200(Router):
|
||||
|
||||
return self._power_supplies
|
||||
|
||||
@power_supplies.setter
|
||||
def power_supplies(self, power_supplies):
|
||||
@asyncio.coroutine
|
||||
def set_power_supplies(self, power_supplies):
|
||||
"""
|
||||
Sets the 2 power supplies with 0 = off, 1 = on.
|
||||
|
||||
@ -222,18 +208,19 @@ class C7200(Router):
|
||||
|
||||
power_supply_id = 0
|
||||
for power_supply in power_supplies:
|
||||
self._hypervisor.send("c7200 set_power_supply {name} {power_supply_id} {powered_on}".format(name=self._name,
|
||||
power_supply_id=power_supply_id,
|
||||
powered_on=power_supply))
|
||||
yield from self._hypervisor.send('c7200 set_power_supply "{name}" {power_supply_id} {powered_on}'.format(name=self._name,
|
||||
power_supply_id=power_supply_id,
|
||||
powered_on=power_supply))
|
||||
|
||||
log.info("router {name} [id={id}]: power supply {power_supply_id} state updated to {powered_on}".format(name=self._name,
|
||||
id=self._id,
|
||||
power_supply_id=power_supply_id,
|
||||
powered_on=power_supply))
|
||||
log.info('Router "{name}" [{id}]: power supply {power_supply_id} state updated to {powered_on}'.format(name=self._name,
|
||||
id=self._id,
|
||||
power_supply_id=power_supply_id,
|
||||
powered_on=power_supply))
|
||||
power_supply_id += 1
|
||||
|
||||
self._power_supplies = power_supplies
|
||||
|
||||
@asyncio.coroutine
|
||||
def start(self):
|
||||
"""
|
||||
Starts this router.
|
||||
@ -242,8 +229,8 @@ class C7200(Router):
|
||||
|
||||
# trick: we must send sensors and power supplies info after starting the router
|
||||
# otherwise they are not taken into account (Dynamips bug?)
|
||||
Router.start(self)
|
||||
yield from Router.start(self)
|
||||
if self._sensors != [22, 22, 22, 22]:
|
||||
self.sensors = self._sensors
|
||||
yield from self.set_sensors(self._sensors)
|
||||
if self._power_supplies != [1, 1]:
|
||||
self.power_supplies = self._power_supplies
|
||||
yield from self.set_power_supplies(self._power_supplies)
|
||||
|
@ -37,8 +37,15 @@ class Router(BaseVM):
|
||||
|
||||
"""
|
||||
Dynamips router implementation.
|
||||
|
||||
:param name: The name of this router
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param platform: Platform of this router
|
||||
"""
|
||||
|
||||
_instances = []
|
||||
_status = {0: "inactive",
|
||||
1: "shutting down",
|
||||
2: "running",
|
||||
@ -136,21 +143,22 @@ class Router(BaseVM):
|
||||
|
||||
self._hypervisor = yield from self.manager.start_new_hypervisor()
|
||||
|
||||
yield from self._hypervisor.send("vm create '{name}' {id} {platform}".format(name=self._name,
|
||||
id=self._id,
|
||||
print("{} {} {}".format(self._name, self._id, self._platform))
|
||||
yield from self._hypervisor.send('vm create "{name}" {id} {platform}'.format(name=self._name,
|
||||
id=1, #FIXME: instance ID!
|
||||
platform=self._platform))
|
||||
|
||||
if not self._ghost_flag:
|
||||
|
||||
log.info("Router {platform} '{name}' [{id}] has been created".format(name=self._name,
|
||||
log.info('Router {platform} "{name}" [{id}] has been created'.format(name=self._name,
|
||||
platform=self._platform,
|
||||
id=self._id))
|
||||
|
||||
yield from self._hypervisor.send("vm set_con_tcp_port '{name}' {console}".format(name=self._name, console=self._console))
|
||||
yield from self._hypervisor.send("vm set_aux_tcp_port '{name}' {aux}".format(name=self._name, aux=self._aux))
|
||||
yield from self._hypervisor.send('vm set_con_tcp_port "{name}" {console}'.format(name=self._name, console=self._console))
|
||||
yield from self._hypervisor.send('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=self._aux))
|
||||
|
||||
# get the default base MAC address
|
||||
mac_addr = yield from self._hypervisor.send("{platform} get_mac_addr '{name}'".format(platform=self._platform,
|
||||
mac_addr = yield from self._hypervisor.send('{platform} get_mac_addr "{name}"'.format(platform=self._platform,
|
||||
name=self._name))
|
||||
self._mac_addr = mac_addr[0]
|
||||
|
||||
@ -164,7 +172,7 @@ class Router(BaseVM):
|
||||
:returns: inactive, shutting down, running or suspended.
|
||||
"""
|
||||
|
||||
status = yield from self._hypervisor.send("vm get_status '{name}'".format(name=self._name))
|
||||
status = yield from self._hypervisor.send('vm get_status "{name}"'.format(name=self._name))
|
||||
return self._status[int(status[0])]
|
||||
|
||||
@asyncio.coroutine
|
||||
@ -181,23 +189,23 @@ class Router(BaseVM):
|
||||
|
||||
if not os.path.isfile(self._image) or not os.path.exists(self._image):
|
||||
if os.path.islink(self._image):
|
||||
raise DynamipsError("IOS image '{}' linked to '{}' is not accessible".format(self._image, os.path.realpath(self._image)))
|
||||
raise DynamipsError('IOS image "{}" linked to "{}" is not accessible'.format(self._image, os.path.realpath(self._image)))
|
||||
else:
|
||||
raise DynamipsError("IOS image '{}' is not accessible".format(self._image))
|
||||
raise DynamipsError('IOS image "{}" is not accessible'.format(self._image))
|
||||
|
||||
try:
|
||||
with open(self._image, "rb") as f:
|
||||
# read the first 7 bytes of the file.
|
||||
elf_header_start = f.read(7)
|
||||
except OSError as e:
|
||||
raise DynamipsError("Cannot read ELF header for IOS image {}: {}".format(self._image, e))
|
||||
raise DynamipsError('Cannot read ELF header for IOS image "{}": {}'.format(self._image, e))
|
||||
|
||||
# IOS images must start with the ELF magic number, be 32-bit, big endian and have an ELF version of 1
|
||||
if elf_header_start != b'\x7fELF\x01\x02\x01':
|
||||
raise DynamipsError("'{}' is not a valid IOS image".format(self._image))
|
||||
raise DynamipsError('"{}" is not a valid IOS image'.format(self._image))
|
||||
|
||||
yield from self._hypervisor.send("vm start '{}'".format(self._name))
|
||||
log.info("router '{name}' [{id}] has been started".format(name=self._name, id=self._id))
|
||||
yield from self._hypervisor.send('vm start "{}"'.format(self._name))
|
||||
log.info('router "{name}" [{id}] has been started'.format(name=self._name, id=self._id))
|
||||
|
||||
@asyncio.coroutine
|
||||
def stop(self):
|
||||
@ -207,8 +215,8 @@ class Router(BaseVM):
|
||||
|
||||
status = yield from self.get_status()
|
||||
if status != "inactive":
|
||||
yield from self._hypervisor.send("vm stop '{name}'".format(self._name))
|
||||
log.info("Router '{name}' [{id}] has been stopped".format(name=self._name, id=self._id))
|
||||
yield from self._hypervisor.send('vm stop "{name}"'.format(self._name))
|
||||
log.info('Router "{name}" [{id}] has been stopped'.format(name=self._name, id=self._id))
|
||||
|
||||
@asyncio.coroutine
|
||||
def suspend(self):
|
||||
@ -218,8 +226,8 @@ class Router(BaseVM):
|
||||
|
||||
status = yield from self.get_status()
|
||||
if status == "running":
|
||||
yield from self._hypervisor.send("vm suspend '{}'".format(self._name))
|
||||
log.info("Router '{name}' [{id}] has been suspended".format(name=self._name, id=self._id))
|
||||
yield from self._hypervisor.send('vm suspend "{}"'.format(self._name))
|
||||
log.info('Router "{name}" [{id}] has been suspended'.format(name=self._name, id=self._id))
|
||||
|
||||
@asyncio.coroutine
|
||||
def resume(self):
|
||||
@ -227,8 +235,8 @@ class Router(BaseVM):
|
||||
Resumes this suspended router
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm resume '{}'".format(self._name))
|
||||
log.info("Router '{name}' [{id}] has been resumed".format(name=self._name, id=self._id))
|
||||
yield from self._hypervisor.send('vm resume "{}"'.format(self._name))
|
||||
log.info('Router "{name}" [{id}] has been resumed'.format(name=self._name, id=self._id))
|
||||
|
||||
@asyncio.coroutine
|
||||
def is_running(self):
|
||||
@ -271,9 +279,9 @@ class Router(BaseVM):
|
||||
"""
|
||||
|
||||
yield from self.close()
|
||||
yield from self._hypervisor.send("vm delete '{}'".format(self._name))
|
||||
yield from self._hypervisor.send('vm delete "{}"'.format(self._name))
|
||||
self._hypervisor.devices.remove(self)
|
||||
log.info("router '{name}' [{id}] has been deleted".format(name=self._name, id=self._id))
|
||||
log.info('Router "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
|
||||
@property
|
||||
def platform(self):
|
||||
@ -326,7 +334,7 @@ class Router(BaseVM):
|
||||
:param level: level number
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_debug_level '{name}' {level}".format(name=self._name, level=level))
|
||||
yield from self._hypervisor.send('vm set_debug_level "{name}" {level}'.format(name=self._name, level=level))
|
||||
|
||||
@property
|
||||
def image(self):
|
||||
@ -348,11 +356,11 @@ class Router(BaseVM):
|
||||
"""
|
||||
|
||||
# encase image in quotes to protect spaces in the path
|
||||
yield from self._hypervisor.send("vm set_ios {name} {image}".format(name=self._name, image='"' + image + '"'))
|
||||
yield from self._hypervisor.send('vm set_ios "{name}" "{image}"'.format(name=self._name, image=image))
|
||||
|
||||
log.info("Router '{name}' [{id}]: has a new IOS image set: {image}".format(name=self._name,
|
||||
id=self._id,
|
||||
image='"' + image + '"'))
|
||||
log.info('Router "{name}" [{id}]: has a new IOS image set: "{image}"'.format(name=self._name,
|
||||
id=self._id,
|
||||
image=image))
|
||||
|
||||
self._image = image
|
||||
|
||||
@ -377,8 +385,8 @@ class Router(BaseVM):
|
||||
if self._ram == ram:
|
||||
return
|
||||
|
||||
yield from self._hypervisor.send("vm set_ram '{name}' {ram}".format(name=self._name, ram=ram))
|
||||
log.info("Router '{name}' [{id}]: RAM updated from {old_ram}MB to {new_ram}MB".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm set_ram "{name}" {ram}'.format(name=self._name, ram=ram))
|
||||
log.info('Router "{name}" [{id}]: RAM updated from {old_ram}MB to {new_ram}MB'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_ram=self._ram,
|
||||
new_ram=ram))
|
||||
@ -405,8 +413,8 @@ class Router(BaseVM):
|
||||
if self._nvram == nvram:
|
||||
return
|
||||
|
||||
yield from self._hypervisor.send("vm set_nvram '{name}' {nvram}".format(name=self._name, nvram=nvram))
|
||||
log.info("Router '{name}' [{id}]: NVRAM updated from {old_nvram}KB to {new_nvram}KB".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm set_nvram "{name}" {nvram}'.format(name=self._name, nvram=nvram))
|
||||
log.info('Router "{name}" [{id}]: NVRAM updated from {old_nvram}KB to {new_nvram}KB'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_nvram=self._nvram,
|
||||
new_nvram=nvram))
|
||||
@ -436,12 +444,12 @@ class Router(BaseVM):
|
||||
else:
|
||||
flag = 0
|
||||
|
||||
yield from self._hypervisor.send("vm set_ram_mmap '{name}' {mmap}".format(name=self._name, mmap=flag))
|
||||
yield from self._hypervisor.send('vm set_ram_mmap "{name}" {mmap}'.format(name=self._name, mmap=flag))
|
||||
|
||||
if mmap:
|
||||
log.info("Router '{name}' [{id}]: mmap enabled".format(name=self._name, id=self._id))
|
||||
log.info('Router "{name}" [{id}]: mmap enabled'.format(name=self._name, id=self._id))
|
||||
else:
|
||||
log.info("Router '{name}' [{id}]: mmap disabled".format(name=self._name, id=self._id))
|
||||
log.info('Router "{name}" [{id}]: mmap disabled'.format(name=self._name, id=self._id))
|
||||
self._mmap = mmap
|
||||
|
||||
@property
|
||||
@ -466,12 +474,12 @@ class Router(BaseVM):
|
||||
flag = 1
|
||||
else:
|
||||
flag = 0
|
||||
yield from self._hypervisor.send("vm set_sparse_mem '{name}' {sparsemem}".format(name=self._name, sparsemem=flag))
|
||||
yield from self._hypervisor.send('vm set_sparse_mem "{name}" {sparsemem}'.format(name=self._name, sparsemem=flag))
|
||||
|
||||
if sparsemem:
|
||||
log.info("Router '{name}' [{id}]: sparse memory enabled".format(name=self._name, id=self._id))
|
||||
log.info('Router "{name}" [{id}]: sparse memory enabled'.format(name=self._name, id=self._id))
|
||||
else:
|
||||
log.info("Router '{name}' [{id}]: sparse memory disabled".format(name=self._name, id=self._id))
|
||||
log.info('Router "{name}" [{id}]: sparse memory disabled'.format(name=self._name, id=self._id))
|
||||
self._sparsemem = sparsemem
|
||||
|
||||
@property
|
||||
@ -493,8 +501,8 @@ class Router(BaseVM):
|
||||
:param clock_divisor: clock divisor value (integer)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_clock_divisor '{name}' {clock}".format(name=self._name, clock=clock_divisor))
|
||||
log.info("Router '{name}' [{id}]: clock divisor updated from {old_clock} to {new_clock}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm set_clock_divisor "{name}" {clock}'.format(name=self._name, clock=clock_divisor))
|
||||
log.info('Router "{name}" [{id}]: clock divisor updated from {old_clock} to {new_clock}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_clock=self._clock_divisor,
|
||||
new_clock=clock_divisor))
|
||||
@ -524,11 +532,11 @@ class Router(BaseVM):
|
||||
is_running = yield from self.is_running()
|
||||
if not is_running:
|
||||
# router is not running
|
||||
yield from self._hypervisor.send("vm set_idle_pc '{name}' {idlepc}".format(name=self._name, idlepc=idlepc))
|
||||
yield from self._hypervisor.send('vm set_idle_pc "{name}" {idlepc}'.format(name=self._name, idlepc=idlepc))
|
||||
else:
|
||||
yield from self._hypervisor.send("vm set_idle_pc_online '{name}' 0 {idlepc}".format(name=self._name, idlepc=idlepc))
|
||||
yield from self._hypervisor.send('vm set_idle_pc_online "{name}" 0 {idlepc}'.format(name=self._name, idlepc=idlepc))
|
||||
|
||||
log.info("Router '{name}' [{id}]: idle-PC set to {idlepc}".format(name=self._name, id=self._id, idlepc=idlepc))
|
||||
log.info('Router "{name}" [{id}]: idle-PC set to {idlepc}'.format(name=self._name, id=self._id, idlepc=idlepc))
|
||||
self._idlepc = idlepc
|
||||
|
||||
@asyncio.coroutine
|
||||
@ -544,12 +552,12 @@ class Router(BaseVM):
|
||||
is_running = yield from self.is_running()
|
||||
if not is_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}] has started calculating Idle-PC values".format(name=self._name, id=self._id))
|
||||
log.info('Router "{name}" [{id}] has started calculating Idle-PC values'.format(name=self._name, id=self._id))
|
||||
begin = time.time()
|
||||
idlepcs = yield from self._hypervisor.send("vm get_idle_pc_prop '{}' 0".format(self._name))
|
||||
log.info("Router '{name}' [{id}] has finished calculating Idle-PC values after {time:.4f} seconds".format(name=self._name,
|
||||
idlepcs = yield from self._hypervisor.send('vm get_idle_pc_prop "{}" 0'.format(self._name))
|
||||
log.info('Router "{name}" [{id}] has finished calculating Idle-PC values after {time:.4f} seconds'.format(name=self._name,
|
||||
id=self._id,
|
||||
time=time.time() - begin))
|
||||
return idlepcs
|
||||
@ -565,9 +573,9 @@ class Router(BaseVM):
|
||||
is_running = yield from self.is_running()
|
||||
if not is_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))
|
||||
|
||||
proposals = yield from self._hypervisor.send("vm show_idle_pc_prop '{}' 0".format(self._name))
|
||||
proposals = yield from self._hypervisor.send('vm show_idle_pc_prop "{}" 0'.format(self._name))
|
||||
return proposals
|
||||
|
||||
@property
|
||||
@ -590,9 +598,9 @@ class Router(BaseVM):
|
||||
|
||||
is_running = yield from self.is_running()
|
||||
if is_running: # router is running
|
||||
yield from self._hypervisor.send("vm set_idle_max '{name}' 0 {idlemax}".format(name=self._name, idlemax=idlemax))
|
||||
yield from self._hypervisor.send('vm set_idle_max "{name}" 0 {idlemax}'.format(name=self._name, idlemax=idlemax))
|
||||
|
||||
log.info("Router '{name}' [{id}]: idlemax updated from {old_idlemax} to {new_idlemax}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: idlemax updated from {old_idlemax} to {new_idlemax}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_idlemax=self._idlemax,
|
||||
new_idlemax=idlemax))
|
||||
@ -619,10 +627,10 @@ class Router(BaseVM):
|
||||
|
||||
is_running = yield from self.is_running()
|
||||
if is_running: # router is running
|
||||
yield from self._hypervisor.send("vm set_idle_sleep_time '{name}' 0 {idlesleep}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm set_idle_sleep_time "{name}" 0 {idlesleep}'.format(name=self._name,
|
||||
idlesleep=idlesleep))
|
||||
|
||||
log.info("Router '{name}' [{id}]: idlesleep updated from {old_idlesleep} to {new_idlesleep}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: idlesleep updated from {old_idlesleep} to {new_idlesleep}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_idlesleep=self._idlesleep,
|
||||
new_idlesleep=idlesleep))
|
||||
@ -647,10 +655,10 @@ class Router(BaseVM):
|
||||
:ghost_file: path to ghost file
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_ghost_file '{name}' {ghost_file}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm set_ghost_file "{name}" {ghost_file}'.format(name=self._name,
|
||||
ghost_file=ghost_file))
|
||||
|
||||
log.info("Router '{name}' [{id}]: ghost file set to {ghost_file}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: ghost file set to {ghost_file}'.format(name=self._name,
|
||||
id=self._id,
|
||||
ghost_file=ghost_file))
|
||||
|
||||
@ -692,10 +700,10 @@ class Router(BaseVM):
|
||||
2 => Use an existing ghost instance
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_ghost_status '{name}' {ghost_status}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm set_ghost_status "{name}" {ghost_status}'.format(name=self._name,
|
||||
ghost_status=ghost_status))
|
||||
|
||||
log.info("Router '{name}' [{id}]: ghost status set to {ghost_status}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: ghost status set to {ghost_status}'.format(name=self._name,
|
||||
id=self._id,
|
||||
ghost_status=ghost_status))
|
||||
self._ghost_status = ghost_status
|
||||
@ -721,10 +729,10 @@ class Router(BaseVM):
|
||||
:param exec_area: exec area value (integer)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_exec_area '{name}' {exec_area}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm set_exec_area "{name}" {exec_area}'.format(name=self._name,
|
||||
exec_area=exec_area))
|
||||
|
||||
log.info("Router '{name}' [{id}]: exec area updated from {old_exec}MB to {new_exec}MB".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: exec area updated from {old_exec}MB to {new_exec}MB'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_exec=self._exec_area,
|
||||
new_exec=exec_area))
|
||||
@ -748,12 +756,12 @@ class Router(BaseVM):
|
||||
:param disk0: disk0 size (integer)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_disk0 '{name}' {disk0}".format(name=self._name, disk0=disk0))
|
||||
yield from self._hypervisor.send('vm set_disk0 "{name}" {disk0}'.format(name=self._name, disk0=disk0))
|
||||
|
||||
log.info("Router {name} [{id}]: disk0 updated from {old_disk0}MB to {new_disk0}MB".format(name=self._name,
|
||||
id=self._id,
|
||||
old_disk0=self._disk0,
|
||||
new_disk0=disk0))
|
||||
log.info('Router "{name}" [{id}]: disk0 updated from {old_disk0}MB to {new_disk0}MB'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_disk0=self._disk0,
|
||||
new_disk0=disk0))
|
||||
self._disk0 = disk0
|
||||
|
||||
@property
|
||||
@ -774,9 +782,9 @@ class Router(BaseVM):
|
||||
:param disk1: disk1 size (integer)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_disk1 '{name}' {disk1}".format(name=self._name, disk1=disk1))
|
||||
yield from self._hypervisor.send('vm set_disk1 "{name}" {disk1}'.format(name=self._name, disk1=disk1))
|
||||
|
||||
log.info("Router '{name}' [{id}]: disk1 updated from {old_disk1}MB to {new_disk1}MB".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: disk1 updated from {old_disk1}MB to {new_disk1}MB'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_disk1=self._disk1,
|
||||
new_disk1=disk1))
|
||||
@ -801,9 +809,9 @@ class Router(BaseVM):
|
||||
:param confreg: configuration register value (string)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_conf_reg '{name}' {confreg}".format(name=self._name, confreg=confreg))
|
||||
yield from self._hypervisor.send('vm set_conf_reg "{name}" {confreg}'.format(name=self._name, confreg=confreg))
|
||||
|
||||
log.info("Router '{name}' [{id}]: confreg updated from {old_confreg} to {new_confreg}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: confreg updated from {old_confreg} to {new_confreg}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_confreg=self._confreg,
|
||||
new_confreg=confreg))
|
||||
@ -827,9 +835,9 @@ class Router(BaseVM):
|
||||
:param console: console port (integer)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_con_tcp_port '{name}' {console}".format(name=self._name, console=console))
|
||||
yield from self._hypervisor.send('vm set_con_tcp_port "{name}" {console}'.format(name=self._name, console=console))
|
||||
|
||||
log.info("Router '{name}' [{id}]: console port updated from {old_console} to {new_console}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: console port updated from {old_console} to {new_console}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_console=self._console,
|
||||
new_console=console))
|
||||
@ -855,9 +863,9 @@ class Router(BaseVM):
|
||||
:param aux: console auxiliary port (integer)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("vm set_aux_tcp_port '{name}' {aux}".format(name=self._name, aux=aux))
|
||||
yield from self._hypervisor.send('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=aux))
|
||||
|
||||
log.info("Router '{name}' [{id}]: aux port updated from {old_aux} to {new_aux}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: aux port updated from {old_aux} to {new_aux}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_aux=self._aux,
|
||||
new_aux=aux))
|
||||
@ -873,7 +881,7 @@ class Router(BaseVM):
|
||||
:returns: cpu usage in seconds
|
||||
"""
|
||||
|
||||
cpu_usage = yield from self._hypervisor.send("vm cpu_usage '{name}' {cpu_id}".format(name=self._name, cpu_id=cpu_id))
|
||||
cpu_usage = yield from self._hypervisor.send('vm cpu_usage "{name}" {cpu_id}'.format(name=self._name, cpu_id=cpu_id))
|
||||
return int(cpu_usage[0])
|
||||
|
||||
@property
|
||||
@ -894,11 +902,11 @@ class Router(BaseVM):
|
||||
:param mac_addr: a MAC address (hexadecimal format: hh:hh:hh:hh:hh:hh)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("{platform} set_mac_addr '{name}' {mac_addr}".format(platform=self._platform,
|
||||
yield from self._hypervisor.send('{platform} set_mac_addr "{name}" {mac_addr}'.format(platform=self._platform,
|
||||
name=self._name,
|
||||
mac_addr=mac_addr))
|
||||
|
||||
log.info("Router '{name}' [{id}]: MAC address updated from {old_mac} to {new_mac}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: MAC address updated from {old_mac} to {new_mac}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_mac=self._mac_addr,
|
||||
new_mac=mac_addr))
|
||||
@ -922,11 +930,11 @@ class Router(BaseVM):
|
||||
:param system_id: a system ID (also called board processor ID)
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send("{platform} set_system_id '{name}' {system_id}".format(platform=self._platform,
|
||||
yield from self._hypervisor.send('{platform} set_system_id "{name}" {system_id}'.format(platform=self._platform,
|
||||
name=self._name,
|
||||
system_id=system_id))
|
||||
|
||||
log.info("Router '{name'} [{id}]: system ID updated from {old_id} to {new_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: system ID updated from {old_id} to {new_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
old_id=self._system_id,
|
||||
new_id=system_id))
|
||||
@ -940,7 +948,7 @@ class Router(BaseVM):
|
||||
:returns: slot bindings (adapter names) list
|
||||
"""
|
||||
|
||||
slot_bindings = yield from self._hypervisor.send("vm slot_bindings '{}'".format(self._name))
|
||||
slot_bindings = yield from self._hypervisor.send('vm slot_bindings "{}"'.format(self._name))
|
||||
return slot_bindings
|
||||
|
||||
@asyncio.coroutine
|
||||
@ -955,11 +963,11 @@ class Router(BaseVM):
|
||||
try:
|
||||
slot = self._slots[slot_id]
|
||||
except IndexError:
|
||||
raise DynamipsError("Slot {slot_id} doesn't exist on router '{name}'".format(name=self._name, slot_id=slot_id))
|
||||
raise DynamipsError('Slot {slot_id} does not exist on router "{name}"'.format(name=self._name, slot_id=slot_id))
|
||||
|
||||
if slot is not None:
|
||||
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,
|
||||
adapter=current_adapter))
|
||||
|
||||
@ -969,14 +977,14 @@ class Router(BaseVM):
|
||||
if is_running and not ((self._platform == 'c7200' and not str(adapter).startswith('C7200'))
|
||||
and not (self._platform == 'c3600' and self.chassis == '3660')
|
||||
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))
|
||||
|
||||
yield from self._hypervisor.send("vm slot_add_binding '{name}' {slot_id} 0 {adapter}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm slot_add_binding "{name}" {slot_id} 0 {adapter}'.format(name=self._name,
|
||||
slot_id=slot_id,
|
||||
adapter=adapter))
|
||||
|
||||
log.info("Router '{name}' [{id}]: adapter {adapter} inserted into slot {slot_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: adapter {adapter} inserted into slot {slot_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
adapter=adapter,
|
||||
slot_id=slot_id))
|
||||
@ -986,9 +994,9 @@ class Router(BaseVM):
|
||||
# Generate an OIR event if the router is running
|
||||
if is_running:
|
||||
|
||||
yield from self._hypervisor.send("vm slot_oir_start '{name}' {slot_id} 0".format(name=self._name, slot_id=slot_id))
|
||||
yield from self._hypervisor.send('vm slot_oir_start "{name}" {slot_id} 0'.format(name=self._name, slot_id=slot_id))
|
||||
|
||||
log.info("Router '{name}' [{id}]: OIR start event sent to slot {slot_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: OIR start event sent to slot {slot_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
slot_id=slot_id))
|
||||
|
||||
@ -1003,10 +1011,10 @@ class Router(BaseVM):
|
||||
try:
|
||||
adapter = self._slots[slot_id]
|
||||
except IndexError:
|
||||
raise DynamipsError("Slot {slot_id} doesn't exist on router '{name}'".format(name=self._name, slot_id=slot_id))
|
||||
raise DynamipsError('Slot {slot_id} does not exist on router "{name}"'.format(name=self._name, slot_id=slot_id))
|
||||
|
||||
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))
|
||||
|
||||
is_running = yield from self.is_running()
|
||||
@ -1015,21 +1023,21 @@ class Router(BaseVM):
|
||||
if is_running and not ((self._platform == 'c7200' and not str(adapter).startswith('C7200'))
|
||||
and not (self._platform == 'c3600' and self.chassis == '3660')
|
||||
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))
|
||||
|
||||
# Generate an OIR event if the router is running
|
||||
if is_running:
|
||||
|
||||
yield from self._hypervisor.send("vm slot_oir_stop '{name}' {slot_id} 0".format(name=self._name, slot_id=slot_id))
|
||||
yield from self._hypervisor.send('vm slot_oir_stop "{name}" {slot_id} 0'.format(name=self._name, slot_id=slot_id))
|
||||
|
||||
log.info("router '{name}' [{id}]: OIR stop event sent to slot {slot_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: OIR stop event sent to slot {slot_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
slot_id=slot_id))
|
||||
|
||||
yield from self._hypervisor.send("vm slot_remove_binding '{name}' {slot_id} 0".format(name=self._name, slot_id=slot_id))
|
||||
yield from self._hypervisor.send('vm slot_remove_binding "{name}" {slot_id} 0'.format(name=self._name, slot_id=slot_id))
|
||||
|
||||
log.info("Router '{name}' [{id}]: adapter {adapter} removed from slot {slot_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: adapter {adapter} removed from slot {slot_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
adapter=adapter,
|
||||
slot_id=slot_id))
|
||||
@ -1060,12 +1068,12 @@ class Router(BaseVM):
|
||||
# Dynamips WICs slot IDs start on a multiple of 16
|
||||
# WIC1 = 16, WIC2 = 32 and WIC3 = 48
|
||||
internal_wic_slot_id = 16 * (wic_slot_id + 1)
|
||||
yield from self._hypervisor.send("vm slot_add_binding '{name}' {slot_id} {wic_slot_id} {wic}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm slot_add_binding "{name}" {slot_id} {wic_slot_id} {wic}'.format(name=self._name,
|
||||
slot_id=slot_id,
|
||||
wic_slot_id=internal_wic_slot_id,
|
||||
wic=wic))
|
||||
|
||||
log.info("Router '{name}' [{id}]: {wic} inserted into WIC slot {wic_slot_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: {wic} inserted into WIC slot {wic_slot_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
wic=wic,
|
||||
wic_slot_id=wic_slot_id))
|
||||
@ -1096,11 +1104,11 @@ class Router(BaseVM):
|
||||
# Dynamips WICs slot IDs start on a multiple of 16
|
||||
# WIC1 = 16, WIC2 = 32 and WIC3 = 48
|
||||
internal_wic_slot_id = 16 * (wic_slot_id + 1)
|
||||
yield from self._hypervisor.send("vm slot_remove_binding '{name}' {slot_id} {wic_slot_id}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm slot_remove_binding "{name}" {slot_id} {wic_slot_id}'.format(name=self._name,
|
||||
slot_id=slot_id,
|
||||
wic_slot_id=internal_wic_slot_id))
|
||||
|
||||
log.info("Router '{name}' [{id}]: {wic} removed from WIC slot {wic_slot_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: {wic} removed from WIC slot {wic_slot_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
wic=adapter.wics[wic_slot_id],
|
||||
wic_slot_id=wic_slot_id))
|
||||
@ -1116,7 +1124,7 @@ class Router(BaseVM):
|
||||
:returns: list of NIO bindings
|
||||
"""
|
||||
|
||||
nio_bindings = yield from self._hypervisor.send("vm slot_nio_bindings '{name}' {slot_id}".format(name=self._name,
|
||||
nio_bindings = yield from self._hypervisor.send('vm slot_nio_bindings "{name}" {slot_id}'.format(name=self._name,
|
||||
slot_id=slot_id))
|
||||
return nio_bindings
|
||||
|
||||
@ -1133,18 +1141,18 @@ class Router(BaseVM):
|
||||
try:
|
||||
adapter = self._slots[slot_id]
|
||||
except IndexError:
|
||||
raise DynamipsError("Slot {slot_id} doesn't exist on router '{name}'".format(name=self._name,
|
||||
slot_id=slot_id))
|
||||
raise DynamipsError('Slot {slot_id} does not exist on router "{name}"'.format(name=self._name,
|
||||
slot_id=slot_id))
|
||||
if not adapter.port_exists(port_id):
|
||||
raise DynamipsError("Port {port_id} doesn't exist in adapter {adapter}".format(adapter=adapter,
|
||||
port_id=port_id))
|
||||
raise DynamipsError("Port {port_id} does not exist in adapter {adapter}".format(adapter=adapter,
|
||||
port_id=port_id))
|
||||
|
||||
yield from self._hypervisor.send("vm slot_add_nio_binding '{name}' {slot_id} {port_id} {nio}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm slot_add_nio_binding "{name}" {slot_id} {port_id} {nio}'.format(name=self._name,
|
||||
slot_id=slot_id,
|
||||
port_id=port_id,
|
||||
nio=nio))
|
||||
|
||||
log.info("Router '{name}' [{id}]: NIO {nio_name} bound to port {slot_id}/{port_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: NIO {nio_name} bound to port {slot_id}/{port_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
nio_name=nio.name,
|
||||
slot_id=slot_id,
|
||||
@ -1167,19 +1175,19 @@ class Router(BaseVM):
|
||||
try:
|
||||
adapter = self._slots[slot_id]
|
||||
except IndexError:
|
||||
raise DynamipsError("Slot {slot_id} doesn't exist on router '{name}'".format(name=self._name, slot_id=slot_id))
|
||||
raise DynamipsError('Slot {slot_id} does not exist on router "{name}"'.format(name=self._name, slot_id=slot_id))
|
||||
if not adapter.port_exists(port_id):
|
||||
raise DynamipsError("Port {port_id} doesn't exist in adapter {adapter}".format(adapter=adapter, port_id=port_id))
|
||||
raise DynamipsError("Port {port_id} does not exist in adapter {adapter}".format(adapter=adapter, port_id=port_id))
|
||||
|
||||
yield from self.slot_disable_nio(slot_id, port_id)
|
||||
yield from self._hypervisor.send("vm slot_remove_nio_binding '{name}' {slot_id} {port_id}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm slot_remove_nio_binding "{name}" {slot_id} {port_id}'.format(name=self._name,
|
||||
slot_id=slot_id,
|
||||
port_id=port_id))
|
||||
|
||||
nio = adapter.get_nio(port_id)
|
||||
adapter.remove_nio(port_id)
|
||||
|
||||
log.info("Router '{name}' [{id}]: NIO {nio_name} removed from port {slot_id}/{port_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: NIO {nio_name} removed from port {slot_id}/{port_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
nio_name=nio.name,
|
||||
slot_id=slot_id,
|
||||
@ -1198,11 +1206,11 @@ class Router(BaseVM):
|
||||
|
||||
is_running = yield from self.is_running()
|
||||
if is_running: # running router
|
||||
yield from self._hypervisor.send("vm slot_enable_nio '{name}' {slot_id} {port_id}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm slot_enable_nio "{name}" {slot_id} {port_id}'.format(name=self._name,
|
||||
slot_id=slot_id,
|
||||
port_id=port_id))
|
||||
|
||||
log.info("Router '{name}' [{id}]: NIO enabled on port {slot_id}/{port_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: NIO enabled on port {slot_id}/{port_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
slot_id=slot_id,
|
||||
port_id=port_id))
|
||||
@ -1217,11 +1225,11 @@ class Router(BaseVM):
|
||||
|
||||
is_running = yield from self.is_running()
|
||||
if is_running: # running router
|
||||
yield from self._hypervisor.send("vm slot_disable_nio '{name}' {slot_id} {port_id}".format(name=self._name,
|
||||
yield from self._hypervisor.send('vm slot_disable_nio "{name}" {slot_id} {port_id}'.format(name=self._name,
|
||||
slot_id=slot_id,
|
||||
port_id=port_id))
|
||||
|
||||
log.info("Router '{name}' [{id}]: NIO disabled on port {slot_id}/{port_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: NIO disabled on port {slot_id}/{port_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
slot_id=slot_id,
|
||||
port_id=port_id))
|
||||
@ -1240,9 +1248,9 @@ class Router(BaseVM):
|
||||
try:
|
||||
adapter = self._slots[slot_id]
|
||||
except IndexError:
|
||||
raise DynamipsError("Slot {slot_id} doesn't exist on router '{name}'".format(name=self._name, slot_id=slot_id))
|
||||
raise DynamipsError('Slot {slot_id} does not exist on router "{name}"'.format(name=self._name, slot_id=slot_id))
|
||||
if not adapter.port_exists(port_id):
|
||||
raise DynamipsError("Port {port_id} doesn't exist in adapter {adapter}".format(adapter=adapter, port_id=port_id))
|
||||
raise DynamipsError("Port {port_id} does not exist in adapter {adapter}".format(adapter=adapter, port_id=port_id))
|
||||
|
||||
data_link_type = data_link_type.lower()
|
||||
if data_link_type.startswith("dlt_"):
|
||||
@ -1264,7 +1272,7 @@ class Router(BaseVM):
|
||||
yield from nio.bind_filter("both", "capture")
|
||||
yield from nio.setup_filter("both", '{} "{}"'.format(data_link_type, output_file))
|
||||
|
||||
log.info("Router '{name}' [{id}]: starting packet capture on port {slot_id}/{port_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: starting packet capture on port {slot_id}/{port_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
nio_name=nio.name,
|
||||
slot_id=slot_id,
|
||||
@ -1281,14 +1289,14 @@ class Router(BaseVM):
|
||||
try:
|
||||
adapter = self._slots[slot_id]
|
||||
except IndexError:
|
||||
raise DynamipsError("Slot {slot_id} doesn't exist on router '{name}'".format(name=self._name, slot_id=slot_id))
|
||||
raise DynamipsError('Slot {slot_id} does not exist on router "{name}"'.format(name=self._name, slot_id=slot_id))
|
||||
if not adapter.port_exists(port_id):
|
||||
raise DynamipsError("Port {port_id} doesn't exist in adapter {adapter}".format(adapter=adapter, port_id=port_id))
|
||||
raise DynamipsError("Port {port_id} does not exist in adapter {adapter}".format(adapter=adapter, port_id=port_id))
|
||||
|
||||
nio = adapter.get_nio(port_id)
|
||||
yield from nio.unbind_filter("both")
|
||||
|
||||
log.info("Router '{name}' [{id}]: stopping packet capture on port {slot_id}/{port_id}".format(name=self._name,
|
||||
log.info('Router "{name}" [{id}]: stopping packet capture on port {slot_id}/{port_id}'.format(name=self._name,
|
||||
id=self._id,
|
||||
nio_name=nio.name,
|
||||
slot_id=slot_id,
|
||||
|
@ -44,10 +44,10 @@ class VPCSVM(BaseVM):
|
||||
"""
|
||||
VPCS vm implementation.
|
||||
|
||||
:param name: name of this VPCS vm
|
||||
:param name: The name of this VM
|
||||
:param vm_id: VPCS instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: parent VM Manager
|
||||
:param manager: Parent VM Manager
|
||||
:param console: TCP console port
|
||||
:param startup_script: Content of vpcs startup script file
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user