mirror of https://github.com/apache/cloudstack.git
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>
This commit is contained in:
parent
0d943d5426
commit
6a51294d19
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue