-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Cisco C9800-CL platform.
- Loading branch information
1 parent
40bff30
commit 6bc95e6
Showing
6 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
Common OVF Tool (COT) | ||
|
||
Copyright (c) 2013-2018 by the following developers: | ||
Copyright (c) 2013-2019 by the following developers: | ||
Glenn F. Matthews | ||
Kevin A. Keim | ||
Quol Fontana | ||
Jusheng Feng | ||
Subba Srinivas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# February 2019, Subba Srinivas | ||
# Copyright (c) 2019 the COT project developers. | ||
# See the COPYRIGHT.txt file at the top-level directory of this distribution | ||
# and at https://github.com/glennmatthews/cot/blob/master/COPYRIGHT.txt. | ||
# | ||
# This file is part of the Common OVF Tool (COT) project. | ||
# It is subject to the license terms in the LICENSE.txt file found in the | ||
# top-level directory of this distribution and at | ||
# https://github.com/glennmatthews/cot/blob/master/LICENSE.txt. No part | ||
# of COT, including this file, may be copied, modified, propagated, or | ||
# distributed except according to the terms contained in the LICENSE.txt file. | ||
|
||
"""Platform logic for the Cisco C9800-CL Wireless Lan Controller.""" | ||
|
||
import logging | ||
|
||
from COT.platforms.platform import Platform, Hardware | ||
from COT.data_validation import ValueUnsupportedError, ValidRange | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class C9800CL(Platform): | ||
"""Platform-specific logic for Cisco C9800-CL platform.""" | ||
|
||
PLATFORM_NAME = "Cisco C9800-CL" | ||
|
||
CONFIG_TEXT_FILE = 'iosxe_config.txt' | ||
LITERAL_CLI_STRING = 'ios-config' | ||
# C9800CL doesn't 'officially' support E1000, but it mostly works | ||
SUPPORTED_NIC_TYPES = ["E1000", "virtio", "VMXNET3"] | ||
|
||
HARDWARE_LIMITS = Platform.HARDWARE_LIMITS.copy() | ||
HARDWARE_LIMITS.update({ | ||
Hardware.cpus: ValidRange(4, 10), | ||
Hardware.memory: ValidRange(8192, 32768), | ||
Hardware.nic_count: ValidRange(1, 3), | ||
Hardware.serial_count: ValidRange(0, 2), | ||
}) | ||
|
||
def controller_type_for_device(self, device_type): | ||
"""C9800CL uses SCSI for hard disks and IDE for CD-ROMs. | ||
Args: | ||
device_type (str): 'harddisk' or 'cdrom' | ||
Returns: | ||
str: 'ide' for CD-ROM, 'scsi' for hard disk | ||
""" | ||
if device_type == 'harddisk': | ||
return 'scsi' | ||
elif device_type == 'cdrom': | ||
return 'ide' | ||
else: | ||
return super(C9800CL, self).controller_type_for_device( | ||
device_type) | ||
|
||
def guess_nic_name(self, nic_number): | ||
"""GigabitEthernet1, GigabitEthernet2, etc. | ||
Args: | ||
nic_number (int): Nth NIC to name. | ||
Returns: | ||
* "GigabitEthernet1" | ||
* "GigabitEthernet2" | ||
* etc. | ||
""" | ||
return "GigabitEthernet" + str(nic_number) | ||
|
||
def validate_cpu_count(self, cpus): | ||
"""C9800CL supports 4,6 or 10 CPUs. | ||
Args: | ||
cpus (int): Number of CPUs. | ||
Raises: | ||
ValueTooLowError: if ``cpus`` is less than 4 | ||
ValueTooHighError: if ``cpus`` is more than 10 | ||
ValueUnsupportedError: if ``cpus`` is a value other than 4, 6, 10 | ||
""" | ||
super(C9800CL, self).validate_cpu_count(cpus) | ||
if cpus not in [4, 6, 10]: | ||
raise ValueUnsupportedError("CPUs", cpus, [4, 6, 10]) | ||
|
||
|
||
Platform.PRODUCT_PLATFORM_MAP['com.cisco.vwlc'] = C9800CL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# test_cisco_c9800cl.py - Unit test cases for Cisco C9800-CL platform | ||
# | ||
# February 2019, Subba Srinivas | ||
# Copyright (c) 2019 the COT project developers. | ||
# See the COPYRIGHT.txt file at the top-level directory of this distribution | ||
# and at https://github.com/glennmatthews/cot/blob/master/COPYRIGHT.txt. | ||
# | ||
# This file is part of the Common OVF Tool (COT) project. | ||
# It is subject to the license terms in the LICENSE.txt file found in the | ||
# top-level directory of this distribution and at | ||
# https://github.com/glennmatthews/cot/blob/master/LICENSE.txt. No part | ||
# of COT, including this file, may be copied, modified, propagated, or | ||
# distributed except according to the terms contained in the LICENSE.txt file. | ||
|
||
"""Unit test cases for C9800-CL platform.""" | ||
|
||
from COT.platforms.cisco_c9800cl import C9800CL | ||
from COT.data_validation import ( | ||
ValueUnsupportedError, ValueTooLowError, ValueTooHighError | ||
) | ||
from COT.platforms.tests import PlatformTests | ||
|
||
|
||
class TestC9800CL(PlatformTests.PlatformTest): | ||
"""Test cases for Cisco C9800CL platform handling.""" | ||
|
||
cls = C9800CL | ||
product_string = "com.cisco.vwlc" | ||
|
||
def test_controller_type_for_device(self): | ||
"""Test platform-specific logic for device controllers.""" | ||
self.assertEqual(self.ins.controller_type_for_device('harddisk'), | ||
'scsi') | ||
self.assertEqual(self.ins.controller_type_for_device('cdrom'), | ||
'ide') | ||
# fallthrough to parent class | ||
self.assertEqual(self.ins.controller_type_for_device('dvd'), | ||
'ide') | ||
|
||
def test_nic_name(self): | ||
"""Test NIC name construction.""" | ||
self.assertEqual(self.ins.guess_nic_name(1), | ||
"GigabitEthernet1") | ||
self.assertEqual(self.ins.guess_nic_name(2), | ||
"GigabitEthernet2") | ||
self.assertEqual(self.ins.guess_nic_name(3), | ||
"GigabitEthernet3") | ||
|
||
def test_cpu_count(self): | ||
"""Test CPU count limits.""" | ||
self.assertRaises(ValueTooLowError, self.ins.validate_cpu_count, 0) | ||
self.assertRaises(ValueTooLowError, self.ins.validate_cpu_count, 3) | ||
self.ins.validate_cpu_count(4) | ||
self.assertRaises(ValueUnsupportedError, | ||
self.ins.validate_cpu_count, 5) | ||
self.ins.validate_cpu_count(6) | ||
self.assertRaises(ValueUnsupportedError, | ||
self.ins.validate_cpu_count, 7) | ||
self.ins.validate_cpu_count(10) | ||
self.assertRaises(ValueTooHighError, self.ins.validate_cpu_count, 11) | ||
|
||
def test_memory_amount(self): | ||
"""Test RAM allocation limits.""" | ||
self.assertRaises(ValueTooLowError, | ||
self.ins.validate_memory_amount, 8191) | ||
self.ins.validate_memory_amount(8192) | ||
self.ins.validate_memory_amount(32768) | ||
self.assertRaises(ValueTooHighError, | ||
self.ins.validate_memory_amount, 32769) | ||
|
||
def test_nic_count(self): | ||
"""Test NIC range limits.""" | ||
self.assertRaises(ValueTooLowError, self.ins.validate_nic_count, 0) | ||
self.ins.validate_nic_count(1) | ||
self.ins.validate_nic_count(2) | ||
self.assertRaises(ValueTooHighError, self.ins.validate_nic_count, 4) | ||
|
||
def test_nic_type(self): | ||
"""Test NIC valid and invalid types.""" | ||
self.assertRaises(ValueUnsupportedError, | ||
self.ins.validate_nic_type, "E1000e") | ||
self.ins.validate_nic_type("E1000") | ||
self.assertRaises(ValueUnsupportedError, | ||
self.ins.validate_nic_type, "PCNet32") | ||
self.ins.validate_nic_type("virtio") | ||
self.ins.validate_nic_type("VMXNET3") | ||
|
||
def test_serial_count(self): | ||
"""Test serial port range limits.""" | ||
self.assertRaises(ValueTooLowError, self.ins.validate_serial_count, -1) | ||
self.ins.validate_serial_count(0) | ||
self.ins.validate_serial_count(2) | ||
self.assertRaises(ValueTooHighError, self.ins.validate_serial_count, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
``COT.platforms.cisco_c9800cl`` module | ||
====================================== | ||
|
||
.. automodule:: COT.platforms.cisco_c9800cl |