'Ensure that an instance\'s filtering rules are enabled.
When migrating an instance, we need the filtering rules to
be configured on the destination host before starting the
migration.
Also, when restarting the compute service, we need to ensure
that filtering rules exist for all running services.'

def ensure_filtering_rules_for_instance(self, instance, network_info):

    self.firewall_driver.setup_basic_filtering(instance, network_info)
    self.firewall_driver.prepare_instance_filter(instance, network_info)
    timeout_count = list(range(CONF.live_migration_retry_count))
    while timeout_count:
        if self.firewall_driver.instance_filter_exists(instance, network_info):
            break
        timeout_count.pop()
        if (len(timeout_count) == 0):
            msg = _('The    firewall    filter    for    %s    does    not    exist')
            raise exception.InternalError((msg % instance.name))
        greenthread.sleep(1)
