Search in sources :

Example 1 with PhysicalNetworkSetupInfo

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);
    }
}
Also used : CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo)

Example 2 with PhysicalNetworkSetupInfo

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");
    }
}
Also used : CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo)

Example 3 with PhysicalNetworkSetupInfo

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());
}
Also used : AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) 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 4 with PhysicalNetworkSetupInfo

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");
}
Also used : CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo)

Example 5 with PhysicalNetworkSetupInfo

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());
}
Also used : Answer(com.cloud.agent.api.Answer) ArrayList(java.util.ArrayList) XenServer620Resource(com.cloud.hypervisor.xenserver.resource.XenServer620Resource) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo) Test(org.junit.Test)

Aggregations

PhysicalNetworkSetupInfo (com.cloud.network.PhysicalNetworkSetupInfo)21 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)15 ArrayList (java.util.ArrayList)14 Answer (com.cloud.agent.api.Answer)13 Test (org.junit.Test)13 CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)6 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)6 CloudStackPluginTest (com.cloud.hypervisor.ovm3.objects.CloudStackPluginTest)5 ConnectionTest (com.cloud.hypervisor.ovm3.objects.ConnectionTest)5 NetworkTest (com.cloud.hypervisor.ovm3.objects.NetworkTest)5 XenTest (com.cloud.hypervisor.ovm3.objects.XenTest)5 XmlTestResultTest (com.cloud.hypervisor.ovm3.objects.XmlTestResultTest)5 Ovm3HypervisorResourceTest (com.cloud.hypervisor.ovm3.resources.Ovm3HypervisorResourceTest)5 Ovm3SupportTest (com.cloud.hypervisor.ovm3.support.Ovm3SupportTest)5 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)4 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)4 RebootAnswer (com.cloud.agent.api.RebootAnswer)2 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)2 StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)1 ClusterVO (com.cloud.dc.ClusterVO)1