'Create a fake Config file.
Huawei storage customize a XML configuration file, the configuration
file is used to set the Huawei storage custom parameters, therefore,
in the UT test we need to simulate such a configuration file.'

def _create_fake_conf_file(self, configs):

    doc = minidom.Document()
    config = doc.createElement('config')
    doc.appendChild(config)
    storage = doc.createElement('Storage')
    config.appendChild(storage)
    url = doc.createElement('RestURL')
    url_text = doc.createTextNode('http://192.0.2.69:8082/deviceManager/rest/')
    url.appendChild(url_text)
    storage.appendChild(url)
    username = doc.createElement('UserName')
    username_text = doc.createTextNode('admin')
    username.appendChild(username_text)
    storage.appendChild(username)
    password = doc.createElement('UserPassword')
    password_text = doc.createTextNode('Admin@storage')
    password.appendChild(password_text)
    storage.appendChild(password)
    product = doc.createElement('Product')
    product_text = doc.createTextNode(configs.get('Product', 'V3'))
    product.appendChild(product_text)
    storage.appendChild(product)
    protocol = doc.createElement('Protocol')
    protocol_text = doc.createTextNode('iSCSI')
    protocol.appendChild(protocol_text)
    storage.appendChild(protocol)
    lun = doc.createElement('LUN')
    config.appendChild(lun)
    if ('LUNType' in configs):
        luntype = doc.createElement('LUNType')
        luntype_text = doc.createTextNode(configs['LUNType'])
        luntype.appendChild(luntype_text)
        lun.appendChild(luntype)
    lun_ready_wait_interval = doc.createElement('LUNReadyWaitInterval')
    lun_ready_wait_interval_text = doc.createTextNode('2')
    lun_ready_wait_interval.appendChild(lun_ready_wait_interval_text)
    lun.appendChild(lun_ready_wait_interval)
    lun_copy_wait_interval = doc.createElement('LUNcopyWaitInterval')
    lun_copy_wait_interval_text = doc.createTextNode('2')
    lun_copy_wait_interval.appendChild(lun_copy_wait_interval_text)
    lun.appendChild(lun_copy_wait_interval)
    timeout = doc.createElement('Timeout')
    timeout_text = doc.createTextNode('43200')
    timeout.appendChild(timeout_text)
    lun.appendChild(timeout)
    write_type = doc.createElement('WriteType')
    write_type_text = doc.createTextNode('1')
    write_type.appendChild(write_type_text)
    lun.appendChild(write_type)
    mirror_switch = doc.createElement('MirrorSwitch')
    mirror_switch_text = doc.createTextNode('1')
    mirror_switch.appendChild(mirror_switch_text)
    lun.appendChild(mirror_switch)
    prefetch = doc.createElement('Prefetch')
    prefetch.setAttribute('Type', '1')
    prefetch.setAttribute('Value', '0')
    lun.appendChild(prefetch)
    pool = doc.createElement('StoragePool')
    pool_text = doc.createTextNode('OpenStack_Pool')
    pool.appendChild(pool_text)
    lun.appendChild(pool)
    iscsi = doc.createElement('iSCSI')
    config.appendChild(iscsi)
    defaulttargetip = doc.createElement('DefaultTargetIP')
    defaulttargetip_text = doc.createTextNode('192.0.2.68')
    defaulttargetip.appendChild(defaulttargetip_text)
    iscsi.appendChild(defaulttargetip)
    initiator = doc.createElement('Initiator')
    initiator.setAttribute('Name', 'iqn.1993-08.debian:01:ec2bff7ac3a3')
    initiator.setAttribute('TargetIP', '192.0.2.2')
    initiator.setAttribute('CHAPinfo', 'mm-user;mm-user@storage')
    initiator.setAttribute('ALUA', '1')
    initiator.setAttribute('TargetPortGroup', 'PortGroup001')
    iscsi.appendChild(initiator)
    fakefile = open(self.conf.cinder_huawei_conf_file, 'w')
    fakefile.write(doc.toprettyxml(indent=''))
    fakefile.close()
