Search in sources :

Example 11 with NetworkOverviewTO

use of com.cloud.agent.api.to.overviews.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);
        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.vm.Nic) UpdateNetworkOverviewCommand(com.cloud.agent.api.UpdateNetworkOverviewCommand) Answer(com.cloud.agent.api.Answer) DataCenter(com.cloud.dc.DataCenter) Network(com.cloud.network.Network) Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.agent.api.to.overviews.NetworkOverviewTO) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

Example 12 with NetworkOverviewTO

use of com.cloud.agent.api.to.overviews.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class VpcVirtualNetworkApplianceManagerImpl method startRemoteAccessVpn.

@Override
public boolean startRemoteAccessVpn(final RemoteAccessVpn vpn, final VirtualRouter router) throws ResourceUnavailableException {
    if (router.getState() != State.Running) {
        s_logger.warn("Unable to apply remote access VPN configuration, virtual router is not in the right state " + router.getState());
        throw new ResourceUnavailableException("Unable to apply remote access VPN configuration," + " virtual router is not in the right state", DataCenter.class, router.getDataCenterId());
    }
    final Commands cmds = new Commands(Command.OnError.Stop);
    final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null, null);
    final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
    cmds.addCommand(updateNetworkOverviewCommand);
    try {
        return _nwHelper.sendCommandsToRouter(router, cmds);
    } catch (final Exception ex) {
        s_logger.warn("Failed to delete remote access VPN: domR " + router + " is not in right state " + router.getState());
        return false;
    }
}
Also used : ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.agent.api.to.overviews.NetworkOverviewTO) UpdateNetworkOverviewCommand(com.cloud.agent.api.UpdateNetworkOverviewCommand) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 13 with NetworkOverviewTO

use of com.cloud.agent.api.to.overviews.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class VpcVirtualNetworkApplianceManagerImpl method refreshSite2SiteVpn.

@Override
public boolean refreshSite2SiteVpn(final Site2SiteVpnConnection conn, final VirtualRouter router) throws ResourceUnavailableException {
    if (router.getState() != State.Running) {
        s_logger.warn("Unable to apply site-to-site VPN configuration, virtual router is not in the right state " + router.getState());
        throw new ResourceUnavailableException("Unable to apply site-to-site VPN configuration," + " virtual router is not in the right state", DataCenter.class, router.getDataCenterId());
    }
    final Commands cmds = new Commands(Command.OnError.Continue);
    final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null, null);
    final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
    cmds.addCommand(updateNetworkOverviewCommand);
    return _nwHelper.sendCommandsToRouter(router, cmds);
}
Also used : ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.agent.api.to.overviews.NetworkOverviewTO) UpdateNetworkOverviewCommand(com.cloud.agent.api.UpdateNetworkOverviewCommand)

Example 14 with NetworkOverviewTO

use of com.cloud.agent.api.to.overviews.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final AdvancedVpnRules vpnRules) throws ResourceUnavailableException {
    final VirtualRouter router = vpnRules.getRouter();
    final Commands cmds = new Commands(Command.OnError.Continue);
    final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null, null);
    final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
    cmds.addCommand(updateNetworkOverviewCommand);
    // results accordingly
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : Commands(com.cloud.agent.manager.Commands) NetworkOverviewTO(com.cloud.agent.api.to.overviews.NetworkOverviewTO) UpdateNetworkOverviewCommand(com.cloud.agent.api.UpdateNetworkOverviewCommand) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 15 with NetworkOverviewTO

use of com.cloud.agent.api.to.overviews.NetworkOverviewTO in project cosmic by MissionCriticalCloud.

the class CommandSetupHelper method createNetworkOverviewFromRouter.

public NetworkOverviewTO createNetworkOverviewFromRouter(final VirtualRouter router, final List<Nic> nicsToExclude, final List<Ip> ipsToExclude, final List<StaticRouteProfile> staticRoutesToExclude, final RemoteAccessVpn remoteAccessVpnToExclude, final Site2SiteVpnConnection site2siteVpnToExclude) {
    final NetworkOverviewTO networkOverviewTO = new NetworkOverviewTO();
    final List<NetworkOverviewTO.InterfaceTO> interfacesTO = new ArrayList<>();
    final NetworkOverviewTO.ServiceTO servicesTO = new NetworkOverviewTO.ServiceTO();
    final List<NetworkOverviewTO.ServiceTO.ServiceSourceNatTO> serviceSourceNatsTO = new ArrayList<>();
    configureInterfacesAndIps(router, nicsToExclude, ipsToExclude, networkOverviewTO, interfacesTO, serviceSourceNatsTO);
    configureStaticRoutes(router, staticRoutesToExclude, networkOverviewTO);
    servicesTO.setSourceNat(serviceSourceNatsTO.toArray(new NetworkOverviewTO.ServiceTO.ServiceSourceNatTO[serviceSourceNatsTO.size()]));
    networkOverviewTO.setServices(servicesTO);
    final NetworkOverviewTO.VPNTO vpnTO = new NetworkOverviewTO.VPNTO();
    configureRemoteAccessVpn(router, remoteAccessVpnToExclude, vpnTO);
    configureSite2SiteVpn(router, site2siteVpnToExclude, vpnTO);
    networkOverviewTO.setVpn(vpnTO);
    configureSyslog(router, networkOverviewTO);
    return networkOverviewTO;
}
Also used : NetworkOverviewTO(com.cloud.agent.api.to.overviews.NetworkOverviewTO) ArrayList(java.util.ArrayList)

Aggregations

NetworkOverviewTO (com.cloud.agent.api.to.overviews.NetworkOverviewTO)15 UpdateNetworkOverviewCommand (com.cloud.agent.api.UpdateNetworkOverviewCommand)13 Commands (com.cloud.agent.manager.Commands)12 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)8 ArrayList (java.util.ArrayList)7 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)5 Network (com.cloud.network.Network)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 Ip (com.cloud.utils.net.Ip)5 ConfigurationException (javax.naming.ConfigurationException)5 DataCenter (com.cloud.dc.DataCenter)4 VirtualRouter (com.cloud.network.router.VirtualRouter)4 PrivateIpVO (com.cloud.network.vpc.PrivateIpVO)3 Vpc (com.cloud.network.vpc.Vpc)3 NicProfile (com.cloud.vm.NicProfile)3 UpdateVmOverviewCommand (com.cloud.agent.api.UpdateVmOverviewCommand)2 VMOverviewTO (com.cloud.agent.api.to.overviews.VMOverviewTO)2 PublicIpAddress (com.cloud.network.PublicIpAddress)2 PrivateIpAddress (com.cloud.network.vpc.PrivateIpAddress)2 Nic (com.cloud.vm.Nic)2