Search in sources :

Example 6 with NetworkOverviewTO

use of com.cloud.legacymodel.to.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class CommandSetupHelper method configureSyslog.

private void configureSyslog(final VirtualRouter router, final NetworkOverviewTO networkOverviewTO) {
    final Vpc vpc = _vpcDao.findById(router.getVpcId());
    if (StringUtils.isNotBlank(vpc.getSyslogServerList())) {
        final NetworkOverviewTO.SyslogTO syslogTO = new NetworkOverviewTO.SyslogTO();
        syslogTO.setServers(vpc.getSyslogServerList().split(","));
        networkOverviewTO.setSyslog(syslogTO);
    }
}
Also used : Vpc(com.cloud.legacymodel.network.vpc.Vpc) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO)

Example 7 with NetworkOverviewTO

use of com.cloud.legacymodel.to.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class VpcVirtualNetworkApplianceManagerImpl method updateVR.

@Override
public boolean updateVR(final Vpc vpc, final DomainRouterVO router) {
    Commands commands = new Commands(Command.OnError.Stop);
    final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null, null, null);
    final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
    commands.addCommand(updateNetworkOverviewCommand);
    _commandSetupHelper.createVRConfigCommands(vpc, router, commands);
    try {
        if (_nwHelper.sendCommandsToRouter(router, commands)) {
            s_logger.debug("Successfully applied source NAT list on the vpc " + router.getHostName());
            return true;
        } else {
            s_logger.warn("Failed to apply source NAT list on vpc " + router.getHostName());
            return false;
        }
    } catch (final Exception ex) {
        s_logger.warn("Failed to send config update to router " + router.getHostName());
        return false;
    }
}
Also used : Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO) UpdateNetworkOverviewCommand(com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand) ConfigurationException(javax.naming.ConfigurationException) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException)

Example 8 with NetworkOverviewTO

use of com.cloud.legacymodel.to.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class VpcVirtualNetworkApplianceManagerImpl method stopRemoteAccessVpn.

@Override
public boolean stopRemoteAccessVpn(final RemoteAccessVpn vpn, final VirtualRouter router) throws ResourceUnavailableException {
    if (router.getState() == State.Running) {
        final Commands cmds = new Commands(Command.OnError.Continue);
        final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), vpn, null, null);
        final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
        cmds.addCommand(updateNetworkOverviewCommand);
        try {
            return _nwHelper.sendCommandsToRouter(router, cmds);
        } catch (final Exception ex) {
            return false;
        }
    } else if (router.getState() == State.Stopped) {
        s_logger.debug("Router " + router + " is in Stopped state, not sending deleteRemoteAccessVpn command to it");
    } else {
        s_logger.warn("Failed to delete remote access VPN: domR " + router + " is not in right state " + router.getState());
        throw new ResourceUnavailableException("Failed to delete remote access VPN: domR is not in right state " + router.getState(), DataCenter.class, router.getDataCenterId());
    }
    return true;
}
Also used : DataCenter(com.cloud.legacymodel.dc.DataCenter) Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) UpdateNetworkOverviewCommand(com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand) ConfigurationException(javax.naming.ConfigurationException) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException)

Example 9 with NetworkOverviewTO

use of com.cloud.legacymodel.to.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class VpcVirtualNetworkApplianceManagerImpl method setupVpcPrivateNetwork.

/**
 * @param router
 * @param add
 * @param privateNic
 * @return
 * @throws ResourceUnavailableException
 */
