Search in sources :

Example 6 with Ip

use of com.cloud.legacymodel.network.Ip in project cosmic by MissionCriticalCloud.

the class AdvancedNetworkVisitor method visit.

@Override
public boolean visit(final VpcIpAssociationRules vpcip) throws ResourceUnavailableException {
    final VirtualRouter router = vpcip.getRouter();
    final Commands cmds = new Commands(Command.OnError.Continue);
    final List<PublicIpAddress> ipsToSend = vpcip.getIpsToSend();
    if (!ipsToSend.isEmpty()) {
        final List<Ip> ipsToExclude = new ArrayList<>();
        _commandSetupHelper.findIpsToExclude(ipsToSend, ipsToExclude);
        final NetworkOverviewTO networkOverview = _commandSetupHelper.createNetworkOverviewFromRouter(router, new ArrayList<>(), ipsToExclude, new ArrayList<>(), null, null, null);
        final UpdateNetworkOverviewCommand updateNetworkOverviewCommand = _commandSetupHelper.createUpdateNetworkOverviewCommand(router, networkOverview);
        updateNetworkOverviewCommand.setPlugNics(true);
        cmds.addCommand(updateNetworkOverviewCommand);
        return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
    } else {
        return true;
    }
}
Also used : PublicIpAddress(com.cloud.network.PublicIpAddress) Ip(com.cloud.legacymodel.network.Ip) Commands(com.cloud.agent.manager.Commands) ArrayList(java.util.ArrayList) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO) UpdateNetworkOverviewCommand(com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand) VirtualRouter(com.cloud.legacymodel.network.VirtualRouter)

Example 7 with Ip

use of com.cloud.legacymodel.network.Ip in project cosmic by MissionCriticalCloud.

the class CommandSetupHelper method configureInterfacesAndIps.

