Search in sources :

Example 11 with PhysicalNetworkSetupInfo

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

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<>();
    setupInfos.add(info);
    final CheckNetworkCommand checkNet = new CheckNetworkCommand(setupInfos);
    final Answer answer = xenServer620Resource.executeRequest(checkNet);
    assertTrue(answer.getResult());
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) ArrayList(java.util.ArrayList) XenServer620Resource(com.cloud.hypervisor.xenserver.resource.XenServer620Resource) CheckNetworkCommand(com.cloud.legacymodel.communication.command.CheckNetworkCommand) PhysicalNetworkSetupInfo(com.cloud.legacymodel.network.PhysicalNetworkSetupInfo) Test(org.junit.Test)

Example 12 with PhysicalNetworkSetupInfo

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

the class CitrixCheckNetworkCommandWrapper method execute.

@Override
public Answer execute(final CheckNetworkCommand command, final CitrixResourceBase citrixResourceBase) {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Checking if network name setup is done on the resource");
    }
    final List<PhysicalNetworkSetupInfo> infoList = command.getPhysicalNetworkInfoList();
    try {
        boolean errorout = false;
        String msg = "";
        for (final PhysicalNetworkSetupInfo info : infoList) {
            if (!citrixResourceBase.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 (!citrixResourceBase.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 (!citrixResourceBase.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(!isNetworkSetupByName(info.getStorageNetworkName())){
                    msg = "For Physical Network id:"+ info.getPhysicalNetworkId() + ", Storage Network is not configured on the backend by name " + info.getStorageNetworkName();
                    errorout = true;
                    break;
                }*/
        }
        if (errorout) {
            s_logger.error(msg);
            return new CheckNetworkAnswer(command, false, msg);
        } else {
            return new CheckNetworkAnswer(command, true, "Network Setup check by names is done");
        }
    } catch (final XenAPIException e) {
        final String msg = "CheckNetworkCommand failed with XenAPIException:" + e.toString() + " host:" + citrixResourceBase.getHost().getUuid();
        s_logger.warn(msg, e);
        return new CheckNetworkAnswer(command, false, msg);
    } catch (final Exception e) {
        final String msg = "CheckNetworkCommand failed with Exception:" + e.getMessage() + " host:" + citrixResourceBase.getHost().getUuid();
        s_logger.warn(msg, e);
        return new CheckNetworkAnswer(command, false, msg);
    }
}
Also used : CheckNetworkAnswer(com.cloud.legacymodel.communication.answer.CheckNetworkAnswer) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XenAPIException(com.xensource.xenapi.Types.XenAPIException) PhysicalNetworkSetupInfo(com.cloud.legacymodel.network.PhysicalNetworkSetupInfo)

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