cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [18/50] [abbrv] git commit: updated refs/heads/reporter to 28300b5
Date Wed, 08 Jul 2015 19:19:53 GMT
CLOUDSTACK-8590 - Refactoring NiciraNVP resource

   - Adding NiciraNvpDeleteLogicalSwitchPortCommandWrapper

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/b4ce81ab
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b4ce81ab
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b4ce81ab

Branch: refs/heads/reporter
Commit: b4ce81ab6ce2a007cc787f3658934cdd9745c359
Parents: 361ab5d
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Tue Jun 30 11:07:59 2015 +0200
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Wed Jul 1 15:04:57 2015 +0200

----------------------------------------------------------------------
 .../resource/NiciraNvpRequestWrapper.java       |  1 +
 .../network/resource/NiciraNvpResource.java     | 16 +-----
 .../network/resource/NiciraNvpUtilities.java    |  1 +
 ...vpDeleteLogicalSwitchPortCommandWrapper.java | 54 ++++++++++++++++++++
 .../network/utils/CommandRetryUtility.java      |  1 +
 5 files changed, 58 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4ce81ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpRequestWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpRequestWrapper.java
b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpRequestWrapper.java
index 55f0c49..9d261b2 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpRequestWrapper.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpRequestWrapper.java
@@ -16,6 +16,7 @@
 // specific language governing permissions and limitations
 // under the License.
 //
+
 package com.cloud.network.resource;
 
 import java.util.Hashtable;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4ce81ab/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 85faf9d..1fd19ea 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
@@ -40,8 +40,6 @@ import com.cloud.agent.api.CreateLogicalRouterAnswer;
 import com.cloud.agent.api.CreateLogicalRouterCommand;
 import com.cloud.agent.api.DeleteLogicalRouterAnswer;
 import com.cloud.agent.api.DeleteLogicalRouterCommand;
-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.PingCommand;
@@ -207,9 +205,7 @@ public class NiciraNvpResource implements ServerResource {
             // [TODO] Remove when all the commands are refactored.
         }
 
-        if (cmd instanceof DeleteLogicalSwitchPortCommand) {
-            return executeRequest((DeleteLogicalSwitchPortCommand)cmd, NUM_RETRIES);
-        } else if (cmd instanceof UpdateLogicalSwitchPortCommand) {
+        if (cmd instanceof UpdateLogicalSwitchPortCommand) {
             return executeRequest((UpdateLogicalSwitchPortCommand)cmd, NUM_RETRIES);
         } else if (cmd instanceof FindLogicalSwitchPortCommand) {
             return executeRequest((FindLogicalSwitchPortCommand)cmd, NUM_RETRIES);
@@ -241,16 +237,6 @@ public class NiciraNvpResource implements ServerResource {
     public void setAgentControl(final IAgentControl agentControl) {
     }
 
-    private Answer executeRequest(final DeleteLogicalSwitchPortCommand cmd, final int numRetries)
{
-        try {
-            niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), cmd.getLogicalSwitchPortUuid());
-            return new DeleteLogicalSwitchPortAnswer(cmd, true, "Logical switch port " +
cmd.getLogicalSwitchPortUuid() + " deleted");
-        } catch (final NiciraNvpApiException e) {
-            retryUtility.addRetry(cmd, NUM_RETRIES);
-            return retryUtility.retry(cmd, DeleteLogicalSwitchPortAnswer.class, e);
-        }
-    }
-
     private Answer executeRequest(final UpdateLogicalSwitchPortCommand cmd, final int numRetries)
{
         final String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         final String logicalSwitchPortUuid = cmd.getLogicalSwitchPortUuid();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4ce81ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpUtilities.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpUtilities.java
b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpUtilities.java
index f63ca98..2ac79c8 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpUtilities.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpUtilities.java
@@ -16,6 +16,7 @@
 // specific language governing permissions and limitations
 // under the License.
 //
+
 package com.cloud.network.resource;
 
 import java.util.ArrayList;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4ce81ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpDeleteLogicalSwitchPortCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpDeleteLogicalSwitchPortCommandWrapper.java
b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpDeleteLogicalSwitchPortCommandWrapper.java
new file mode 100644
index 0000000..834cccb
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpDeleteLogicalSwitchPortCommandWrapper.java
@@ -0,0 +1,54 @@
+//
+// 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 static com.cloud.network.resource.NiciraNvpResource.NUM_RETRIES;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.DeleteLogicalSwitchPortAnswer;
+import com.cloud.agent.api.DeleteLogicalSwitchPortCommand;
+import com.cloud.network.nicira.NiciraNvpApi;
+import com.cloud.network.nicira.NiciraNvpApiException;
+import com.cloud.network.resource.NiciraNvpResource;
+import com.cloud.network.utils.CommandRetryUtility;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+
+@ResourceWrapper(handles =  DeleteLogicalSwitchPortCommand.class)
+public final class NiciraNvpDeleteLogicalSwitchPortCommandWrapper extends CommandWrapper<DeleteLogicalSwitchPortCommand,
Answer, NiciraNvpResource> {
+
+    private static final Logger s_logger = Logger.getLogger(NiciraNvpDeleteLogicalSwitchPortCommandWrapper.class);
+
+    @Override
+    public Answer execute(final DeleteLogicalSwitchPortCommand command, final NiciraNvpResource
niciraNvpResource) {
+        final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
+
+        try {
+            niciraNvpApi.deleteLogicalSwitchPort(command.getLogicalSwitchUuid(), command.getLogicalSwitchPortUuid());
+            return new DeleteLogicalSwitchPortAnswer(command, true, "Logical switch port
" + command.getLogicalSwitchPortUuid() + " deleted");
+        } catch (final NiciraNvpApiException e) {
+            final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
+            retryUtility.addRetry(command, NUM_RETRIES);
+            return retryUtility.retry(command, DeleteLogicalSwitchPortAnswer.class, e);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4ce81ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java
b/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java
index 6244821..4969db8 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java
@@ -16,6 +16,7 @@
 // specific language governing permissions and limitations
 // under the License.
 //
+
 package com.cloud.network.utils;
 
 import java.lang.reflect.Constructor;


Mime
View raw message