'Determine if networks are needed to be deallocated before reschedule
Check the cached network info for any assigned SR-IOV ports.
SR-IOV ports should be deallocated prior to rescheduling
in order to allow new sriov pci devices to be allocated on a new host.'

def deallocate_sriov_ports_on_reschedule(self, instance):

    info_cache = instance.info_cache
    def _has_sriov_port(vif):
        return (vif['vnic_type'] in network_model.VNIC_TYPES_SRIOV)
    if (info_cache and info_cache.network_info):
        for vif in info_cache.network_info:
            if _has_sriov_port(vif):
                return True
    return False
