'Test host and FC targets
Tests that host and fc targets are provided
if the host is not defined'

def test_get_host_and_fc_targets_if_host_not_defined(self):

    p = self.proxy(self.default_storage_info, mock.MagicMock(), test_mock.cinder.exception)
    p.meta = mock.MagicMock()
    p.meta.ibm_storage_iqn = 'BLAIQN'
    p.meta.ibm_storage_portal = 'BLAPORTAL'
    p.meta.openstack_version = 'cinder-2013.2'
    pool = {'name': 'WTF32', 'domain': 'pool_domain_bla'}
    p.ibm_storage_cli = mock.MagicMock()
    p.ibm_storage_cli.cmd.host_list.return_value.as_list = []
    p.ibm_storage_cli.cmd.host_list_ports.return_value = []
    p.ibm_storage_cli.cmd.pool_list.return_value.as_list = [pool]
    p._get_bunch_from_host = mock.MagicMock()
    p._get_bunch_from_host.return_value = {'name': ('nova-compute-%s' % TEST_INITIATOR), 'initiator': TEST_INITIATOR, 'id': 123, 'wwpns': 111, 'chap': 'chap'}
    (fc_targets, host) = getattr(p, '_get_host_and_fc_targets')(TEST_VOLUME, TEST_CONNECTOR)
    hostname = storage.get_host_or_create_from_iqn(TEST_CONNECTOR)
    p.ibm_storage_cli.cmd.host_define.assert_called_once_with(host=hostname, domain=pool.get('domain'))
    p.ibm_storage_cli.cmd.host_add_port.assert_called_once_with(host=hostname, iscsi_name=TEST_CONNECTOR['initiator'])