private void configureInterfacesAndIps(final VirtualRouter router, final List<Nic> nicsToExclude, final List<Ip> ipsToExclude, final NetworkOverviewTO networkOverviewTO, final List<NetworkOverviewTO.InterfaceTO> interfacesTO, final List<NetworkOverviewTO.ServiceTO.ServiceSourceNatTO> serviceSourceNatsTO) {
    final List<NicVO> nics = _nicDao.listByVmId(router.getId());
    nics.stream().filter(nic -> !nicsToExclude.contains(nic)).forEach(nic -> {
        final NetworkOverviewTO.InterfaceTO interfaceTO = new NetworkOverviewTO.InterfaceTO();
        interfaceTO.setMacAddress(nic.getMacAddress());
        final List<NetworkOverviewTO.InterfaceTO.IPv4AddressTO> ipv4Addresses = new ArrayList<>();
        if (StringUtils.isNotBlank(nic.getIPv4Address()) && StringUtils.isNotBlank(nic.getIPv4Netmask())) {
            ipv4Addresses.add(new NetworkOverviewTO.InterfaceTO.IPv4AddressTO(NetUtils.getIpv4AddressWithCidrSize(nic.getIPv4Address(), nic.getIPv4Netmask()), nic.getIPv4Gateway()));
        }
        final NetworkVO network = _networkDao.findById(nic.getNetworkId());
        if (network != null) {
            final TrafficType trafficType = network.getTrafficType();
            if (TrafficType.Public.equals(trafficType)) {
                ipv4Addresses.addAll(_ipAddressDao.listByVpc(router.getVpcId(), false).stream().filter(ipAddressVO -> !ipsToExclude.contains(ipAddressVO.getAddress()) && ipAddressVO.getAssociatedWithNetworkId() != null).map(ipAddressVO -> {
                    final Ip ip = ipAddressVO.getAddress();
                    final VlanVO vlanVO = _vlanDao.findById(ipAddressVO.getVlanId());
                    return new NetworkOverviewTO.InterfaceTO.IPv4AddressTO(NetUtils.getIpv4AddressWithCidrSize(ip.addr(), vlanVO.getVlanNetmask()), nic.getIPv4Gateway());
                }).collect(Collectors.toList()));
                serviceSourceNatsTO.addAll(_ipAddressDao.listByVpc(router.getVpcId(), true).stream().map(IPAddressVO::getAddress).filter(ip -> !ipsToExclude.contains(ip)).map(Ip::addr).map(ip -> new NetworkOverviewTO.ServiceTO.ServiceSourceNatTO(ip, nic.getIPv4Gateway())).collect(Collectors.toList()));
            }
            interfaceTO.setMetadata(new NetworkOverviewTO.InterfaceTO.MetadataTO(network));
        }
        interfaceTO.setIpv4Addresses(ipv4Addresses.toArray(new NetworkOverviewTO.InterfaceTO.IPv4AddressTO[ipv4Addresses.size()]));
        interfacesTO.add(interfaceTO);
    });
    networkOverviewTO.setInterfaces(interfacesTO.toArray(new NetworkOverviewTO.InterfaceTO[interfacesTO.size()]));
}
Also used : LbStickinessPolicy(com.cloud.legacymodel.network.LoadBalancingRule.LbStickinessPolicy) NetworkModel(com.cloud.network.NetworkModel) VpnUser(com.cloud.legacymodel.network.VpnUser) Nic(com.cloud.legacymodel.network.Nic) StaticRouteProfile(com.cloud.legacymodel.network.vpc.StaticRouteProfile) NetworkACLTO(com.cloud.legacymodel.to.NetworkACLTO) ServiceOfferingDao(com.cloud.service.dao.ServiceOfferingDao) VlanDao(com.cloud.dc.dao.VlanDao) Map(java.util.Map) ZoneRepository(com.cloud.db.repository.ZoneRepository) LoadBalancerVMMapDao(com.cloud.network.dao.LoadBalancerVMMapDao) FirewallRule(com.cloud.legacymodel.network.FirewallRule) NetworkACLItemVO(com.cloud.network.vpc.NetworkACLItemVO) NicTO(com.cloud.legacymodel.to.NicTO) LoadBalancingRule(com.cloud.legacymodel.network.LoadBalancingRule) RemoteAccessVpnVO(com.cloud.network.dao.RemoteAccessVpnVO) StaticNatRule(com.cloud.legacymodel.network.StaticNatRule) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) SetPublicIpACLCommand(com.cloud.legacymodel.communication.command.SetPublicIpACLCommand) VpcGateway(com.cloud.legacymodel.network.vpc.VpcGateway) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) SetStaticNatRulesCommand(com.cloud.legacymodel.communication.command.SetStaticNatRulesCommand) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) VpnUserDao(com.cloud.network.dao.VpnUserDao) NumbersUtil(com.cloud.utils.NumbersUtil) VirtualMachine(com.cloud.legacymodel.vm.VirtualMachine) Ip(com.cloud.legacymodel.network.Ip) Zone(com.cloud.db.model.Zone) UpdateVmOverviewCommand(com.cloud.legacymodel.communication.command.UpdateVmOverviewCommand) NicProfile(com.cloud.vm.NicProfile) ArrayList(java.util.ArrayList) Purpose(com.cloud.legacymodel.network.FirewallRule.Purpose) VlanVO(com.cloud.dc.VlanVO) ConfigurationDao(com.cloud.framework.config.dao.ConfigurationDao) DomainRouterVO(com.cloud.vm.DomainRouterVO) UpdateNetworkOverviewCommand(com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand) BroadcastDomainType(com.cloud.model.enumeration.BroadcastDomainType) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection) PortForwardingRule(com.cloud.legacymodel.network.PortForwardingRule) DomainRouterDao(com.cloud.vm.dao.DomainRouterDao) SavePasswordCommand(com.cloud.legacymodel.communication.command.SavePasswordCommand) LbDestination(com.cloud.legacymodel.network.LoadBalancingRule.LbDestination) PublicIpACLTO(com.cloud.legacymodel.to.PublicIpACLTO) Site2SiteVpnConnectionDao(com.cloud.network.dao.Site2SiteVpnConnectionDao) Site2SiteVpnConnectionVO(com.cloud.network.dao.Site2SiteVpnConnectionVO) UserVmDao(com.cloud.vm.dao.UserVmDao) NetworkElementCommand(com.cloud.legacymodel.communication.command.NetworkElementCommand) NicDao(com.cloud.vm.dao.NicDao) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn) Site2SiteCustomerGatewayDao(com.cloud.network.dao.Site2SiteCustomerGatewayDao) StaticRouteDao(com.cloud.network.vpc.dao.StaticRouteDao) SetPortForwardingRulesVpcCommand(com.cloud.legacymodel.communication.command.SetPortForwardingRulesVpcCommand) FirewallRuleTO(com.cloud.legacymodel.to.FirewallRuleTO) PortForwardingRuleTO(com.cloud.legacymodel.to.PortForwardingRuleTO) SetPortForwardingRulesCommand(com.cloud.legacymodel.communication.command.SetPortForwardingRulesCommand) Site2SiteVpnGatewayDao(com.cloud.network.dao.Site2SiteVpnGatewayDao) Site2SiteVpnGatewayVO(com.cloud.network.dao.Site2SiteVpnGatewayVO) StaticNatRuleTO(com.cloud.legacymodel.to.StaticNatRuleTO) URI(java.net.URI) Config(com.cloud.configuration.Config) SetFirewallRulesCommand(com.cloud.legacymodel.communication.command.SetFirewallRulesCommand) StringUtils(com.cloud.utils.StringUtils) SetNetworkACLCommand(com.cloud.legacymodel.communication.command.SetNetworkACLCommand) TrafficType(com.cloud.model.enumeration.TrafficType) LBStickinessPolicyDao(com.cloud.network.dao.LBStickinessPolicyDao) Commands(com.cloud.agent.manager.Commands) IpAddress(com.cloud.network.IpAddress) LoadBalancerDao(com.cloud.network.dao.LoadBalancerDao) NicVO(com.cloud.vm.NicVO) Site2SiteCustomerGatewayVO(com.cloud.network.dao.Site2SiteCustomerGatewayVO) Collectors(java.util.stream.Collectors) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO) List(java.util.List) LoadBalancerTO(com.cloud.legacymodel.to.LoadBalancerTO) NetworkACLItem(com.cloud.legacymodel.network.vpc.NetworkACLItem) RemoteAccessVpnDao(com.cloud.network.dao.RemoteAccessVpnDao) VirtualMachineManager(com.cloud.vm.VirtualMachineManager) Optional(java.util.Optional) NetUtils(com.cloud.utils.net.NetUtils) LoadBalancerConfigCommand(com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) StaticNat(com.cloud.network.rules.StaticNat) VirtualRouter(com.cloud.legacymodel.network.VirtualRouter) HashMap(java.util.HashMap) NetworkDao(com.cloud.network.dao.NetworkDao) Inject(javax.inject.Inject) IPAddressVO(com.cloud.network.dao.IPAddressVO) NetworkVO(com.cloud.network.dao.NetworkVO) Qualifier(org.springframework.beans.factory.annotation.Qualifier) IPAddressDao(com.cloud.network.dao.IPAddressDao) VMOverviewTO(com.cloud.legacymodel.to.VMOverviewTO) GuestType(com.cloud.model.enumeration.GuestType) FirewallRulesDao(com.cloud.network.dao.FirewallRulesDao) Network(com.cloud.legacymodel.network.Network) NetworkACLItemDao(com.cloud.network.vpc.NetworkACLItemDao) SetupVRCommand(com.cloud.legacymodel.communication.command.SetupVRCommand) PublicIpAddress(com.cloud.network.PublicIpAddress) NetworkOffering(com.cloud.offering.NetworkOffering) UserVmVO(com.cloud.vm.UserVmVO) VpcDao(com.cloud.network.vpc.dao.VpcDao) NetworkOfferingDao(com.cloud.offerings.dao.NetworkOfferingDao) LoadBalancer(com.cloud.legacymodel.network.LoadBalancer) Vpc(com.cloud.legacymodel.network.vpc.Vpc) FirewallRuleVO(com.cloud.network.rules.FirewallRuleVO) NetworkVO(com.cloud.network.dao.NetworkVO) Ip(com.cloud.legacymodel.network.Ip) ArrayList(java.util.ArrayList) NetworkOverviewTO(com.cloud.legacymodel.to.NetworkOverviewTO) VlanVO(com.cloud.dc.VlanVO) NicVO(com.cloud.vm.NicVO) TrafficType(com.cloud.model.enumeration.TrafficType)

