{"record":{"id":"900c5f509e4df0fd","repo":"theforeman/foreman","slug":"unable-to-connect-to-libvirt-due-to-s-please-ma","errorCode":null,"errorMessage":"Unable to connect to libvirt due to: %s. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions.","messagePattern":"Unable to connect to libvirt due to: (.+?)\\. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions\\.","errorType":"exception","errorClass":"Foreman::Exception","httpStatus":null,"severity":"error","filePath":"app/models/compute_resources/foreman/model/libvirt.rb","lineNumber":277,"sourceCode":"          conn.terminate if conn.respond_to?(:terminate)\n          Thread.current[name] = nil\n        end\n      end\n    end\n\n    def disconnect\n      self.class.terminate_connection(url)\n    end\n\n    def image_exists?(uuid)\n      client.volumes.get(uuid) != nil\n    end\n\n    protected\n\n    def libvirt_connection_error\n      msg = N_('Unable to connect to libvirt due to: %s. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions.')\n      raise Foreman::Exception.new(msg, errors.full_messages.join(', '))\n    end\n\n    def client\n      tries ||= 3\n      key = \"libvirt_connection_#{url}\"\n      Thread.current[key] ||= begin\n        conn = ::Fog::Compute.new(:provider => \"Libvirt\", :libvirt_uri => url)\n        logger.debug { \"Created libvirt connection #{conn.object_id}: #{url}\" }\n        conn\n      end\n    rescue ::Libvirt::RetrieveError\n      logger.debug { \"Libvirt connection failed, trying again\" }\n      Thread.current[key] = nil\n      retry unless (tries -= 1).zero?\n    end\n\n    def vm_instance_defaults\n      super.merge(","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/models/compute_resources/foreman/model/libvirt.rb#L259-L295","documentation":"Error \"Unable to connect to libvirt due to: %s. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions.\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/models/compute_resources/foreman/model/libvirt.rb:277 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6b05625475cfe6aac31a88f8c8ee6e62e4efe620","analyzedAt":"2026-08-23T17:46:34.094Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}