Search in sources :

Example 6 with PhysicalNetworkSetupInfo

use of com.cloud.legacymodel.network.PhysicalNetworkSetupInfo in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testCheckNetworkCommandFail3.

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

Example 7 with PhysicalNetworkSetupInfo

use of com.cloud.legacymodel.network.PhysicalNetworkSetupInfo 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(this.libvirtComputingResource.checkNetwork(networkSetupInfo.getGuestNetworkName())).thenReturn(true);
    when(this.libvirtComputingResource.checkNetwork(networkSetupInfo.getPrivateNetworkName())).thenReturn(false);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getGuestNetworkName());
    verify(this.libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getPrivateNetworkName());
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) ArrayList(java.util.ArrayList) CheckNetworkCommand(com.cloud.legacymodel.communication.command.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.legacymodel.network.PhysicalNetworkSetupInfo) Test(org.junit.Test)

Example 8 with PhysicalNetworkSetupInfo

use of com.cloud.legacymodel.network.PhysicalNetworkSetupInfo in project cosmic by MissionCriticalCloud.

the class LibvirtCheckNetworkCommandWrapper method execute.

@Override
public Answer execute(final CheckNetworkCommand command, final LibvirtComputingResource libvirtComputingResource) {
    final List<PhysicalNetworkSetupInfo> phyNics = command.getPhysicalNetworkInfoList();
    String errMsg = null;
    for (final PhysicalNetworkSetupInfo nic : phyNics) {
        if (!libvirtComputingResource.checkNetwork(nic.getGuestNetworkName())) {
            errMsg = "Can not find network: " + nic.getGuestNetworkName();
            break;
        } else if (!libvirtComputingResource.checkNetwork(nic.getPrivateNetworkName())) {
            errMsg = "Can not find network: " + nic.getPrivateNetworkName();
            break;
        } else if (!libvirtComputingResource.checkNetwork(nic.getPublicNetworkName())) {
            errMsg = "Can not find network: " + nic.getPublicNetworkName();
            break;
        }
    }
    if (errMsg != null) {
        return new CheckNetworkAnswer(command, false, errMsg);
    } else {
        return new CheckNetworkAnswer(command, true, null);
    }
}
Also used : CheckNetworkAnswer(com.cloud.legacymodel.communication.answer.CheckNetworkAnswer) PhysicalNetworkSetupInfo(com.cloud.legacymodel.network.PhysicalNetworkSetupInfo)

Example 9 with PhysicalNetworkSetupInfo

use of com.cloud.legacymodel.network.PhysicalNetworkSetupInfo 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, this.citrixResourceBase);
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.legacymodel.communication.answer.RebootAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CreateAnswer(com.cloud.legacymodel.communication.answer.CreateAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) ArrayList(java.util.ArrayList) CheckNetworkCommand(com.cloud.legacymodel.communication.command.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.legacymodel.network.PhysicalNetworkSetupInfo) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with PhysicalNetworkSetupInfo

use of com.cloud.legacymodel.network.PhysicalNetworkSetupInfo in project cosmic by MissionCriticalCloud.

the class XenServer610WrapperTest method testCheckNetworkCommandFailure.

@Test
public void testCheckNetworkCommandFailure() {
    final XenServer610Resource xenServer610Resource = new XenServer610Resource();
    final PhysicalNetworkSetupInfo info = new PhysicalNetworkSetupInfo();
    final List<PhysicalNetworkSetupInfo> setupInfos = new ArrayList<>();
    setupInfos.add(info);
    final CheckNetworkCommand checkNet = new CheckNetworkCommand(setupInfos);
    final Answer answer = xenServer610Resource.executeRequest(checkNet);
    assertTrue(answer.getResult());
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) XenServer610Resource(com.cloud.hypervisor.xenserver.resource.XenServer610Resource) ArrayList(java.util.ArrayList) CheckNetworkCommand(com.cloud.legacymodel.communication.command.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.legacymodel.network.PhysicalNetworkSetupInfo) Test(org.junit.Test)

Aggregations

PhysicalNetworkSetupInfo (com.cloud.legacymodel.network.PhysicalNetworkSetupInfo)12 ArrayList (java.util.ArrayList)10 CheckNetworkCommand (com.cloud.legacymodel.communication.command.CheckNetworkCommand)9 Answer (com.cloud.legacymodel.communication.answer.Answer)8 Test (org.junit.Test)8 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)6 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)4 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)4 CheckNetworkAnswer (com.cloud.legacymodel.communication.answer.CheckNetworkAnswer)3 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)2 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)2 PhysicalNetworkTrafficTypeVO (com.cloud.network.dao.PhysicalNetworkTrafficTypeVO)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Zone (com.cloud.db.model.Zone)1 XenServer610Resource (com.cloud.hypervisor.xenserver.resource.XenServer610Resource)1 XenServer620Resource (com.cloud.hypervisor.xenserver.resource.XenServer620Resource)1 StartupCommand (com.cloud.legacymodel.communication.command.startup.StartupCommand)1 StartupRoutingCommand (com.cloud.legacymodel.communication.command.startup.StartupRoutingCommand)1 ConnectionException (com.cloud.legacymodel.exceptions.ConnectionException)1