'Safely sets the host of the network.'

def set_network_host(self, context, network_ref):

    if (not isinstance(network_ref, obj_base.NovaObject)):
        network_ref = objects.Network._from_db_object(context, objects.Network(), network_ref)
    LOG.debug('Setting    host    %s    for    network    %s', self.host, network_ref.uuid)
    network_ref.host = self.host
    network_ref.save()
    return self.host
