[ONOS-6756] Replicate node version information for ISSU

Change-Id: Ibd31c573990f2732b7abf8615ca914ffb77615ec
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
index a2b9000..b7c9045 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
@@ -44,6 +44,7 @@
 import org.onosproject.cluster.NodeId;
 import org.onosproject.cluster.Partition;
 import org.onosproject.cluster.PartitionId;
+import org.onosproject.core.Version;
 import org.onosproject.event.AbstractListenerManager;
 import org.slf4j.Logger;
 
@@ -135,6 +136,13 @@
     }
 
     @Override
+    public Version getVersion(NodeId nodeId) {
+        checkPermission(CLUSTER_READ);
+        checkNotNull(nodeId, INSTANCE_ID_NULL);
+        return store.getVersion(nodeId);
+    }
+
+    @Override
     public void markFullyStarted(boolean started) {
         store.markFullyStarted(started);
     }
diff --git a/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java b/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java
index cda738f..4ff6eb0 100644
--- a/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java
+++ b/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java
@@ -35,18 +35,13 @@
 import org.onosproject.core.IdBlockStore;
 import org.onosproject.core.IdGenerator;
 import org.onosproject.core.Version;
+import org.onosproject.core.VersionService;
 import org.onosproject.event.EventDeliveryService;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.Dictionary;
-import java.util.List;
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -54,7 +49,6 @@
 import static org.onosproject.security.AppPermission.Type.APP_READ;
 import static org.onosproject.security.AppPermission.Type.APP_WRITE;
 
-
 /**
  * Core service implementation.
  */
@@ -64,8 +58,8 @@
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private static final File VERSION_FILE = new File("../VERSION");
-    private static Version version = Version.version("1.11.0-SNAPSHOT");
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected VersionService versionService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected ApplicationIdStore applicationIdStore;
@@ -105,16 +99,6 @@
     protected void activate() {
         registerApplication(CORE_APP_NAME);
         cfgService.registerProperties(getClass());
-        try {
-            Path path = Paths.get(VERSION_FILE.getPath());
-            List<String> versionLines = Files.readAllLines(path);
-            if (versionLines != null && !versionLines.isEmpty()) {
-                version = Version.version(versionLines.get(0));
-            }
-        } catch (IOException e) {
-            // version file not found, using default
-            log.trace("Version file not found", e);
-        }
     }
 
     @Deactivate
@@ -127,7 +111,7 @@
     @Override
     public Version version() {
         checkPermission(APP_READ);
-        return version;
+        return versionService.version();
     }
 
     @Override
@@ -148,7 +132,6 @@
         return applicationIdStore.getAppId(name);
     }
 
-
     @Override
     public ApplicationId registerApplication(String name) {
         checkPermission(APP_WRITE);
@@ -171,7 +154,6 @@
         return new BlockAllocatorBasedIdGenerator(allocator);
     }
 
-
     @Modified
     protected void modified(ComponentContext context) {
         Dictionary<?, ?> properties = context.getProperties();
diff --git a/core/net/src/main/java/org/onosproject/core/impl/VersionManager.java b/core/net/src/main/java/org/onosproject/core/impl/VersionManager.java
new file mode 100644
index 0000000..c683205
--- /dev/null
+++ b/core/net/src/main/java/org/onosproject/core/impl/VersionManager.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.core.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.onosproject.core.Version;
+import org.onosproject.core.VersionService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Node version service implementation.
+ */
+@Component(immediate = true)
+@Service
+public class VersionManager implements VersionService {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private static final File VERSION_FILE = new File("../VERSION");
+    private static Version version = Version.version("1.11.0-SNAPSHOT");
+
+    @Activate
+    protected void activate() {
+        try {
+            Path path = Paths.get(VERSION_FILE.getPath());
+            List<String> versionLines = Files.readAllLines(path);
+            if (versionLines != null && !versionLines.isEmpty()) {
+                version = Version.version(versionLines.get(0));
+            }
+        } catch (IOException e) {
+            // version file not found, using default
+            log.trace("Version file not found", e);
+        }
+    }
+
+    @Override
+    public Version version() {
+        return version;
+    }
+}
\ No newline at end of file