use of com.cloud.network.PhysicalNetworkSetupInfo in project cloudstack by apache.
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.network.PhysicalNetworkSetupInfo in project cloudstack by apache.
the class OvmResourceBase method execute.
protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Checking if network name setup is done on the resource");
}
List<PhysicalNetworkSetupInfo> infoList = cmd.getPhysicalNetworkInfoList();
boolean errorout = false;
String msg = "";
for (PhysicalNetworkSetupInfo info : infoList) {
if (!isNetworkSetupByName(info.getGuestNetworkName())) {
msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Guest Network is not configured on the backend by name " + info.getGuestNetworkName();
errorout = true;
break;
}
if (!isNetworkSetupByName(info.getPrivateNetworkName())) {
msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Private Network is not configured on the backend by name " + info.getPrivateNetworkName();
errorout = true;
break;
}
if (!isNetworkSetupByName(info.getPublicNetworkName())) {
msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Public Network is not configured on the backend by name " + info.getPublicNetworkName();
errorout = true;
break;
}
}
if (errorout) {
s_logger.error(msg);
return new CheckNetworkAnswer(cmd, false, msg);
} else {
return new CheckNetworkAnswer(cmd, true, "Network Setup check by names is done");
}
}
use of com.cloud.network.PhysicalNetworkSetupInfo in project cloudstack by apache.
the class LibvirtComputingResourceTest method testCheckNetworkCommand.
@Test
public void testCheckNetworkCommand() {
final List<PhysicalNetworkSetupInfo> networkInfoList = new ArrayList<PhysicalNetworkSetupInfo>();
final PhysicalNetworkSetupInfo nic = Mockito.mock(PhysicalNetworkSetupInfo.class);
networkInfoList.add(nic);
final CheckNetworkCommand command = new CheckNetworkCommand(networkInfoList);
when(libvirtComputingResource.checkNetwork(nic.getGuestNetworkName())).thenReturn(true);
when(libvirtComputingResource.checkNetwork(nic.getPrivateNetworkName())).thenReturn(true);
when(libvirtComputingResource.checkNetwork(nic.getPublicNetworkName())).thenReturn(true);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, libvirtComputingResource);
assertTrue(answer.getResult());
verify(libvirtComputingResource, times(3)).checkNetwork(nic.getGuestNetworkName());
verify(libvirtComputingResource, times(3)).checkNetwork(nic.getPrivateNetworkName());
verify(libvirtComputingResource, times(3)).checkNetwork(nic.getPublicNetworkName());
}
use of com.cloud.network.PhysicalNetworkSetupInfo in project cloudstack by apache.
the class Ovm3HypervisorNetwork method execute.
/* this might have to change in the future, works for now... */
public CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
LOGGER.debug("Checking if network name setup is done on " + config.getAgentHostname());
List<PhysicalNetworkSetupInfo> infoList = cmd.getPhysicalNetworkInfoList();
/* here we assume all networks are set */
for (PhysicalNetworkSetupInfo info : infoList) {
if (info.getGuestNetworkName() == null) {
info.setGuestNetworkName(config.getAgentGuestNetworkName());
}
if (info.getPublicNetworkName() == null) {
info.setPublicNetworkName(config.getAgentPublicNetworkName());
}
if (info.getPrivateNetworkName() == null) {
info.setPrivateNetworkName(config.getAgentPrivateNetworkName());
}
if (info.getStorageNetworkName() == null) {
info.setStorageNetworkName(config.getAgentStorageNetworkName());
}
if (!isNetworkSetupByName(info.getGuestNetworkName())) {
String msg = "Guest Physical Network id:" + info.getPhysicalNetworkId() + ", Guest Network is not configured on the backend by name " + info.getGuestNetworkName();
LOGGER.error(msg);
return new CheckNetworkAnswer(cmd, false, msg);
}
if (!isNetworkSetupByName(info.getPrivateNetworkName())) {
String msg = "Private Physical Network id:" + info.getPhysicalNetworkId() + ", Private Network is not configured on the backend by name " + info.getPrivateNetworkName();
LOGGER.error(msg);
return new CheckNetworkAnswer(cmd, false, msg);
}
if (!isNetworkSetupByName(info.getPublicNetworkName())) {
String msg = "Public Physical Network id:" + info.getPhysicalNetworkId() + ", Public Network is not configured on the backend by name " + info.getPublicNetworkName();
LOGGER.error(msg);
return new CheckNetworkAnswer(cmd, false, msg);
}
/* Storage network is optional, will revert to private otherwise */
}
return new CheckNetworkAnswer(cmd, true, "Network Setup check by names is done");
}
use of com.cloud.network.PhysicalNetworkSetupInfo in project cloudstack by apache.
the class XenServer620WrapperTest method testCheckNetworkCommandFailure.
@Test
public void testCheckNetworkCommandFailure() {
final XenServer620Resource xenServer620Resource = new XenServer620Resource();
final PhysicalNetworkSetupInfo info = new PhysicalNetworkSetupInfo();
final List<PhysicalNetworkSetupInfo> setupInfos = new ArrayList<PhysicalNetworkSetupInfo>();
setupInfos.add(info);
final CheckNetworkCommand checkNet = new CheckNetworkCommand(setupInfos);
final Answer answer = xenServer620Resource.executeRequest(checkNet);
assertTrue(answer.getResult());
}
Aggregations