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());
}
}
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;
}
}
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);
}
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);
}
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;
}
Aggregations