package org.opendaylight.netconf.callhome.mount;
import com.google.common.collect.Iterables;
-import com.google.common.net.InetAddresses;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.credentials.Credentials;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.AllowedDevices;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.Global;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.Global.MountPointNamingStrategy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.Device;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
deviceOpReg.close();
}
- private static String fromRemoteAddress(final SocketAddress remoteAddress) {
+ private String fromRemoteAddress(final SocketAddress remoteAddress) {
if (remoteAddress instanceof InetSocketAddress) {
InetSocketAddress socketAddress = (InetSocketAddress) remoteAddress;
- return InetAddresses.toAddrString(socketAddress.getAddress()) + ":" + socketAddress.getPort();
+ String ip = socketAddress.getAddress().getHostAddress();
+
+ final MountPointNamingStrategy strat = globalConfig.getMountPointNamingStrategy();
+ switch (strat) {
+ case IPONLY:
+ return ip;
+ case IPPORT:
+ return ip + ":" + socketAddress.getPort();
+ default:
+ throw new IllegalStateException("Unhandled naming strategy " + strat);
+ }
}
return remoteAddress.toString();
}
final Global local = current;
return local != null ? local.getCredentials() : null;
}
+
+ MountPointNamingStrategy getMountPointNamingStrategy() {
+ final Global local = current;
+ final MountPointNamingStrategy strat = local != null ? local.getMountPointNamingStrategy() : null;
+ return strat == null ? MountPointNamingStrategy.IPPORT : strat;
+ }
}
}