Example 8 with Ip

use of com.cloud.legacymodel.network.Ip 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 9 with Ip

use of com.cloud.legacymodel.network.Ip in project cosmic by MissionCriticalCloud.

the class VirtualNetworkApplianceManagerImpl method finalizeNetworkRulesForNetwork.

protected void finalizeNetworkRulesForNetwork(final Commands cmds, final DomainRouterVO router, final Provider provider, final Long guestNetworkId) {
    s_logger.debug("Resending ipAssoc, port forwarding, load balancing rules as a part of Virtual router start");
    final ArrayList<? extends PublicIpAddress> publicIps = getPublicIpsToApply(router, provider, guestNetworkId);
    final List<FirewallRule> firewallRulesEgress = new ArrayList<>();
    // Fetch firewall Egress rules.
    if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
        firewallRulesEgress.addAll(_rulesDao.listByNetworkPurposeTrafficType(guestNetworkId, Purpose.Firewall, FirewallRule.TrafficType.Egress));
        if (firewallRulesEgress.isEmpty()) {
            // create egress default rule for VR
            createDefaultEgressFirewallRule(firewallRulesEgress, guestNetworkId);
        }
    }
    // Re-apply firewall Egress rules
    s_logger.debug("Found " + firewallRulesEgress.size() + " firewall Egress rule(s) to apply as a part of domR " + router + " start.");
    if (!firewallRulesEgress.isEmpty()) {
        _commandSetupHelper.createFirewallRulesCommands(firewallRulesEgress, router, cmds, guestNetworkId);
    }
    if (publicIps != null && !publicIps.isEmpty()) {
        final List<PortForwardingRule> pfRules = new ArrayList<>();
        final List<FirewallRule> staticNatFirewallRules = new ArrayList<>();
        final List<StaticNat> staticNats = new ArrayList<>();
        final List<FirewallRule> firewallRulesIngress = new ArrayList<>();
        // StaticNatRules; PFVPN to reapply on domR start)
        for (final PublicIpAddress ip : publicIps) {
            if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.PortForwarding, provider)) {
                pfRules.addAll(_pfRulesDao.listForApplication(ip.getId()));
            }
            if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
                staticNatFirewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.StaticNat));
            }
            if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
                firewallRulesIngress.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.Firewall));
            }
            if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
                if (ip.isOneToOneNat()) {
                    final StaticNatImpl staticNat = new StaticNatImpl(ip.getAccountId(), ip.getDomainId(), guestNetworkId, ip.getId(), ip.getVmIp(), false);
                    staticNats.add(staticNat);
                }
            }
        }
        // Re-apply static nats
        s_logger.debug("Found " + staticNats.size() + " static nat(s) to apply as a part of domR " + router + " start.");
        if (!staticNats.isEmpty()) {
            _commandSetupHelper.createApplyStaticNatCommands(staticNats, router, cmds);
        }
        // Re-apply firewall Ingress rules
        s_logger.debug("Found " + firewallRulesIngress.size() + " firewall Ingress rule(s) to apply as a part of domR " + router + " start.");
        if (!firewallRulesIngress.isEmpty()) {
            _commandSetupHelper.createFirewallRulesCommands(firewallRulesIngress, router, cmds, guestNetworkId);
        }
        // Re-apply port forwarding rules
        s_logger.debug("Found " + pfRules.size() + " port forwarding rule(s) to apply as a part of domR " + router + " start.");
        if (!pfRules.isEmpty()) {
            _commandSetupHelper.createApplyPortForwardingRulesCommands(pfRules, router, cmds, guestNetworkId);
        }
        // Re-apply static nat rules
        s_logger.debug("Found " + staticNatFirewallRules.size() + " static nat rule(s) to apply as a part of domR " + router + " start.");
        if (!staticNatFirewallRules.isEmpty()) {
            final List<StaticNatRule> staticNatRules = new ArrayList<>();
            for (final FirewallRule rule : staticNatFirewallRules) {
                staticNatRules.add(_rulesMgr.buildStaticNatRule(rule, false));
            }
            _commandSetupHelper.createApplyStaticNatRulesCommands(staticNatRules, router, cmds, guestNetworkId);
        }
        final List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkIdAndScheme(guestNetworkId, Scheme.Public);
        final List<LoadBalancingRule> lbRules = new ArrayList<>();
        if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb, provider)) {
            // Re-apply load balancing rules
            for (final LoadBalancerVO lb : lbs) {
                final List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
                final List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
                final List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
                final Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
                final LbSslCert sslCert = _lbMgr.getLbSslCert(lb.getId());
                final LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList, sourceIp, sslCert, lb.getLbProtocol());
                lbRules.add(loadBalancing);
            }
        }
        s_logger.debug("Found " + lbRules.size() + " load balancing rule(s) to apply as a part of domR " + router + " start.");
        if (!lbRules.isEmpty()) {
            _commandSetupHelper.createApplyLoadBalancingRulesCommands(lbRules, router, cmds, guestNetworkId);
        }
    }
}
Also used : LbSslCert(com.cloud.legacymodel.network.LoadBalancingRule.LbSslCert) LoadBalancingRule(com.cloud.legacymodel.network.LoadBalancingRule) Ip(com.cloud.legacymodel.network.Ip) PublicIp(com.cloud.network.addr.PublicIp) ArrayList(java.util.ArrayList) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) LbStickinessPolicy(com.cloud.legacymodel.network.LoadBalancingRule.LbStickinessPolicy) StaticNatRule(com.cloud.legacymodel.network.StaticNatRule) PortForwardingRule(com.cloud.legacymodel.network.PortForwardingRule) StaticNat(com.cloud.network.rules.StaticNat) LbDestination(com.cloud.legacymodel.network.LoadBalancingRule.LbDestination) PublicIpAddress(com.cloud.network.PublicIpAddress) StaticNatImpl(com.cloud.network.rules.StaticNatImpl) LbHealthCheckPolicy(com.cloud.legacymodel.network.LoadBalancingRule.LbHealthCheckPolicy) FirewallRule(com.cloud.legacymodel.network.FirewallRule)

