+ return propertyValue;
+ }
+
+ public static String getNetconfServerAddressKey(InfixProp infixProp) {
+ return PREFIX_PROP + infixProp + ADDRESS_SUFFIX_PROP;
+ }
+
+ /**
+ * @param context from which properties are being read.
+ * @param infixProp either tcp or ssh
+ * @return value if address and port are present and valid, Optional.absent otherwise.
+ * @throws IllegalStateException if address or port are invalid, or configuration is missing
+ */
+ public static Optional<InetSocketAddress> extractNetconfServerAddress(final BundleContext context,
+ final InfixProp infixProp) {
+
+ final Optional<String> address = getProperty(context, getNetconfServerAddressKey(infixProp));
+ final Optional<String> port = getProperty(context, PREFIX_PROP + infixProp + PORT_SUFFIX_PROP);
+
+ if (address.isPresent() && port.isPresent()) {
+ try {
+ return Optional.of(parseAddress(address, port));
+ } catch (final RuntimeException e) {
+ logger.warn("Unable to parse {} netconf address from {}:{}, fallback to default",
+ infixProp, address, port, e);
+ }