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
This commit is contained in:
Sandhya Dasu 2017-07-20 12:28:33 -04:00
parent 183b875f0d
commit 924ea0b371
2 changed files with 24 additions and 1 deletions

View File

@ -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:

View File

@ -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)