Fix formatting in callhome-provider 14/54314/1
authorTomas Cere <tcere@cisco.com>
Tue, 4 Apr 2017 14:09:38 +0000 (16:09 +0200)
committerTomas Cere <tcere@cisco.com>
Tue, 4 Apr 2017 14:09:38 +0000 (16:09 +0200)
Change-Id: Iaf85efcc8a1233717f947ada3ff9a47ad2a6d328
Signed-off-by: Tomas Cere <tcere@cisco.com>
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/BaseCallHomeTopology.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountSessionContext.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountSessionManager.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallhomeStatusReporter.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/ContextKey.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java

index 2b73e4f9505ef507bd0d519c10e87f721e87dd49..0b1972a3ef559bdbcd504886a81618c2f6f60125 100644 (file)
@@ -24,14 +24,14 @@ abstract class BaseCallHomeTopology extends AbstractNetconfTopology {
     protected DOMMountPointService mountPointService = null;
 
     BaseCallHomeTopology(String topologyId, NetconfClientDispatcher clientDispatcher,
-                                   BindingAwareBroker bindingAwareBroker,
-                                   Broker domBroker,
-                                   EventExecutor eventExecutor,
-                                   ScheduledThreadPool keepaliveExecutor,
-                                   ThreadPool processingExecutor,
-                                   SchemaRepositoryProvider schemaRepositoryProvider,
-                                   DataBroker dataBroker,
-                                   DOMMountPointService mountPointService) {
+                         BindingAwareBroker bindingAwareBroker,
+                         Broker domBroker,
+                         EventExecutor eventExecutor,
+                         ScheduledThreadPool keepaliveExecutor,
+                         ThreadPool processingExecutor,
+                         SchemaRepositoryProvider schemaRepositoryProvider,
+                         DataBroker dataBroker,
+                         DOMMountPointService mountPointService) {
         super(topologyId, clientDispatcher, bindingAwareBroker, domBroker, eventExecutor, keepaliveExecutor,
                 processingExecutor, schemaRepositoryProvider, dataBroker);
         this.mountPointService = mountPointService;
index 8e582dec26996702f1fa5d38fd6d91102fa32122..7f50653eed4fdc143d8670d2074d3d899908a863 100644 (file)
@@ -9,14 +9,13 @@ package org.opendaylight.netconf.callhome.mount;
 
 import com.google.common.base.Objects;
 import com.google.common.net.InetAddresses;
-
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
-import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
+import java.security.PublicKey;
+import java.security.spec.InvalidKeySpecException;
 import java.util.Collection;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -101,7 +100,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
         final Credentials credentials = deviceCred != null ? deviceCred : globalConfig.getCredentials();
 
         if (credentials == null) {
-            LOG.info("No credentials found for {}, rejecting.",remoteAddress);
+            LOG.info("No credentials found for {}, rejecting.", remoteAddress);
             return CallHomeAuthorization.rejected();
         }
 
@@ -236,8 +235,7 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
             try {
                 skey = AuthorizedKeysDecoder.encodePublicKey(serverKey);
                 return byPublicKey.get(skey);
-            }
-            catch (IOException | IllegalArgumentException e) {
+            } catch (IOException | IllegalArgumentException e) {
                 LOG.error("Unable to encode server key: {}", skey, e);
                 return null;
             }
index 7fc17996393de7acbfb291b5a4505ca3cd1446a1..16eed1f208ae74109a0210824ea4de7a9a2fce98 100644 (file)
@@ -40,7 +40,7 @@ class CallHomeMountSessionContext {
     private final ContextKey key;
 
     CallHomeMountSessionContext(String nodeId, CallHomeProtocolSessionContext protocol,
-            CallHomeChannelActivator activator, CloseCallback callback) {
+                                CallHomeChannelActivator activator, CloseCallback callback) {
 
         this.nodeId = new NodeId(Preconditions.checkNotNull(nodeId, "nodeId"));
         this.key = ContextKey.from(protocol.getRemoteAddress());
@@ -73,7 +73,7 @@ class CallHomeMountSessionContext {
     }
 
     @SuppressWarnings("unchecked")
-     <V> Promise<V> activateNetconfChannel(NetconfClientSessionListener sessionListener) {
+    <V> Promise<V> activateNetconfChannel(NetconfClientSessionListener sessionListener) {
         return (Promise<V>) activator.activate(wrap(sessionListener));
     }
 
index e700a145cabf4d3b2c40a86c2c16a3bafa8f755a..0657740e28e8692db36d382d366cac672fec4102 100644 (file)
@@ -37,14 +37,14 @@ public class CallHomeMountSessionManager implements CallHomeMountSessionContext.
     }
 
     CallHomeMountSessionContext createSession(CallHomeProtocolSessionContext session,
-            CallHomeChannelActivator activator, final CloseCallback onCloseHandler) {
+                                              CallHomeChannelActivator activator, final CloseCallback onCloseHandler) {
 
         String name = session.getSessionName();
         CallHomeMountSessionContext deviceContext = new CallHomeMountSessionContext(name,
                 session, activator, devCtxt -> {
-                CallHomeMountSessionManager.this.onClosed(devCtxt);
-                onCloseHandler.onClosed(devCtxt);
-            });
+            CallHomeMountSessionManager.this.onClosed(devCtxt);
+            onCloseHandler.onClosed(devCtxt);
+        });
 
         contextByAddress.put(deviceContext.getRemoteAddress(), deviceContext);
         contextByPublicKey.put(deviceContext.getRemoteServerKey(), deviceContext);
@@ -55,6 +55,6 @@ public class CallHomeMountSessionManager implements CallHomeMountSessionContext.
     @Override
     public synchronized void onClosed(CallHomeMountSessionContext deviceContext) {
         contextByAddress.remove(deviceContext.getRemoteAddress());
-        contextByPublicKey.remove(deviceContext.getRemoteServerKey(),deviceContext);
+        contextByPublicKey.remove(deviceContext.getRemoteServerKey(), deviceContext);
     }
 }
index 016bd57de29601452938ea2f272a992f7eab71a6..ba551202f92713fff13f7c85ed261201585aa91e 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.netconf.callhome.mount;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
-
 import java.io.IOException;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
@@ -19,7 +18,6 @@ import java.security.spec.InvalidKeySpecException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
@@ -74,7 +72,7 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
     @Override
     public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
         for (InstanceIdentifier<?> removedPath : change.getRemovedPaths()) {
-            if(removedPath.getTargetType() != NetconfNode.class)
+            if (removedPath.getTargetType() != NetconfNode.class)
                 continue;
 
             final NodeId nodeId = getNodeId(removedPath);
@@ -127,8 +125,8 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
             LOG.warn("No corresponding callhome device found - exiting.");
         } else {
             Device modifiedDevice = withConnectedStatus(opDev);
-            if(modifiedDevice == null)
-                return ;
+            if (modifiedDevice == null)
+                return;
             LOG.info("Setting successful status for callhome device id:{}.", nodeId);
             writeDevice(nodeId, modifiedDevice);
         }
@@ -142,7 +140,7 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
             LOG.warn("No corresponding callhome device found - exiting.");
         } else {
             Device modifiedDevice = withDisconnectedStatus(opDev);
-            if(modifiedDevice == null)
+            if (modifiedDevice == null)
                 return;
             LOG.info("Setting disconnected status for callhome device id:{}.", nodeId);
             writeDevice(nodeId, modifiedDevice);
@@ -160,7 +158,7 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
             LOG.warn("No corresponding callhome device found - exiting.");
         } else {
             Device modifiedDevice = withFailedStatus(opDev);
-            if(modifiedDevice == null)
+            if (modifiedDevice == null)
                 return;
             LOG.info("Setting failed status for callhome device id:{}.", nodeId);
             writeDevice(nodeId, modifiedDevice);
@@ -237,7 +235,7 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
     private Device withConnectedStatus(Device opDev) {
         Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.CONNECTED).build();
         return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
-            .setSshHostKey(opDev.getSshHostKey()).build();
+                .setSshHostKey(opDev.getSshHostKey()).build();
     }
 
     private Device withFailedStatus(Device opDev) {
@@ -255,7 +253,7 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
     private Device withFailedAuthStatus(Device opDev) {
         Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILEDAUTHFAILURE).build();
         return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
-               .setSshHostKey(opDev.getSshHostKey()).build();
+                .setSshHostKey(opDev.getSshHostKey()).build();
     }
 
     private void setDeviceStatus(Device device) {
@@ -304,7 +302,7 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
                 PublicKey pubKey = decoder.decodePublicKey(keyString);
                 if (sshKey.getAlgorithm().equals(pubKey.getAlgorithm()) && sshKey.equals(pubKey)) {
                     Device failedDevice = withFailedAuthStatus(device);
-                    if(failedDevice==null)
+                    if (failedDevice == null)
                         return;
                     LOG.info("Setting auth failed status for callhome device id:{}.", failedDevice.getUniqueId());
                     setDeviceStatus(failedDevice);
index 6fe0c29894f2c3fa804a1daf4fe1bedc17d62ccf..124f87d39c41e1bc869cff37b719a11b250e4130 100644 (file)
@@ -38,6 +38,7 @@ class ContextKey {
         result = prime * result + port.hashCode();
         return result;
     }
+
     @Override
     public boolean equals(Object obj) {
         if (this == obj)
@@ -68,7 +69,7 @@ class ContextKey {
         InetAddress ipAddress = inetSocketAddr.getAddress();
 
         final IpAddress yangIp;
-        if(ipAddress instanceof Inet4Address) {
+        if (ipAddress instanceof Inet4Address) {
             yangIp = new IpAddress(IetfInetUtil.INSTANCE.ipv4AddressFor(ipAddress));
         } else {
             Preconditions.checkArgument(ipAddress instanceof Inet6Address);
@@ -79,7 +80,7 @@ class ContextKey {
 
     @Override
     public String toString() {
-        if(address.getIpv4Address() != null) {
+        if (address.getIpv4Address() != null) {
             return address.getIpv4Address().getValue() + ":" + port.getValue();
         }
         return address.getIpv6Address().getValue() + ":" + port.getValue();
index bcc5707b140668d20982b802db0334739337b116..ca26f8606432136ee0ff8dc619ad701787d451b9 100644 (file)
@@ -13,8 +13,8 @@ import static com.google.common.base.Preconditions.checkArgument;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
-import java.io.IOException;
 import java.io.File;
+import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -45,8 +45,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataChangeListener
-{
+public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataChangeListener {
     private static final String APPNAME = "CallHomeServer";
     static final InstanceIdentifier<AllowedDevices> ALL_DEVICES = InstanceIdentifier.create(NetconfCallhomeServer.class).child(AllowedDevices.class);
 
@@ -54,14 +53,14 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
 
     private final DataBroker dataBroker;
     private final CallHomeMountDispatcher mountDispacher;
-    private CallHomeAuthProviderImpl authProvider ;
+    private CallHomeAuthProviderImpl authProvider;
 
     protected NetconfCallHomeServer server;
 
     private ListenerRegistration<IetfZeroTouchCallHomeServerProvider> listenerReg = null;
 
     private static final String CALL_HOME_PORT_KEY = "DefaultCallHomePort";
-    private static String configurationPath = "etc"+File.pathSeparator+"ztp-callhome-config.cfg";
+    private static String configurationPath = "etc" + File.pathSeparator + "ztp-callhome-config.cfg";
     private int port = 0; // 0 = use default in NetconfCallHomeBuilder
     private CallhomeStatusReporter statusReporter;
 
@@ -78,10 +77,9 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
             LOG.info("Initializing provider for {}", APPNAME);
             loadConfigurableValues(configurationPath);
             initializeServer();
-            dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,ALL_DEVICES,this, AsyncDataBroker.DataChangeScope.SUBTREE);
-            LOG.info( "Initialization complete for {}", APPNAME);
-        }
-        catch(IOException | Configuration.ConfigurationException e) {
+            dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, ALL_DEVICES, this, AsyncDataBroker.DataChangeScope.SUBTREE);
+            LOG.info("Initialization complete for {}", APPNAME);
+        } catch (IOException | Configuration.ConfigurationException e) {
             LOG.error("Unable to successfully initialize", e);
         }
     }
@@ -91,8 +89,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         try {
             Configuration configuration = new Configuration(configurationPath);
             port = configuration.getAsPort(CALL_HOME_PORT_KEY);
-        }
-        catch(Configuration.ConfigurationException e) {
+        } catch (Configuration.ConfigurationException e) {
             LOG.error("Problem trying to load configuration values from {}", configurationPath, e);
         }
     }
@@ -102,7 +99,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
     }
 
     private void initializeServer() throws IOException {
-        LOG.info( "Initializing Call Home server instance");
+        LOG.info("Initializing Call Home server instance");
         CallHomeAuthorizationProvider provider = this.getCallHomeAuthorization();
         NetconfCallHomeServerBuilder builder = new NetconfCallHomeServerBuilder(
                 provider, mountDispacher, statusReporter);
@@ -111,7 +108,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         server = builder.build();
         server.bind();
         mountDispacher.createTopology();
-        LOG.info( "Initialization complete for Call Home server instance");
+        LOG.info("Initialization complete for Call Home server instance");
     }
 
     @VisibleForTesting
@@ -126,10 +123,10 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         statusReporter.close();
 
         // FIXME unbind the server
-        if ( this.listenerReg != null ) {
+        if (this.listenerReg != null) {
             listenerReg.close();
         }
-        if(server != null ) {
+        if (server != null) {
             server.close();
         }
 
@@ -152,11 +149,10 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
             handleDeletedDevices(change);
 
         try {
-            for(Device confDevice : getReadDevices(devicesFuture)) {
+            for (Device confDevice : getReadDevices(devicesFuture)) {
                 readAndUpdateStatus(confDevice);
             }
-        }
-        catch(ReadFailedException e) {
+        } catch (ReadFailedException e) {
             LOG.error("Error trying to read the whitelist devices: {}", e);
         }
     }
@@ -174,9 +170,9 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         int numRemoved = removedDevices.size();
 
         Iterator<InstanceIdentifier<?>> iterator = removedDevices.iterator();
-        while(iterator.hasNext()){
+        while (iterator.hasNext()) {
             InstanceIdentifier<?> removedIID = iterator.next();
-            LOG.info("Deleting the entry for callhome device {}",removedIID);
+            LOG.info("Deleting the entry for callhome device {}", removedIID);
             opTx.delete(LogicalDatastoreType.OPERATIONAL, removedIID);
         }
 
@@ -200,7 +196,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
     }
 
     private void readAndUpdateStatus(Device cfgDevice) throws ReadFailedException {
-        InstanceIdentifier<Device> deviceIID  = InstanceIdentifier.create(NetconfCallhomeServer.class)
+        InstanceIdentifier<Device> deviceIID = InstanceIdentifier.create(NetconfCallhomeServer.class)
                 .child(AllowedDevices.class)
                 .child(Device.class, new DeviceKey(cfgDevice.getUniqueId()));
 
@@ -209,7 +205,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
 
         Optional<Device> opDevGet = deviceFuture.checkedGet();
         Device1 devStatus = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build();
-        if(opDevGet.isPresent()) {
+        if (opDevGet.isPresent()) {
             Device opDevice = opDevGet.get();
             devStatus = opDevice.getAugmentation(Device1.class);
         }