mirror of https://github.com/apache/cloudstack.git
Network-refactor: In preparation for moving the read-only interface NetworkModel
to the api project, ensure that all methods use interfaces from the api project. By moving it to the api project, it lessens the dependency of plugins on the server components. Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>
This commit is contained in:
parent
6b6d8c5710
commit
504264236c
|
|
@ -101,8 +101,8 @@ import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
|||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -497,8 +497,8 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
s_logger.debug("Creating the ELB vm " + id);
|
||||
}
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
|
||||
NetworkOffering controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(2);
|
||||
|
|
|
|||
|
|
@ -98,8 +98,8 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ResourceStateAdapter;
|
||||
|
|
@ -239,9 +239,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
private ServiceOfferingVO _serviceOffering;
|
||||
|
||||
NetworkOfferingVO _publicNetworkOffering;
|
||||
NetworkOfferingVO _managementNetworkOffering;
|
||||
NetworkOfferingVO _linkLocalNetworkOffering;
|
||||
NetworkOffering _publicNetworkOffering;
|
||||
NetworkOffering _managementNetworkOffering;
|
||||
NetworkOffering _linkLocalNetworkOffering;
|
||||
|
||||
@Inject
|
||||
private VirtualMachineManager _itMgr;
|
||||
|
|
@ -769,7 +769,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
NetworkVO defaultNetwork = defaultNetworks.get(0);
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork);
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork, NetworkOffering.SystemManagementNetwork);
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
|
|
@ -777,7 +777,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, _networkOfferingDao.findById(defaultNetwork.getNetworkOfferingId()), plan, null, null, false).get(0), defaultNic));
|
||||
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
for (NetworkOffering offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||
IPAddressVO sourceNatIp = null;
|
||||
if (!sharedSourceNat) {
|
||||
// Get the source NAT IP address for this account
|
||||
List<IPAddressVO> sourceNatIps = _networkMgr.listPublicIpsAssignedToAccount(network.getAccountId(),
|
||||
List<? extends IpAddress> sourceNatIps = _networkMgr.listPublicIpsAssignedToAccount(network.getAccountId(),
|
||||
zoneId, true);
|
||||
|
||||
if (sourceNatIps.size() != 1) {
|
||||
|
|
@ -393,7 +393,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||
s_logger.error(errorMsg);
|
||||
return true;
|
||||
} else {
|
||||
sourceNatIp = sourceNatIps.get(0);
|
||||
sourceNatIp = _ipAddressDao.findById(sourceNatIps.get(0).getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,10 +87,10 @@ public interface NetworkManager {
|
|||
*/
|
||||
public boolean disassociatePublicIpAddress(long id, long userId, Account caller);
|
||||
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
throws ConcurrentOperationException;
|
||||
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException;
|
||||
|
||||
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
|
@ -143,7 +143,7 @@ public interface NetworkManager {
|
|||
|
||||
boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List<PublicIp> publicIps) throws ResourceUnavailableException;
|
||||
boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List<? extends PublicIpAddress> publicIps) throws ResourceUnavailableException;
|
||||
|
||||
boolean startNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
|
|
|
|||
|
|
@ -548,15 +548,15 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
|||
|
||||
@Override
|
||||
public boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError,
|
||||
List<PublicIp> publicIps) throws ResourceUnavailableException {
|
||||
List<? extends PublicIpAddress> publicIps) throws ResourceUnavailableException {
|
||||
boolean success = true;
|
||||
|
||||
Map<PublicIp, Set<Service>> ipToServices = _networkModel.getIpToServices(publicIps, rulesRevoked, true);
|
||||
Map<Provider, ArrayList<PublicIp>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
|
||||
Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(publicIps, rulesRevoked, true);
|
||||
Map<Provider, ArrayList<PublicIpAddress>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
|
||||
|
||||
for (Provider provider : providerToIpList.keySet()) {
|
||||
try {
|
||||
ArrayList<PublicIp> ips = providerToIpList.get(provider);
|
||||
ArrayList<PublicIpAddress> ips = providerToIpList.get(provider);
|
||||
if (ips == null || ips.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -568,7 +568,7 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
|||
throw new CloudRuntimeException("Fail to get ip deployer for element: " + element);
|
||||
}
|
||||
Set<Service> services = new HashSet<Service>();
|
||||
for (PublicIp ip : ips) {
|
||||
for (PublicIpAddress ip : ips) {
|
||||
if (!ipToServices.containsKey(ip)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -680,16 +680,16 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
|||
|
||||
protected IPAddressVO getExistingSourceNatInNetwork(long ownerId, Long networkId) {
|
||||
|
||||
List<IPAddressVO> addrs = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, networkId, true);
|
||||
List<? extends IpAddress> addrs = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, networkId, true);
|
||||
|
||||
IPAddressVO sourceNatIp = null;
|
||||
if (addrs.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
// Account already has ip addresses
|
||||
for (IPAddressVO addr : addrs) {
|
||||
for (IpAddress addr : addrs) {
|
||||
if (addr.isSourceNat()) {
|
||||
sourceNatIp = addr;
|
||||
sourceNatIp = _ipAddressDao.findById(addr.getId());
|
||||
return sourceNatIp;
|
||||
}
|
||||
}
|
||||
|
|
@ -1088,7 +1088,7 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name,
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name,
|
||||
String displayText, boolean isDefault)
|
||||
throws ConcurrentOperationException {
|
||||
return setupNetwork(owner, offering, null, plan, name, displayText, false, null, null, null, null);
|
||||
|
|
@ -1096,7 +1096,7 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan
|
||||
plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException {
|
||||
|
||||
|
|
|
|||
|
|
@ -29,21 +29,16 @@ import com.cloud.network.Network.Capability;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
/**
|
||||
* @author chiradeep
|
||||
*
|
||||
*/
|
||||
|
||||
public interface NetworkModel {
|
||||
|
||||
/**
|
||||
|
|
@ -57,9 +52,9 @@ public interface NetworkModel {
|
|||
* - (optional) true if the IP address should be a source NAT address
|
||||
* @return - list of IP addresses
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpsAssignedToGuestNtwk(long accountId, long associatedNetworkId, Boolean sourceNat);
|
||||
List<? extends IpAddress> listPublicIpsAssignedToGuestNtwk(long accountId, long associatedNetworkId, Boolean sourceNat);
|
||||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
List<? extends NetworkOffering> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
List<? extends Nic> getNics(long vmId);
|
||||
|
||||
|
|
@ -71,7 +66,7 @@ public interface NetworkModel {
|
|||
|
||||
List<? extends Vlan> listPodVlans(long podId);
|
||||
|
||||
List<NetworkVO> listNetworksUsedByVm(long vmId, boolean isSystem);
|
||||
List<? extends Network> listNetworksUsedByVm(long vmId, boolean isSystem);
|
||||
|
||||
Nic getNicInNetwork(long vmId, long networkId);
|
||||
|
||||
|
|
@ -89,13 +84,13 @@ public interface NetworkModel {
|
|||
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
|
||||
NetworkVO getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
Network getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
|
||||
String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
|
||||
|
||||
List<NetworkVO> listNetworksForAccount(long accountId, long zoneId, Network.GuestType type);
|
||||
List<? extends Network> listNetworksForAccount(long accountId, long zoneId, Network.GuestType type);
|
||||
|
||||
List<NetworkVO> listAllNetworksInAllZonesByType(Network.GuestType type);
|
||||
List<? extends Network> listAllNetworksInAllZonesByType(Network.GuestType type);
|
||||
|
||||
String getGlobalGuestDomainSuffix();
|
||||
|
||||
|
|
@ -145,12 +140,12 @@ public interface NetworkModel {
|
|||
|
||||
boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, List<Service> services);
|
||||
|
||||
Map<PublicIp, Set<Service>> getIpToServices(List<PublicIp> publicIps, boolean rulesRevoked,
|
||||
Map<PublicIpAddress, Set<Service>> getIpToServices(List<? extends PublicIpAddress> publicIps, boolean rulesRevoked,
|
||||
boolean includingFirewall);
|
||||
|
||||
Map<Provider, ArrayList<PublicIp>> getProviderToIpList(Network network, Map<PublicIp, Set<Service>> ipToServices);
|
||||
Map<Provider, ArrayList<PublicIpAddress>> getProviderToIpList(Network network, Map<PublicIpAddress, Set<Service>> ipToServices);
|
||||
|
||||
boolean checkIpForService(IPAddressVO ip, Service service, Long networkId);
|
||||
boolean checkIpForService(IpAddress ip, Service service, Long networkId);
|
||||
|
||||
void checkCapabilityForProvider(Set<Provider> providers, Service service, Capability cap, String capValue);
|
||||
|
||||
|
|
@ -196,7 +191,7 @@ public interface NetworkModel {
|
|||
* @param sourceNat
|
||||
* @return
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat);
|
||||
List<? extends IpAddress> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat);
|
||||
|
||||
/**
|
||||
* @param zoneId
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
return element.canEnableIndividualServices();
|
||||
}
|
||||
|
||||
Set<Purpose> getPublicIpPurposeInRules(PublicIp ip, boolean includeRevoked, boolean includingFirewall) {
|
||||
Set<Purpose> getPublicIpPurposeInRules(PublicIpAddress ip, boolean includeRevoked, boolean includingFirewall) {
|
||||
Set<Purpose> result = new HashSet<Purpose>();
|
||||
List<FirewallRuleVO> rules = null;
|
||||
if (includeRevoked) {
|
||||
|
|
@ -235,12 +235,12 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<PublicIp, Set<Service>> getIpToServices(List<PublicIp> publicIps, boolean rulesRevoked, boolean includingFirewall) {
|
||||
Map<PublicIp, Set<Service>> ipToServices = new HashMap<PublicIp, Set<Service>>();
|
||||
public Map<PublicIpAddress, Set<Service>> getIpToServices(List<? extends PublicIpAddress> publicIps, boolean rulesRevoked, boolean includingFirewall) {
|
||||
Map<PublicIpAddress, Set<Service>> ipToServices = new HashMap<PublicIpAddress, Set<Service>>();
|
||||
|
||||
if (publicIps != null && !publicIps.isEmpty()) {
|
||||
Set<Long> networkSNAT = new HashSet<Long>();
|
||||
for (PublicIp ip : publicIps) {
|
||||
for (PublicIpAddress ip : publicIps) {
|
||||
Set<Service> services = ipToServices.get(ip);
|
||||
if (services == null) {
|
||||
services = new HashSet<Service>();
|
||||
|
|
@ -328,9 +328,9 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
|
||||
public boolean canIpUsedForNonConserveService(PublicIp ip, Service service) {
|
||||
// If it's non-conserve mode, then the new ip should not be used by any other services
|
||||
List<PublicIp> ipList = new ArrayList<PublicIp>();
|
||||
List<PublicIpAddress> ipList = new ArrayList<PublicIpAddress>();
|
||||
ipList.add(ip);
|
||||
Map<PublicIp, Set<Service>> ipToServices = getIpToServices(ipList, false, false);
|
||||
Map<PublicIpAddress, Set<Service>> ipToServices = getIpToServices(ipList, false, false);
|
||||
Set<Service> services = ipToServices.get(ip);
|
||||
// Not used currently, safe
|
||||
if (services == null || services.isEmpty()) {
|
||||
|
|
@ -361,9 +361,9 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
}
|
||||
|
||||
public boolean canIpUsedForService(PublicIp publicIp, Service service, Long networkId) {
|
||||
List<PublicIp> ipList = new ArrayList<PublicIp>();
|
||||
List<PublicIpAddress> ipList = new ArrayList<PublicIpAddress>();
|
||||
ipList.add(publicIp);
|
||||
Map<PublicIp, Set<Service>> ipToServices = getIpToServices(ipList, false, true);
|
||||
Map<PublicIpAddress, Set<Service>> ipToServices = getIpToServices(ipList, false, true);
|
||||
Set<Service> services = ipToServices.get(publicIp);
|
||||
if (services == null || services.isEmpty()) {
|
||||
return true;
|
||||
|
|
@ -404,10 +404,10 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<Provider, ArrayList<PublicIp>> getProviderToIpList(Network network, Map<PublicIp, Set<Service>> ipToServices) {
|
||||
public Map<Provider, ArrayList<PublicIpAddress>> getProviderToIpList(Network network, Map<PublicIpAddress, Set<Service>> ipToServices) {
|
||||
NetworkOffering offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
||||
if (!offering.isConserveMode()) {
|
||||
for (PublicIp ip : ipToServices.keySet()) {
|
||||
for (PublicIpAddress ip : ipToServices.keySet()) {
|
||||
Set<Service> services = new HashSet<Service>() ;
|
||||
services.addAll(ipToServices.get(ip));
|
||||
if (services != null && services.contains(Service.Firewall)) {
|
||||
|
|
@ -418,12 +418,12 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
}
|
||||
}
|
||||
}
|
||||
Map<Service, Set<PublicIp>> serviceToIps = new HashMap<Service, Set<PublicIp>>();
|
||||
for (PublicIp ip : ipToServices.keySet()) {
|
||||
Map<Service, Set<PublicIpAddress>> serviceToIps = new HashMap<Service, Set<PublicIpAddress>>();
|
||||
for (PublicIpAddress ip : ipToServices.keySet()) {
|
||||
for (Service service : ipToServices.get(ip)) {
|
||||
Set<PublicIp> ips = serviceToIps.get(service);
|
||||
Set<PublicIpAddress> ips = serviceToIps.get(service);
|
||||
if (ips == null) {
|
||||
ips = new HashSet<PublicIp>();
|
||||
ips = new HashSet<PublicIpAddress>();
|
||||
}
|
||||
ips.add(ip);
|
||||
serviceToIps.put(service, ips);
|
||||
|
|
@ -431,19 +431,19 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
}
|
||||
// TODO Check different provider for same IP
|
||||
Map<Provider, Set<Service>> providerToServices = getProviderServicesMap(network.getId());
|
||||
Map<Provider, ArrayList<PublicIp>> providerToIpList = new HashMap<Provider, ArrayList<PublicIp>>();
|
||||
Map<Provider, ArrayList<PublicIpAddress>> providerToIpList = new HashMap<Provider, ArrayList<PublicIpAddress>>();
|
||||
for (Provider provider : providerToServices.keySet()) {
|
||||
Set<Service> services = providerToServices.get(provider);
|
||||
ArrayList<PublicIp> ipList = new ArrayList<PublicIp>();
|
||||
Set<PublicIp> ipSet = new HashSet<PublicIp>();
|
||||
ArrayList<PublicIpAddress> ipList = new ArrayList<PublicIpAddress>();
|
||||
Set<PublicIpAddress> ipSet = new HashSet<PublicIpAddress>();
|
||||
for (Service service : services) {
|
||||
Set<PublicIp> serviceIps = serviceToIps.get(service);
|
||||
Set<PublicIpAddress> serviceIps = serviceToIps.get(service);
|
||||
if (serviceIps == null || serviceIps.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ipSet.addAll(serviceIps);
|
||||
}
|
||||
Set<PublicIp> sourceNatIps = serviceToIps.get(Service.SourceNat);
|
||||
Set<PublicIpAddress> sourceNatIps = serviceToIps.get(Service.SourceNat);
|
||||
if (sourceNatIps != null && !sourceNatIps.isEmpty()) {
|
||||
ipList.addAll(0, sourceNatIps);
|
||||
ipSet.removeAll(sourceNatIps);
|
||||
|
|
@ -1361,7 +1361,7 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkIpForService(IPAddressVO userIp, Service service, Long networkId) {
|
||||
public boolean checkIpForService(IpAddress userIp, Service service, Long networkId) {
|
||||
if (networkId == null) {
|
||||
networkId = userIp.getAssociatedWithNetworkId();
|
||||
}
|
||||
|
|
@ -1371,7 +1371,8 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
|||
if (offering.getGuestType() != GuestType.Isolated) {
|
||||
return true;
|
||||
}
|
||||
PublicIp publicIp = new PublicIp(userIp, _vlanDao.findById(userIp.getVlanId()), NetUtils.createSequenceBasedMacAddress(userIp.getMacAddress()));
|
||||
IPAddressVO ipVO = _ipAddressDao.findById(userIp.getId());
|
||||
PublicIp publicIp = new PublicIp(ipVO, _vlanDao.findById(userIp.getVlanId()), NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress()));
|
||||
if (!canIpUsedForService(publicIp, service, networkId)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package com.cloud.network.router;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
|
|
@ -67,7 +66,6 @@ import com.cloud.agent.api.routing.NetworkElementCommand;
|
|||
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetNetworkACLCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
|
|
@ -76,7 +74,6 @@ import com.cloud.agent.api.routing.VpnUsersCfgCommand;
|
|||
import com.cloud.agent.api.to.FirewallRuleTO;
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.agent.api.to.NetworkACLTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.PortForwardingRuleTO;
|
||||
import com.cloud.agent.api.to.StaticNatRuleTO;
|
||||
|
|
@ -175,8 +172,8 @@ import com.cloud.network.rules.StaticNatImpl;
|
|||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpn.Site2SiteVpnManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
|
|
@ -1633,8 +1630,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
//2) Control network
|
||||
s_logger.debug("Adding nic for Virtual Router in Control network ");
|
||||
List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
|
||||
NetworkOffering controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
|
||||
|
||||
|
|
@ -1656,7 +1653,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (hasGuestNetwork) {
|
||||
defaultNic.setDeviceId(2);
|
||||
}
|
||||
NetworkOfferingVO publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
|
||||
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), defaultNic));
|
||||
}
|
||||
|
|
@ -2257,11 +2254,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
protected ArrayList<? extends PublicIpAddress> getPublicIpsToApply(VirtualRouter router, Provider provider,
|
||||
Long guestNetworkId, com.cloud.network.IpAddress.State... skipInStates) {
|
||||
long ownerId = router.getAccountId();
|
||||
final List<IPAddressVO> userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
|
||||
final List<? extends IpAddress> userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
|
||||
List<PublicIp> allPublicIps = new ArrayList<PublicIp>();
|
||||
if (userIps != null && !userIps.isEmpty()) {
|
||||
boolean addIp = true;
|
||||
for (IPAddressVO userIp : userIps) {
|
||||
for (IpAddress userIp : userIps) {
|
||||
if (skipInStates != null) {
|
||||
for (IpAddress.State stateToSkip : skipInStates) {
|
||||
if (userIp.getState() == stateToSkip) {
|
||||
|
|
@ -2273,8 +2270,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
if (addIp) {
|
||||
PublicIp publicIp = new PublicIp(userIp, _vlanDao.findById(userIp.getVlanId()),
|
||||
NetUtils.createSequenceBasedMacAddress(userIp.getMacAddress()));
|
||||
IPAddressVO ipVO = _ipAddressDao.findById(userIp.getId());
|
||||
PublicIp publicIp = new PublicIp(ipVO, _vlanDao.findById(userIp.getVlanId()),
|
||||
NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress()));
|
||||
allPublicIps.add(publicIp);
|
||||
}
|
||||
}
|
||||
|
|
@ -2282,11 +2280,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
//Get public Ips that should be handled by router
|
||||
Network network = _networkDao.findById(guestNetworkId);
|
||||
Map<PublicIp, Set<Service>> ipToServices = _networkModel.getIpToServices(allPublicIps, false, true);
|
||||
Map<Provider, ArrayList<PublicIp>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
|
||||
Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(allPublicIps, false, true);
|
||||
Map<Provider, ArrayList<PublicIpAddress>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
|
||||
// Only cover virtual router for now, if ELB use it this need to be modified
|
||||
|
||||
ArrayList<PublicIp> publicIps = providerToIpList.get(provider);
|
||||
ArrayList<PublicIpAddress> publicIps = providerToIpList.get(provider);
|
||||
return publicIps;
|
||||
}
|
||||
|
||||
|
|
@ -2520,7 +2518,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
return null;
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = _networkOfferingDao.findById(_networkDao.findById(defaultNic.getNetworkId()).getNetworkOfferingId());
|
||||
NetworkOffering offering = _networkOfferingDao.findById(_networkDao.findById(defaultNic.getNetworkId()).getNetworkOfferingId());
|
||||
if (offering.getRedundantRouter()) {
|
||||
return findGatewayIp(userVmId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.AgentManager.OnError;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetDomRVersionCmd;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.PlugNicAnswer;
|
||||
import com.cloud.agent.api.PlugNicCommand;
|
||||
|
|
@ -105,7 +104,7 @@ import com.cloud.network.vpc.dao.StaticRouteDao;
|
|||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.network.vpn.Site2SiteVpnManager;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserStatisticsVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -1235,7 +1234,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
publicNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
publicNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag()));
|
||||
publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
|
||||
NetworkOfferingVO publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
|
||||
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), publicNic));
|
||||
publicVlans.add(publicIp.getVlanTag());
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
|
|
@ -550,14 +551,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
|
||||
NetworkVO defaultNetwork = defaultNetworks.get(0);
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork, NetworkOfferingVO.SystemStorageNetwork);
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork, NetworkOfferingVO.SystemStorageNetwork);
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setDeviceId(2);
|
||||
try {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, _networkOfferingDao.findById(defaultNetwork.getNetworkOfferingId()), plan, null, null, false).get(0), defaultNic));
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
for (NetworkOffering offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
}
|
||||
} catch (ConcurrentOperationException e) {
|
||||
|
|
|
|||
|
|
@ -2048,12 +2048,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
// If no network is specified, find system security group enabled network
|
||||
if (networkIdList == null || networkIdList.isEmpty()) {
|
||||
NetworkVO networkWithSecurityGroup = _networkModel.getNetworkWithSecurityGroupEnabled(zone.getId());
|
||||
Network networkWithSecurityGroup = _networkModel.getNetworkWithSecurityGroupEnabled(zone.getId());
|
||||
if (networkWithSecurityGroup == null) {
|
||||
throw new InvalidParameterValueException("No network with security enabled is found in zone id=" + zone.getId());
|
||||
}
|
||||
|
||||
networkList.add(networkWithSecurityGroup);
|
||||
networkList.add(_networkDao.findById(networkWithSecurityGroup.getId()));
|
||||
isSecurityGroupEnabledNetworkUsed = true;
|
||||
|
||||
} else if (securityGroupIdList != null && !securityGroupIdList.isEmpty()) {
|
||||
|
|
@ -2165,7 +2165,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
// get Virtual networks
|
||||
List<NetworkVO> virtualNetworks = _networkModel.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
List<? extends Network> virtualNetworks = _networkModel.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
// Validate physical network
|
||||
|
|
@ -3603,7 +3603,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
// get Virtual networks
|
||||
List<NetworkVO> virtualNetworks = _networkModel.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
List<? extends Network> virtualNetworks = _networkModel.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
// Validate physical network
|
||||
|
|
|
|||
|
|
@ -174,14 +174,14 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
|||
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
throws ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
@ -475,7 +475,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
|||
*/
|
||||
@Override
|
||||
public boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError,
|
||||
List<PublicIp> publicIps) throws ResourceUnavailableException {
|
||||
List<? extends PublicIpAddress> publicIps) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -478,31 +478,11 @@ public class MockNetworkModelImpl implements NetworkModel, Manager {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getIpToServices(java.util.List, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Map<PublicIp, Set<Service>> getIpToServices(List<PublicIp> publicIps, boolean rulesRevoked,
|
||||
boolean includingFirewall) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getProviderToIpList(com.cloud.network.Network, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public Map<Provider, ArrayList<PublicIp>> getProviderToIpList(Network network,
|
||||
Map<PublicIp, Set<Service>> ipToServices) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#checkIpForService(com.cloud.network.IPAddressVO, com.cloud.network.Network.Service, java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public boolean checkIpForService(IPAddressVO ip, Service service, Long networkId) {
|
||||
public boolean checkIpForService(IpAddress ip, Service service, Long networkId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
|
@ -795,4 +775,24 @@ public class MockNetworkModelImpl implements NetworkModel, Manager {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getIpToServices(java.util.List, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Map<PublicIpAddress, Set<Service>> getIpToServices(List<? extends PublicIpAddress> publicIps, boolean rulesRevoked,
|
||||
boolean includingFirewall) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getProviderToIpList(com.cloud.network.Network, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public Map<Provider, ArrayList<PublicIpAddress>> getProviderToIpList(Network network,
|
||||
Map<PublicIpAddress, Set<Service>> ipToServices) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -655,7 +655,7 @@ public class MockNetworkManagerImpl implements NetworkManager, NetworkService, M
|
|||
* @see com.cloud.network.NetworkManager#setupNetwork(com.cloud.user.Account, com.cloud.offerings.NetworkOfferingVO, com.cloud.deploy.DeploymentPlan, java.lang.String, java.lang.String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name,
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name,
|
||||
String displayText, boolean isDefault) throws ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
@ -669,7 +669,7 @@ public class MockNetworkManagerImpl implements NetworkManager, NetworkService, M
|
|||
* @see com.cloud.network.NetworkManager#setupNetwork(com.cloud.user.Account, com.cloud.offerings.NetworkOfferingVO, com.cloud.network.Network, com.cloud.deploy.DeploymentPlan, java.lang.String, java.lang.String, boolean, java.lang.Long, com.cloud.acl.ControlledEntity.ACLType, java.lang.Boolean, java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined,
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, Network predefined,
|
||||
DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
@ -892,7 +892,7 @@ public class MockNetworkManagerImpl implements NetworkManager, NetworkService, M
|
|||
*/
|
||||
@Override
|
||||
public boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError,
|
||||
List<PublicIp> publicIps) throws ResourceUnavailableException {
|
||||
List<? extends PublicIpAddress> publicIps) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue