"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/tests/unit/volume/drivers/dell_emc/powerstore/test_volume_attach_detach.py" between
cinder-17.0.1.tar.gz and cinder-17.1.0.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Victoria" series (latest release).

test_volume_attach_detach.py  (cinder-17.0.1):test_volume_attach_detach.py  (cinder-17.1.0)
skipping to change at line 27 skipping to change at line 27
from cinder import exception from cinder import exception
from cinder.objects import fields from cinder.objects import fields
from cinder.objects import volume_attachment from cinder.objects import volume_attachment
from cinder.tests.unit import fake_volume from cinder.tests.unit import fake_volume
from cinder.tests.unit.volume.drivers.dell_emc import powerstore from cinder.tests.unit.volume.drivers.dell_emc import powerstore
from cinder.volume.drivers.dell_emc.powerstore import utils from cinder.volume.drivers.dell_emc.powerstore import utils
class TestVolumeAttachDetach(powerstore.TestPowerStoreDriver): class TestVolumeAttachDetach(powerstore.TestPowerStoreDriver):
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client." @mock.patch("cinder.volume.drivers.dell_emc.powerstore.client."
"PowerStoreClient.get_chap_config")
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client."
"PowerStoreClient.get_appliance_id_by_name") "PowerStoreClient.get_appliance_id_by_name")
def setUp(self, mock_appliance): def setUp(self, mock_appliance, mock_chap):
super(TestVolumeAttachDetach, self).setUp() super(TestVolumeAttachDetach, self).setUp()
mock_appliance.return_value = "A1" mock_appliance.return_value = "A1"
mock_chap.return_value = {"mode": "Single"}
self.iscsi_driver.check_for_setup_error() self.iscsi_driver.check_for_setup_error()
self.fc_driver.check_for_setup_error() self.fc_driver.check_for_setup_error()
self.volume = fake_volume.fake_volume_obj( self.volume = fake_volume.fake_volume_obj(
{}, {},
host="host@backend#test-appliance", host="host@backend#test-appliance",
provider_id="fake_id", provider_id="fake_id",
size=8 size=8
) )
self.volume.volume_attachment = ( self.volume.volume_attachment = (
volume_attachment.VolumeAttachmentList() volume_attachment.VolumeAttachmentList()
skipping to change at line 52 skipping to change at line 55
self.volume.volume_attachment.objects = [ self.volume.volume_attachment.objects = [
volume_attachment.VolumeAttachment( volume_attachment.VolumeAttachment(
attach_status=fields.VolumeAttachStatus.ATTACHED, attach_status=fields.VolumeAttachStatus.ATTACHED,
attached_host=self.volume.host attached_host=self.volume.host
), ),
volume_attachment.VolumeAttachment( volume_attachment.VolumeAttachment(
attach_status=fields.VolumeAttachStatus.ATTACHED, attach_status=fields.VolumeAttachStatus.ATTACHED,
attached_host=self.volume.host attached_host=self.volume.host
) )
] ]
self.fake_iscsi_targets_response = [ fake_iscsi_targets_response = [
{ {
"address": "1.2.3.4", "address": "1.2.3.4",
"ip_port": { "ip_port": {
"target_iqn": "target_iqn":
"iqn.2020-07.com.dell:dellemc-powerstore-test-iqn-1" "iqn.2020-07.com.dell:dellemc-powerstore-test-iqn-1"
}, },
}, },
{ {
"address": "5.6.7.8", "address": "5.6.7.8",
"ip_port": { "ip_port": {
"target_iqn": "target_iqn":
"iqn.2020-07.com.dell:dellemc-powerstore-test-iqn-1" "iqn.2020-07.com.dell:dellemc-powerstore-test-iqn-1"
}, },
}, },
] ]
self.fake_fc_wwns_response = [ fake_fc_wwns_response = [
{ {
"wwn": "58:cc:f0:98:49:21:07:02" "wwn": "58:cc:f0:98:49:21:07:02"
}, },
{ {
"wwn": "58:cc:f0:98:49:23:07:02" "wwn": "58:cc:f0:98:49:23:07:02"
}, },
] ]
self.fake_connector = { self.fake_connector = {
"host": self.volume.host, "host": self.volume.host,
"wwpns": ["58:cc:f0:98:49:21:07:02", "58:cc:f0:98:49:23:07:02"], "wwpns": ["58:cc:f0:98:49:21:07:02", "58:cc:f0:98:49:23:07:02"],
"initiator": "fake_initiator", "initiator": "fake_initiator",
} }
self.iscsi_targets_mock = self.mock_object(
self.iscsi_driver.adapter.client,
"get_ip_pool_address",
return_value=fake_iscsi_targets_response
)
self.fc_wwns_mock = self.mock_object(
self.fc_driver.adapter.client,
"get_fc_port",
return_value=fake_fc_wwns_response
)
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client." def test_initialize_connection_chap_enabled(self):
"PowerStoreClient.get_fc_port") self.iscsi_driver.adapter.use_chap_auth = True
def test_get_fc_targets(self, mock_get_ip_pool): with mock.patch.object(self.iscsi_driver.adapter,
mock_get_ip_pool.return_value = self.fake_fc_wwns_response "_create_host_and_attach",
return_value=(
utils.get_chap_credentials(),
1
)):
connection_properties = self.iscsi_driver.initialize_connection(
self.volume,
self.fake_connector
)
self.assertIn("auth_username", connection_properties["data"])
self.assertIn("auth_password", connection_properties["data"])
def test_initialize_connection_chap_disabled(self):
self.iscsi_driver.adapter.use_chap_auth = False
with mock.patch.object(self.iscsi_driver.adapter,
"_create_host_and_attach",
return_value=(
utils.get_chap_credentials(),
1
)):
connection_properties = self.iscsi_driver.initialize_connection(
self.volume,
self.fake_connector
)
self.assertNotIn("auth_username", connection_properties["data"])
self.assertNotIn("auth_password", connection_properties["data"])
def test_get_fc_targets(self):
wwns = self.fc_driver.adapter._get_fc_targets("A1") wwns = self.fc_driver.adapter._get_fc_targets("A1")
self.assertEqual(2, len(wwns)) self.assertEqual(2, len(wwns))
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client." def test_get_fc_targets_filtered(self):
"PowerStoreClient.get_fc_port")
def test_get_fc_targets_filtered(self, mock_get_ip_pool):
mock_get_ip_pool.return_value = self.fake_fc_wwns_response
self.fc_driver.adapter.allowed_ports = ["58:cc:f0:98:49:23:07:02"] self.fc_driver.adapter.allowed_ports = ["58:cc:f0:98:49:23:07:02"]
wwns = self.fc_driver.adapter._get_fc_targets("A1") wwns = self.fc_driver.adapter._get_fc_targets("A1")
self.assertEqual(1, len(wwns)) self.assertEqual(1, len(wwns))
self.assertFalse( self.assertFalse(
utils.fc_wwn_to_string("58:cc:f0:98:49:21:07:02") in wwns utils.fc_wwn_to_string("58:cc:f0:98:49:21:07:02") in wwns
) )
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client." def test_get_fc_targets_filtered_no_matched_ports(self):
"PowerStoreClient.get_fc_port")
def test_get_fc_targets_filtered_no_matched_ports(self, mock_get_ip_pool):
mock_get_ip_pool.return_value = self.fake_fc_wwns_response
self.fc_driver.adapter.allowed_ports = ["fc_wwn_1", "fc_wwn_2"] self.fc_driver.adapter.allowed_ports = ["fc_wwn_1", "fc_wwn_2"]
error = self.assertRaises(exception.VolumeBackendAPIException, error = self.assertRaises(exception.VolumeBackendAPIException,
self.fc_driver.adapter._get_fc_targets, self.fc_driver.adapter._get_fc_targets,
"A1") "A1")
self.assertIn("There are no accessible Fibre Channel targets on the " self.assertIn("There are no accessible Fibre Channel targets on the "
"system.", error.msg) "system.", error.msg)
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client." def test_get_iscsi_targets(self):
"PowerStoreClient.get_ip_pool_address")
def test_get_iscsi_targets(self, mock_get_ip_pool):
mock_get_ip_pool.return_value = self.fake_iscsi_targets_response
iqns, portals = self.iscsi_driver.adapter._get_iscsi_targets("A1") iqns, portals = self.iscsi_driver.adapter._get_iscsi_targets("A1")
self.assertTrue(len(iqns) == len(portals)) self.assertTrue(len(iqns) == len(portals))
self.assertEqual(2, len(portals)) self.assertEqual(2, len(portals))
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client." def test_get_iscsi_targets_filtered(self):
"PowerStoreClient.get_ip_pool_address")
def test_get_iscsi_targets_filtered(self, mock_get_ip_pool):
mock_get_ip_pool.return_value = self.fake_iscsi_targets_response
self.iscsi_driver.adapter.allowed_ports = ["1.2.3.4"] self.iscsi_driver.adapter.allowed_ports = ["1.2.3.4"]
iqns, portals = self.iscsi_driver.adapter._get_iscsi_targets("A1") iqns, portals = self.iscsi_driver.adapter._get_iscsi_targets("A1")
self.assertTrue(len(iqns) == len(portals)) self.assertTrue(len(iqns) == len(portals))
self.assertEqual(1, len(portals)) self.assertEqual(1, len(portals))
self.assertFalse( self.assertFalse(
"iqn.2020-07.com.dell:dellemc-powerstore-test-iqn-2" in iqns "iqn.2020-07.com.dell:dellemc-powerstore-test-iqn-2" in iqns
) )
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.client." def test_get_iscsi_targets_filtered_no_matched_ports(self):
"PowerStoreClient.get_ip_pool_address")
def test_get_iscsi_targets_filtered_no_matched_ports(self,
mock_get_ip_pool):
mock_get_ip_pool.return_value = self.fake_iscsi_targets_response
self.iscsi_driver.adapter.allowed_ports = ["1.1.1.1", "2.2.2.2"] self.iscsi_driver.adapter.allowed_ports = ["1.1.1.1", "2.2.2.2"]
error = self.assertRaises(exception.VolumeBackendAPIException, error = self.assertRaises(exception.VolumeBackendAPIException,
self.iscsi_driver.adapter._get_iscsi_targets, self.iscsi_driver.adapter._get_iscsi_targets,
"A1") "A1")
self.assertIn("There are no accessible iSCSI targets on the system.", self.assertIn("There are no accessible iSCSI targets on the system.",
error.msg) error.msg)
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.adapter." @mock.patch("cinder.volume.drivers.dell_emc.powerstore.adapter."
"CommonAdapter._detach_volume_from_hosts") "CommonAdapter._detach_volume_from_hosts")
@mock.patch("cinder.volume.drivers.dell_emc.powerstore.adapter." @mock.patch("cinder.volume.drivers.dell_emc.powerstore.adapter."
 End of changes. 12 change blocks. 
28 lines changed or deleted 52 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)