2013-12-22 00:42:33 +00: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 3725 instances module ("c3725")
|
|
|
|
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L346
|
|
|
|
"""
|
|
|
|
|
2015-02-11 04:50:02 +00:00
|
|
|
import asyncio
|
2013-12-22 00:42:33 +00:00
|
|
|
from .router import Router
|
|
|
|
from ..adapters.gt96100_fe import GT96100_FE
|
2015-03-21 19:58:52 +00:00
|
|
|
from ..dynamips_error import DynamipsError
|
2013-12-22 00:42:33 +00:00
|
|
|
|
2014-01-31 23:31:34 +00:00
|
|
|
import logging
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2013-12-22 00:42:33 +00:00
|
|
|
|
|
|
|
class C3725(Router):
|
2015-02-13 13:43:28 +00:00
|
|
|
|
2013-12-22 00:42:33 +00:00
|
|
|
"""
|
|
|
|
Dynamips c3725 router.
|
|
|
|
|
2015-02-11 04:50:02 +00:00
|
|
|
:param name: The name of this router
|
2016-05-11 17:35:36 +00:00
|
|
|
:param node_id: Node identifier
|
2015-02-11 04:50:02 +00:00
|
|
|
:param project: Project instance
|
|
|
|
:param manager: Parent VM Manager
|
2015-02-12 02:21:34 +00:00
|
|
|
:param dynamips_id: ID to use with Dynamips
|
2015-02-26 23:15:44 +00:00
|
|
|
:param console: console port
|
2020-07-29 06:53:51 +00:00
|
|
|
:param console_type: console type
|
2015-02-26 23:15:44 +00:00
|
|
|
:param aux: auxiliary console port
|
2020-07-29 06:53:51 +00:00
|
|
|
:param aux_type: auxiliary console type
|
2013-12-22 00:42:33 +00:00
|
|
|
"""
|
|
|
|
|
2020-07-29 06:53:51 +00:00
|
|
|
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", chassis=None):
|
2015-04-08 17:17:34 +00:00
|
|
|
|
2020-07-29 06:53:51 +00:00
|
|
|
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c3725")
|
2013-12-22 00:42:33 +00:00
|
|
|
|
2015-02-22 00:24:39 +00:00
|
|
|
# Set default values for this platform (must be the same as Dynamips)
|
2013-12-22 00:42:33 +00:00
|
|
|
self._ram = 128
|
|
|
|
self._nvram = 112
|
|
|
|
self._disk0 = 16
|
|
|
|
self._disk1 = 0
|
|
|
|
self._iomem = 5 # percentage
|
|
|
|
self._clock_divisor = 8
|
|
|
|
|
|
|
|
self._create_slots(3)
|
|
|
|
self._slots[0] = GT96100_FE()
|
|
|
|
|
2015-03-21 19:58:52 +00:00
|
|
|
if chassis is not None:
|
|
|
|
raise DynamipsError("c3725 routers do not have chassis")
|
|
|
|
|
2015-02-11 04:50:02 +00:00
|
|
|
def __json__(self):
|
2014-01-31 23:31:34 +00:00
|
|
|
|
2015-02-11 04:50:02 +00:00
|
|
|
c3725_router_info = {"iomem": self._iomem}
|
2013-12-22 00:42:33 +00:00
|
|
|
|
2015-02-11 04:50:02 +00:00
|
|
|
router_info = Router.__json__(self)
|
|
|
|
router_info.update(c3725_router_info)
|
|
|
|
return router_info
|
2013-12-22 00:42:33 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def iomem(self):
|
|
|
|
"""
|
|
|
|
Returns I/O memory size for this router.
|
|
|
|
|
|
|
|
:returns: I/O memory size (integer)
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self._iomem
|
|
|
|
|
2018-10-15 10:05:49 +00:00
|
|
|
async def set_iomem(self, iomem):
|
2013-12-22 00:42:33 +00:00
|
|
|
"""
|
2014-01-31 23:31:34 +00:00
|
|
|
Sets I/O memory size for this router.
|
2013-12-22 00:42:33 +00:00
|
|
|
|
|
|
|
:param iomem: I/O memory size
|
|
|
|
"""
|
|
|
|
|
2021-04-13 09:07:58 +00:00
|
|
|
await self._hypervisor.send(f'c3725 set_iomem "{self._name}" {iomem}')
|
2014-01-31 23:31:34 +00:00
|
|
|
|
2015-02-11 04:50:02 +00: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 00:42:33 +00:00
|
|
|
self._iomem = iomem
|