'Check on chap state and define host accordingly.'

@proxy._trace_time
def _define_host_according_to_chap(self, host, in_domain):

    chap_name = None
    chap_secret = None
    if ((self._get_connection_type() == storage.XIV_CONNECTION_TYPE_ISCSI) and (self._get_chap_type() == storage.CHAP_ENABLED)):
        host_bunch = {'name': host, 'chap': None}
        chap = self._create_chap(host=host_bunch)
        chap_name = chap[0]
        chap_secret = chap[1]
        LOG.debug('_define_host_according_to_chap:    %(name)s    :    %(secret)s', {'name': chap_name, 'secret': chap_secret})
    return self._call_host_define(host=host, chap_name=chap_name, chap_secret=chap_secret, domain_name=in_domain)
