Set the IP address on a virtual interface (vif)

def set_vm_ip(name=None,
              ipv4_cidr=None,
              ipv4_gw=None,
              session=None,
              call=None):
    '''
    Set the IP address on a virtual interface (vif)

    '''
    mode = 'static'
    # TODO: Need to add support for IPv6
    if call == 'function':
        raise SaltCloudException(
            'The function must be called with -a or --action.')

    log.debug(
        'Setting name: %s ipv4_cidr: %s ipv4_gw: %s mode: %s',
        name, ipv4_cidr, ipv4_gw, mode
    )
    if session is None:
        log.debug('New session being created')
        session = _get_session()
    vm = _get_vm(name, session)
    # -- try to get ip from vif
    # TODO: for now will take first interface
    #       addition consideration needed for
    #       multiple interface(vif) VMs
    vifs = session.xenapi.VM.get_VIFs(vm)
    if vifs is not None:
        log.debug('There are %s vifs.', len(vifs))
        for vif in vifs:
            record = session.xenapi.VIF.get_record(vif)
            log.debug(record)
            try:
                session.xenapi.VIF.configure_ipv4(
                    vif, mode, ipv4_cidr, ipv4_gw)
            except XenAPI.Failure:
                log.info('Static IP assignment could not be performed.')

    return True