Search in sources :

Example 6 with CheckNetworkAnswer

use of com.cloud.agent.api.CheckNetworkAnswer 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.agent.api.CheckNetworkAnswer) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo)

Example 7 with CheckNetworkAnswer

use of com.cloud.agent.api.CheckNetworkAnswer in project CloudStack-archive by CloudStack-extras.

the class DummyResource method executeRequest.

@Override
public Answer executeRequest(Command cmd) {
    if (cmd instanceof CheckNetworkCommand) {
        return new CheckNetworkAnswer((CheckNetworkCommand) cmd, true, null);
    }
    System.out.println("Received Command: " + cmd.toString());
    Answer answer = new Answer(cmd, !_negative, "response");
    System.out.println("Replying with: " + answer.toString());
    return answer;
}
Also used : CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) Answer(com.cloud.agent.api.Answer) CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand)

Example 8 with CheckNetworkAnswer

use of com.cloud.agent.api.CheckNetworkAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method execute.

private CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
    List<PhysicalNetworkSetupInfo> phyNics = cmd.getPhysicalNetworkInfoList();
    String errMsg = null;
    for (PhysicalNetworkSetupInfo nic : phyNics) {
        if (!checkNetwork(nic.getGuestNetworkName())) {
            errMsg = "Can not find network: " + nic.getGuestNetworkName();
            break;
        } else if (!checkNetwork(nic.getPrivateNetworkName())) {
            errMsg = "Can not find network: " + nic.getPrivateNetworkName();
            break;
        } else if (!checkNetwork(nic.getPublicNetworkName())) {
            errMsg = "Can not find network: " + nic.getPublicNetworkName();
            break;
        }
    }
    if (errMsg != null) {
        return new CheckNetworkAnswer(cmd, false, errMsg);
    } else {
        return new CheckNetworkAnswer(cmd, true, null);
    }
}
Also used : CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo)

Example 9 with CheckNetworkAnswer

use of com.cloud.agent.api.CheckNetworkAnswer 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.agent.api.CheckNetworkAnswer) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XenAPIException(com.xensource.xenapi.Types.XenAPIException) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo)

Example 10 with CheckNetworkAnswer

use of com.cloud.agent.api.CheckNetworkAnswer in project cosmic by MissionCriticalCloud.

the class CheckNetworkAnswerTest method setUp.

@Before
public void setUp() {
    cnc = Mockito.mock(CheckNetworkCommand.class);
    cna = new CheckNetworkAnswer(cnc, true, "details", true);
}
Also used : CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand) Before(org.junit.Before)

Aggregations

CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)13 PhysicalNetworkSetupInfo (com.cloud.network.PhysicalNetworkSetupInfo)9 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)6 Answer (com.cloud.agent.api.Answer)2 StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)2 ConnectionException (com.cloud.exception.ConnectionException)2 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)2 PhysicalNetworkTrafficTypeVO (com.cloud.network.dao.PhysicalNetworkTrafficTypeVO)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 XenAPIException (com.xensource.xenapi.Types.XenAPIException)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 Zone (com.cloud.db.model.Zone)1 DataCenterVO (com.cloud.dc.DataCenterVO)1