/** * Gets the home directory. * * @return the home directory */ protected String getHomeDirectory() { return ConfigFileConstants.getHome(); }
/** * Method to return the string for the managed address include files for * discovery, capsd and polling. * * @return String, the file url for the include file */ public static String getIncludeFileString() { return "file:" + getHome() + File.separator + "etc" + File.separator + "include"; }
/** * Method to return the string for path of the etc directory. * * @return String, the file url for the include file */ public static String getFilePathString() { return getHome() + File.separator + "etc" + File.separator; }
/** * Gets the mapping group file. * * @param mappingFileName the mapping file name * @return the mapping group file */ public File getMappingGroupFile(String mappingFileName) { return new File(ConfigFileConstants.getHome(), "etc" + File.separator + mappingFileName); }
public DiscoveryConfigurationMigratorOffline() throws OnmsUpgradeException { super(); m_configFile = Paths.get(ConfigFileConstants.getHome(), "etc", "discovery-configuration.xml").toFile(); }
public AbstractMergingJaxbConfigDao(final Class<K> entityClass, final String description, final Path rootFile, final Path includeFolder) { m_entityClass = Objects.requireNonNull(entityClass, "entityClass argument"); m_description = Objects.requireNonNull(description, "description argument"); m_rootFile = rootFile; m_includeFolder = Objects.requireNonNull(includeFolder, "includeFolder argument"); m_opennmsHome = Paths.get(ConfigFileConstants.getHome()); }
public DiscoveryConfigurationLocationMigratorOffline() throws OnmsUpgradeException { super(); m_configFile = Paths.get(ConfigFileConstants.getHome(), "etc", "discovery-configuration.xml").toFile(); }
/** * Instantiates a new data collection configuration migrator for OpenNMS 17 offline. * * @throws OnmsUpgradeException the OpenNMS upgrade exception */ public DataCollectionConfigMigrator17Offline() throws OnmsUpgradeException { super(); sourceFile = Paths.get(ConfigFileConstants.getHome(), "etc", "datacollection-config.xml").toFile(); backupFile= new File(sourceFile.getAbsolutePath() + ZIP_EXT); }
public static File getDefaultRulesFolder() { return Paths.get(ConfigFileConstants.getHome(), "etc", "alarmd", "drools-rules.d").toFile(); }
public static File getDefaultRulesFolder() { return Paths.get(ConfigFileConstants.getHome(), "etc", "alarmd", "drools-rules.d").toFile(); }
public String getConfigDirectory() { if (m_configDirectory == null) { final StringBuilder sb = new StringBuilder(ConfigFileConstants.getHome()); sb.append(File.separator); sb.append("etc"); sb.append(File.separator); sb.append("datacollection"); sb.append(File.separator); m_configDirectory = sb.toString(); } return m_configDirectory; }
/** * Gets the configuration directory. * * @return the configuration directory */ private File getConfigDirectory() { if (m_configDirectory == null) { final StringBuilder sb = new StringBuilder(ConfigFileConstants.getHome()); sb.append(File.separator); sb.append("etc"); sb.append(File.separator); m_configDirectory = new File(sb.toString()); } return m_configDirectory; }
public DataCollectionConfigMigratorOffline() throws OnmsUpgradeException { super(); // Substitutions to make substitutionMap.put("org.opennms.netmgt.collectd.PersistAllSelectorStrategy", "org.opennms.netmgt.collection.support.PersistAllSelectorStrategy"); substitutionMap.put("org.opennms.netmgt.dao.support.IndexStorageStrategy", "org.opennms.netmgt.collection.support.IndexStorageStrategy"); // Grab the data collection configuration directory dataCollectionConfigDir = Paths.get(ConfigFileConstants.getHome(), "etc", "datacollection").toFile(); // Make sure it's a valid directory before continuing if (!dataCollectionConfigDir.isDirectory()) { throw new OnmsUpgradeException(String.format("Failed to determine the data collection configuration directory. " + "%s is not a directory", dataCollectionConfigDir.getAbsolutePath())); } dataCollectionConfigDirBackupZip = new File(dataCollectionConfigDir.getAbsolutePath() + ZIP_EXT); }
/** * This when invoked marshals the report XML from the classes. * * @throws java.io.IOException if any. * @throws java.lang.Exception if any. */ public void marshalReport() throws IOException, Exception { File file = new File(ConfigFileConstants.getHome() + "/share/reports/AvailReport.xml"); try { Writer fileWriter = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8); JaxbUtils.marshal(m_report, fileWriter); LOG.debug("The xml marshalled from the JAXB classes is saved in {}/share/reports/AvailReport.xml", ConfigFileConstants.getHome()); fileWriter.close(); } catch (Throwable e) { LOG.error("Exception", e); } }
/** * This when invoked marshals the report XML from the classes. * * @throws java.io.IOException if any. * @throws java.lang.Exception if any. */ public void marshalReport() throws IOException, Exception { File file = new File(ConfigFileConstants.getHome() + "/share/reports/AvailReport.xml"); try { Writer fileWriter = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8); JaxbUtils.marshal(m_report, fileWriter); LOG.debug("The xml marshalled from the JAXB classes is saved in {}/share/reports/AvailReport.xml", ConfigFileConstants.getHome()); fileWriter.close(); } catch (Throwable e) { LOG.error("Exception", e); } }
/** * Instantiates a new magic users migrator offline. * * @throws OnmsUpgradeException the OpenNMS upgrade exception */ public MagicUsersMigratorOffline() throws OnmsUpgradeException { super(); try { magicUsersFile = new File(ConfigFileConstants.getHome(), "etc" + File.separator + "magic-users.properties"); magicUsersFileRPM = new File(magicUsersFile.getAbsolutePath() + ".rpmsave"); magicUsersFileDEB = new File(magicUsersFile.getAbsolutePath() + ".dpkg-remove"); usersFile = ConfigFileConstants.getFile(ConfigFileConstants.USERS_CONF_FILE_NAME); } catch (Exception e) { } }
@Override public void run() { LOG.debug("inside generatePDF"); File file = new File(ConfigFileConstants.getHome() + "/share/reports/AvailReport.xml"); try { LOG.debug("The xml marshalled from the JAXB classes is saved in {}/share/reports/AvailReport.xml", ConfigFileConstants.getHome()); Reader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); if (!format.equals("HTML")) { new PDFReportRenderer().render(fileReader, out, new InputStreamReader(new FileInputStream(xsltFileName), StandardCharsets.UTF_8)); } else { new HTMLReportRenderer().render(fileReader, out, new InputStreamReader(new FileInputStream(xsltFileName), StandardCharsets.UTF_8)); } } catch (Throwable e) { LOG.error("Exception", e); } LOG.info("leaving generatePDF"); }
/** * Parses the XML groups. * * @param source the XML source */ private void parseXmlGroups(XmlSource source) { if (!source.hasImportGroups()) { return; } for (String importGroup : source.getImportGroupsList()) { File file = new File(ConfigFileConstants.getHome(), "/etc/" + importGroup); LOG.debug("parseXmlGroups: parsing {}", file); XmlGroups groups = JaxbUtils.unmarshal(XmlGroups.class, new FileSystemResource(file)); source.getXmlGroups().addAll(groups.getXmlGroups()); } }
/** * Parses the XML groups. * * @param source the XML source */ private void parseXmlGroups(XmlSource source) { if (!source.hasImportGroups()) { return; } for (String importGroup : source.getImportGroupsList()) { File file = new File(ConfigFileConstants.getHome(), "/etc/" + importGroup); LOG.debug("parseXmlGroups: parsing {}", file); XmlGroups groups = JaxbUtils.unmarshal(XmlGroups.class, new FileSystemResource(file)); source.getXmlGroups().addAll(groups.getXmlGroups()); } }
/** * Generate graph templates. * * @param parser the MIB parser * @param logger the logger */ public void generateGraphTemplates(final MibParser parser, final Logger logger) { final File configDir = new File(ConfigFileConstants.getHome(), "etc" + File.separatorChar + "snmp-graph.properties.d"); final File file = new File(configDir, parser.getMibName().replaceAll(" ", "_") + "-graph.properties"); try { FileWriter writer = new FileWriter(file); List<PrefabGraph> graphs = parser.getPrefabGraphs(); PrefabGraphDumper dumper = new PrefabGraphDumper(); dumper.dump(graphs, writer); writer.close(); logger.info("Graph templates successfully generated on " + file); } catch (Exception e) { logger.error("Can't generate the graph templates on " + file); } }