'calls setup/teardown on network hosts for an instance.'

def setup_networks_on_host(self, context, instance_id, host, instance=None, teardown=False):

    green_threads = []
    if teardown:
        call_func = self._teardown_network_on_host
    else:
        call_func = self._setup_network_on_host
    if (instance is None):
        instance = objects.Instance.get_by_id(context, instance_id)
    vifs = objects.VirtualInterfaceList.get_by_instance_uuid(context, instance.uuid)
    LOG.debug('Setup    networks    on    host', instance=instance)
    for vif in vifs:
        network = objects.Network.get_by_id(context, vif.network_id)
        if (not network.multi_host):
            host = network['host']
        if ((self.host == host) or (host is None)):
            call_func(context, network)
        else:
            green_threads.append(utils.spawn(self.network_rpcapi.rpc_setup_network_on_host, context, network.id, teardown, host))
    for gt in green_threads:
        gt.wait()