Example 10 with Ip

use of com.cloud.legacymodel.network.Ip in project cosmic by MissionCriticalCloud.

the class FirewallRules method accept.

@Override
public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
    _router = router;
    _purpose = _rules.get(0).getPurpose();
    if (_purpose == Purpose.LoadBalancing) {
        final LoadBalancerDao loadBalancerDao = visitor.getVirtualNetworkApplianceFactory().getLoadBalancerDao();
        // for load balancer we have to resend all lb rules for the network
        final List<LoadBalancerVO> lbs = loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public);
        _loadbalancingRules = new ArrayList<>();
        final LoadBalancingRulesManager lbMgr = visitor.getVirtualNetworkApplianceFactory().getLbMgr();
        final NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
        for (final LoadBalancerVO lb : lbs) {
            final List<LbDestination> dstList = lbMgr.getExistingDestinations(lb.getId());
            final List<LbStickinessPolicy> policyList = lbMgr.getStickinessPolicies(lb.getId());
            final List<LbHealthCheckPolicy> hcPolicyList = lbMgr.getHealthCheckPolicies(lb.getId());
            final LbSslCert sslCert = lbMgr.getLbSslCert(lb.getId());
            final Ip sourceIp = networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
            final LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList, sourceIp, sslCert, lb.getLbProtocol());
            _loadbalancingRules.add(loadBalancing);
        }
    }
    return visitor.visit(this);
}
Also used : LoadBalancerDao(com.cloud.network.dao.LoadBalancerDao) LbSslCert(com.cloud.legacymodel.network.LoadBalancingRule.LbSslCert) LoadBalancingRule(com.cloud.legacymodel.network.LoadBalancingRule) LoadBalancingRulesManager(com.cloud.network.lb.LoadBalancingRulesManager) Ip(com.cloud.legacymodel.network.Ip) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) LbStickinessPolicy(com.cloud.legacymodel.network.LoadBalancingRule.LbStickinessPolicy) LbDestination(com.cloud.legacymodel.network.LoadBalancingRule.LbDestination) NetworkModel(com.cloud.network.NetworkModel) LbHealthCheckPolicy(com.cloud.legacymodel.network.LoadBalancingRule.LbHealthCheckPolicy)

