import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import ch.qos.logback.classic.Level;
import com.google.common.base.Charsets;
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
- static class Params {
+ public static class Params {
@Arg(dest = "schemas-dir")
public File schemasDir;
@Arg(dest = "debug")
public boolean debug;
+ @Arg(dest = "notification-file")
+ public File notificationFile;
+
static ArgumentParser getParser() {
final ArgumentParser parser = ArgumentParsers.newArgumentParser("netconf testool");
.help("Directory containing yang schemas to describe simulated devices. Some schemas e.g. netconf monitoring and inet types are included by default")
.dest("schemas-dir");
+ parser.addArgument("--notification-file")
+ .type(File.class)
+ .help("Xml file containing notifications that should be sent to clients after create subscription is called")
+ .dest("notification-file");
+
parser.addArgument("--starting-port")
.type(Integer.class)
.setDefault(17830)
}
private static class ConfigGenerator {
- public static final String NETCONF_CONNECTOR_XML = "/initial/99-netconf-connector.xml";
- public static final String NETCONF_CONNECTOR_NAME = "controller-config";
- public static final String NETCONF_CONNECTOR_PORT = "1830";
- public static final String NETCONF_CONNECTOR_ADDRESS = "127.0.0.1";
- public static final String NETCONF_USE_SSH = "false";
+ public static final String NETCONF_CONNECTOR_XML = "/99-netconf-connector-simulated.xml";
public static final String SIM_DEVICE_SUFFIX = "-sim-device";
private static final String SIM_DEVICE_CFG_PREFIX = "simulated-devices_";
checkNotNull(stream, "Cannot load %s", NETCONF_CONNECTOR_XML);
String configBlueprint = CharStreams.toString(new InputStreamReader(stream, Charsets.UTF_8));
- checkState(configBlueprint.contains(NETCONF_CONNECTOR_NAME));
- checkState(configBlueprint.contains(NETCONF_CONNECTOR_PORT));
- checkState(configBlueprint.contains(NETCONF_USE_SSH));
- checkState(configBlueprint.contains(NETCONF_CONNECTOR_ADDRESS));
- configBlueprint = configBlueprint.replace(NETCONF_CONNECTOR_NAME, "%s");
- configBlueprint = configBlueprint.replace(NETCONF_CONNECTOR_ADDRESS, "%s");
- configBlueprint = configBlueprint.replace(NETCONF_CONNECTOR_PORT, "%s");
- configBlueprint = configBlueprint.replace(NETCONF_USE_SSH, "%s");
-
final String before = configBlueprint.substring(0, configBlueprint.indexOf("<module>"));
final String middleBlueprint = configBlueprint.substring(configBlueprint.indexOf("<module>"), configBlueprint.indexOf("</module>"));
final String after = configBlueprint.substring(configBlueprint.indexOf("</module>") + "</module>".length());