@Override public boolean stop() { try { final Connect conn = LibvirtConnection.getConnection(); conn.close(); } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } return true; }
conn.close(); } catch (final LibvirtException e) { LOGGER.error("Caught libvirt exception while fetching host information", e);
dconn.close();
/** * Count the amount of active VMs * * @return */ private int countRunningVMs() throws LibvirtException { Connect connect = connectToKVM(settings.get(SETTINGS_URL)); try { return connect.numOfDomains(); } finally { connect.close(); } }
/** * Remove a factory instance. * <p/> * Remove the factory instance associated with the PID. If the instance was * registered with the service registry, it should be unregistered. * <p/> * If this method throws any <code>Exception</code>, the Configuration * Admin service must catch it and should log it. * <p/> * The Configuration Admin service must call this method asynchronously. * * @param pid the PID of the service to be removed */ @Override public void deleted(String pid) { ServiceRegistration oldRegistration = registrations.remove(pid); if (bundleContext != null) { Connect connect = (Connect) bundleContext.getService(oldRegistration.getReference()); try { connect.close(); } catch (LibvirtException e) { LOG.error("Error closing libvirt connection", e); } } if (oldRegistration != null) { oldRegistration.unregister(); } } }
@Override public void close() throws VMMgmtException { for (VMData vm : vms) { vm.releaseSSHResources(); } try { conn.close(); } catch (LibvirtException ex) { throw new VMMgmtException(ex); } }
@Override public Map<String, String> validateSettings(Map<String, String> settings) { Map<String, String> errors = new HashMap<>(); if (settings.containsKey(SETTINGS_URL)) { Connect conn = null; try { conn = connectToKVM(settings.get(SETTINGS_URL)); NodeInfo ni = conn.nodeInfo(); } catch (LibvirtException e) { logger().error("Couldn't connect to kvm host {}", settings.get(SETTINGS_URL), e); } finally { if (conn != null) { try { conn.close(); } catch (LibvirtException e) { logger().error("Couldn't close connection to kvm host {}", settings.get(SETTINGS_URL), e); } } } } else { errors.put("Empty", "Url is empty"); } return errors; }
.collect(Collectors.toList()); } finally { connect.close();
commit(); delegate.close();
conn.close();