mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8590 - Refactoring NiciraNVP resource
- Adding NiciraNvpDeleteLogicalSwitchPortCommandWrapper Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
This commit is contained in:
parent
361ab5ddbd
commit
b4ce81ab6c
|
|
@ -16,6 +16,7 @@
|
|||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
|
||||
package com.cloud.network.resource;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
|
||||
package com.cloud.network.resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
|
||||
package com.cloud.network.utils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
|
|
|||
Loading…
Reference in New Issue