cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject [02/11] git commit: updated refs/heads/master to 96ad6f6
Date Wed, 01 Jul 2015 13:05:19 GMT
CLOUDSTACK-8590 - Refactoring NiciraNVP resource

   - Refactoring NiciraNvpResource
   - Added NiciraNvpMaintainCommandWrapper
   - Removing 1 execute methods form NiciraNvpResource
   - Added 1 unit test

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6a51294d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6a51294d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6a51294d

Branch: refs/heads/master
Commit: 6a51294d1972bbfd116fcd9ed36835c48423b76b
Parents: 0d943d5
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Tue Jun 23 09:38:56 2015 +0200
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Wed Jul 1 15:04:56 2015 +0200

----------------------------------------------------------------------
 .../network/resource/NiciraNvpResource.java     | 10 +-----
 .../NiciraNvpMaintainCommandWrapper.java        | 36 ++++++++++++++++++++
 .../resource/NiciraNvpRequestWrapperTest.java   | 13 +++++++
 3 files changed, 50 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6a51294d/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
index 3c1f9b5..9af541f 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
@@ -50,8 +50,6 @@ import com.cloud.agent.api.DeleteLogicalSwitchPortAnswer;
 import com.cloud.agent.api.DeleteLogicalSwitchPortCommand;
 import com.cloud.agent.api.FindLogicalSwitchPortAnswer;
 import com.cloud.agent.api.FindLogicalSwitchPortCommand;
-import com.cloud.agent.api.MaintainAnswer;
-import com.cloud.agent.api.MaintainCommand;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupNiciraNvpCommand;
@@ -204,9 +202,7 @@ public class NiciraNvpResource implements ServerResource {
             // [TODO] Remove when all the commands are refactored.
         }
 
-        if (cmd instanceof MaintainCommand) {
-            return executeRequest((MaintainCommand)cmd);
-        } else if (cmd instanceof CreateLogicalSwitchCommand) {
+        if (cmd instanceof CreateLogicalSwitchCommand) {
             return executeRequest((CreateLogicalSwitchCommand)cmd, numRetries);
         } else if (cmd instanceof DeleteLogicalSwitchCommand) {
             return executeRequest((DeleteLogicalSwitchCommand)cmd, numRetries);
@@ -650,10 +646,6 @@ public class NiciraNvpResource implements ServerResource {
 
     }
 
-    private Answer executeRequest(final MaintainCommand cmd) {
-        return new MaintainAnswer(cmd);
-    }
-
     private Answer retry(final Command cmd, final int numRetries) {
         s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries
remaining: " + numRetries);
         return executeRequest(cmd, numRetries);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6a51294d/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java
b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java
new file mode 100644
index 0000000..3015378
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpMaintainCommandWrapper.java
@@ -0,0 +1,36 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 com.cloud.network.resource.wrapper;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.MaintainAnswer;
+import com.cloud.agent.api.MaintainCommand;
+import com.cloud.network.resource.NiciraNvpResource;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+
+@ResourceWrapper(handles =  MaintainCommand.class)
+public final class NiciraNvpMaintainCommandWrapper extends CommandWrapper<MaintainCommand,
Answer, NiciraNvpResource> {
+
+    @Override
+    public Answer execute(final MaintainCommand command, final NiciraNvpResource niciraNvpResource)
{
+        return new MaintainAnswer(command);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6a51294d/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java
b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java
index 5e5425e..ba22d18 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java
@@ -27,6 +27,7 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 
 import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.MaintainCommand;
 import com.cloud.agent.api.ReadyCommand;
 
 public class NiciraNvpRequestWrapperTest {
@@ -45,4 +46,16 @@ public class NiciraNvpRequestWrapperTest {
 
         assertTrue(answer.getResult());
     }
+
+    @Test
+    public void testMaintainCommandWrapper() {
+        final MaintainCommand command = new MaintainCommand();
+
+        final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
+        assertNotNull(wrapper);
+
+        final Answer answer = wrapper.execute(command, niciraNvpResource);
+
+        assertTrue(answer.getResult());
+    }
 }
\ No newline at end of file


Mime
View raw message