'Setup or teardown the network structures.'

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

    if (not self._has_port_binding_extension(context, refresh_cache=True)):
        return
    port_migrating = (host and (instance.host != host))
    if (port_migrating or teardown):
        search_opts = {'device_id': instance.uuid, 'tenant_id': instance.project_id, BINDING_HOST_ID: instance.host}
        data = self.list_ports(context, **search_opts)
        ports = data['ports']
        admin_client = get_client(context, admin=True)
        if teardown:
            self._clear_migration_port_profile(context, instance, admin_client, ports)
        elif port_migrating:
            self._setup_migration_port_profile(context, instance, host, admin_client, ports)