Aggregations

Ip (com.cloud.legacymodel.network.Ip)30 ArrayList (java.util.ArrayList)17 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)12 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)10 PublicIp (com.cloud.network.addr.PublicIp)10 IPAddressVO (com.cloud.network.dao.IPAddressVO)10 LoadBalancingRule (com.cloud.legacymodel.network.LoadBalancingRule)8 Network (com.cloud.legacymodel.network.Network)8 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)8 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)6 LbDestination (com.cloud.legacymodel.network.LoadBalancingRule.LbDestination)6 LbStickinessPolicy (com.cloud.legacymodel.network.LoadBalancingRule.LbStickinessPolicy)6 Nic (com.cloud.legacymodel.network.Nic)6 UpdateNetworkOverviewCommand (com.cloud.legacymodel.communication.command.UpdateNetworkOverviewCommand)5 LbHealthCheckPolicy (com.cloud.legacymodel.network.LoadBalancingRule.LbHealthCheckPolicy)5 NetworkOverviewTO (com.cloud.legacymodel.to.NetworkOverviewTO)5 Account (com.cloud.legacymodel.user.Account)5 DB (com.cloud.utils.db.DB)5 Commands (com.cloud.agent.manager.Commands)4 DataCenterVO (com.cloud.dc.DataCenterVO)4