protected boolean setupVpcPrivateNetwork(final VirtualRouter router, final boolean add, final NicProfile privateNic) throws ResourceUnavailableException {
    if (router.getState() == State.Running) {
        final PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(), privateNic.getIPv4Address());
        final Network network = _networkDao.findById(privateNic.getNetworkId());
        final String netmask = NetUtils.getCidrNetmask(network.getCidr());
        String broadcastUri = "";
        if (network.getBroadcastUri() != null) {
            broadcastUri = network.getBroadcastUri().toString();
        }
        final PrivateIpAddress ip = new PrivateIpAddress(ipVO, broadcastUri, network.getGateway(), netmask, privateNic.getMacAddress());
        final Commands cmds = new Commands(Command.OnError.Stop);
        final List<Ip> ipsToExclude = new ArrayList<>();
        if (!add) {
            ipsToExclude.add(new Ip(NetUtils.ip2Long(ip.getIpAddress())));
        }
        final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), ipsToExclude, new ArrayList<>(), null, null, null);
        final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
        cmds.addCommand(updateNetworkOverviewCommand);
        try {
            if (_nwHelper.sendCommandsToRouter(router, cmds)) {
                s_logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network);
                return true;
            } else {
                s_logger.warn("Failed to associate ip address " + ip + " in vpc network " + network);
                return false;
            }
        } catch (final Exception ex) {
            s_logger.warn("Failed to send  " + (add ? "add " : "delete ") + " private network " + network + " commands to rotuer ");
            return false;
        }
    } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
        s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending setup private network command to the backend");
    } else {
        s_logger.warn("Unable to setup private gateway, virtual router " + router + " is not in the right state " + router.getState());
        throw new ResourceUnavailableException("Unable to setup Private gateway on the backend," + " virtual router " + router + " is not in the right state", DataCenter.class, router.getDataCenterId());
    }
    return true;
}
Also used : PrivateIpAddress(com.cloud.network.vpc.PrivateIpAddress) Ip(com.cloud.legacymodel.network.Ip) PublicIp(com.cloud.network.addr.PublicIp) ArrayList(java.util.ArrayList) PrivateIpVO(com.cloud.network.vpc.PrivateIpVO) UpdateNetworkOverviewCommand(com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand) ConfigurationException(javax.naming.ConfigurationException) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) DataCenter(com.cloud.legacymodel.dc.DataCenter) Network(com.cloud.legacymodel.network.Network) Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException)

Example 10 with NetworkOverviewTO

use of com.cloud.legacymodel.to.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class VpcVirtualNetworkApplianceManagerImpl method setupVpcGuestNetwork.

protected boolean setupVpcGuestNetwork(final VirtualRouter router, final boolean add, final NicProfile guestNic) throws ConcurrentOperationException, ResourceUnavailableException {
    boolean result = true;
    if (router.getState() == State.Running) {
        final Commands cmds = new Commands(Command.OnError.Stop);
        final List<Nic> nicsToExclude = new ArrayList<>();
        if (!add) {
            final Network network = _networkModel.getNetwork(guestNic.getNetworkId());
            final Nic nic = _nicDao.findByNtwkIdAndInstanceId(network.getId(), router.getId());
            nicsToExclude.add(nic);
        }
        final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, nicsToExclude, new ArrayList<>(), new ArrayList<>(), null, null, null);
        final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
        cmds.addCommand("networkoverview", updateNetworkOverviewCommand);
        _nwHelper.sendCommandsToRouter(router, cmds);
        final Answer setupAnswer = cmds.getAnswer("networkoverview");
        final String setup = add ? "set" : "destroy";
        if (!(setupAnswer != null && setupAnswer.getResult())) {
            s_logger.warn("Unable to " + setup + " guest network on router " + router);
            result = false;
        }
        return result;
    } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
        s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending setup guest network command to the backend");
        return true;
    } else {
        s_logger.warn("Unable to setup guest network on virtual router " + router + " is not in the right state " + router.getState());
        throw new ResourceUnavailableException("Unable to setup guest network on the backend, virtual router " + router + " is not in the right state", DataCenter.class, router.getDataCenterId());
    }
}
Also used : ArrayList(java.util.ArrayList) Nic(com.cloud.legacymodel.network.Nic) UpdateNetworkOverviewCommand(com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand) Answer(com.cloud.legacymodel.communication.answer.Answer) DataCenter(com.cloud.legacymodel.dc.DataCenter) Network(com.cloud.legacymodel.network.Network) Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException)

Aggregations

NetworkOverviewTO (com.cloud.legacymodel.to.NetworkOverviewTO)16 UpdateNetworkOverviewCommand (com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand)14 Commands (com.cloud.agent.manager.Commands)13 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)9 ArrayList (java.util.ArrayList)8 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)6 ConcurrentOperationException (com.cloud.legacymodel.exceptions.ConcurrentOperationException)6 ConfigurationException (javax.naming.ConfigurationException)6 DataCenter (com.cloud.legacymodel.dc.DataCenter)5 Ip (com.cloud.legacymodel.network.Ip)5 Network (com.cloud.legacymodel.network.Network)5 VirtualRouter (com.cloud.legacymodel.network.VirtualRouter)5 Vpc (com.cloud.legacymodel.network.vpc.Vpc)4 UpdateVmOverviewCommand (com.cloud.legacymodel.communication.command.UpdateVmOverviewCommand)2 Nic (com.cloud.legacymodel.network.Nic)2 LoadBalancerTO (com.cloud.legacymodel.to.LoadBalancerTO)2 PublicIpAddress (com.cloud.network.PublicIpAddress)2 PrivateIpAddress (com.cloud.network.vpc.PrivateIpAddress)2 PrivateIpVO (com.cloud.network.vpc.PrivateIpVO)2 DomainRouterVO (com.cloud.vm.DomainRouterVO)2