From 924ea0b3710c7830cd81ca6d2a6924ad6b341db9 Mon Sep 17 00:00:00 2001 From: Sandhya Dasu Date: Thu, 20 Jul 2017 12:28:33 -0400 Subject: [PATCH] UCSM ML2 driver: Fix issue in parsing of single UCSM config Since the single UCSM config is still being used (after introduction of multi-UCSM config), a re-test revealed a issue. The credetials were stored incorrectly. Change-Id: Icbc465591bc496181652ae73fdaa4904b16394ad Closes-bug: #1705532 --- .../plugins/ml2/drivers/cisco/ucsm/config.py | 2 +- .../cisco/ucsm/test_cisco_ucsm_driver.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/networking_cisco/plugins/ml2/drivers/cisco/ucsm/config.py b/networking_cisco/plugins/ml2/drivers/cisco/ucsm/config.py index acb3c3c..644164d 100644 --- a/networking_cisco/plugins/ml2/drivers/cisco/ucsm/config.py +++ b/networking_cisco/plugins/ml2/drivers/cisco/ucsm/config.py @@ -149,8 +149,8 @@ class UcsmConfig(object): """Creates a dictionary of UCSM data for 1 UCS Manager.""" ucsm_info = [] eth_port_list = [] - ucsm_info.append(cfg.CONF.ml2_cisco_ucsm.ucsm_password) ucsm_info.append(cfg.CONF.ml2_cisco_ucsm.ucsm_username) + ucsm_info.append(cfg.CONF.ml2_cisco_ucsm.ucsm_password) self.ucsm_dict[cfg.CONF.ml2_cisco_ucsm.ucsm_ip] = ucsm_info eth_port_list = parse_virtio_eth_ports() if eth_port_list: diff --git a/networking_cisco/tests/unit/ml2/drivers/cisco/ucsm/test_cisco_ucsm_driver.py b/networking_cisco/tests/unit/ml2/drivers/cisco/ucsm/test_cisco_ucsm_driver.py index 01b2a0b..81a321f 100644 --- a/networking_cisco/tests/unit/ml2/drivers/cisco/ucsm/test_cisco_ucsm_driver.py +++ b/networking_cisco/tests/unit/ml2/drivers/cisco/ucsm/test_cisco_ucsm_driver.py @@ -1071,3 +1071,26 @@ class TestCiscoUcsmMechDriver(testlib_api.SqlTestCase, # Resetting the ucsm_host_dict value to what the other tests expect. self.ucsm_driver.ucsm_host_dict[HOST1] = '1.1.1.1' + + def test_parsing_of_single_ucsm_config(self): + cfg.CONF.ml2_cisco_ucsm.ucsm_ip = "1.1.1.1" + cfg.CONF.ml2_cisco_ucsm.ucsm_username = "user1" + cfg.CONF.ml2_cisco_ucsm.ucsm_password = "password1" + cfg.CONF.ml2_cisco_ucsm.ucsm_virtio_eth_ports = ["eth0", "eth1"] + expected_parsed_virtio_eth_ports = ["/ether-eth0", "/ether-eth1"] + + ucsm_config = conf.UcsmConfig() + + ucsm_config._create_single_ucsm_dicts() + + username, password = ucsm_config.get_credentials_for_ucsm_ip( + cfg.CONF.ml2_cisco_ucsm.ucsm_ip) + + self.assertEqual(username, cfg.CONF.ml2_cisco_ucsm.ucsm_username) + self.assertEqual(password, cfg.CONF.ml2_cisco_ucsm.ucsm_password) + + virtio_port_list = ucsm_config.get_ucsm_eth_port_list( + cfg.CONF.ml2_cisco_ucsm.ucsm_ip) + + self.assertEqual(expected_parsed_virtio_eth_ports, + virtio_port_list)