Merge "Cisco: can't add new zone when no zone is created before"
This commit is contained in:
commit
152138b13b
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"""Unit tests for Cisco FC zone driver."""
|
"""Unit tests for Cisco FC zone driver."""
|
||||||
|
|
||||||
|
import mock
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
@ -24,6 +25,7 @@ from oslo_utils import importutils
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.volume import configuration as conf
|
from cinder.volume import configuration as conf
|
||||||
|
from cinder.zonemanager.drivers.cisco import cisco_fc_zone_driver as driver
|
||||||
|
|
||||||
_active_cfg_before_add = {}
|
_active_cfg_before_add = {}
|
||||||
_active_cfg_before_delete = {
|
_active_cfg_before_delete = {
|
||||||
@ -32,6 +34,12 @@ _active_cfg_before_delete = {
|
|||||||
['10:00:8c:7c:ff:52:3b:01',
|
['10:00:8c:7c:ff:52:3b:01',
|
||||||
'20:24:00:02:ac:00:0a:50'])},
|
'20:24:00:02:ac:00:0a:50'])},
|
||||||
'active_zone_config': 'cfg1'}
|
'active_zone_config': 'cfg1'}
|
||||||
|
_active_cfg_default = {
|
||||||
|
'zones': {
|
||||||
|
'openstack10008c7cff523b0120240002ac000b90': (
|
||||||
|
['10:00:8c:7c:ff:52:3b:01',
|
||||||
|
'20:24:00:02:ac:00:0a:50'])},
|
||||||
|
'active_zone_config': 'cfg1'}
|
||||||
_activate = True
|
_activate = True
|
||||||
_zone_name = 'openstack10008c7cff523b0120240002ac000a50'
|
_zone_name = 'openstack10008c7cff523b0120240002ac000a50'
|
||||||
_target_ns_map = {'100000051e55a100': ['20240002ac000a50']}
|
_target_ns_map = {'100000051e55a100': ['20240002ac000a50']}
|
||||||
@ -127,6 +135,34 @@ class TestCiscoFcZoneDriver(CiscoFcZoneDriverBaseTest, test.TestCase):
|
|||||||
'CISCO_FAB_1', _initiator_target_map)
|
'CISCO_FAB_1', _initiator_target_map)
|
||||||
self.assertNotIn(_zone_name, GlobalVars._zone_state)
|
self.assertNotIn(_zone_name, GlobalVars._zone_state)
|
||||||
|
|
||||||
|
@mock.patch.object(driver.CiscoFCZoneDriver, 'get_zoning_status')
|
||||||
|
@mock.patch.object(driver.CiscoFCZoneDriver, 'get_active_zone_set')
|
||||||
|
def test_add_connection(self, get_active_zone_set_mock,
|
||||||
|
get_zoning_status_mock):
|
||||||
|
"""Test normal flows."""
|
||||||
|
GlobalVars._is_normal_test = True
|
||||||
|
GlobalVars._zone_state = []
|
||||||
|
self.setup_driver(self.setup_config(True, 1))
|
||||||
|
get_zoning_status_mock.return_value = {'mode': 'basis',
|
||||||
|
'session': 'none'}
|
||||||
|
get_active_zone_set_mock.return_value = _active_cfg_default
|
||||||
|
self.driver.add_connection('CISCO_FAB_1', _initiator_target_map)
|
||||||
|
self.assertTrue(_zone_name in GlobalVars._zone_state)
|
||||||
|
|
||||||
|
@mock.patch.object(driver.CiscoFCZoneDriver, 'get_zoning_status')
|
||||||
|
@mock.patch.object(driver.CiscoFCZoneDriver, 'get_active_zone_set')
|
||||||
|
def test_add_connection_with_no_cfg(self, get_active_zone_set_mock,
|
||||||
|
get_zoning_status_mock):
|
||||||
|
"""Test normal flows."""
|
||||||
|
GlobalVars._is_normal_test = True
|
||||||
|
GlobalVars._zone_state = []
|
||||||
|
self.setup_driver(self.setup_config(True, 1))
|
||||||
|
get_zoning_status_mock.return_value = {'mode': 'basis',
|
||||||
|
'session': 'none'}
|
||||||
|
get_active_zone_set_mock.return_value = {}
|
||||||
|
self.driver.add_connection('CISCO_FAB_1', _initiator_target_map)
|
||||||
|
self.assertTrue(_zone_name in GlobalVars._zone_state)
|
||||||
|
|
||||||
def test_add_connection_for_invalid_fabric(self):
|
def test_add_connection_for_invalid_fabric(self):
|
||||||
"""Test abnormal flows."""
|
"""Test abnormal flows."""
|
||||||
GlobalVars._is_normal_test = True
|
GlobalVars._is_normal_test = True
|
||||||
@ -157,7 +193,8 @@ class FakeCiscoFCZoneClientCLI(object):
|
|||||||
def get_active_zone_set(self):
|
def get_active_zone_set(self):
|
||||||
return GlobalVars._active_cfg
|
return GlobalVars._active_cfg
|
||||||
|
|
||||||
def add_zones(self, zones, isActivate):
|
def add_zones(self, zones, activate, fabric_vsan, active_zone_set,
|
||||||
|
zone_status):
|
||||||
GlobalVars._zone_state.extend(zones.keys())
|
GlobalVars._zone_state.extend(zones.keys())
|
||||||
|
|
||||||
def delete_zones(self, zone_names, isActivate):
|
def delete_zones(self, zone_names, isActivate):
|
||||||
|
@ -199,7 +199,6 @@ class CiscoFCZoneDriver(fc_zone_driver.FCZoneDriver):
|
|||||||
target = t.lower()
|
target = t.lower()
|
||||||
zone_members.append(
|
zone_members.append(
|
||||||
zm_utils.get_formatted_wwn(target))
|
zm_utils.get_formatted_wwn(target))
|
||||||
|
|
||||||
zone_name = (
|
zone_name = (
|
||||||
driver_utils.get_friendly_zone_name(
|
driver_utils.get_friendly_zone_name(
|
||||||
zoning_policy,
|
zoning_policy,
|
||||||
@ -221,9 +220,8 @@ class CiscoFCZoneDriver(fc_zone_driver.FCZoneDriver):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.FCZoneDriverException(msg)
|
raise exception.FCZoneDriverException(msg)
|
||||||
|
|
||||||
LOG.info(_LI("Zone map to add: %s"), zone_map)
|
|
||||||
|
|
||||||
if len(zone_map) > 0:
|
if len(zone_map) > 0:
|
||||||
|
LOG.debug("Zone map to add: %s", zone_map)
|
||||||
conn = None
|
conn = None
|
||||||
try:
|
try:
|
||||||
conn = importutils.import_object(
|
conn = importutils.import_object(
|
||||||
@ -246,8 +244,6 @@ class CiscoFCZoneDriver(fc_zone_driver.FCZoneDriver):
|
|||||||
LOG.exception(msg)
|
LOG.exception(msg)
|
||||||
raise exception.FCZoneDriverException(msg)
|
raise exception.FCZoneDriverException(msg)
|
||||||
LOG.debug("Zones added successfully: %s", zone_map)
|
LOG.debug("Zones added successfully: %s", zone_map)
|
||||||
else:
|
|
||||||
LOG.debug("Zoning session exists VSAN: %s", zoning_vsan)
|
|
||||||
|
|
||||||
@lockutils.synchronized('cisco', 'fcfabric-', True)
|
@lockutils.synchronized('cisco', 'fcfabric-', True)
|
||||||
def delete_connection(self, fabric, initiator_target_map, host_name=None,
|
def delete_connection(self, fabric, initiator_target_map, host_name=None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user