Search in sources :

Example 11 with CheckNetworkCommand

use of com.cloud.agent.api.CheckNetworkCommand in project CloudStack-archive by CloudStack-extras.

the class DummyResource method executeRequest.

@Override
public Answer executeRequest(Command cmd) {
    if (cmd instanceof CheckNetworkCommand) {
        return new CheckNetworkAnswer((CheckNetworkCommand) cmd, true, null);
    }
    System.out.println("Received Command: " + cmd.toString());
    Answer answer = new Answer(cmd, !_negative, "response");
    System.out.println("Replying with: " + answer.toString());
    return answer;
}
Also used : CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) Answer(com.cloud.agent.api.Answer) CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand)

Example 12 with CheckNetworkCommand

use of com.cloud.agent.api.CheckNetworkCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testCheckNetworkCommandFail2.

@Test
public void testCheckNetworkCommandFail2() {
    final List<PhysicalNetworkSetupInfo> networkInfoList = new ArrayList<>();
    final PhysicalNetworkSetupInfo networkSetupInfo = Mockito.mock(PhysicalNetworkSetupInfo.class);
    networkInfoList.add(networkSetupInfo);
    final CheckNetworkCommand command = new CheckNetworkCommand(networkInfoList);
    when(libvirtComputingResource.checkNetwork(networkSetupInfo.getGuestNetworkName())).thenReturn(true);
    when(libvirtComputingResource.checkNetwork(networkSetupInfo.getPrivateNetworkName())).thenReturn(false);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getGuestNetworkName());
    verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getPrivateNetworkName());
}
Also used : Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AttachAnswer(com.cloud.storage.command.AttachAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) ArrayList(java.util.ArrayList) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo) Test(org.junit.Test)

Example 13 with CheckNetworkCommand

use of com.cloud.agent.api.CheckNetworkCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testCheckNetworkCommandFail1.

@Test
public void testCheckNetworkCommandFail1() {
    final List<PhysicalNetworkSetupInfo> networkInfoList = new ArrayList<>();
    final PhysicalNetworkSetupInfo networkSetupInfo = Mockito.mock(PhysicalNetworkSetupInfo.class);
    networkInfoList.add(networkSetupInfo);
    final CheckNetworkCommand command = new CheckNetworkCommand(networkInfoList);
    when(libvirtComputingResource.checkNetwork(networkSetupInfo.getGuestNetworkName())).thenReturn(false);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getGuestNetworkName());
}
Also used : Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AttachAnswer(com.cloud.storage.command.AttachAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) ArrayList(java.util.ArrayList) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo) Test(org.junit.Test)

Example 14 with CheckNetworkCommand

use of com.cloud.agent.api.CheckNetworkCommand in project cosmic by MissionCriticalCloud.

the class CheckNetworkCommandTest method setUp.

@Before
public void setUp() {
    final List<PhysicalNetworkSetupInfo> net = Mockito.mock(List.class);
    cnc = new CheckNetworkCommand(net);
}
Also used : CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo) Before(org.junit.Before)

Example 15 with CheckNetworkCommand

use of com.cloud.agent.api.CheckNetworkCommand in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testCheckNetworkCommandFailure.

@Test
public void testCheckNetworkCommandFailure() {
    final PhysicalNetworkSetupInfo info = new PhysicalNetworkSetupInfo();
    final List<PhysicalNetworkSetupInfo> setupInfos = new ArrayList<>();
    setupInfos.add(info);
    final CheckNetworkCommand checkNet = new CheckNetworkCommand(setupInfos);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(checkNet, citrixResourceBase);
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) Answer(com.cloud.agent.api.Answer) AttachAnswer(com.cloud.storage.command.AttachAnswer) ArrayList(java.util.ArrayList) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)30 Answer (com.cloud.agent.api.Answer)26 PhysicalNetworkSetupInfo (com.cloud.network.PhysicalNetworkSetupInfo)25 ArrayList (java.util.ArrayList)23 Test (org.junit.Test)21 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)8 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 AttachAnswer (com.cloud.storage.command.AttachAnswer)6 CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)5 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)5 RebootAnswer (com.cloud.agent.api.RebootAnswer)4 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)3 BackupSnapshotCommand (com.cloud.agent.api.BackupSnapshotCommand)3 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)3 CreatePrivateTemplateFromSnapshotCommand (com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand)3 CreatePrivateTemplateFromVolumeCommand (com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand)3 CreateVolumeFromSnapshotCommand (com.cloud.agent.api.CreateVolumeFromSnapshotCommand)3 DeleteStoragePoolCommand (com.cloud.agent.api.DeleteStoragePoolCommand)3 GetHostStatsCommand (com.cloud.agent.api.GetHostStatsCommand)3