Bug 5592 - NodeId+DatapathId in Services (remove dependency on DeviceContext)
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / RoleService.java
index 0bf66fa960a12eaaf04c6279edf3097d677412cb..c677c53a68247079504cb9a8664125eb798020f6 100644 (file)
@@ -54,8 +54,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
     }
 
     public Future<BigInteger> getGenerationIdFromDevice(final Short version) {
-        final NodeId nodeId = deviceContext.getPrimaryConnectionContext().getNodeId();
-        LOG.info("getGenerationIdFromDevice called for device:{}", nodeId.getValue());
+        LOG.info("getGenerationIdFromDevice called for device:{}", getNodeId().getValue());
 
         // send a dummy no-change role request to get the generation-id of the switch
         final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
@@ -75,7 +74,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
                         finalFuture.set(roleRequestOutput.getGenerationId());
                     } else {
                         LOG.info("roleRequestOutput is null in getGenerationIdFromDevice");
-                        finalFuture.setException(new RoleChangeException("Exception in getting generationId for device:" + nodeId.getValue()));
+                        finalFuture.setException(new RoleChangeException("Exception in getting generationId for device:" + getNodeId().getValue()));
                     }
 
                 } else {
@@ -98,7 +97,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
 
     public Future<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole, final Short version, final BigInteger generationId) {
         LOG.info("submitRoleChange called for device:{}, role:{}",
-                deviceContext.getPrimaryConnectionContext().getNodeId(), ofpRole);
+                getNodeId(), ofpRole);
         final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
         roleRequestInputBuilder.setRole(toOFJavaRole(ofpRole));
         roleRequestInputBuilder.setVersion(version);
@@ -111,7 +110,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
             @Override
             public void onSuccess(final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
                 LOG.info("submitRoleChange onSuccess for device:{}, role:{}",
-                        deviceContext.getPrimaryConnectionContext().getNodeId(), ofpRole);
+                        getNodeId(), ofpRole);
                 final RoleRequestOutput roleRequestOutput = roleRequestOutputRpcResult.getResult();
                 final Collection<RpcError> rpcErrors = roleRequestOutputRpcResult.getErrors();
                 if (roleRequestOutput != null) {
@@ -133,7 +132,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
             @Override
             public void onFailure(final Throwable throwable) {
                 LOG.error("submitRoleChange onFailure for device:{}, role:{}",
-                        deviceContext.getPrimaryConnectionContext().getNodeId(), ofpRole, throwable);
+                        getNodeId(), ofpRole, throwable);
                 finalFuture.setException(throwable);
             }
         });