From df798f4beabb04425513ed048bba8729867f9c93 Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 6 Feb 2014 11:22:58 -0700 Subject: [PATCH] Add default values for exec area and system id settings --- gns3server/modules/dynamips/nodes/router.py | 11 ++++++++--- tests/dynamips/test_c1700.py | 4 ++-- tests/dynamips/test_c2600.py | 4 ++-- tests/dynamips/test_c2691.py | 13 ++++++------- tests/dynamips/test_c3600.py | 4 ++-- tests/dynamips/test_c3725.py | 4 ++-- tests/dynamips/test_c3745.py | 4 ++-- tests/dynamips/test_c7200.py | 4 ++-- tests/dynamips/test_router.py | 12 ++++++++---- 9 files changed, 34 insertions(+), 26 deletions(-) diff --git a/gns3server/modules/dynamips/nodes/router.py b/gns3server/modules/dynamips/nodes/router.py index bcb2886c..95944ff7 100644 --- a/gns3server/modules/dynamips/nodes/router.py +++ b/gns3server/modules/dynamips/nodes/router.py @@ -22,6 +22,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L77 from __future__ import unicode_literals from ..dynamips_error import DynamipsError +import sys import os import logging @@ -68,15 +69,18 @@ class Router(object): self._idlesleep = 30 self._ghost_file = "" self._ghost_status = 0 - self._exec_area = None # Megabytes (None = default for the router platform) + if sys.platform.startswith("win"): + self._exec_area = 16 # 16 MB by default on Windows (Cygwin) + else: + self._exec_area = 64 # 64 MB on other systems self._jit_sharing_group = None self._disk0 = 0 # Megabytes self._disk1 = 0 # Megabytes - self._confreg = '0x2102' + self._confreg = "0x2102" self._console = None self._aux = None self._mac_addr = None - self._system_id = None # processor board ID in IOS + self._system_id = "FTX0945W0MY" # processor board ID in IOS self._slots = [] self._hypervisor.send("vm create {name} {id} {platform}".format(name=self._name, @@ -90,6 +94,7 @@ class Router(object): self.console = self._hypervisor.baseconsole + self._id self.aux = self._hypervisor.baseaux + self._id + # get the default base MAC address self._mac_addr = self._hypervisor.send("{platform} get_mac_addr {name}".format(platform=self._platform, name=self._name))[0] else: diff --git a/tests/dynamips/test_c1700.py b/tests/dynamips/test_c1700.py index 2202a50f..4ed3a2d2 100644 --- a/tests/dynamips/test_c1700.py +++ b/tests/dynamips/test_c1700.py @@ -89,7 +89,7 @@ def test_iomem(router_c1700): def test_mac_addr(router_c1700): - assert router_c1700.mac_addr == None # default value + assert router_c1700.mac_addr != None router_c1700.mac_addr = "aa:aa:aa:aa:aa:aa" assert router_c1700.mac_addr == "aa:aa:aa:aa:aa:aa" @@ -102,7 +102,7 @@ def test_bogus_mac_addr(router_c1700): def test_system_id(router_c1700): - assert router_c1700.system_id == None # default value + assert router_c1700.system_id == "FTX0945W0MY" # default value router_c1700.system_id = "FTX0945W0MO" assert router_c1700.system_id == "FTX0945W0MO" diff --git a/tests/dynamips/test_c2600.py b/tests/dynamips/test_c2600.py index d17ee345..ae94f1b4 100644 --- a/tests/dynamips/test_c2600.py +++ b/tests/dynamips/test_c2600.py @@ -165,7 +165,7 @@ def test_iomem(router_c2600): def test_mac_addr(router_c2600): - assert router_c2600.mac_addr == None # default value + assert router_c2600.mac_addr != None router_c2600.mac_addr = "aa:aa:aa:aa:aa:aa" assert router_c2600.mac_addr == "aa:aa:aa:aa:aa:aa" @@ -178,7 +178,7 @@ def test_bogus_mac_addr(router_c2600): def test_system_id(router_c2600): - assert router_c2600.system_id == None # default value + assert router_c2600.system_id == "FTX0945W0MY" # default value router_c2600.system_id = "FTX0945W0MO" assert router_c2600.system_id == "FTX0945W0MO" diff --git a/tests/dynamips/test_c2691.py b/tests/dynamips/test_c2691.py index 8cda066a..64acc6c1 100644 --- a/tests/dynamips/test_c2691.py +++ b/tests/dynamips/test_c2691.py @@ -29,7 +29,7 @@ def test_iomem(router_c2691): def test_mac_addr(router_c2691): - assert router_c2691.mac_addr == None # default value + assert router_c2691.mac_addr != None router_c2691.mac_addr = "aa:aa:aa:aa:aa:aa" assert router_c2691.mac_addr == "aa:aa:aa:aa:aa:aa" @@ -40,12 +40,11 @@ def test_bogus_mac_addr(router_c2691): router_c2691.mac_addr = "zz:zz:zz:zz:zz:zz" -def test_system_id(hypervisor): - router = C2691(hypervisor, "test system id") - assert router.system_id == None # default value - router.system_id = "FTX0945W0MO" - assert router.system_id == "FTX0945W0MO" - router.delete() +def test_system_id(router_c2691): + + assert router_c2691.system_id == "FTX0945W0MY" # default value + router_c2691.system_id = "FTX0945W0MO" + assert router_c2691.system_id == "FTX0945W0MO" def test_get_hardware_info(router_c2691): diff --git a/tests/dynamips/test_c3600.py b/tests/dynamips/test_c3600.py index f3bd06cb..435f1b27 100644 --- a/tests/dynamips/test_c3600.py +++ b/tests/dynamips/test_c3600.py @@ -60,7 +60,7 @@ def test_iomem(router_c3600): def test_mac_addr(router_c3600): - assert router_c3600.mac_addr == None # default value + assert router_c3600.mac_addr != None router_c3600.mac_addr = "aa:aa:aa:aa:aa:aa" assert router_c3600.mac_addr == "aa:aa:aa:aa:aa:aa" @@ -73,7 +73,7 @@ def test_bogus_mac_addr(router_c3600): def test_system_id(router_c3600): - assert router_c3600.system_id == None # default value + assert router_c3600.system_id == "FTX0945W0MY" # default value router_c3600.system_id = "FTX0945W0MO" assert router_c3600.system_id == "FTX0945W0MO" diff --git a/tests/dynamips/test_c3725.py b/tests/dynamips/test_c3725.py index 5bb6f6e9..a4a923cf 100644 --- a/tests/dynamips/test_c3725.py +++ b/tests/dynamips/test_c3725.py @@ -29,7 +29,7 @@ def test_iomem(router_c3725): def test_mac_addr(router_c3725): - assert router_c3725.mac_addr == None # default value + assert router_c3725.mac_addr != None router_c3725.mac_addr = "aa:aa:aa:aa:aa:aa" assert router_c3725.mac_addr == "aa:aa:aa:aa:aa:aa" @@ -42,7 +42,7 @@ def test_bogus_mac_addr(router_c3725): def test_system_id(router_c3725): - assert router_c3725.system_id == None # default value + assert router_c3725.system_id == "FTX0945W0MY" # default value router_c3725.system_id = "FTX0945W0MO" assert router_c3725.system_id == "FTX0945W0MO" diff --git a/tests/dynamips/test_c3745.py b/tests/dynamips/test_c3745.py index 78cc53e3..c58b5c2e 100644 --- a/tests/dynamips/test_c3745.py +++ b/tests/dynamips/test_c3745.py @@ -29,7 +29,7 @@ def test_iomem(router_c3745): def test_mac_addr(router_c3745): - assert router_c3745.mac_addr == None # default value + assert router_c3745.mac_addr != None router_c3745.mac_addr = "aa:aa:aa:aa:aa:aa" assert router_c3745.mac_addr == "aa:aa:aa:aa:aa:aa" @@ -42,7 +42,7 @@ def test_bogus_mac_addr(router_c3745): def test_system_id(router_c3745): - assert router_c3745.system_id == None # default value + assert router_c3745.system_id == "FTX0945W0MY" # default value router_c3745.system_id = "FTX0945W0MO" assert router_c3745.system_id == "FTX0945W0MO" diff --git a/tests/dynamips/test_c7200.py b/tests/dynamips/test_c7200.py index d3929188..7b74cc7f 100644 --- a/tests/dynamips/test_c7200.py +++ b/tests/dynamips/test_c7200.py @@ -57,7 +57,7 @@ def test_power_supplies(router_c7200): def test_mac_addr(router_c7200): - assert router_c7200.mac_addr == None # default value + assert router_c7200.mac_addr != None router_c7200.mac_addr = "aa:aa:aa:aa:aa:aa" assert router_c7200.mac_addr == "aa:aa:aa:aa:aa:aa" @@ -70,7 +70,7 @@ def test_bogus_mac_addr(router_c7200): def test_system_id(router_c7200): - assert router_c7200.system_id == None # default value + assert router_c7200.system_id == "FTX0945W0MY" # default value router_c7200.system_id = "FTX0945W0MO" assert router_c7200.system_id == "FTX0945W0MO" diff --git a/tests/dynamips/test_router.py b/tests/dynamips/test_router.py index 50cc7b79..1affa539 100644 --- a/tests/dynamips/test_router.py +++ b/tests/dynamips/test_router.py @@ -1,5 +1,6 @@ from gns3server.modules.dynamips import Router from gns3server.modules.dynamips import DynamipsError +import sys import pytest import tempfile import base64 @@ -140,9 +141,12 @@ def test_idlesleep(router): def test_exec_area(router): - assert router.exec_area == None # default value - router.exec_area = 64 - assert router.exec_area == 64 + if sys.platform.startswith("win"): + assert router.exec_area == 16 # default value + else: + assert router.exec_area == 64 # default value + router.exec_area = 48 + assert router.exec_area == 48 def test_disk0(router): @@ -218,7 +222,7 @@ def test_bogus_mac_addr(router): def test_system_id(router): - assert router.system_id == None # default value + assert router.system_id == "FTX0945W0MY" # default value router.system_id = "FTX0945W0MO" assert router.system_id == "FTX0945W0MO"