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());
}
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());
}
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);
}
}
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());
}
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());
}
Aggregations