2013-12-22 02:42:33 +02:00
|
|
|
#
|
|
|
|
# Copyright (C) 2013 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/>.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Interface for Dynamips virtual Cisco 2600 instances module ("c2600")
|
|
|
|
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L404
|
|
|
|
"""
|
|
|
|
|
2015-02-11 06:50:02 +02:00
|
|
|
import asyncio
|
2013-12-22 02:42:33 +02:00
|
|
|
from .router import Router
|
|
|
|
from ..adapters.c2600_mb_1e import C2600_MB_1E
|
|
|
|
from ..adapters.c2600_mb_2e import C2600_MB_2E
|
|
|
|
from ..adapters.c2600_mb_1fe import C2600_MB_1FE
|
|
|
|
from ..adapters.c2600_mb_2fe import C2600_MB_2FE
|
|
|
|
|
2014-02-01 01:31:34 +02:00
|
|
|
import logging
|
2021-04-13 12:16:50 +03:00
|
|
|
|
2014-02-01 01:31:34 +02:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2013-12-22 02:42:33 +02:00
|
|
|
|
|
|
|
class C2600(Router):
|
2015-02-13 15:43:28 +02:00
|
|
|
|
2013-12-22 02:42:33 +02:00
|
|
|
"""
|
|
|
|
Dynamips c2600 router.
|
|
|
|
|
2015-02-11 06:50:02 +02:00
|
|
|
:param name: The name of this router
|
2016-05-11 20:35:36 +03:00
|
|
|
:param node_id: Node identifier
|
2015-02-11 06:50:02 +02:00
|
|
|
:param project: Project instance
|
|
|
|
:param manager: Parent VM Manager
|
2015-02-12 04:21:34 +02:00
|
|
|
:param dynamips_id: ID to use with Dynamips
|
2015-02-27 01:15:44 +02:00
|
|
|
:param console: console port
|
2020-07-29 09:53:51 +03:00
|
|
|
:param console_type: console type
|
2015-02-27 01:15:44 +02:00
|
|
|
:param aux: auxiliary console port
|
2020-07-29 09:53:51 +03:00
|
|
|
:param aux_type: auxiliary console type
|
2013-12-22 02:42:33 +02:00
|
|
|
:param chassis: chassis for this router:
|
|
|
|
2610, 2611, 2620, 2621, 2610XM, 2611XM
|
|
|
|
2620XM, 2621XM, 2650XM or 2651XM (default = 2610).
|
|
|
|
"""
|
|
|
|
|
|
|
|
# adapters to insert by default corresponding the
|
|
|
|
# chosen chassis.
|
2021-04-13 12:16:50 +03:00
|
|
|
integrated_adapters = {
|
|
|
|
"2610": C2600_MB_1E,
|
|
|
|
"2611": C2600_MB_2E,
|
|
|
|
"2620": C2600_MB_1FE,
|
|
|
|
"2621": C2600_MB_2FE,
|
|
|
|
"2610XM": C2600_MB_1FE,
|
|
|
|
"2611XM": C2600_MB_2FE,
|
|
|
|
"2620XM": C2600_MB_1FE,
|
|
|
|
"2621XM": C2600_MB_2FE,
|
|
|
|
"2650XM": C2600_MB_1FE,
|
|
|
|
"2651XM": C2600_MB_2FE,
|
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
name,
|
|
|
|
node_id,
|
|
|
|
project,
|
|
|
|
manager,
|
|
|
|
dynamips_id,
|
|
|
|
console=None,
|
|
|
|
console_type="telnet",
|
|
|
|
aux=None,
|
|
|
|
aux_type="none",
|
|
|
|
chassis="2610",
|
|
|
|
):
|
|
|
|
|
|
|
|
super().__init__(
|
|
|
|
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c2600"
|
|
|
|
)
|
2013-12-22 02:42:33 +02:00
|
|
|
|
2015-02-22 02:24:39 +02:00
|
|
|
# Set default values for this platform (must be the same as Dynamips)
|
|
|
|
self._ram = 64
|
2013-12-22 02:42:33 +02:00
|
|
|
self._nvram = 128
|
|
|
|
self._disk0 = 0
|
|
|
|
self._disk1 = 0
|
|
|
|
self._chassis = chassis
|
|
|
|
self._iomem = 15 # percentage
|
|
|
|
self._clock_divisor = 8
|
2015-02-11 06:50:02 +02:00
|
|
|
self._sparsemem = False # never activate sparsemem for c2600 (unstable)
|
2013-12-22 02:42:33 +02:00
|
|
|
|
2021-04-17 17:04:28 +03:00
|
|
|
def asdict(self):
|
2013-12-22 02:42:33 +02:00
|
|
|
|
2021-04-13 12:16:50 +03:00
|
|
|
c2600_router_info = {"iomem": self._iomem, "chassis": self._chassis, "sparsemem": self._sparsemem}
|
2014-02-01 01:31:34 +02:00
|
|
|
|
2021-04-17 17:04:28 +03:00
|
|
|
router_info = Router.asdict(self)
|
2015-02-11 06:50:02 +02:00
|
|
|
router_info.update(c2600_router_info)
|
|
|
|
return router_info
|
2014-02-01 01:31:34 +02:00
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
async def create(self):
|
2013-12-22 02:42:33 +02:00
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
await Router.create(self)
|
2015-02-11 06:50:02 +02:00
|
|
|
if self._chassis != "2610":
|
2018-10-15 13:05:49 +03:00
|
|
|
await self.set_chassis(self._chassis)
|
2015-02-11 06:50:02 +02:00
|
|
|
self._setup_chassis()
|
2013-12-22 02:42:33 +02:00
|
|
|
|
|
|
|
def _setup_chassis(self):
|
|
|
|
"""
|
2014-02-01 01:31:34 +02:00
|
|
|
Sets up the router with the corresponding chassis
|
2013-12-22 02:42:33 +02:00
|
|
|
(create slots and insert default adapters).
|
|
|
|
"""
|
|
|
|
|
|
|
|
self._create_slots(2)
|
|
|
|
self._slots[0] = self.integrated_adapters[self._chassis]()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def chassis(self):
|
|
|
|
"""
|
|
|
|
Returns the chassis.
|
|
|
|
|
|
|
|
:returns: chassis string
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self._chassis
|
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
async def set_chassis(self, chassis):
|
2013-12-22 02:42:33 +02:00
|
|
|
"""
|
2014-02-01 01:31:34 +02:00
|
|
|
Sets the chassis.
|
2013-12-22 02:42:33 +02:00
|
|
|
|
|
|
|
:param: chassis string:
|
|
|
|
2610, 2611, 2620, 2621, 2610XM, 2611XM
|
|
|
|
2620XM, 2621XM, 2650XM or 2651XM
|
|
|
|
"""
|
|
|
|
|
2021-04-13 12:07:58 +03:00
|
|
|
await self._hypervisor.send(f'c2600 set_chassis "{self._name}" {chassis}')
|
2014-02-01 01:31:34 +02:00
|
|
|
|
2021-04-13 12:16:50 +03:00
|
|
|
log.info(
|
|
|
|
'Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name, id=self._id, chassis=chassis)
|
|
|
|
)
|
2013-12-22 02:42:33 +02:00
|
|
|
self._chassis = chassis
|
|
|
|
self._setup_chassis()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def iomem(self):
|
|
|
|
"""
|
|
|
|
Returns I/O memory size for this router.
|
|
|
|
|
|
|
|
:returns: I/O memory size (integer)
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self._iomem
|
|
|
|
|
2018-10-15 13:05:49 +03:00
|
|
|
async def set_iomem(self, iomem):
|
2013-12-22 02:42:33 +02:00
|
|
|
"""
|
2014-02-01 01:31:34 +02:00
|
|
|
Sets I/O memory size for this router.
|
2013-12-22 02:42:33 +02:00
|
|
|
|
|
|
|
:param iomem: I/O memory size
|
|
|
|
"""
|
|
|
|
|
2021-04-13 12:07:58 +03:00
|
|
|
await self._hypervisor.send(f'c2600 set_iomem "{self._name}" {iomem}')
|
2014-02-01 01:31:34 +02:00
|
|
|
|
2021-04-13 12:16:50 +03:00
|
|
|
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
|
|
|
|
)
|
|
|
|
)
|
2013-12-22 02:42:33 +02:00
|
|
|
self._iomem = iomem
|