'Login Huawei storage array.'

def login(self):

    device_id = None
    for item_url in self.san_address:
        url = (item_url + 'xx/sessions')
        data = {'username': self.san_user, 'password': self.san_password, 'scope': '0'}
        self.init_http_head()
        result = self.do_call(url, data, 'POST', calltimeout=constants.LOGIN_SOCKET_TIMEOUT, log_filter_flag=True)
        if ((result['error']['code'] != 0) or ('data' not in result)):
            LOG.error('Login    error.    URL:    %(url)s\nReason:    %(reason)s.', {'url': item_url, 'reason': result})
            continue
        LOG.debug('Login    success:    %(url)s', {'url': item_url})
        device_id = result['data']['deviceid']
        self.device_id = device_id
        self.url = (item_url + device_id)
        self.session.headers['iBaseToken'] = result['data']['iBaseToken']
        if (result['data']['accountstate'] in (constants.PWD_EXPIRED, constants.PWD_RESET)):
            self.logout()
            msg = _('Password    has    expired    or    has    been    reset,    please    change    the    password.')
            LOG.error(msg)
            raise exception.VolumeBackendAPIException(data=msg)
        break
    if (device_id is None):
        msg = _('Failed    to    login    with    all    rest    URLs.')
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    return device_id
