use of org.opennms.netmgt.config.service.ServiceConfiguration in project opennms by OpenNMS.
the class EOLServiceConfigMigratorOffline method execute.
/* (non-Javadoc)
* @see org.opennms.upgrade.api.OnmsUpgrade#execute()
*/
@Override
public void execute() throws OnmsUpgradeException {
final String[] eol = { "OpenNMS:Name=Linkd", "OpenNMS:Name=Xmlrpcd", "OpenNMS:Name=XmlrpcProvisioner", "OpenNMS:Name=AccessPointMonitor" };
try {
final ServiceConfiguration currentCfg = JaxbUtils.unmarshal(ServiceConfiguration.class, configFile);
// Remove any end-of-life'd daemons from service configuration
for (final String serviceName : eol) {
final Service eolService = getService(currentCfg, serviceName);
if (eolService == null) {
continue;
}
final String eolServiceName = eolService.getName();
if (eolServiceName.equals(serviceName)) {
final String displayName = serviceName.replace("OpenNMS:Name=", "");
log("Disabling EOL service: " + displayName + "\n");
eolService.setEnabled(false);
}
}
final StringWriter sw = new StringWriter();
sw.write("<?xml version=\"1.0\"?>\n");
sw.write("<!-- NOTE!!!!!!!!!!!!!!!!!!!\n");
sw.write("The order in which these services are specified is important - for example, Eventd\n");
sw.write("will need to come up last so that none of the event topic subcribers loose any event.\n");
sw.write("\nWhen splitting services to run on mutiple VMs, the order of the services should be\n");
sw.write("maintained\n");
sw.write("-->\n");
JaxbUtils.marshal(currentCfg, sw);
final FileWriter fw = new FileWriter(configFile);
fw.write(sw.toString());
fw.close();
} catch (final Exception e) {
throw new OnmsUpgradeException("Can't fix services configuration because " + e.getMessage(), e);
}
}
Aggregations