data = {"NAME": new_name, "DESCRIPTION": des}
mock_call.assert_called_once_with(url, data, "PUT")
+ @mock.patch.object(rest_client.RestClient, 'call',
+ return_value={"data": {}})
+ def test_is_host_associated_to_hostgroup_no_data(self, mock_call):
+ res = self.driver.client.is_host_associated_to_hostgroup('1')
+ self.assertFalse(res)
+
+ @mock.patch.object(rest_client.RestClient, 'call',
+ return_value={"data": {'ISADD2HOSTGROUP': 'true'}})
+ def test_is_host_associated_to_hostgroup_true(self, mock_call):
+ res = self.driver.client.is_host_associated_to_hostgroup('1')
+ self.assertTrue(res)
+
+ @mock.patch.object(rest_client.RestClient, 'call',
+ return_value={"data": {'ISADD2HOSTGROUP': 'false'}})
+ def test_is_host_associated_to_hostgroup_false(self, mock_call):
+ res = self.driver.client.is_host_associated_to_hostgroup('1')
+ self.assertFalse(res)
+
class HuaweiConfTestCase(test.TestCase):
def setUp(self):
self.client.get_host_fc_initiators(host_id))
iqns_in_host = (
self.client.get_host_iscsi_initiators(host_id))
- if not wwns_in_host and not iqns_in_host:
+ if not (wwns_in_host or iqns_in_host or
+ self.client.is_host_associated_to_hostgroup(host_id)):
self.client.remove_host(host_id)
msg = _('No FC initiator can be added to host.')
msg = _('Set pair secondary access error.')
self._assert_rest_result(result, msg)
+
+ def is_host_associated_to_hostgroup(self, host_id):
+ url = "/host/" + host_id
+ result = self.call(url, None, "GET")
+ data = result.get('data')
+ if data is not None:
+ return data.get('ISADD2HOSTGROUP') == 'true'
+ return False