Search in sources :

Example 1 with GetDomRVersionAnswer

use of com.cloud.legacymodel.communication.answer.GetDomRVersionAnswer in project cosmic by MissionCriticalCloud.

the class VirtualRoutingResource method execute.

private Answer execute(final GetDomRVersionCommand cmd) {
    final ExecutionResult result = this._vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VERSION, null);
    if (!result.isSuccess()) {
        return new GetDomRVersionAnswer(cmd, "GetDomRVersionCommand failed");
    }
    final String[] lines = result.getDetails().split("&");
    if (lines.length != 2) {
        return new GetDomRVersionAnswer(cmd, result.getDetails());
    }
    return new GetDomRVersionAnswer(cmd, result.getDetails(), lines[0], lines[1]);
}
Also used : ExecutionResult(com.cloud.legacymodel.ExecutionResult) GetDomRVersionAnswer(com.cloud.legacymodel.communication.answer.GetDomRVersionAnswer)

Example 2 with GetDomRVersionAnswer

use of com.cloud.legacymodel.communication.answer.GetDomRVersionAnswer in project cosmic by MissionCriticalCloud.

the class VirtualNetworkApplianceManagerImpl method finalizeStart.

@Override
public boolean finalizeStart(final VirtualMachineProfile profile, final long hostId, final Commands cmds, final ReservationContext context) {
    final DomainRouterVO router = _routerDao.findById(profile.getId());
    // process all the answers
    for (final Answer answer : cmds.getAnswers()) {
        // handle any command failures
        if (!answer.getResult()) {
            final String cmdClassName = answer.getClass().getCanonicalName().replace("Answer", "Command");
            final String errorMessage = "Command: " + cmdClassName + " failed while starting virtual router";
            final String errorDetails = "Details: " + answer.getDetails() + " " + answer.toString();
            // add alerts for the failed commands
            _alertMgr.sendAlert(AlertService.AlertType.ALERT_TYPE_DOMAIN_ROUTER, router.getDataCenterId(), router.getPodIdToDeployIn(), errorMessage, errorDetails);
            s_logger.error(answer.getDetails());
            s_logger.warn(errorMessage);
            // Stop the router if any of the commands failed
            return false;
        }
    }
    // at this point, all the router command are successful.
    boolean result = true;
    // Get guest networks info
    final List<Network> guestNetworks = new ArrayList<>();
    final List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
    for (final Nic nic : routerNics) {
        final Network network = _networkModel.getNetwork(nic.getNetworkId());
        final Zone zone = zoneRepository.findById(network.getDataCenterId()).orElse(null);
        if (network.getTrafficType() == TrafficType.Guest) {
            guestNetworks.add(network);
            if (nic.getBroadcastUri().getScheme().equals("pvlan")) {
                final NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, "pvlan-nic");
                final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(zone);
                try {
                    result = networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nicProfile);
                } catch (final ResourceUnavailableException e) {
                    s_logger.debug("ERROR in finalizeStart: ", e);
                }
            }
        }
    }
    if (result) {
        final GetDomRVersionAnswer versionAnswer = (GetDomRVersionAnswer) cmds.getAnswer("getDomRVersion");
        router.setTemplateVersion(versionAnswer.getTemplateVersion());
        router.setScriptsVersion(versionAnswer.getScriptsVersion());
        _routerDao.persist(router, guestNetworks);
    }
    final List<DomainRouterVO> routers = _routerDao.listByVpcId(router.getVpcId());
    for (final DomainRouterVO domainRouterVO : routers) {
        s_logger.info("Updating the redundant state of router " + domainRouterVO);
        updateRoutersRedundantState(domainRouterVO);
    }
    return result;
}
Also used : Zone(com.cloud.db.model.Zone) TimeZone(java.util.TimeZone) ArrayList(java.util.ArrayList) Nic(com.cloud.legacymodel.network.Nic) NicProfile(com.cloud.vm.NicProfile) NetworkUsageAnswer(com.cloud.legacymodel.communication.answer.NetworkUsageAnswer) GetDomRVersionAnswer(com.cloud.legacymodel.communication.answer.GetDomRVersionAnswer) AgentControlAnswer(com.cloud.legacymodel.communication.answer.AgentControlAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.legacymodel.communication.answer.CheckS2SVpnConnectionsAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) Network(com.cloud.legacymodel.network.Network) NetworkTopology(com.cloud.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) GetDomRVersionAnswer(com.cloud.legacymodel.communication.answer.GetDomRVersionAnswer) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

GetDomRVersionAnswer (com.cloud.legacymodel.communication.answer.GetDomRVersionAnswer)2 Zone (com.cloud.db.model.Zone)1 ExecutionResult (com.cloud.legacymodel.ExecutionResult)1 AgentControlAnswer (com.cloud.legacymodel.communication.answer.AgentControlAnswer)1 Answer (com.cloud.legacymodel.communication.answer.Answer)1 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)1 CheckS2SVpnConnectionsAnswer (com.cloud.legacymodel.communication.answer.CheckS2SVpnConnectionsAnswer)1 NetworkUsageAnswer (com.cloud.legacymodel.communication.answer.NetworkUsageAnswer)1 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)1 Network (com.cloud.legacymodel.network.Network)1 Nic (com.cloud.legacymodel.network.Nic)1 NetworkTopology (com.cloud.network.topology.NetworkTopology)1 DomainRouterVO (com.cloud.vm.DomainRouterVO)1 NicProfile (com.cloud.vm.NicProfile)1 ArrayList (java.util.ArrayList)1 TimeZone (java.util.TimeZone)1