perfsonar-dev - perfsonar: r3085 - in trunk/geant2_java-sshtelnet-mp: ant src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters
Subject: perfsonar development work
List archive
perfsonar: r3085 - in trunk/geant2_java-sshtelnet-mp: ant src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3085 - in trunk/geant2_java-sshtelnet-mp: ant src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters
- Date: Wed, 5 Dec 2007 04:21:32 -0500
Author: melis
Date: 2007-12-05 04:21:31 -0500 (Wed, 05 Dec 2007)
New Revision: 3085
Removed:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/QuaggaBgpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/QuaggaIpAdapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/QuaggaIpv6Adapter.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/QuaggaStatusAdapter.java
Modified:
trunk/geant2_java-sshtelnet-mp/ant/configure-targets.xml
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands/CommandInterface.java
Log:
Added ongoing development for XML metadata configuration file
Removed quagga devices from the MP
Modified: trunk/geant2_java-sshtelnet-mp/ant/configure-targets.xml
===================================================================
--- trunk/geant2_java-sshtelnet-mp/ant/configure-targets.xml 2007-12-05
06:29:40 UTC (rev 3084)
+++ trunk/geant2_java-sshtelnet-mp/ant/configure-targets.xml 2007-12-05
09:21:31 UTC (rev 3085)
@@ -76,9 +76,11 @@
<propertyfile file="${basedir}/conf/service.properties">
- <entry key="service.sax_parser.config"
value="${service.home}/${deploy.root}/WEB-INF/classes/perfsonar/conf/objects.config"/>
- <entry key="service.log.log4j.config"
value="${service.home}/${deploy.root}/WEB-INF/classes/perfsonar/conf/log4j.properties"/>
+ <entry key="service.sax_parser.config"
value="${service.home}/${deploy.root}/WEB-INF/classes/perfsonar/conf/objects.config"/>
+ <entry key="service.log.log4j.config"
value="${service.home}/${deploy.root}/WEB-INF/classes/perfsonar/conf/log4j.properties"/>
+ <entry key="service.ls.registration_file" value=""/>
+
<!-- for LookupInfoRequest message -->
<entry key="service.r.service_type" value="mp"/>
<entry key="service.r.service_name"
value="${service.name}"/>
Deleted:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters/QuaggaBgpAdapter.java
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
2007-12-05 06:29:40 UTC (rev 3084)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
2007-12-05 09:21:31 UTC (rev 3085)
@@ -3,7 +3,6 @@
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
@@ -12,24 +11,36 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import java.util.StringTokenizer;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.IllegalAddException;
+import org.jdom.JDOMException;
+import org.jdom.Namespace;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.XMLOutputter;
import
org.perfsonar.service.measurementPoint.lookingGlassType.encryption.PasswordEncryptor;
public class ServicePropertiesConfigurator {
+ private static Namespace NMWG = Namespace.getNamespace("nmwg",
"http://ggf.org/ns/nmwg/base/2.0/");
+
String[] lines;
String previousDevices;
- private Properties prop;
-
+ //private Properties prop;
+ Document doc;
+ Element store;
+ Element metadata;
+ Element data;
+
private static String MINIMUM_PACKAGE = "minimumpackage.txt";
public ServicePropertiesConfigurator() {
lines = new String[3];
- prop = new Properties();
+ //prop = new Properties();
}
public void doStuff(String outputFile) {
@@ -38,34 +49,22 @@
BufferedReader br = new BufferedReader(new
InputStreamReader(
System.in));
- //BufferedWriter out = null;
- //out = new BufferedWriter(new FileWriter(outputFile,
true));
- //FileOutputStream out = new FileOutputStream
(outputFile, true);
+ doc = new Document();
+ store = new Element("store", NMWG);
- //List devices = new ArrayList();
previousDevices = new String(); // devices defined
in given service.properties file
- //List types = new ArrayList();
- //List commands = new ArrayList();
+ File outpFile = new File (outputFile);
- List previousCommands = new ArrayList(); // list of
commands for every device in given
- // service.properties (also in String format)
-
- //List allCommands = new ArrayList();
-
- File outpFile = new File (outputFile);
-
- //System.out.println("outputFile object created");
-
- if (outpFile.exists()) {
+ /*if (outpFile.exists()) {
System.out.println("Loading existing
properties...");
prop.load(new FileInputStream(outputFile));
System.out.println("Properties loaded");
}
System.out.println("Starting configuration...");
prop.setProperty("service.ls.registration_file", "");
-
+ */
System.out.println();
System.out
.println("|---------------------------------------------|");
@@ -76,7 +75,7 @@
System.out.println();
System.out
- .println("Do you already have a manually edited
service.properties files available ? (yes/no)");
+ .println("Do you already have a manually edited
metadataConfiguration files available ? (yes/no)");
String previous = "";
previous = br.readLine();
while (!previous.equalsIgnoreCase("yes")
@@ -86,13 +85,22 @@
}
if (previous.equalsIgnoreCase("yes")) { // manually
edited service.properties
- System.out.println();
- System.out
- .println("Please enter the path to this
configuration file");
- String file = br.readLine();
-
- prop.load(new FileInputStream(new
File(file)));
-
+ try {
+ System.out.println();
+ System.out
+ .println("Please enter the path to
this configuration file");
+ String file = br.readLine();
+
+ SAXBuilder builder = new SAXBuilder();
+ doc = builder.build(file);
+
+ store = doc.getRootElement();
+
+ } catch (JDOMException e) {
+ System.out.println("[ERROR] entered
configuration file does not exist");
+ e.printStackTrace();
+ }
+
} else { // answer == no
System.out
.println("Do you have a CSV file which
defines the configuration? (yes/no)");
@@ -118,9 +126,18 @@
askManually(outputFile); // manually
provide configuration information
}
}
+
+ doc.setRootElement(store);
- prop.store(new FileOutputStream(outputFile),
"Service.properties");
-
+ XMLOutputter outputter = new XMLOutputter("\t", true);
+ try {
+ outputter.output(doc, new
FileOutputStream(outputFile));
+ }
+ catch (IOException e) {
+ System.err.println(e);
+ }
+ //prop.store(new FileOutputStream(outputFile),
"Service.properties");
+
} catch (IOException e) {
e.printStackTrace();
}
@@ -137,118 +154,303 @@
String device;
String deviceType;
- String[] devicesArray = new String[lines.length];
+ //String[] devicesArray = new String[lines.length];
+
+ System.out.println("[DEBUG] number of lines to be
parsed: " + lines.length);
+
for (int i=0; i<lines.length && lines[i] != null;
i++){
+
+ System.out.println("[DEBUG] line: "+lines[i]);
+
+ metadata = new Element("metadata", NMWG);
+ metadata.setAttribute("id", "metadata" + i);
+
tok = new StringTokenizer(lines[i],"%%%");
// First the device info
deviceInfo = tok.nextToken();
deviceTok = new
StringTokenizer(deviceInfo,"@@@");
device = deviceTok.nextToken();
- devicesArray[i] = device;
+
+ Element subject = new Element("subject",
NMWG);
+ subject.setAttribute("id", "subject"+i);
+ subject.addContent(device);
+ metadata.addContent(subject);
+
+ //devicesArray[i] = device;
deviceType = deviceTok.nextToken();
- if
(deviceType.equalsIgnoreCase("quaggatelnet")) {
- prop.setProperty("service.mp."+ device
- + ".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.QuaggaAdapter");
- prop.setProperty("service.r.mp." +
device + ".url", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".rate", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".password", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
- prop.setProperty("service.r.mp." +
device + ".bgp.port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".bgp.prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".bgp.password", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
- } else if
(deviceType.equalsIgnoreCase("ciscotelnet")) {
- prop.setProperty("service.mp."+ device
- + ".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoAdapter");
- prop.setProperty("service.r.mp." +
device + ".url", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".rate", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".username", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".password", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
+
+ Element params = new Element("parameters",
NMWG);
+ params.setAttribute("id", "metaParams"+i);
+
+ Element param;
+
+ if
(deviceType.equalsIgnoreCase("ciscotelnet")) {
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoAdapter");
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","url");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","port");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","prompt");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","rate");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","username");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","password");
+ param.setAttribute("value","" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","cache");
+ param.setAttribute("value", "0");
+ params.addContent(param);
+
+ metadata.addContent(params);
} else if
(deviceType.equalsIgnoreCase("ciscossh")) {
- prop.setProperty("service.mp."+ device
- + ".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoSshAdapter");
- prop.setProperty("service.r.mp." +
device + ".url", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".rate", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".username", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".password", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoSshAdapter");
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","url");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","port");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","prompt");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","rate");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","username");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","password");
+ param.setAttribute("value","" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","cache");
+ param.setAttribute("value","0");
+ params.addContent(param);
+
+ metadata.addContent(params);
} else if
(deviceType.equalsIgnoreCase("ciscokey")) {
- prop.setProperty("service.mp."+ device
- + ".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoKeyAdapter");
- prop.setProperty("service.r.mp." +
device + ".url", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".rate", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".username", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".keyUrl", "" + deviceTok.nextToken());
- if (deviceTok.hasMoreTokens())
-
prop.setProperty("service.r.mp." + device + ".passphrase", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoKeyAdapter");
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","url");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","port");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","prompt");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","rate");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","username");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","keyUrl");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ if (deviceTok.hasMoreTokens()){
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","passphrase");
+ param.setAttribute("value",""
+ PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
+ params.addContent(param);
+ }
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","cache");
+ param.setAttribute("value","0");
+ params.addContent(param);
+
+ metadata.addContent(params);
} else if
(deviceType.equalsIgnoreCase("junipertelnet")) {
- prop.setProperty("service.mp."+ device
- + ".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperAdapter");
- prop.setProperty("service.r.mp." +
device + ".url", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".rate", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".username", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".password", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperAdapter");
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","url");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","port");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","prompt");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","rate");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","username");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","password");
+ param.setAttribute("value","" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","cache");
+ param.setAttribute("value","0");
+ params.addContent(param);
+
+ metadata.addContent(params);
} else if
(deviceType.equalsIgnoreCase("juniperssh")) {
- prop.setProperty("service.mp."+ device
- + ".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperSshAdapter");
- prop.setProperty("service.r.mp." +
device + ".url", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".rate", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".username", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".password", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperSshAdapter");
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","url");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","port");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","prompt");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","rate");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","username");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","password");
+ param.setAttribute("value","" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","cache");
+ param.setAttribute("value","0");
+ params.addContent(param);
+
+ metadata.addContent(params);
} else if
(deviceType.equalsIgnoreCase("juniperkey")) {
- prop.setProperty("service.mp."+ device
- + ".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperKeyAdapter");
- prop.setProperty("service.r.mp." +
device + ".url", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".port", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".prompt", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".rate", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".username", "" + deviceTok.nextToken());
- prop.setProperty("service.r.mp." +
device + ".keyUrl", "" + deviceTok.nextToken() + "\n");
- if (deviceTok.hasMoreTokens())
-
prop.setProperty("service.r.mp." + device + ".passphrase", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
-
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperKeyAdapter");
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","url");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","port");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","prompt");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","rate");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","username");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","keyUrl");
+ param.setAttribute("value","" +
deviceTok.nextToken());
+ params.addContent(param);
+ if (deviceTok.hasMoreTokens()){
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","passphrase");
+ param.setAttribute("value",""
+ PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
+ params.addContent(param);
+ }
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","cache");
+ param.setAttribute("value","0");
+ params.addContent(param);
+
+ metadata.addContent(params);
} else {
System.out.println("There was an
unknown device type in the csv file: "+deviceType);
}
+ store.addContent(metadata);
+
+ System.out.println("[DEBUG] Store has
"+store.getChildren("metadata", NMWG).size()+ " metadata elements");
+
File tempFile =
File.createTempFile(device+"commands", ".tmp");
DataOutputStream dos = new
DataOutputStream(new FileOutputStream(tempFile, true));
while (tok.hasMoreTokens()) {
//Then write all command info to a
temporary file
-
- dos.writeBytes(tok.nextToken()+"\n");
+ String s = tok.nextToken();
+ System.out.println("[DEBUG] Token to
parse: "+ s);
+ dos.writeBytes(s+"\n");
dos.flush();
}
dos.close();
+
+ data = new Element("data", NMWG);
+ System.out.println("[DEBUG] Data Element
created");
+ data.setAttribute("id", "data" + i);
+ System.out.println("[DEBUG] Data Element
attribute set: \"id\"="+data.getAttributeValue("id"));
+ data.setAttribute("metadataIdRef", "metadata"
+ i);
+ System.out.println("[DEBUG] Data Element
attribute set: \"metadataIdRef\"="+data.getAttributeValue("metadataIdRef"));
+
+
//Then use this temporary file for writing
all command info
addSelectedCommandsToConfig(device,
outputFile, tempFile.toString());
+
+ store.addContent(data);
+
+ System.out.println("[DEBUG] Store has
"+store.getChildren("data", NMWG).size()+ " data elements");
+
}
- String tmp = "";
+ /*String tmp = "";
for (int i=0; i<devicesArray.length &&
devicesArray[i] != null ; i++){
tmp += devicesArray[i]+",";
}
prop.setProperty("service.mp.devices",
tmp.substring(0, tmp.length()-1));
-
+ */
} catch (IOException e) {
e.printStackTrace();
}
@@ -284,10 +486,7 @@
List devices = new ArrayList();
List types = new ArrayList();
- //List commands = new ArrayList();
- // service.properties (also in String format)
-
System.out.println("First the names of the devices
that have to be supported will " +
"be asked.\nHere you can specify
anything you like, but mostly this is the " +
"URL or\nthe hostname of the machine.");
@@ -300,29 +499,25 @@
devices.add(input);
}
- String devicesString = "";
if (devices.size() > 0) {
Iterator it = devices.iterator();
System.out.println(devices.size() + " devices
added.");
- //devicesString += it.next();
- //while (it.hasNext()) {
-
System.out.println("");
System.out
.println("Choose one of the following types
of equipment for every ");
System.out.println("device specified
previously ...");
- System.out.println("1) Quagga - Password
Login (Telnet)");
- System.out.println("2) Cisco - Password Login
(Telnet)");
- System.out.println("3) Cisco - Password Login
(SSH)");
- System.out.println("4) Cisco - Key-based
Login (SSH)");
- System.out.println("5) Juniper - Password
Login (Telnet)");
- System.out.println("6) Juniper - Password
Login (SSH)");
- System.out.println("7) Juniper - Key-based
Login (SSH)");
+ System.out.println("1) Cisco - Password Login
(Telnet)");
+ System.out.println("2) Cisco - Password Login
(SSH)");
+ System.out.println("3) Cisco - Key-based
Login (SSH)");
+ System.out.println("4) Juniper - Password
Login (Telnet)");
+ System.out.println("5) Juniper - Password
Login (SSH)");
+ System.out.println("6) Juniper - Key-based
Login (SSH)");
System.out.println();
Iterator it2 = devices.iterator();
String device = null;
+
while (it2.hasNext()) {
device = (String) it2.next();
System.out.println(device + ": ");
@@ -331,52 +526,19 @@
while (invalid) {
try {
int t =
Integer.parseInt(input);
- if (t <= 7 && t > 0)
+ if (t <= 6 && t > 0)
invalid =
false;
else {
-
System.out.println("Please provide a number between 1 and 7.");
+
System.out.println("Please provide a number between 1 and 6.");
input =
br.readLine();
}
} catch
(NumberFormatException e) {
invalid = true;
-
System.out.println("Please provide a number between 1 and 7.");
+
System.out.println("Please provide a number between 1 and 6.");
input = br.readLine();
}
}
types.add(input);
-
- if (input.equalsIgnoreCase("1"))
- prop.setProperty("service.mp."
- + device
- +
".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.QuaggaAdapter");
- else if (input.equalsIgnoreCase("2"))
- prop.setProperty("service.mp."
- + device
- +
".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoAdapter");
- else if (input.equalsIgnoreCase("3"))
- prop.setProperty("service.mp."
- + device
- +
".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoSshAdapter");
-
- else if (input.equalsIgnoreCase("4"))
- prop.setProperty("service.mp."
- + device
- +
".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoKeyAdapter");
-
- else if (input.equalsIgnoreCase("5"))
- prop.setProperty("service.mp."
- + device
- +
".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperAdapter");
-
- else if (input.equalsIgnoreCase("6"))
- prop.setProperty("service.mp."
- + device
- +
".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperSshAdapter");
-
- else if (input.equalsIgnoreCase("7"))
- prop.setProperty("service.mp."
- + device
- +
".class_name",
"org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperKeyAdapter");
}
System.out.println();
@@ -384,96 +546,87 @@
"some\nmore questions will be
asked to configure the URL, port, username,\n" +
"password or key, prompt and
access-rate (Here you can specify what\n" +
"the minimum interval has to be between
requests (in ms)).");
- //System.out.println("Now, some access
parameters will be asked ...");
System.out.println();
- //}
it = devices.iterator();
int index = -1;
String type = "";
- //String device = "";
while (it.hasNext()) {
device = (String) it.next();
index = devices.indexOf(device);
type = (String) types.get(index);
- //devicesString += it.next() + ",";
- devicesString +=device + ",";
- //System.out.println("devicesString:
"+devicesString);
- //if (previousDevices.equals(""))
- //
prop.setProperty("service.mp.devices=" +
devicesString.substring(0,devicesString.length()-1));
- //else
out.write("service.mp.devices=" + previousDevices +"," + devicesString +
"\n");
-
System.out.println(device);
System.out.println("======");
System.out.println();
- if (type.equalsIgnoreCase("1")) {
+ metadata = new Element("metadata",
NMWG);
+ metadata.setAttribute("id",
"metadata"+index);
+
+ Element subject = new Element
("subject", NMWG);
+ subject.setAttribute("id",
"subject0");
+ subject.addContent(device);
+
+ metadata.addContent(subject);
+
+ Element params = new
Element("parameters", NMWG);
+ params.setAttribute("id",
"metaParams0");
+
+ Element param;
+
+ if (type.equalsIgnoreCase("1")
+ ||
type.equalsIgnoreCase("2")
+ ||
type.equalsIgnoreCase("4")
+ ||
type.equalsIgnoreCase("5")) {
+
+ param = new
Element("parameter", NMWG);
+ if
(type.equalsIgnoreCase("1")) {
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoAdapter");
+
params.addContent(param);
+ } else if
(type.equalsIgnoreCase("2")) {
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoSshAdapter");
+
params.addContent(param);
+ } else if
(type.equalsIgnoreCase("4")) {
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperAdapter");
+
params.addContent(param);
+ } else if
(type.equalsIgnoreCase("5")) {
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperSshAdapter");
+
params.addContent(param);
+ } else System.out.print("An
error that should be possible occured!");
+
System.out.println("Please
give the hostname or IP address for device: "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".url", input );
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","url");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out.println("Please
give the port for device: "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".port", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","port");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
- .println("Please give the
prompt for device: " + device + ": ");
- input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".prompt", input);
- System.out
- .println("Please give the
access rate for device (in ms): "
- + device + ":
");
- input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".rate", input);
- System.out
- .println("Please give the
password for device: "
- + device + ":
");
- input = br.readLine();
- while (input == null ||
input.equals("")){
- System.out.
- println("You have to
provide a password. Please give" +
- " the
password for device: "
- +
device + ": ");
- input = br.readLine();
- }
-
prop.setProperty("service.r.mp." + device + ".password",
PasswordEncryptor.encryptPassword(input));
- System.out
- .println("Please give the
bgp-daemon port for device: "
- + device + ":
");
- input = br.readLine();
-
prop.setProperty("service.r.mp." + device + "bgp.port", input);
- System.out
- .println("Please give the
bgp-daemon prompt for device: "
- + device + ":
");
- input = br.readLine();
-
prop.setProperty("service.r.mp." + device + "bgp.prompt", input);
- System.out
- .println("Please give the
bgp-daemon password for device: "
- + device + ":
");
- input = br.readLine();
-
prop.setProperty("service.r.mp." + device + "bgp.password",
PasswordEncryptor.encryptPassword(input));
- } else if (type.equalsIgnoreCase("2")
- ||
type.equalsIgnoreCase("3")
- ||
type.equalsIgnoreCase("5")
- ||
type.equalsIgnoreCase("6")) {
- System.out.println("Please
give the hostname or IP address for device: "
- + device + ":
");
- input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".url", input);
- System.out.println("Please
give the port for device: "
- + device + ":
");
- input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".port", input);
- System.out
.println("Please give the
prompt for device: "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".prompt", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","prompt");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please give the
access rate for device (in ms): "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".rate", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","rate");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please give the
username for device: "
+ device + ":
");
@@ -485,7 +638,10 @@
+
device + ": ");
input = br.readLine();
}
-
prop.setProperty("service.r.mp." + device + ".username", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","username");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please give the
password for device: "
+ device + ":
");
@@ -497,32 +653,67 @@
+
device + ": ");
input = br.readLine();
}
-
prop.setProperty("service.r.mp." + device + ".password",
PasswordEncryptor.encryptPassword(input));
-
//System.out.println("Encrypted password: " +
PasswordEncryptor.encryptPassword(input));
- } else if (type.equalsIgnoreCase("4")
- ||
type.equalsIgnoreCase("7")) {
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","password");
+ param.setAttribute("value",
PasswordEncryptor.encryptPassword(input));
+ params.addContent(param);
+
+ param = new
Element("parameter", NMWG);
+ param.setAttribute("name",
"cache");
+ param.setAttribute("value",
"0");
+ params.addContent(param);
+
+ metadata.addContent(params);
+ } else if (type.equalsIgnoreCase("3")
+ ||
type.equalsIgnoreCase("6")) {
+
+ param = new
Element("parameter", NMWG);
+ if
(type.equalsIgnoreCase("3")) {
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoKeyAdapter");
+
params.addContent(param);
+ } else if
(type.equalsIgnoreCase("6")) {
+
param.setAttribute("name","class_name");
+
param.setAttribute("value","org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.JuniperKeyAdapter");
+
params.addContent(param);
+
+ } else System.out.print("An
error that should be possible occured!");
+
System.out.println("Please
give the hostname or IP address for device: "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".url", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","url");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out.println("Please
give the port for device: "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".port", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","port");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please give the
prompt for device: "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".prompt", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","prompt");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please give the
access rate for device (in ms): "
+ device + ":
");
input = br.readLine();
-
prop.setProperty("service.r.mp." + device + ".rate", input);
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","rate");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please give the
username for device: "
+ device + ":
");
input = br.readLine();
+ param = new
Element("parameter", NMWG);
while (input == null ||
input.equals("")){
System.out
.println("You have to
provide a username. " +
@@ -530,11 +721,14 @@
+
device + ": ");
input = br.readLine();
}
-
prop.setProperty("service.r.mp." + device + ".username", input);
+
param.setAttribute("name","username");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please give the
path to the public ssh key for device: "
+ device + ":
");
input = br.readLine();
+ param = new
Element("parameter", NMWG);
while (input == null ||
input.equals("")){
System.out
.println("You have to
provide a path to the public ssh key. " +
@@ -542,17 +736,32 @@
+
device + ": ");
input = br.readLine();
}
-
prop.setProperty("service.r.mp." + device + ".keyUrl", input);
+
param.setAttribute("name","keyUrl");
+ param.setAttribute("value",
input);
+ params.addContent(param);
System.out
.println("Please provide the
passphrase for the public ssh key. " +
"Leave this blank if you
don't have to enter a passphrase.");
input = br.readLine();
+
if (input != null &&
!input.equals("")){
-
prop.setProperty("service.r.mp." + device + ".passphrase",
PasswordEncryptor.encryptPassword(input));
+ param = new
Element("parameter", NMWG);
+
param.setAttribute("name","passphrase");
+
param.setAttribute("value", PasswordEncryptor.encryptPassword(input));
+
params.addContent(param);
+
}
+
+ param = new
Element("parameter", NMWG);
+ param.setAttribute("name",
"cache");
+ param.setAttribute("value",
"0");
+ params.addContent(param);
+
+ metadata.addContent(params);
}
- prop.setProperty("service.r.mp." +
device + ".cache", "0");
+ store.addContent(metadata);
+
System.out.println();
@@ -591,12 +800,8 @@
DataOutputStream tempout =
new DataOutputStream(new FileOutputStream(tempFile, true));
File minimumFile;
- if
(type.equalsIgnoreCase("1")){
- minimumFile = new
File("conf/quagga"+MINIMUM_PACKAGE);
- if
(!minimumFile.exists())
- minimumFile =
new File("../conf/quagga"+MINIMUM_PACKAGE);
- } else if
(type.equalsIgnoreCase("2") || type.equalsIgnoreCase("3")
- ||
type.equalsIgnoreCase("4")){
+ if
(type.equalsIgnoreCase("1") || type.equalsIgnoreCase("2")
+ ||
type.equalsIgnoreCase("3")){
minimumFile = new
File("conf/cisco"+MINIMUM_PACKAGE);
if
(!minimumFile.exists())
minimumFile =
new File("../conf/cisco"+MINIMUM_PACKAGE);
@@ -614,13 +819,21 @@
in =
tempbr.readLine();
}
-
addSelectedCommandsToConfig(device, outputFile, tempFile.toString());
+ data = new Element("data",
NMWG);
+ data.setAttribute("id",
"data" + index);
+
data.setAttribute("metadataIdRef", "metadata" + index);
+
+
addSelectedCommandsToConfig(device, outputFile, tempFile.toString());
+
+ store.addContent(data);
+
+ tempFile.delete();
} else {
System.out.println("\nYou
will now be given the opportunity to select\n" +
"the commands you wish the MP
supports.");
- if
(type.equalsIgnoreCase("2") || type.equalsIgnoreCase("3")
- ||
type.equalsIgnoreCase("4")) { // Cisco device
+ if
(type.equalsIgnoreCase("1") || type.equalsIgnoreCase("2")
+ ||
type.equalsIgnoreCase("3")) { // Cisco device
File tempFile =
File.createTempFile("ciscominimum",".tmp");
System.out.println("\nFirst you can choose which IP-commands you wish to be
supported:");
selectCommands("cisco", "ip", tempFile.toString());
@@ -631,11 +844,17 @@
System.out.println("Select which BGP-commands you wish to be supported:");
selectCommands("cisco", "bgp", tempFile.toString());
+ data = new
Element("data", NMWG);
+
data.setAttribute("id", "data" + index);
+
data.setAttribute("metadataIdRef", "metadata" + index);
+
addSelectedCommandsToConfig(device, outputFile, tempFile.toString());
+
+
store.addContent(data);
tempFile.delete();
- } else if
(type.equalsIgnoreCase("5") || type.equalsIgnoreCase("6")
- ||
type.equalsIgnoreCase("7")) { // Juniper device
+ } else if
(type.equalsIgnoreCase("4") || type.equalsIgnoreCase("5")
+ ||
type.equalsIgnoreCase("6")) { // Juniper device
File tempFile =
File.createTempFile("ciscominimum",".tmp");
System.out.println("\nFirst you can choose which IP-commands you wish to be
supported:");
selectCommands("juniper", "ip", tempFile.toString());
@@ -646,30 +865,21 @@
System.out.println("Select which BGP-commands you wish to be supported:");
selectCommands("juniper", "bgp", tempFile.toString());
-
addSelectedCommandsToConfig(device, outputFile, tempFile.toString());
- tempFile.delete();
- } else if
(type.equalsIgnoreCase("1")) { // Quagga device
- File tempFile =
File.createTempFile("ciscominimum",".tmp");
-
System.out.println("\nFirst you can choose which IP-commands you wish to be
supported:");
-
selectCommands("quagga", "ip", tempFile.toString());
-
System.out.println("Select which IPv6-commands you wish to be supported:");
-
selectCommands("quagga", "ipv6", tempFile.toString());
-
System.out.println("Select which status commands you wish to be supported:");
-
selectCommands("quagga", "status", tempFile.toString());
-
System.out.println("Select which BGP-commands you wish to be supported:");
-
selectCommands("quagga", "bgp", tempFile.toString());
+ data = new
Element("data", NMWG);
+
data.setAttribute("id", "data" + index);
+
data.setAttribute("metadataIdRef", "metadata" + index);
+
addSelectedCommandsToConfig(device, outputFile, tempFile.toString());
+
+
store.addContent(data);
+
tempFile.delete();
} else { // Shouldn't happen
System.out.println("ERROR - Not a valid device.");
}
}
}
- if (previousDevices.equals(""))
-
prop.setProperty("service.mp.devices",
devicesString.substring(0,devicesString.length()-1));
- else prop.setProperty("service.mp.devices",
previousDevices +"," + devicesString);
}
- //out.close();
} catch (IOException e) {
e.printStackTrace();
}
@@ -775,7 +985,6 @@
}
}
- //File outputfile = new File("temp/" + device
+ "" + TEMPFILE);
DataOutputStream dos = new
DataOutputStream(new FileOutputStream(outFile, true));
br = new BufferedReader(new
FileReader(file)); //go back to beginning of file
@@ -804,20 +1013,19 @@
public void addSelectedCommandsToConfig(String device, String
outputFile, String inputFile) {
+ System.out.println("[DEBUG]
addSelectedCommandsToConfig("+device+", "+outputFile+","+ inputFile+")
called");
+
File inputfile = new File(inputFile);
String input = "";
try {
- //add selected commands to the configuration
- File outputfile = new File(outputFile);
- //DataOutputStream out = new DataOutputStream(new
FileOutputStream(outputfile, true));
- FileOutputStream out = new
FileOutputStream(outputfile, true);
-
BufferedReader br = new BufferedReader(new
FileReader(inputfile));
input = br.readLine();
+ System.out.println("[DEBUG] Line read: " + input);
+
String command = "";
String realCommand = "";
String minParamCount = "";
@@ -829,72 +1037,110 @@
StringTokenizer tok;
- String commandList = "";
-
+ Element key;
+
+ Element params;
+ Element param;
+
+ Element eventType;
+
while (input != null && !input.equals("")){
tok = new StringTokenizer(input, "@@@");
-
+
+ key = new Element("key", NMWG);
+
+ params = new Element("parameters", NMWG);
+ params.setAttribute("id", "params0");
+
+ System.out.println("[DEBUG] Tokenizer
made...");
+
command = tok.nextToken();
+ System.out.println("[DEBUG] Command: " +
command);
realCommand = tok.nextToken();
+ System.out.println("[DEBUG] Real Command: " +
realCommand);
minParamCount = tok.nextToken();
+ System.out.println("[DEBUG] MinParamCount: "
+ minParamCount);
maxParamCount = tok.nextToken();
+ System.out.println("[DEBUG] MaxParamCount: "
+ maxParamCount);
cache = tok.nextToken();
+ System.out.println("[DEBUG] Cache: " + cache);
description = tok.nextToken();
+ System.out.println("[DEBUG] Description: " +
description);
syntax = tok.nextToken();
+ System.out.println("[DEBUG] Syntax: " +
syntax);
regExp = tok.nextToken();
-
- commandList += command + ",";
-
- prop.setProperty("service.mp." + device +
".commands." + command + "", realCommand);
- //out.flush();
-
+ System.out.println("[DEBUG] RegExp: " +
regExp);
+
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name","command");
+ param.setAttribute("value",realCommand);
+ params.addContent(param);
+
if (!minParamCount.equalsIgnoreCase("---")) {
- prop.setProperty("service.mp." +
device + ".commands."
- + command +
".minParamCount", minParamCount);
- //out.flush();
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","minParamCount");
+
param.setAttribute("value",minParamCount);
+ params.addContent(param);
}
if (!maxParamCount.equalsIgnoreCase("---")) {
- prop.setProperty("service.mp." +
device + ".commands."
- + command +
".maxParamCount", maxParamCount);
- //out.flush();
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","maxParamCount");
+
param.setAttribute("value",maxParamCount);
+ params.addContent(param);
}
if (!cache.equalsIgnoreCase("---")) {
- prop.setProperty("service.mp." +
device + ".commands."
- + command +
".caching", cache);
- //out.flush();
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","caching");
+ param.setAttribute("value",cache);
+ params.addContent(param);
}
if (!description.equalsIgnoreCase("---")) {
- prop.setProperty("service.mp." +
device + ".commands."
- + command +
".description", description);
- //out.flush();
+ param = new Element("parameter",
NMWG);
+
param.setAttribute("name","description");
+
param.setAttribute("value",description);
+ params.addContent(param);
}
if (!syntax.equalsIgnoreCase("---")) {
- prop.setProperty("service.mp." +
device + ".commands."
- + command +
".syntax", syntax);
- //out.flush();
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","syntax");
+ param.setAttribute("value",syntax);
+ params.addContent(param);
}
if (!regExp.equalsIgnoreCase("---")) {
- prop.setProperty("service.mp." +
device + ".commands."
- + command + ".regex",
regExp);
- //out.flush();
+ param = new Element("parameter",
NMWG);
+ param.setAttribute("name","regex");
+ param.setAttribute("value",regExp);
+ params.addContent(param);
}
+ System.out.println("[DEBUG] parameter
elements made...");
+
+ eventType = new Element("eventType", NMWG);
+ eventType.addContent(command);
+
+ key.addContent(eventType);
+ System.out.println("[DEBUG] eventTypes added
to key element...");
+ key.addContent(params);
+ System.out.println("[DEBUG] parameters added
to key element...");
+ data.addContent(key);
+ System.out.println("[DEBUG] key added to data
element...");
+
+
+ System.out.println("[DEBUG] Number of keys
inside the data element: "+data.getChildren("key", NMWG).size());
+
input = br.readLine();
+ System.out.println("[DEBUG] Line read: " +
input);
}
- commandList = commandList.substring(0,
commandList.length()-1);
- prop.setProperty("service.mp." + device +
".commands", commandList);
- //out.flush();
-
- out.close();
-
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
+ } catch (IllegalAddException iae) {
+ iae.printStackTrace();
}
inputfile.delete();
}
@@ -905,10 +1151,8 @@
System.err.println("Wrong number of
arguments!");
System.exit(0);
} else {
- //System.out.println(args[0]);
ServicePropertiesConfigurator stitcher = new
ServicePropertiesConfigurator();
stitcher.doStuff(args[0]);
- //createServiceStorageXML(args[0], args[0] +
"XML.xml");
}
} catch (RuntimeException e) {
} catch (Exception e){
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands/CommandInterface.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands/CommandInterface.java
2007-12-05 06:29:40 UTC (rev 3084)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands/CommandInterface.java
2007-12-05 09:21:31 UTC (rev 3085)
@@ -8,7 +8,7 @@
/**
- * Implementation class that supports querying the device (Quagga) for
+ * Implementation class that supports querying the device for
* ip information
*
* TODO::Correct error classes TODO::Parse output ??
Deleted:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters/QuaggaIpAdapter.java
Deleted:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters/QuaggaIpv6Adapter.java
Deleted:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters/QuaggaStatusAdapter.java
- perfsonar: r3085 - in trunk/geant2_java-sshtelnet-mp: ant src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/bgp/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/commands src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ip/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/ipv6/adapters src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/status/adapters, svnlog, 12/05/2007
Archive powered by MHonArc 2.6.16.