mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Network-refactor: Refactor NetworkManager into NetworkModel and NetworkManager.
NetworkManager's exclusive focus is now - handling plugins during orchestration, and - to deal with ip address allocation. Those classes that used to refer to NetworkManager to get access to the datamodel now refer to NetworkModel Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>
This commit is contained in:
parent
af1abe4056
commit
5a830c4db0
@ -48,7 +48,7 @@ import com.cloud.hypervisor.HypervisorGuruBase;
|
||||
import com.cloud.hypervisor.vmware.VmwareCleanupMaid;
|
||||
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
@ -84,7 +84,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
@Inject VmwareManager _vmwareMgr;
|
||||
@Inject SecondaryStorageVmManager _secStorageMgr;
|
||||
@Inject CheckPointManager _checkPointMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
||||
protected VMwareGuru() {
|
||||
super();
|
||||
|
||||
@ -50,7 +50,7 @@ import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
|
||||
import com.cloud.hypervisor.vmware.resource.VmwareResource;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.DiscovererBase;
|
||||
@ -84,7 +84,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
||||
@Inject
|
||||
NetworkManager _netmgr;
|
||||
NetworkModel _netmgr;
|
||||
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
|
||||
|
||||
@ -73,7 +73,7 @@ import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
||||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||
import com.cloud.org.Cluster.ClusterType;
|
||||
import com.cloud.secstorage.CommandExecLogDao;
|
||||
@ -113,7 +113,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject
|
||||
protected NetworkManager _netMgr;
|
||||
protected NetworkModel _netMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject ClusterDao _clusterDao;
|
||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||
|
||||
@ -36,7 +36,7 @@ import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
@ -57,7 +57,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalancingServiceProvider, IpDeployer {
|
||||
private static final Logger s_logger = Logger.getLogger(ElasticLoadBalancerElement.class);
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
@Inject NetworkManager _networkManager;
|
||||
@Inject NetworkModel _networkManager;
|
||||
@Inject ElasticLoadBalancerManager _lbMgr;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
|
||||
@ -79,6 +79,7 @@ import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
@ -147,6 +148,8 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
LoadBalancerDao _loadBalancerDao = null;
|
||||
@ -291,7 +294,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
String protocol = rule.getProtocol();
|
||||
String algorithm = rule.getAlgorithm();
|
||||
|
||||
String elbIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress()
|
||||
String elbIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress()
|
||||
.addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
String uuid = rule.getUuid();
|
||||
@ -472,7 +475,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
|
||||
try {
|
||||
|
||||
if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
if (_networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
owner = _accountService.getSystemAccount();
|
||||
}
|
||||
|
||||
@ -494,7 +497,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
s_logger.debug("Creating the ELB vm " + id);
|
||||
}
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
|
||||
@ -507,7 +510,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
VMTemplateVO template = _templateDao.findSystemVMTemplate(dcId);
|
||||
|
||||
String typeString = "ElasticLoadBalancerVm";
|
||||
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(guestNetwork);
|
||||
Long physicalNetworkId = _networkModel.getPhysicalNetworkId(guestNetwork);
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, typeString);
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " + typeString + " in physical network " + physicalNetworkId);
|
||||
@ -593,7 +596,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
|
||||
@DB
|
||||
public PublicIp allocDirectIp(Account account, long guestNetworkId) throws InsufficientAddressCapacityException {
|
||||
Network frontEndNetwork = _networkMgr.getNetwork(guestNetworkId);
|
||||
Network frontEndNetwork = _networkModel.getNetwork(guestNetworkId);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
@ -620,7 +623,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
@DB
|
||||
public LoadBalancer handleCreateLoadBalancerRule(CreateLoadBalancerRuleCmd lb, Account account, long networkId) throws InsufficientAddressCapacityException, NetworkRuleConflictException {
|
||||
//this part of code is executed when the LB provider is Elastic Load Balancer vm
|
||||
if (!_networkMgr.isProviderSupportServiceInNetwork(lb.getNetworkId(), Service.Lb, Provider.ElasticLoadBalancerVm)) {
|
||||
if (!_networkModel.isProviderSupportServiceInNetwork(lb.getNetworkId(), Service.Lb, Provider.ElasticLoadBalancerVm)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -659,7 +662,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
||||
throw new NetworkRuleConflictException("ELB: Found existing load balancers matching requested new LB");
|
||||
}
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
IPAddressVO ipAddr = _ipAddressDao.findById(ipId);
|
||||
|
||||
LoadBalancer result = null;
|
||||
|
||||
@ -61,7 +61,7 @@ import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
@ -95,7 +95,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
||||
private static final Logger s_logger = Logger.getLogger(F5ExternalLoadBalancerElement.class);
|
||||
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
|
||||
@ -61,7 +61,7 @@ import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkExternalFirewallVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkVO;
|
||||
@ -99,7 +99,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
|
||||
@ -73,7 +73,7 @@ import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
@ -117,7 +117,7 @@ StaticNatServiceProvider {
|
||||
public static final AutoScaleCounterType AutoScaleCounterNetscaler = new AutoScaleCounterType("netscaler");
|
||||
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
@ -125,7 +125,7 @@ StaticNatServiceProvider {
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
|
||||
@ -75,6 +75,7 @@ import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
@ -159,6 +160,8 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@ -182,7 +185,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_networkManager.isProviderForNetwork(getProvider(),
|
||||
if (!_networkModel.isProviderForNetwork(getProvider(),
|
||||
network.getId())) {
|
||||
s_logger.debug("NiciraNvpElement is not a provider for network "
|
||||
+ network.getDisplayText());
|
||||
@ -246,58 +249,50 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
* Lock the network as we might need to do multiple operations that
|
||||
* should be done only once.
|
||||
*/
|
||||
Network lock = _networkDao.acquireInLockTable(network.getId(),
|
||||
_networkManager.getNetworkLockTimeout());
|
||||
if (lock == null) {
|
||||
throw new ConcurrentOperationException("Unable to lock network "
|
||||
+ network.getId());
|
||||
}
|
||||
try {
|
||||
// Implement SourceNat immediately as we have al the info already
|
||||
if (_networkManager.isProviderSupportServiceInNetwork(
|
||||
network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
|
||||
s_logger.debug("Apparently we are supposed to provide SourceNat on this network");
|
||||
// Network lock = _networkDao.acquireInLockTable(network.getId(),
|
||||
// _networkModel.getNetworkLockTimeout());
|
||||
// if (lock == null) {
|
||||
// throw new ConcurrentOperationException("Unable to lock network "
|
||||
// + network.getId());
|
||||
// }
|
||||
|
||||
PublicIp sourceNatIp = _networkManager
|
||||
.assignSourceNatIpAddressToGuestNetwork(owner, network);
|
||||
String publicCidr = sourceNatIp.getAddress().addr() + "/"
|
||||
+ NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
|
||||
String internalCidr = network.getGateway() + "/"
|
||||
+ network.getCidr().split("/")[1];
|
||||
long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
|
||||
: Long.parseLong(sourceNatIp.getVlanTag());
|
||||
// Implement SourceNat immediately as we have al the info already
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(
|
||||
network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
|
||||
s_logger.debug("Apparently we are supposed to provide SourceNat on this network");
|
||||
|
||||
CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
|
||||
niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
|
||||
network.getBroadcastUri().getSchemeSpecificPart(),
|
||||
"router-" + network.getDisplayText(), publicCidr,
|
||||
sourceNatIp.getGateway(), internalCidr, context
|
||||
.getDomain().getName()
|
||||
+ "-"
|
||||
+ context.getAccount().getAccountName());
|
||||
CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
|
||||
.easySend(niciraNvpHost.getId(), cmd);
|
||||
if (answer.getResult() == false) {
|
||||
s_logger.error("Failed to create Logical Router for network "
|
||||
+ network.getDisplayText());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the uuid so we can easily find it during cleanup
|
||||
NiciraNvpRouterMappingVO routermapping =
|
||||
new NiciraNvpRouterMappingVO(answer.getLogicalRouterUuid(), network.getId());
|
||||
_niciraNvpRouterMappingDao.persist(routermapping);
|
||||
}
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
_networkDao.releaseFromLockTable(lock.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Lock is released for network id "
|
||||
+ lock.getId() + " as a part of router startup in "
|
||||
+ dest);
|
||||
}
|
||||
}
|
||||
PublicIp sourceNatIp = _networkManager
|
||||
.assignSourceNatIpAddressToGuestNetwork(owner, network);
|
||||
String publicCidr = sourceNatIp.getAddress().addr() + "/"
|
||||
+ NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
|
||||
String internalCidr = network.getGateway() + "/"
|
||||
+ network.getCidr().split("/")[1];
|
||||
long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
|
||||
: Long.parseLong(sourceNatIp.getVlanTag());
|
||||
|
||||
CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
|
||||
niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
|
||||
network.getBroadcastUri().getSchemeSpecificPart(),
|
||||
"router-" + network.getDisplayText(), publicCidr,
|
||||
sourceNatIp.getGateway(), internalCidr, context
|
||||
.getDomain().getName()
|
||||
+ "-"
|
||||
+ context.getAccount().getAccountName());
|
||||
CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
|
||||
.easySend(niciraNvpHost.getId(), cmd);
|
||||
if (answer.getResult() == false) {
|
||||
s_logger.error("Failed to create Logical Router for network "
|
||||
+ network.getDisplayText());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the uuid so we can easily find it during cleanup
|
||||
NiciraNvpRouterMappingVO routermapping =
|
||||
new NiciraNvpRouterMappingVO(answer.getLogicalRouterUuid(), network.getId());
|
||||
_niciraNvpRouterMappingDao.persist(routermapping);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -446,7 +441,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
|
||||
HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
|
||||
|
||||
if (_networkManager.isProviderSupportServiceInNetwork(network.getId(),
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(),
|
||||
Service.SourceNat, Provider.NiciraNvp)) {
|
||||
s_logger.debug("Apparently we were providing SourceNat on this network");
|
||||
|
||||
@ -888,7 +883,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
|
||||
List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();
|
||||
for (StaticNat rule : rules) {
|
||||
IpAddress sourceIp = _networkManager.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
// Force the nat rule into the StaticNatRuleTO, no use making a new TO object
|
||||
// we only need the source and destination ip. Unfortunately no mention if a rule
|
||||
// is new.
|
||||
@ -936,7 +931,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
|
||||
List<PortForwardingRuleTO> portForwardingRules = new ArrayList<PortForwardingRuleTO>();
|
||||
for (PortForwardingRule rule : rules) {
|
||||
IpAddress sourceIp = _networkManager.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());
|
||||
PortForwardingRuleTO ruleTO = new PortForwardingRuleTO((PortForwardingRule) rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
|
||||
portForwardingRules.add(ruleTO);
|
||||
|
||||
@ -41,7 +41,7 @@ import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
@ -71,9 +71,9 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(NiciraNvpGuestNetworkGuru.class);
|
||||
|
||||
@Inject
|
||||
NetworkManager _externalNetworkManager;
|
||||
NetworkModel _externalNetworkManager;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
@ -153,7 +153,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
network.getDataCenterId(), physicalNetworkId);
|
||||
|
||||
@ -33,6 +33,7 @@ import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
@ -48,6 +49,7 @@ public class NiciraNvpElementTest {
|
||||
|
||||
NiciraNvpElement _element = new NiciraNvpElement();
|
||||
NetworkManager _networkManager = mock(NetworkManager.class);
|
||||
NetworkModel _networkModel = mock(NetworkModel.class);
|
||||
NetworkServiceMapDao _ntwkSrvcDao = mock (NetworkServiceMapDao.class);
|
||||
|
||||
@Before
|
||||
@ -55,9 +57,10 @@ public class NiciraNvpElementTest {
|
||||
_element._resourceMgr = mock(ResourceManager.class);
|
||||
_element._networkManager = _networkManager;
|
||||
_element._ntwkSrvcDao = _ntwkSrvcDao;
|
||||
_element._networkModel = _networkModel;
|
||||
|
||||
// Standard responses
|
||||
when(_networkManager.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
|
||||
_element.configure("NiciraNvpTestElement", Collections.<String, Object> emptyMap());
|
||||
}
|
||||
@ -81,12 +84,12 @@ public class NiciraNvpElementTest {
|
||||
// No nvp provider in the network
|
||||
assertFalse(_element.canHandle(net, Service.Connectivity));
|
||||
|
||||
when(_networkManager.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(false);
|
||||
when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(false);
|
||||
when(_ntwkSrvcDao.canProviderSupportServiceInNetwork(42L, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
|
||||
// NVP provider does not provide Connectivity for this network
|
||||
assertFalse(_element.canHandle(net, Service.Connectivity));
|
||||
|
||||
when(_networkManager.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
// Only service Connectivity is supported
|
||||
assertFalse(_element.canHandle(net, Service.Dhcp));
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
@ -67,6 +68,8 @@ public class NiciraNvpGuestNetworkGuruTest {
|
||||
NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
|
||||
AgentManager agentmgr = mock (AgentManager.class);
|
||||
NetworkManager netmgr = mock (NetworkManager.class);
|
||||
NetworkModel netmodel = mock (NetworkModel.class);
|
||||
|
||||
HostDao hostdao = mock (HostDao.class);
|
||||
NetworkDao netdao = mock(NetworkDao.class);
|
||||
NiciraNvpGuestNetworkGuru guru;
|
||||
@ -80,7 +83,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
||||
guru._niciraNvpDao = nvpdao;
|
||||
guru._dcDao = dcdao;
|
||||
guru._ntwkOfferingSrvcDao = nosd;
|
||||
guru._networkMgr = netmgr;
|
||||
guru._networkModel = netmodel;
|
||||
guru._hostDao = hostdao;
|
||||
guru._agentMgr = agentmgr;
|
||||
guru._networkDao = netdao;
|
||||
@ -261,7 +264,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
||||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
@ -318,7 +321,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
||||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
@ -374,7 +377,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
||||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
@ -432,7 +435,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
||||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@ -29,32 +27,25 @@ import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.ovs.OvsTunnelManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
|
||||
@Local(value=NetworkGuru.class)
|
||||
public class OvsGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(OvsGuestNetworkGuru.class);
|
||||
|
||||
@Inject NetworkManager _externalNetworkManager;
|
||||
@Inject OvsTunnelManager _ovsTunnelMgr;
|
||||
|
||||
OvsGuestNetworkGuru() {
|
||||
|
||||
@ -25,7 +25,7 @@ import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.projects.ProjectManager;
|
||||
@ -47,7 +47,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||
@Inject LaunchPermissionDao _launchPermissionDao;
|
||||
@Inject ProjectManager _projectMgr;
|
||||
@Inject ProjectAccountDao _projecAccountDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
||||
protected DomainChecker() {
|
||||
super();
|
||||
|
||||
@ -60,6 +60,7 @@ import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkDomainVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkRuleConfigVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
@ -174,6 +175,7 @@ public class ApiDBUtils {
|
||||
private static StorageManager _storageMgr;
|
||||
private static UserVmManager _userVmMgr;
|
||||
private static NetworkManager _networkMgr;
|
||||
private static NetworkModel _networkModel;
|
||||
private static StatsCollector _statsCollector;
|
||||
|
||||
private static AccountDao _accountDao;
|
||||
@ -240,6 +242,7 @@ public class ApiDBUtils {
|
||||
_storageMgr = locator.getManager(StorageManager.class);
|
||||
_userVmMgr = locator.getManager(UserVmManager.class);
|
||||
_networkMgr = locator.getManager(NetworkManager.class);
|
||||
_networkModel = locator.getManager(NetworkModel.class);
|
||||
_configMgr = locator.getManager(ConfigurationService.class);
|
||||
|
||||
_accountDao = locator.getDao(AccountDao.class);
|
||||
@ -341,7 +344,7 @@ public class ApiDBUtils {
|
||||
}
|
||||
|
||||
public static Long getPodIdForVlan(long vlanDbId) {
|
||||
return _networkMgr.getPodIdForVlan(vlanDbId);
|
||||
return _networkModel.getPodIdForVlan(vlanDbId);
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
@ -696,11 +699,11 @@ public class ApiDBUtils {
|
||||
}
|
||||
|
||||
public static Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId, long zoneId) {
|
||||
return _networkMgr.getNetworkCapabilities(networkId);
|
||||
return _networkModel.getNetworkCapabilities(networkId);
|
||||
}
|
||||
|
||||
public static long getPublicNetworkIdByZone(long zoneId) {
|
||||
return _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
return _networkModel.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
}
|
||||
|
||||
public static Long getVlanNetworkId(long vlanId) {
|
||||
@ -730,7 +733,7 @@ public class ApiDBUtils {
|
||||
}
|
||||
|
||||
public static Long getDedicatedNetworkDomain(long networkId) {
|
||||
return _networkMgr.getDedicatedNetworkDomain(networkId);
|
||||
return _networkModel.getDedicatedNetworkDomain(networkId);
|
||||
}
|
||||
|
||||
public static float getCpuOverprovisioningFactor() {
|
||||
@ -787,25 +790,25 @@ public class ApiDBUtils {
|
||||
}
|
||||
|
||||
public static Map<Service, Set<Provider>> listNetworkOfferingServices(long networkOfferingId) {
|
||||
return _networkMgr.getNetworkOfferingServiceProvidersMap(networkOfferingId);
|
||||
return _networkModel.getNetworkOfferingServiceProvidersMap(networkOfferingId);
|
||||
}
|
||||
|
||||
public static List<Service> getElementServices(Provider provider) {
|
||||
return _networkMgr.getElementServices(provider);
|
||||
return _networkModel.getElementServices(provider);
|
||||
}
|
||||
|
||||
public static List<? extends Provider> getProvidersForService(Service service) {
|
||||
return _networkMgr.listSupportedNetworkServiceProviders(service.getName());
|
||||
return _networkModel.listSupportedNetworkServiceProviders(service.getName());
|
||||
}
|
||||
|
||||
public static boolean canElementEnableIndividualServices(Provider serviceProvider) {
|
||||
return _networkMgr.canElementEnableIndividualServices(serviceProvider);
|
||||
return _networkModel.canElementEnableIndividualServices(serviceProvider);
|
||||
}
|
||||
|
||||
public static Pair<Long, Boolean> getDomainNetworkDetails(long networkId) {
|
||||
NetworkDomainVO map = _networkDomainDao.getDomainNetworkMapByNetworkId(networkId);
|
||||
|
||||
boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : _networkMgr.getAllowSubdomainAccessGlobal();
|
||||
boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : _networkModel.getAllowSubdomainAccessGlobal();
|
||||
|
||||
return new Pair<Long, Boolean>(map.getDomainId(), subdomainAccess);
|
||||
}
|
||||
@ -832,11 +835,11 @@ public class ApiDBUtils {
|
||||
}
|
||||
|
||||
public static List<? extends Network> listVpcNetworks(long vpcId) {
|
||||
return _networkMgr.listNetworksByVpc(vpcId);
|
||||
return _networkModel.listNetworksByVpc(vpcId);
|
||||
}
|
||||
|
||||
public static boolean canUseForDeploy(Network network) {
|
||||
return _networkMgr.canUseForDeploy(network);
|
||||
return _networkModel.canUseForDeploy(network);
|
||||
}
|
||||
|
||||
public static String getUuid(String resourceId, TaggedResourceType resourceType) {
|
||||
|
||||
@ -19,7 +19,7 @@ package com.cloud.async;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.async.dao.AsyncJobDao;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.StorageManager;
|
||||
@ -37,7 +37,7 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
public interface AsyncJobExecutorContext extends Manager {
|
||||
public ManagementServer getManagementServer();
|
||||
public AgentManager getAgentMgr();
|
||||
public NetworkManager getNetworkMgr();
|
||||
public NetworkModel getNetworkMgr();
|
||||
public UserVmManager getVmMgr();
|
||||
public SnapshotManager getSnapshotMgr();
|
||||
public AccountManager getAccountMgr();
|
||||
|
||||
@ -25,6 +25,7 @@ import com.cloud.agent.AgentManager;
|
||||
import com.cloud.async.dao.AsyncJobDao;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.StorageManager;
|
||||
@ -44,7 +45,7 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
||||
private String _name;
|
||||
|
||||
private AgentManager _agentMgr;
|
||||
private NetworkManager _networkMgr;
|
||||
private NetworkModel _networkMgr;
|
||||
private UserVmManager _vmMgr;
|
||||
private SnapshotManager _snapMgr;
|
||||
private AccountManager _accountMgr;
|
||||
@ -72,7 +73,7 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkManager getNetworkMgr() {
|
||||
public NetworkModel getNetworkMgr() {
|
||||
return _networkMgr;
|
||||
}
|
||||
|
||||
@ -159,9 +160,9 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
||||
throw new ConfigurationException("unable to get " + AgentManager.class.getName());
|
||||
}
|
||||
|
||||
_networkMgr = locator.getManager(NetworkManager.class);
|
||||
_networkMgr = locator.getManager(NetworkModel.class);
|
||||
if (_networkMgr == null) {
|
||||
throw new ConfigurationException("unable to get " + NetworkManager.class.getName());
|
||||
throw new ConfigurationException("unable to get " + NetworkModel.class.getName());
|
||||
}
|
||||
|
||||
_vmMgr = locator.getManager(UserVmManager.class);
|
||||
|
||||
@ -307,7 +307,7 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
||||
s_logger.warn("Bare Metal only supports basical network mode now, switch to baisc network automatically");
|
||||
}
|
||||
|
||||
Network defaultNetwork = _networkMgr.getExclusiveGuestNetwork(dc.getId());
|
||||
Network defaultNetwork = _networkModel.getExclusiveGuestNetwork(dc.getId());
|
||||
if (defaultNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find a default network to start a vm");
|
||||
}
|
||||
|
||||
@ -109,6 +109,7 @@ import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
@ -213,6 +214,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
@Inject
|
||||
NetworkService _networkSvc;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
ClusterDao _clusterDao;
|
||||
@Inject
|
||||
AlertManager _alertMgr;
|
||||
@ -758,7 +761,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
|
||||
// Delete vlans associated with the pod
|
||||
List<? extends Vlan> vlans = _networkMgr.listPodVlans(podId);
|
||||
List<? extends Vlan> vlans = _networkModel.listPodVlans(podId);
|
||||
if (vlans != null && !vlans.isEmpty()) {
|
||||
for (Vlan vlan : vlans) {
|
||||
_vlanDao.remove(vlan.getId());
|
||||
@ -1527,15 +1530,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
PhysicalNetwork mgmtPhyNetwork;
|
||||
if (NetworkType.Advanced == zone.getNetworkType()) {
|
||||
// zone should have a physical network with public and management traffiType
|
||||
_networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
|
||||
mgmtPhyNetwork = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
_networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
|
||||
mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
} else {
|
||||
// zone should have a physical network with management traffiType
|
||||
mgmtPhyNetwork = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
}
|
||||
|
||||
try {
|
||||
_networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
|
||||
_networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
|
||||
} catch (InvalidParameterValueException noStorage) {
|
||||
PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Management);
|
||||
_networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(),
|
||||
@ -2134,14 +2137,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
} else {
|
||||
if (forVirtualNetwork) {
|
||||
// default physical network with public traffic in the zone
|
||||
physicalNetworkId = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
} else {
|
||||
if (zone.getNetworkType() == DataCenter.NetworkType.Basic) {
|
||||
// default physical network with guest traffic in the zone
|
||||
physicalNetworkId = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
} else if (zone.getNetworkType() == DataCenter.NetworkType.Advanced) {
|
||||
if (zone.isSecurityGroupEnabled()) {
|
||||
physicalNetworkId = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Physical Network Id is null, please provide the Network id for Direct vlan creation ");
|
||||
}
|
||||
@ -2165,18 +2168,18 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (forVirtualNetwork) {
|
||||
if (network == null) {
|
||||
// find default public network in the zone
|
||||
networkId = _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
network = _networkMgr.getNetwork(networkId);
|
||||
networkId = _networkModel.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
network = _networkModel.getNetwork(networkId);
|
||||
} else if (network.getGuestType() != null || network.getTrafficType() != TrafficType.Public) {
|
||||
throw new InvalidParameterValueException("Can't find Public network by id=" + networkId);
|
||||
}
|
||||
} else {
|
||||
if (network == null) {
|
||||
if (zone.getNetworkType() == DataCenter.NetworkType.Basic) {
|
||||
networkId = _networkMgr.getExclusiveGuestNetwork(zoneId).getId();
|
||||
network = _networkMgr.getNetwork(networkId);
|
||||
networkId = _networkModel.getExclusiveGuestNetwork(zoneId).getId();
|
||||
network = _networkModel.getNetwork(networkId);
|
||||
} else {
|
||||
network = _networkMgr.getNetworkWithSecurityGroupEnabled(zoneId);
|
||||
network = _networkModel.getNetworkWithSecurityGroupEnabled(zoneId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Nework id is required for Direct vlan creation ");
|
||||
}
|
||||
@ -2275,7 +2278,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
String vlanId, Account vlanOwner) {
|
||||
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
|
||||
//Validate the zone
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
@ -2516,7 +2519,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
" as ip " + ip + " belonging to the range is used for static nat purposes. Cleanup the rules first");
|
||||
}
|
||||
|
||||
if (ip.isSourceNat() && _networkMgr.getNetwork(ip.getAssociatedWithNetworkId()) != null) {
|
||||
if (ip.isSourceNat() && _networkModel.getNetwork(ip.getAssociatedWithNetworkId()) != null) {
|
||||
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
|
||||
" as ip " + ip + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId() +
|
||||
". IP range with the source nat ip address can be removed either as a part of Network, or account removal");
|
||||
@ -3060,7 +3063,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
|
||||
// validate providers combination here
|
||||
_networkMgr.canProviderSupportServices(providerCombinationToVerify);
|
||||
_networkModel.canProviderSupportServices(providerCombinationToVerify);
|
||||
|
||||
// validate the LB service capabilities specified in the network offering
|
||||
Map<Capability, String> lbServiceCapabilityMap = cmd.getServiceCapabilities(Service.Lb);
|
||||
@ -3243,7 +3246,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if ((lbServiceCapabilityMap != null) && (!lbServiceCapabilityMap.isEmpty())) {
|
||||
String isolationCapability = lbServiceCapabilityMap.get(Capability.SupportedLBIsolation);
|
||||
if (isolationCapability != null) {
|
||||
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.SupportedLBIsolation, isolationCapability);
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.SupportedLBIsolation, isolationCapability);
|
||||
dedicatedLb = isolationCapability.contains("dedicated");
|
||||
} else {
|
||||
dedicatedLb = true;
|
||||
@ -3259,14 +3262,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if ((sourceNatServiceCapabilityMap != null) && (!sourceNatServiceCapabilityMap.isEmpty())) {
|
||||
String sourceNatType = sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes);
|
||||
if (sourceNatType != null) {
|
||||
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
Capability.SupportedSourceNatTypes, sourceNatType);
|
||||
sharedSourceNat = sourceNatType.contains("perzone");
|
||||
}
|
||||
|
||||
String param = sourceNatServiceCapabilityMap.get(Capability.RedundantRouter);
|
||||
if (param != null) {
|
||||
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
Capability.RedundantRouter, param);
|
||||
redundantRouter = param.contains("true");
|
||||
}
|
||||
@ -3426,7 +3429,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
Network network = null;
|
||||
if (networkId != null) {
|
||||
// check if network exists and the caller can operate with it
|
||||
network = _networkMgr.getNetwork(networkId);
|
||||
network = _networkModel.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Unable to find the network by id=" + networkId);
|
||||
}
|
||||
@ -3438,7 +3441,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, network);
|
||||
|
||||
List<Long> offeringIds = _networkMgr.listNetworkOfferingsForUpgrade(networkId);
|
||||
List<Long> offeringIds = _networkModel.listNetworkOfferingsForUpgrade(networkId);
|
||||
|
||||
if (!offeringIds.isEmpty()) {
|
||||
sc.addAnd("id", SearchCriteria.Op.IN, offeringIds.toArray());
|
||||
@ -3517,21 +3520,21 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
|
||||
if (listBySupportedServices) {
|
||||
addOffering = addOffering && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), supportedServices);
|
||||
addOffering = addOffering && _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), supportedServices);
|
||||
}
|
||||
|
||||
if (checkIfProvidersAreEnabled) {
|
||||
if (supportedServices != null && supportedServices.length > 0) {
|
||||
checkForProviders = Arrays.asList(supportedServices);
|
||||
} else {
|
||||
checkForProviders = _networkMgr.listNetworkOfferingServices(offering.getId());
|
||||
checkForProviders = _networkModel.listNetworkOfferingServices(offering.getId());
|
||||
}
|
||||
|
||||
addOffering = addOffering && _networkMgr.areServicesEnabledInZone(zoneId, offering, checkForProviders);
|
||||
addOffering = addOffering && _networkModel.areServicesEnabledInZone(zoneId, offering, checkForProviders);
|
||||
}
|
||||
|
||||
if (sourceNatSupported != null) {
|
||||
addOffering = addOffering && (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
|
||||
addOffering = addOffering && (_networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
|
||||
}
|
||||
|
||||
if (forVpc != null) {
|
||||
@ -3656,7 +3659,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
} else {
|
||||
if (availability == NetworkOffering.Availability.Required) {
|
||||
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated
|
||||
&& _networkMgr.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
&& _networkModel.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
if (!canOffBeRequired) {
|
||||
throw new InvalidParameterValueException("Availability can be " +
|
||||
NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
@ -3782,7 +3785,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
Long networkId = vlan.getNetworkId();
|
||||
if (networkId != null) {
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
if (network != null) {
|
||||
accountId = network.getAccountId();
|
||||
}
|
||||
|
||||
@ -92,6 +92,7 @@ import com.cloud.keystore.KeystoreVO;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
@ -212,6 +213,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
ServiceOfferingDao _offeringDao;
|
||||
@ -766,7 +769,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
|
||||
NetworkVO defaultNetwork = defaultNetworks.get(0);
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork);
|
||||
List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork);
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
|
||||
@ -27,7 +27,7 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.Nic;
|
||||
@ -40,7 +40,7 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl {
|
||||
|
||||
private String _name = null;
|
||||
@Inject private HostDao _hostDao = null;
|
||||
@Inject private NetworkManager _networkMgr = null;
|
||||
@Inject private NetworkModel _networkMgr = null;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -31,7 +31,7 @@ import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||
@ -49,7 +49,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
||||
private String _name = null;
|
||||
@Inject private final UserVmDao _userVmDao = null;
|
||||
@Inject private final AgentManager _agentMgr = null;
|
||||
@Inject private final NetworkManager _networkMgr = null;
|
||||
@Inject private final NetworkModel _networkMgr = null;
|
||||
@Inject private final VpcVirtualNetworkApplianceManager _vnaMgr = null;
|
||||
|
||||
@Override
|
||||
|
||||
@ -52,7 +52,7 @@ import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.DiscovererBase;
|
||||
@ -79,7 +79,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
||||
@Inject ClusterDao _clusterDao;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
||||
@Override
|
||||
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
|
||||
|
||||
@ -111,7 +111,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject NetworkServiceMapDao _ntwkSrvcProviderDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
@Inject InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
|
||||
@ -127,6 +127,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
@ -801,7 +803,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
String protocol = rule.getProtocol();
|
||||
String algorithm = rule.getAlgorithm();
|
||||
String uuid = rule.getUuid();
|
||||
String srcIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
String srcIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
List<LbDestination> destinations = rule.getDestinations();
|
||||
List<String> sourceCidrs = rule.getSourceCidrList();
|
||||
@ -930,7 +932,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
long guestVlanTag = Long.parseLong(guestConfig.getBroadcastUri().getHost());
|
||||
String selfIp = null;
|
||||
String guestVlanNetmask = NetUtils.cidr2Netmask(guestConfig.getCidr());
|
||||
Integer networkRate = _networkMgr.getNetworkRate(guestConfig.getId(), null);
|
||||
Integer networkRate = _networkModel.getNetworkRate(guestConfig.getId(), null);
|
||||
|
||||
if (add) {
|
||||
// Acquire a self-ip address from the guest network IP address range
|
||||
|
||||
@ -88,7 +88,7 @@ public class ExternalLoadBalancerUsageManagerImpl implements ExternalLoadBalance
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
@Inject
|
||||
|
||||
@ -80,7 +80,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
||||
@Inject ExternalDhcpManager _dhcpMgr;
|
||||
@Inject PxeServerManager _pxeMgr;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject AccountDao _accountDao;
|
||||
|
||||
@ -16,14 +16,11 @@
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
@ -34,13 +31,8 @@ import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
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.guru.NetworkGuru;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
@ -62,7 +54,7 @@ import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
* NetworkManager manages the network for the different end users.
|
||||
*
|
||||
*/
|
||||
public interface NetworkManager {
|
||||
public interface NetworkManager {
|
||||
/**
|
||||
* Assigns a new public ip address.
|
||||
*
|
||||
@ -95,27 +87,12 @@ public interface NetworkManager {
|
||||
*/
|
||||
public boolean disassociatePublicIpAddress(long id, long userId, Account caller);
|
||||
|
||||
/**
|
||||
* Lists IP addresses that belong to VirtualNetwork VLANs
|
||||
*
|
||||
* @param accountId
|
||||
* - account that the IP address should belong to
|
||||
* @param associatedNetworkId
|
||||
* TODO
|
||||
* @param sourceNat
|
||||
* - (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<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO 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,
|
||||
ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException;
|
||||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
@ -128,25 +105,13 @@ public interface NetworkManager {
|
||||
|
||||
void expungeNics(VirtualMachineProfile<? extends VMInstanceVO> vm);
|
||||
|
||||
List<? extends Nic> getNics(long vmId);
|
||||
|
||||
List<NicProfile> getNicProfiles(VirtualMachine vm);
|
||||
|
||||
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
|
||||
|
||||
boolean applyRules(List<? extends FirewallRule> rules, FirewallRule.Purpose purpose, NetworkRuleApplier applier, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
public boolean validateRule(FirewallRule rule);
|
||||
|
||||
PublicIpAddress getPublicIpAddress(long ipAddressId);
|
||||
|
||||
List<? extends Vlan> listPodVlans(long podId);
|
||||
|
||||
Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException;
|
||||
|
||||
List<NetworkVO> listNetworksUsedByVm(long vmId, boolean isSystem);
|
||||
|
||||
<T extends VMInstanceVO> void prepareNicForMigration(VirtualMachineProfile<T> vm, DeployDestination dest);
|
||||
|
||||
boolean shutdownNetwork(long networkId, ReservationContext context, boolean cleanupElements);
|
||||
@ -174,135 +139,35 @@ public interface NetworkManager {
|
||||
boolean associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId, Network guestNetwork) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceUnavailableException, ResourceAllocationException;
|
||||
|
||||
Nic getNicInNetwork(long vmId, long networkId);
|
||||
|
||||
List<? extends Nic> getNicsForTraffic(long vmId, TrafficType type);
|
||||
|
||||
Network getDefaultNetworkForVm(long vmId);
|
||||
|
||||
Nic getDefaultNic(long vmId);
|
||||
|
||||
UserDataServiceProvider getPasswordResetProvider(Network network);
|
||||
|
||||
UserDataServiceProvider getUserDataUpdateProvider(Network network);
|
||||
|
||||
boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId);
|
||||
|
||||
Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service);
|
||||
|
||||
boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List<PublicIp> publicIps) throws ResourceUnavailableException;
|
||||
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
|
||||
NetworkVO getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
|
||||
boolean startNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
|
||||
|
||||
List<NetworkVO> listNetworksForAccount(long accountId, long zoneId, Network.GuestType type);
|
||||
|
||||
List<NetworkVO> listAllNetworksInAllZonesByType(Network.GuestType type);
|
||||
|
||||
IPAddressVO markIpAsUnavailable(long addrId);
|
||||
|
||||
public String acquireGuestIpAddress(Network network, String requestedIp);
|
||||
|
||||
String getGlobalGuestDomainSuffix();
|
||||
|
||||
String getStartIpAddress(long networkId);
|
||||
|
||||
boolean applyStaticNats(List<? extends StaticNat> staticNats, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
String getIpInNetwork(long vmId, long networkId);
|
||||
|
||||
String getIpInNetworkIncludingRemoved(long vmId, long networkId);
|
||||
|
||||
Long getPodIdForVlan(long vlanDbId);
|
||||
|
||||
List<Long> listNetworkOfferingsForUpgrade(long networkId);
|
||||
|
||||
boolean isSecurityGroupSupportedInNetwork(Network network);
|
||||
|
||||
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
|
||||
|
||||
boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName);
|
||||
|
||||
String getNetworkTag(HypervisorType hType, Network network);
|
||||
|
||||
List<Service> getElementServices(Provider provider);
|
||||
|
||||
boolean canElementEnableIndividualServices(Provider provider);
|
||||
|
||||
boolean areServicesSupportedInNetwork(long networkId, Service... services);
|
||||
|
||||
boolean isNetworkSystem(Network network);
|
||||
|
||||
boolean reallocate(VirtualMachineProfile<? extends VMInstanceVO> vm,
|
||||
DataCenterDeployment dest) throws InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service);
|
||||
|
||||
Long getPhysicalNetworkId(Network network);
|
||||
|
||||
boolean getAllowSubdomainAccessGlobal();
|
||||
|
||||
boolean isProviderForNetwork(Provider provider, long networkId);
|
||||
|
||||
boolean isProviderForNetworkOffering(Provider provider, long networkOfferingId);
|
||||
|
||||
void canProviderSupportServices(Map<Provider, Set<Service>> providersMap);
|
||||
|
||||
List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfo(long dcId,
|
||||
HypervisorType hypervisorType);
|
||||
|
||||
boolean canAddDefaultSecurityGroup();
|
||||
|
||||
List<Service> listNetworkOfferingServices(long networkOfferingId);
|
||||
|
||||
boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, List<Service> services);
|
||||
|
||||
public Map<PublicIp, Set<Service>> getIpToServices(List<PublicIp> publicIps, boolean rulesRevoked, boolean includingFirewall);
|
||||
|
||||
public Map<Provider, ArrayList<PublicIp>> getProviderToIpList(Network network, Map<PublicIp, Set<Service>> ipToServices);
|
||||
|
||||
public boolean checkIpForService(IPAddressVO ip, Service service, Long networkId);
|
||||
|
||||
void checkCapabilityForProvider(Set<Provider> providers, Service service,
|
||||
Capability cap, String capValue);
|
||||
|
||||
Provider getDefaultUniqueProviderForService(String serviceName);
|
||||
|
||||
IpAddress assignSystemIp(long networkId, Account owner,
|
||||
boolean forElasticLb, boolean forElasticIp)
|
||||
throws InsufficientAddressCapacityException;
|
||||
|
||||
boolean handleSystemIpRelease(IpAddress ip);
|
||||
|
||||
void checkNetworkPermissions(Account owner, Network network);
|
||||
|
||||
void allocateDirectIp(NicProfile nic, DataCenter dc,
|
||||
VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
Network network, String requestedIp)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException;
|
||||
|
||||
String getDefaultManagementTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultStorageTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultPublicTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
String getDefaultGuestTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
/**
|
||||
* @param providerName
|
||||
* @return
|
||||
*/
|
||||
NetworkElement getElementImplementingProvider(String providerName);
|
||||
|
||||
/**
|
||||
* @param owner
|
||||
* @param guestNetwork
|
||||
@ -313,27 +178,6 @@ public interface NetworkManager {
|
||||
PublicIp assignSourceNatIpAddressToGuestNetwork(Account owner, Network guestNetwork) throws InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param zoneId
|
||||
* @return
|
||||
*/
|
||||
String getAccountNetworkDomain(long accountId, long zoneId);
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getDefaultNetworkDomain();
|
||||
|
||||
|
||||
/**
|
||||
* @param ntwkOffId
|
||||
* @return
|
||||
*/
|
||||
List<Provider> getNtwkOffDistinctProviders(long ntwkOffId);
|
||||
|
||||
|
||||
/**
|
||||
* @param requested
|
||||
* @param network
|
||||
@ -375,15 +219,6 @@ public interface NetworkManager {
|
||||
void removeNic(VirtualMachineProfile<? extends VMInstanceVO> vm, Nic nic);
|
||||
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param dcId
|
||||
* @param sourceNat
|
||||
* @return
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat);
|
||||
|
||||
|
||||
/**
|
||||
* @param ipAddrId
|
||||
* @param networkId
|
||||
@ -393,15 +228,6 @@ public interface NetworkManager {
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* @param vm
|
||||
* @param networkId
|
||||
* @param broadcastUri TODO
|
||||
* @return
|
||||
*/
|
||||
NicProfile getNicProfile(VirtualMachine vm, long networkId, String broadcastUri);
|
||||
|
||||
|
||||
/**
|
||||
* @param network
|
||||
* @param provider
|
||||
@ -420,21 +246,6 @@ public interface NetworkManager {
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* @param zoneId
|
||||
* @param trafficType
|
||||
* @return
|
||||
*/
|
||||
List<? extends PhysicalNetwork> getPhysicalNtwksSupportingTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
|
||||
/**
|
||||
* @param guestNic
|
||||
* @return
|
||||
*/
|
||||
boolean isPrivateGateway(Nic guestNic);
|
||||
|
||||
|
||||
/**
|
||||
* @param network
|
||||
* @param requested
|
||||
@ -497,42 +308,6 @@ public interface NetworkManager {
|
||||
NetworkOfferingVO findById) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
|
||||
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
|
||||
|
||||
|
||||
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
|
||||
|
||||
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
|
||||
|
||||
|
||||
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
|
||||
|
||||
List<? extends Network> listNetworksByVpc(long vpcId);
|
||||
|
||||
boolean canUseForDeploy(Network network);
|
||||
|
||||
Network getExclusiveGuestNetwork(long zoneId);
|
||||
|
||||
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
|
||||
|
||||
Integer getNetworkRate(long networkId, Long vmId);
|
||||
|
||||
|
||||
boolean isVmPartOfNetwork(long vmId, long ntwkId);
|
||||
|
||||
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
|
||||
Network getNetwork(long networkId);
|
||||
|
||||
|
||||
IpAddress getIp(long sourceIpAddressId);
|
||||
|
||||
|
||||
IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller,
|
||||
DataCenter zone) throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
250
server/src/com/cloud/network/NetworkModel.java
Normal file
250
server/src/com/cloud/network/NetworkModel.java
Normal file
@ -0,0 +1,250 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
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 {
|
||||
|
||||
/**
|
||||
* Lists IP addresses that belong to VirtualNetwork VLANs
|
||||
*
|
||||
* @param accountId
|
||||
* - account that the IP address should belong to
|
||||
* @param associatedNetworkId
|
||||
* TODO
|
||||
* @param sourceNat
|
||||
* - (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<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
List<? extends Nic> getNics(long vmId);
|
||||
|
||||
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
|
||||
|
||||
boolean validateRule(FirewallRule rule);
|
||||
|
||||
PublicIpAddress getPublicIpAddress(long ipAddressId);
|
||||
|
||||
List<? extends Vlan> listPodVlans(long podId);
|
||||
|
||||
List<NetworkVO> listNetworksUsedByVm(long vmId, boolean isSystem);
|
||||
|
||||
Nic getNicInNetwork(long vmId, long networkId);
|
||||
|
||||
List<? extends Nic> getNicsForTraffic(long vmId, TrafficType type);
|
||||
|
||||
Network getDefaultNetworkForVm(long vmId);
|
||||
|
||||
Nic getDefaultNic(long vmId);
|
||||
|
||||
UserDataServiceProvider getUserDataUpdateProvider(Network network);
|
||||
|
||||
boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId);
|
||||
|
||||
Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service);
|
||||
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
|
||||
NetworkVO getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
|
||||
String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
|
||||
|
||||
List<NetworkVO> listNetworksForAccount(long accountId, long zoneId, Network.GuestType type);
|
||||
|
||||
List<NetworkVO> listAllNetworksInAllZonesByType(Network.GuestType type);
|
||||
|
||||
String getGlobalGuestDomainSuffix();
|
||||
|
||||
String getStartIpAddress(long networkId);
|
||||
|
||||
String getIpInNetwork(long vmId, long networkId);
|
||||
|
||||
String getIpInNetworkIncludingRemoved(long vmId, long networkId);
|
||||
|
||||
Long getPodIdForVlan(long vlanDbId);
|
||||
|
||||
List<Long> listNetworkOfferingsForUpgrade(long networkId);
|
||||
|
||||
boolean isSecurityGroupSupportedInNetwork(Network network);
|
||||
|
||||
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
|
||||
|
||||
boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName);
|
||||
|
||||
String getNetworkTag(HypervisorType hType, Network network);
|
||||
|
||||
List<Service> getElementServices(Provider provider);
|
||||
|
||||
boolean canElementEnableIndividualServices(Provider provider);
|
||||
|
||||
boolean areServicesSupportedInNetwork(long networkId, Service... services);
|
||||
|
||||
boolean isNetworkSystem(Network network);
|
||||
|
||||
Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service);
|
||||
|
||||
Long getPhysicalNetworkId(Network network);
|
||||
|
||||
boolean getAllowSubdomainAccessGlobal();
|
||||
|
||||
boolean isProviderForNetwork(Provider provider, long networkId);
|
||||
|
||||
boolean isProviderForNetworkOffering(Provider provider, long networkOfferingId);
|
||||
|
||||
void canProviderSupportServices(Map<Provider, Set<Service>> providersMap);
|
||||
|
||||
List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfo(long dcId, HypervisorType hypervisorType);
|
||||
|
||||
boolean canAddDefaultSecurityGroup();
|
||||
|
||||
List<Service> listNetworkOfferingServices(long networkOfferingId);
|
||||
|
||||
boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, List<Service> services);
|
||||
|
||||
Map<PublicIp, Set<Service>> getIpToServices(List<PublicIp> publicIps, boolean rulesRevoked,
|
||||
boolean includingFirewall);
|
||||
|
||||
Map<Provider, ArrayList<PublicIp>> getProviderToIpList(Network network, Map<PublicIp, Set<Service>> ipToServices);
|
||||
|
||||
boolean checkIpForService(IPAddressVO ip, Service service, Long networkId);
|
||||
|
||||
void checkCapabilityForProvider(Set<Provider> providers, Service service, Capability cap, String capValue);
|
||||
|
||||
Provider getDefaultUniqueProviderForService(String serviceName);
|
||||
|
||||
void checkNetworkPermissions(Account owner, Network network);
|
||||
|
||||
String getDefaultManagementTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultStorageTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultPublicTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
String getDefaultGuestTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
/**
|
||||
* @param providerName
|
||||
* @return
|
||||
*/
|
||||
NetworkElement getElementImplementingProvider(String providerName);
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param zoneId
|
||||
* @return
|
||||
*/
|
||||
String getAccountNetworkDomain(long accountId, long zoneId);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getDefaultNetworkDomain();
|
||||
|
||||
/**
|
||||
* @param ntwkOffId
|
||||
* @return
|
||||
*/
|
||||
List<Provider> getNtwkOffDistinctProviders(long ntwkOffId);
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param dcId
|
||||
* @param sourceNat
|
||||
* @return
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat);
|
||||
|
||||
/**
|
||||
* @param zoneId
|
||||
* @param trafficType
|
||||
* @return
|
||||
*/
|
||||
List<? extends PhysicalNetwork> getPhysicalNtwksSupportingTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
/**
|
||||
* @param guestNic
|
||||
* @return
|
||||
*/
|
||||
boolean isPrivateGateway(Nic guestNic);
|
||||
|
||||
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
|
||||
|
||||
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
|
||||
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
|
||||
|
||||
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
|
||||
|
||||
List<? extends Network> listNetworksByVpc(long vpcId);
|
||||
|
||||
boolean canUseForDeploy(Network network);
|
||||
|
||||
Network getExclusiveGuestNetwork(long zoneId);
|
||||
|
||||
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
|
||||
|
||||
Integer getNetworkRate(long networkId, Long vmId);
|
||||
|
||||
boolean isVmPartOfNetwork(long vmId, long ntwkId);
|
||||
|
||||
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
Network getNetwork(long networkId);
|
||||
|
||||
IpAddress getIp(long sourceIpAddressId);
|
||||
|
||||
boolean isNetworkAvailableInDomain(long networkId, long domainId);
|
||||
|
||||
NicProfile getNicProfile(VirtualMachine vm, long networkId, String broadcastUri);
|
||||
|
||||
Set<Long> getAvailableIps(Network network, String requestedIp);
|
||||
|
||||
String getDomainNetworkDomain(long domainId, long zoneId);
|
||||
|
||||
}
|
||||
1734
server/src/com/cloud/network/NetworkModelImpl.java
Normal file
1734
server/src/com/cloud/network/NetworkModelImpl.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -226,6 +226,8 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
ResourceTagDao _resourceTagDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
|
||||
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
@ -364,7 +366,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
|
||||
private boolean canIpsUseOffering(List<PublicIp> publicIps, long offeringId) {
|
||||
Map<PublicIp, Set<Service>> ipToServices = getIpToServices(publicIps, false, true);
|
||||
Map<Service, Set<Provider>> serviceToProviders = _networkMgr.getNetworkOfferingServiceProvidersMap(offeringId);
|
||||
Map<Service, Set<Provider>> serviceToProviders = _networkModel.getNetworkOfferingServiceProvidersMap(offeringId);
|
||||
for (PublicIp ip : ipToServices.keySet()) {
|
||||
Set<Service> services = ipToServices.get(ip);
|
||||
Provider provider = null;
|
||||
@ -1146,7 +1148,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
if (canUseForDeploy != null) {
|
||||
List<NetworkVO> networksForDeploy = new ArrayList<NetworkVO>();
|
||||
for (NetworkVO network : networksToReturn) {
|
||||
if (_networkMgr.canUseForDeploy(network) == canUseForDeploy) {
|
||||
if (_networkModel.canUseForDeploy(network) == canUseForDeploy) {
|
||||
networksForDeploy.add(network);
|
||||
}
|
||||
}
|
||||
@ -1429,7 +1431,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
|
||||
// FIXME we return the capabilities of the first provider of the service - what if we have multiple providers
|
||||
// for same Service?
|
||||
NetworkElement element = _networkMgr.getElementImplementingProvider(provider);
|
||||
NetworkElement element = _networkModel.getElementImplementingProvider(provider);
|
||||
if (element != null) {
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
|
||||
;
|
||||
@ -2301,7 +2303,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
}
|
||||
|
||||
if (provider != null) {
|
||||
NetworkElement element = _networkMgr.getElementImplementingProvider(providerName);
|
||||
NetworkElement element = _networkModel.getElementImplementingProvider(providerName);
|
||||
if (element == null) {
|
||||
throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + providerName + "'");
|
||||
}
|
||||
@ -2348,7 +2350,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
}
|
||||
|
||||
// check if services can be turned off
|
||||
NetworkElement element = _networkMgr.getElementImplementingProvider(providerName);
|
||||
NetworkElement element = _networkModel.getElementImplementingProvider(providerName);
|
||||
if (element == null) {
|
||||
throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + providerName + "'");
|
||||
}
|
||||
@ -2441,7 +2443,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
throw new InvalidParameterValueException("Network Service Provider id=" + id + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
NetworkElement element = _networkMgr.getElementImplementingProvider(provider.getProviderName());
|
||||
NetworkElement element = _networkModel.getElementImplementingProvider(provider.getProviderName());
|
||||
if (element == null) {
|
||||
throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + provider.getProviderName() + "'");
|
||||
}
|
||||
@ -2530,7 +2532,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Shutting down the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId());
|
||||
}
|
||||
NetworkElement element = _networkMgr.getElementImplementingProvider(provider.getProviderName());
|
||||
NetworkElement element = _networkModel.getElementImplementingProvider(provider.getProviderName());
|
||||
if (element == null) {
|
||||
throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + provider.getProviderName() + "'");
|
||||
}
|
||||
@ -2788,7 +2790,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
|
||||
PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName(), null, null);
|
||||
// add instance of the provider
|
||||
VirtualRouterElement element = (VirtualRouterElement) _networkMgr.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
|
||||
VirtualRouterElement element = (VirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
|
||||
if (element == null) {
|
||||
throw new CloudRuntimeException("Unable to find the Network Element implementing the VirtualRouter Provider");
|
||||
}
|
||||
@ -2802,7 +2804,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||
PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId,
|
||||
Network.Provider.VPCVirtualRouter.getName(), null, null);
|
||||
// add instance of the provider
|
||||
VpcVirtualRouterElement element = (VpcVirtualRouterElement) _networkMgr.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
|
||||
VpcVirtualRouterElement element = (VpcVirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
|
||||
if (element == null) {
|
||||
throw new CloudRuntimeException("Unable to find the Network Element implementing the VPCVirtualRouter Provider");
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
@ -72,7 +72,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
||||
@Inject
|
||||
NetworkDao _networkConfigDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
UserVmManager _userVmMgr;
|
||||
@Inject
|
||||
|
||||
@ -43,7 +43,7 @@ import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
@ -102,7 +102,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
@Inject
|
||||
NetworkDao _networksDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
LoadBalancingRulesManager _lbMgr;
|
||||
@Inject
|
||||
|
||||
@ -46,6 +46,7 @@ import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkRuleApplier;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
@ -112,6 +113,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
UsageEventDao _usageEventDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@ -186,7 +189,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
|
||||
" doesn't exist in the system");
|
||||
}
|
||||
|
||||
_networkMgr.checkIpForService(ipAddress, Service.Firewall, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.Firewall, null);
|
||||
|
||||
validateFirewallRule(caller, ipAddress, portStart, portEnd, protocol, Purpose.Firewall, type);
|
||||
|
||||
@ -421,7 +424,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
|
||||
networkId = ipAddress.getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
assert network != null : "Can't create port forwarding rule as network associated with public ip address is null?";
|
||||
|
||||
// Verify that the network guru supports the protocol specified
|
||||
@ -429,10 +432,10 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
|
||||
|
||||
if (purpose == Purpose.LoadBalancing) {
|
||||
if (!_elbEnabled) {
|
||||
caps = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.Lb);
|
||||
caps = _networkModel.getNetworkServiceCapabilities(network.getId(), Service.Lb);
|
||||
}
|
||||
} else if (purpose == Purpose.PortForwarding) {
|
||||
caps = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.PortForwarding);
|
||||
caps = _networkModel.getNetworkServiceCapabilities(network.getId(), Service.PortForwarding);
|
||||
}
|
||||
|
||||
if (caps != null) {
|
||||
|
||||
@ -35,7 +35,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
@ -58,7 +58,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(ControlNetworkGuru.class);
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
String _cidr;
|
||||
String _gateway;
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
@ -64,6 +65,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
@Inject
|
||||
VlanDao _vlanDao;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
IPAddressDao _ipAddressDao;
|
||||
@ -132,7 +135,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSecurityGroupEnabled = _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
||||
boolean isSecurityGroupEnabled = _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
||||
if (isSecurityGroupEnabled) {
|
||||
config.setName("SecurityGroupEnabledNetwork");
|
||||
config.setDisplayText("SecurityGroupEnabledNetwork");
|
||||
|
||||
@ -109,7 +109,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
||||
}
|
||||
|
||||
if (rsStrategy == ReservationStrategy.Create) {
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(network.getId());
|
||||
String mac = _networkModel.getNextAvailableMacAddressInNetwork(network.getId());
|
||||
nic.setMacAddress(mac);
|
||||
}
|
||||
return nic;
|
||||
|
||||
@ -106,7 +106,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
NetworkVO config = (NetworkVO) super.design(offering, plan, userSpecified, owner);
|
||||
if (config == null) {
|
||||
return null;
|
||||
} else if (_networkMgr.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
|
||||
} else if (_networkModel.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
|
||||
/* In order to revert userSpecified network setup */
|
||||
config.setState(State.Allocated);
|
||||
}
|
||||
@ -122,7 +122,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (!_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
return super.implement(config, offering, dest, context);
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
|
||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
profile.setStrategy(ReservationStrategy.Start);
|
||||
/* We won't clear IP address, because router may set gateway as it IP, and it would be updated properly later */
|
||||
//profile.setIp4Address(null);
|
||||
@ -225,7 +225,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
nic.setIp4Address(null);
|
||||
nic.setGateway(null);
|
||||
nic.setNetmask(null);
|
||||
@ -245,7 +245,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
|
||||
DataCenter dc = _dcDao.findById(config.getDataCenterId());
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
nic.setBroadcastUri(config.getBroadcastUri());
|
||||
nic.setIsolationUri(config.getBroadcastUri());
|
||||
nic.setDns1(dc.getDns1());
|
||||
@ -280,7 +280,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
|
||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||
|
||||
if (network != null && _networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
if (network != null && _networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
return true;
|
||||
} else {
|
||||
return super.release(nic, vm, reservationId);
|
||||
|
||||
@ -45,6 +45,7 @@ import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
@ -82,6 +83,8 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
@Inject
|
||||
protected NetworkManager _networkMgr;
|
||||
@Inject
|
||||
protected NetworkModel _networkModel;
|
||||
@Inject
|
||||
protected DataCenterDao _dcDao;
|
||||
@Inject
|
||||
protected VlanDao _vlanDao;
|
||||
@ -310,7 +313,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(),
|
||||
network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
@ -355,11 +358,11 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
boolean isGateway = false;
|
||||
if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
|
||||
if (network.getVpcId() != null) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VPCVirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VPCVirtualRouter)) {
|
||||
isGateway = true;
|
||||
}
|
||||
} else {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
isGateway = true;
|
||||
}
|
||||
}
|
||||
@ -387,7 +390,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||
nic.setStrategy(ReservationStrategy.Start);
|
||||
|
||||
if (nic.getMacAddress() == null) {
|
||||
nic.setMacAddress(_networkMgr.getNextAvailableMacAddressInNetwork(network.getId()));
|
||||
nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId()));
|
||||
if (nic.getMacAddress() == null) {
|
||||
throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", Network.class, network.getId());
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
@ -62,7 +62,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
@Inject
|
||||
protected PrivateIpDao _privateIpDao;
|
||||
@Inject
|
||||
protected NetworkManager _networkMgr;
|
||||
protected NetworkModel _networkMgr;
|
||||
|
||||
private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
|
||||
|
||||
|
||||
@ -68,6 +68,7 @@ import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkRuleApplier;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.as.AutoScalePolicy;
|
||||
@ -157,6 +158,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
RulesManager _rulesMgr;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@ -234,7 +237,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
// Will return a string. For LB Stickiness this will be a json, for autoscale this will be "," separated values
|
||||
@Override
|
||||
public String getLBCapability(long networkid, String capabilityName) {
|
||||
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkMgr.getNetworkCapabilities(networkid);
|
||||
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkModel.getNetworkCapabilities(networkid);
|
||||
if (serviceCapabilitiesMap != null) {
|
||||
for (Service service : serviceCapabilitiesMap.keySet()) {
|
||||
ServiceResponse serviceResponse = new ServiceResponse();
|
||||
@ -486,7 +489,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
List<LbStickinessPolicy> policyList = new ArrayList<LbStickinessPolicy>();
|
||||
policyList.add(new LbStickinessPolicy(cmd.getStickinessMethodName(), lbpolicy.getParams()));
|
||||
LoadBalancingRule lbRule = new LoadBalancingRule(loadBalancer, getExistingDestinations(lbpolicy.getId()), policyList);
|
||||
if (!_networkMgr.validateRule(lbRule)) {
|
||||
if (!_networkModel.validateRule(lbRule)) {
|
||||
throw new InvalidParameterValueException("Failed to create Stickiness policy: Validation Failed " + cmd.getLbRuleId());
|
||||
}
|
||||
|
||||
@ -624,7 +627,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
}
|
||||
|
||||
// Let's check to make sure the vm has a nic in the same network as the load balancing rule.
|
||||
List<? extends Nic> nics = _networkMgr.getNics(vm.getId());
|
||||
List<? extends Nic> nics = _networkModel.getNics(vm.getId());
|
||||
Nic nicInSameNetwork = null;
|
||||
for (Nic nic : nics) {
|
||||
if (nic.getNetworkId() == loadBalancer.getNetworkId()) {
|
||||
@ -858,7 +861,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
// gather external network usage stats for this lb rule
|
||||
NetworkVO network = _networkDao.findById(lb.getNetworkId());
|
||||
if (network != null) {
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
_externalLBUsageMgr.updateExternalLoadBalancerNetworkUsageStats(loadBalancerId);
|
||||
}
|
||||
}
|
||||
@ -939,7 +942,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
ipVO = _ipAddressDao.findById(ipAddrId);
|
||||
}
|
||||
|
||||
Network network = _networkMgr.getNetwork(lb.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(lb.getNetworkId());
|
||||
|
||||
// FIXME: breaking the dependency on ELB manager. This breaks functionality of ELB using virtual router
|
||||
// Bug CS-15411 opened to document this
|
||||
@ -968,14 +971,14 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
//set networkId just for verification purposes
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
_networkModel.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
|
||||
ipVO = _networkMgr.associateIPToGuestNetwork(ipAddrId, lb.getNetworkId(), false);
|
||||
performedIpAssoc = true;
|
||||
}
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, null);
|
||||
_networkModel.checkIpForService(ipVO, Service.Lb, null);
|
||||
}
|
||||
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
@ -1047,7 +1050,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
_accountMgr.checkAccess(caller.getCaller(), null, true, ipAddr);
|
||||
|
||||
// verify that lb service is supported by the network
|
||||
if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("LB service is not supported in specified network id");
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
|
||||
@ -130,6 +130,7 @@ import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
@ -290,6 +291,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
VirtualMachineManager _itMgr;
|
||||
@Inject
|
||||
VpnUserDao _vpnUsersDao;
|
||||
@ -805,7 +808,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (privateIP != null) {
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Public) {
|
||||
boolean forVpc = router.getVpcId() != null;
|
||||
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
|
||||
@ -1320,7 +1323,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
// 1) Get deployment plan and find out the list of routers
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic ||
|
||||
_networkMgr.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SecurityGroup))
|
||||
_networkModel.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SecurityGroup))
|
||||
&& guestNetwork.getTrafficType() == TrafficType.Guest;
|
||||
|
||||
// dest has pod=null, for Basic Zone findOrDeployVRs for all Pods
|
||||
@ -1380,7 +1383,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
// Check if providers are supported in the physical networks
|
||||
VirtualRouterProviderType type = VirtualRouterProviderType.VirtualRouter;
|
||||
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(guestNetwork);
|
||||
Long physicalNetworkId = _networkModel.getPhysicalNetworkId(guestNetwork);
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " + type.toString() + " in physical network " + physicalNetworkId);
|
||||
@ -1390,13 +1393,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
throw new CloudRuntimeException("Cannot find virtual router provider " + type.toString() + " as service provider " + provider.getId());
|
||||
}
|
||||
|
||||
if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
if (_networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
|
||||
}
|
||||
|
||||
// Check if public network has to be set on VR
|
||||
boolean publicNetwork = false;
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
publicNetwork = true;
|
||||
}
|
||||
if (isRedundant && !publicNetwork) {
|
||||
@ -1598,7 +1601,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
s_logger.debug("Adding nic for Virtual Router in Guest network " + guestNetwork);
|
||||
String defaultNetworkStartIp = null;
|
||||
if (guestNetwork.getCidr() != null && !setupPublicNetwork) {
|
||||
String startIp = _networkMgr.getStartIpAddress(guestNetwork.getId());
|
||||
String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
|
||||
if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(), startIp).getAllocatedTime() == null) {
|
||||
defaultNetworkStartIp = startIp;
|
||||
} else if (s_logger.isDebugEnabled()){
|
||||
@ -1630,7 +1633,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
//2) Control network
|
||||
s_logger.debug("Adding nic for Virtual Router in Control network ");
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
|
||||
@ -1653,7 +1656,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (hasGuestNetwork) {
|
||||
defaultNic.setDeviceId(2);
|
||||
}
|
||||
NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
NetworkOfferingVO publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), defaultNic));
|
||||
}
|
||||
@ -1871,8 +1874,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
}
|
||||
} else if (nic.getTrafficType() == TrafficType.Guest) {
|
||||
dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dns, Provider.VirtualRouter);
|
||||
dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter);
|
||||
dnsProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dns, Provider.VirtualRouter);
|
||||
dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter);
|
||||
//build bootloader parameter for the guest
|
||||
buf.append(createGuestBootLoadArgs(nic, defaultDns1, defaultDns2, router));
|
||||
} else if (nic.getTrafficType() == TrafficType.Public) {
|
||||
@ -1973,7 +1976,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
s_logger.error("Failed to get update priority!", e);
|
||||
throw new CloudRuntimeException("Failed to get update priority!");
|
||||
}
|
||||
Network net = _networkMgr.getNetwork(guestNic.getNetworkId());
|
||||
Network net = _networkModel.getNetwork(guestNic.getNetworkId());
|
||||
buf.append(" guestgw=").append(net.getGateway());
|
||||
String brd = NetUtils.long2Ip(NetUtils.ip2Long(guestNic.getIp4Address()) | ~NetUtils.ip2Long(guestNic.getNetmask()));
|
||||
buf.append(" guestbrd=").append(brd);
|
||||
@ -2129,13 +2132,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
}
|
||||
|
||||
protected void finalizeUserDataAndDhcpOnStart(Commands cmds, DomainRouterVO router, Provider provider, Long guestNetworkId) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)) {
|
||||
// Resend dhcp
|
||||
s_logger.debug("Reapplying dhcp entries as a part of domR " + router + " start...");
|
||||
createDhcpEntryCommandsForVMs(router, cmds, guestNetworkId);
|
||||
}
|
||||
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.UserData, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.UserData, provider)) {
|
||||
// Resend user data
|
||||
s_logger.debug("Reapplying vm data (userData and metaData) entries as a part of domR " + router + " start...");
|
||||
createVmDataCommandForVMs(router, cmds, guestNetworkId);
|
||||
@ -2156,26 +2159,26 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
//Get information about all the rules (StaticNats and StaticNatRules; PFVPN to reapply on domR start)
|
||||
for (PublicIpAddress ip : publicIps) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.PortForwarding, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.PortForwarding, provider)) {
|
||||
pfRules.addAll(_pfRulesDao.listForApplication(ip.getId()));
|
||||
}
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
staticNatFirewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.StaticNat));
|
||||
}
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
firewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.Firewall));
|
||||
}
|
||||
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Vpn, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Vpn, provider)) {
|
||||
RemoteAccessVpn vpn = _vpnDao.findById(ip.getId());
|
||||
if (vpn != null) {
|
||||
vpns.add(vpn);
|
||||
}
|
||||
}
|
||||
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
if (ip.isOneToOneNat()) {
|
||||
String dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), guestNetworkId);
|
||||
String dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), guestNetworkId);
|
||||
StaticNatImpl staticNat = new StaticNatImpl(ip.getAccountId(), ip.getDomainId(), guestNetworkId, ip.getId(), dstIp, false);
|
||||
staticNats.add(staticNat);
|
||||
}
|
||||
@ -2220,7 +2223,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkId(guestNetworkId);
|
||||
List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb, provider)) {
|
||||
// Re-apply load balancing rules
|
||||
for (LoadBalancerVO lb : lbs) {
|
||||
List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
|
||||
@ -2245,7 +2248,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (publicIps != null && !publicIps.isEmpty()) {
|
||||
s_logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR " + router + " start.");
|
||||
// Re-apply public ip addresses - should come before PF/LB/VPN
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
createAssociateIPCommands(router, publicIps, cmds, 0);
|
||||
}
|
||||
}
|
||||
@ -2254,7 +2257,7 @@ 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 = _networkMgr.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
|
||||
final List<IPAddressVO> userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
|
||||
List<PublicIp> allPublicIps = new ArrayList<PublicIp>();
|
||||
if (userIps != null && !userIps.isEmpty()) {
|
||||
boolean addIp = true;
|
||||
@ -2279,8 +2282,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
//Get public Ips that should be handled by router
|
||||
Network network = _networkDao.findById(guestNetworkId);
|
||||
Map<PublicIp, Set<Service>> ipToServices = _networkMgr.getIpToServices(allPublicIps, false, true);
|
||||
Map<Provider, ArrayList<PublicIp>> providerToIpList = _networkMgr.getProviderToIpList(network, ipToServices);
|
||||
Map<PublicIp, Set<Service>> ipToServices = _networkModel.getIpToServices(allPublicIps, false, true);
|
||||
Map<Provider, ArrayList<PublicIp>> 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);
|
||||
@ -2313,7 +2316,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Guest) {
|
||||
guestNetworks.add(network);
|
||||
}
|
||||
@ -2413,7 +2416,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
for (VirtualRouter router : routers) {
|
||||
if (router.getState() == State.Running) {
|
||||
Commands cmds = new Commands(OnError.Continue);
|
||||
IpAddress ip = _networkMgr.getIp(vpn.getServerAddressId());
|
||||
IpAddress ip = _networkModel.getIp(vpn.getServerAddressId());
|
||||
|
||||
RemoteAccessVpnCfgCommand removeVpnCmd = new RemoteAccessVpnCfgCommand(false, ip.getAddress().addr(),
|
||||
vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
|
||||
@ -2513,7 +2516,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
|
||||
|
||||
//check if DNS provider is the domR
|
||||
if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
|
||||
if (!_networkModel.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -2522,7 +2525,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
return findGatewayIp(userVmId);
|
||||
}
|
||||
|
||||
DataCenter dc = _dcDao.findById(_networkMgr.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
|
||||
DataCenter dc = _dcDao.findById(_networkModel.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
|
||||
boolean isZoneBasic = (dc.getNetworkType() == NetworkType.Basic);
|
||||
|
||||
//find domR's nic in the network
|
||||
@ -2741,8 +2744,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
});
|
||||
|
||||
// Get network rate - required for IpAssoc
|
||||
Integer networkRate = _networkMgr.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkMgr.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
|
||||
IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
|
||||
int i = 0;
|
||||
@ -2765,7 +2768,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, networkRate, ipAddr.isOneToOneNat());
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
||||
ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
||||
ipsToSend[i++] = ip;
|
||||
/* send the firstIP = true for the first Add, this is to create primary on interface*/
|
||||
if (!firstIP || add) {
|
||||
@ -2788,7 +2791,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (rules != null) {
|
||||
rulesTO = new ArrayList<PortForwardingRuleTO>();
|
||||
for (PortForwardingRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, null, sourceIp.getAddress().addr());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
@ -2816,7 +2819,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (rules != null) {
|
||||
rulesTO = new ArrayList<StaticNatRuleTO>();
|
||||
for (StaticNatRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(rule, null, sourceIp.getAddress().addr(), rule.getDestIpAddress());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
@ -2841,7 +2844,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
String algorithm = rule.getAlgorithm();
|
||||
String uuid = rule.getUuid();
|
||||
|
||||
String srcIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
String srcIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
List<LbDestination> destinations = rule.getDestinations();
|
||||
List<LbStickinessPolicy> stickinessPolicies = rule.getStickinessPolicies();
|
||||
@ -2855,12 +2858,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
routerPublicIp = domr.getPublicIpAddress();
|
||||
}
|
||||
|
||||
Network guestNetwork = _networkMgr.getNetwork(guestNetworkId);
|
||||
Network guestNetwork = _networkModel.getNetwork(guestNetworkId);
|
||||
Nic nic = _nicDao.findByInstanceIdAndNetworkId(guestNetwork.getId(), router.getId());
|
||||
NicProfile nicProfile = new NicProfile(nic, guestNetwork, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
_networkMgr.getNetworkRate(guestNetwork.getId(), router.getId()),
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(guestNetwork),
|
||||
_networkMgr.getNetworkTag(router.getHypervisorType(), guestNetwork));
|
||||
_networkModel.getNetworkRate(guestNetwork.getId(), router.getId()),
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(guestNetwork),
|
||||
_networkModel.getNetworkTag(router.getHypervisorType(), guestNetwork));
|
||||
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,routerPublicIp,
|
||||
getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress(),
|
||||
@ -2898,7 +2901,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(vpn.getNetworkId(), router.getId()));
|
||||
addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
IpAddress ip = _networkMgr.getIp(vpn.getServerAddressId());
|
||||
IpAddress ip = _networkModel.getIp(vpn.getServerAddressId());
|
||||
|
||||
RemoteAccessVpnCfgCommand startVpnCmd = new RemoteAccessVpnCfgCommand(true, ip.getAddress().addr(),
|
||||
vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
|
||||
@ -3173,7 +3176,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (rules != null) {
|
||||
rulesTO = new ArrayList<FirewallRuleTO>();
|
||||
for (FirewallRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
FirewallRuleTO ruleTO = new FirewallRuleTO(rule, null, sourceIp.getAddress().addr());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
@ -3317,7 +3320,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (rules != null) {
|
||||
rulesTO = new ArrayList<StaticNatRuleTO>();
|
||||
for (StaticNat rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(0, sourceIp.getAddress().addr(), null,
|
||||
null, rule.getDestIpAddress(), null, null, null, rule.isForRevoke(), false);
|
||||
rulesTO.add(ruleTO);
|
||||
@ -3450,7 +3453,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (privateIP != null) {
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Public) {
|
||||
boolean forVpc = router.getVpcId() != null;
|
||||
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
|
||||
|
||||
@ -287,12 +287,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
//Check if router is a part of the Guest network
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
if (!_networkModel.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean result = setupVpcGuestNetwork(network, router, false, _networkMgr.getNicProfile(router, network.getId(), null));
|
||||
boolean result = setupVpcGuestNetwork(network, router, false, _networkModel.getNicProfile(router, network.getId(), null));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
|
||||
return false;
|
||||
@ -421,13 +421,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
protected SetupGuestNetworkCommand createSetupGuestNetworkCommand(VirtualRouter router, boolean add, NicProfile guestNic) {
|
||||
Network network = _networkMgr.getNetwork(guestNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(guestNic.getNetworkId());
|
||||
|
||||
String defaultDns1 = null;
|
||||
String defaultDns2 = null;
|
||||
|
||||
boolean dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
|
||||
boolean dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||
boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
|
||||
boolean dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||
Provider.VPCVirtualRouter);
|
||||
|
||||
boolean setupDns = dnsProvided || dhcpProvided;
|
||||
@ -441,7 +441,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
String networkDomain = network.getNetworkDomain();
|
||||
String dhcpRange = getGuestDhcpRange(guestNic, network, _configMgr.getZone(network.getDataCenterId()));
|
||||
|
||||
NicProfile nicProfile = _networkMgr.getNicProfile(router, nic.getNetworkId(), null);
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null);
|
||||
|
||||
SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, false, null,
|
||||
defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
|
||||
@ -482,8 +482,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
List<PublicIpAddress> ipAddrList = vlanAndIp.getValue();
|
||||
|
||||
// Get network rate - required for IpAssoc
|
||||
Integer networkRate = _networkMgr.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkMgr.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
|
||||
IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
|
||||
int i = 0;
|
||||
@ -498,7 +498,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
networkRate, ipAddr.isOneToOneNat());
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
||||
ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
||||
ipsToSend[i++] = ip;
|
||||
if (ipAddr.isSourceNat()) {
|
||||
sourceNatIpAdd = new Pair<IpAddressTO, Long>(ip, ipAddr.getNetworkId());
|
||||
@ -528,7 +528,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
protected NicTO getNicTO(final VirtualRouter router, Long networkId, String broadcastUri) {
|
||||
NicProfile nicProfile = _networkMgr.getNicProfile(router, networkId, broadcastUri);
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(router, networkId, broadcastUri);
|
||||
|
||||
return _itMgr.toNicTO(nicProfile, router.getHypervisorType());
|
||||
}
|
||||
@ -557,7 +557,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
for (String vlanTag : nicsToUnplug.keySet()) {
|
||||
Network publicNtwk = null;
|
||||
try {
|
||||
publicNtwk = _networkMgr.getNetwork(nicsToUnplug.get(vlanTag).getNetworkId());
|
||||
publicNtwk = _networkModel.getNetwork(nicsToUnplug.get(vlanTag).getNetworkId());
|
||||
URI broadcastUri = BroadcastDomainType.Vlan.toUri(vlanTag);
|
||||
_itMgr.removeVmFromNetwork(router, publicNtwk, broadcastUri);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
@ -589,7 +589,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
NicProfile publicNic = null;
|
||||
Network publicNtwk = null;
|
||||
try {
|
||||
publicNtwk = _networkMgr.getNetwork(ip.getNetworkId());
|
||||
publicNtwk = _networkModel.getNetwork(ip.getNetworkId());
|
||||
publicNic = _itMgr.addVmToNetwork(router, publicNtwk, defaultNic);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
@ -772,7 +772,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Guest) {
|
||||
Pair<Nic, Network> guestNic = new Pair<Nic, Network>(routerNic, network);
|
||||
guestNics.add(guestNic);
|
||||
@ -835,10 +835,10 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName());
|
||||
cmds.addCommand(plugNicCmd);
|
||||
|
||||
if (!_networkMgr.isPrivateGateway(guestNic)) {
|
||||
if (!_networkModel.isPrivateGateway(guestNic)) {
|
||||
//set guest network
|
||||
VirtualMachine vm = _vmDao.findById(router.getId());
|
||||
NicProfile nicProfile = _networkMgr.getNicProfile(vm, guestNic.getNetworkId(), null);
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(), null);
|
||||
SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, true, nicProfile);
|
||||
cmds.addCommand(setupCmd);
|
||||
} else {
|
||||
@ -918,7 +918,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
super.finalizeNetworkRulesForNetwork(cmds, router, provider, guestNetworkId);
|
||||
|
||||
if (router.getVpcId() != null) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) {
|
||||
List<? extends FirewallRule> networkACLs = _networkACLMgr.listNetworkACLs(guestNetworkId);
|
||||
s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + router
|
||||
+ " start for guest network id=" + guestNetworkId);
|
||||
@ -933,7 +933,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
public boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
boolean result = true;
|
||||
try {
|
||||
Network network = _networkMgr.getNetwork(gateway.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(gateway.getNetworkId());
|
||||
NicProfile requested = createPrivateNicProfileForGateway(gateway);
|
||||
|
||||
NicProfile guestNic = _itMgr.addVmToNetwork(router, network, requested);
|
||||
@ -1006,15 +1006,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
|
||||
if (!_networkModel.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
|
||||
s_logger.debug("Router doesn't have nic for gateway " + gateway + " so no need to removed it");
|
||||
return true;
|
||||
}
|
||||
|
||||
Network privateNetwork = _networkMgr.getNetwork(gateway.getNetworkId());
|
||||
Network privateNetwork = _networkModel.getNetwork(gateway.getNetworkId());
|
||||
|
||||
s_logger.debug("Releasing private ip for gateway " + gateway + " from " + router);
|
||||
boolean result = setupVpcPrivateNetwork(router, false, _networkMgr.getNicProfile(router, privateNetwork.getId(), null));
|
||||
boolean result = setupVpcPrivateNetwork(router, false, _networkModel.getNicProfile(router, privateNetwork.getId(), null));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to release private ip for gateway " + gateway + " on router " + router);
|
||||
return false;
|
||||
@ -1167,13 +1167,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
int i = 0;
|
||||
|
||||
for (final PrivateIpAddress ipAddr : ipAddrList) {
|
||||
Network network = _networkMgr.getNetwork(ipAddr.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(ipAddr.getNetworkId());
|
||||
IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false,
|
||||
false, ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(),
|
||||
null, false);
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
||||
ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
||||
ipsToSend[i++] = ip;
|
||||
|
||||
}
|
||||
@ -1205,7 +1205,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
VpcGateway privateGateway = _vpcMgr.getPrivateGatewayForVpc(vpcId);
|
||||
if (privateGateway != null) {
|
||||
NicProfile privateNic = createPrivateNicProfileForGateway(privateGateway);
|
||||
Network privateNetwork = _networkMgr.getNetwork(privateGateway.getNetworkId());
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO) privateNetwork, privateNic));
|
||||
}
|
||||
|
||||
@ -1235,7 +1235,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 = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
NetworkOfferingVO publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.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());
|
||||
@ -1247,7 +1247,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
@DB
|
||||
protected NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
|
||||
Network privateNetwork = _networkMgr.getNetwork(privateGateway.getNetworkId());
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getIp4Address());
|
||||
Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
|
||||
|
||||
@ -1256,9 +1256,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
if (privateNic != null) {
|
||||
VirtualMachine vm = _vmDao.findById(privateNic.getId());
|
||||
privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(),
|
||||
_networkMgr.getNetworkRate(privateNetwork.getId(), vm.getId()),
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(privateNetwork),
|
||||
_networkMgr.getNetworkTag(vm.getHypervisorType(), privateNetwork));
|
||||
_networkModel.getNetworkRate(privateNetwork.getId(), vm.getId()),
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
|
||||
_networkModel.getNetworkTag(vm.getHypervisorType(), privateNetwork));
|
||||
} else {
|
||||
String vlanTag = privateNetwork.getBroadcastUri().getHost();
|
||||
String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
|
||||
|
||||
@ -33,6 +33,7 @@ import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
@ -90,6 +91,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
EventDao _eventDao;
|
||||
@Inject
|
||||
UsageEventDao _usageEventDao;
|
||||
@ -173,14 +176,14 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
|
||||
Long networkId = rule.getNetworkId();
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
//associate ip address to network (if needed)
|
||||
boolean performedIpAssoc = false;
|
||||
if (ipAddress.getAssociatedWithNetworkId() == null) {
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipAddress.getVpcId() != null && ipAddress.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.PortForwarding, networkId);
|
||||
_networkModel.checkIpForService(ipAddress, Service.PortForwarding, networkId);
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ networkId + ", so assigning");
|
||||
try {
|
||||
@ -192,7 +195,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.PortForwarding, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.PortForwarding, null);
|
||||
}
|
||||
|
||||
if (ipAddress.getAssociatedWithNetworkId() == null) {
|
||||
@ -228,7 +231,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
|
||||
// Verify that vm has nic in the network
|
||||
Ip dstIp = rule.getDestinationIpAddress();
|
||||
Nic guestNic = _networkMgr.getNicInNetwork(vmId, networkId);
|
||||
Nic guestNic = _networkModel.getNicInNetwork(vmId, networkId);
|
||||
if (guestNic == null || guestNic.getIp4Address() == null) {
|
||||
throw new InvalidParameterValueException("Vm doesn't belong to network associated with ipAddress");
|
||||
} else {
|
||||
@ -326,15 +329,15 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
Long accountId = ipAddress.getAllocatedToAccountId();
|
||||
Long domainId = ipAddress.getAllocatedInDomainId();
|
||||
|
||||
_networkMgr.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
if (off.getElasticIp()) {
|
||||
throw new InvalidParameterValueException("Can't create ip forwarding rules for the network where elasticIP service is enabled");
|
||||
}
|
||||
|
||||
String dstIp = _networkMgr.getIpInNetwork(ipAddress.getAssociatedWithVmId(), networkId);
|
||||
String dstIp = _networkModel.getIpInNetwork(ipAddress.getAssociatedWithVmId(), networkId);
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
@ -398,19 +401,19 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
boolean performedIpAssoc = false;
|
||||
boolean result = false;
|
||||
try {
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Unable to find network by id");
|
||||
}
|
||||
|
||||
// Check that vm has a nic in the network
|
||||
Nic guestNic = _networkMgr.getNicInNetwork(vmId, networkId);
|
||||
Nic guestNic = _networkModel.getNicInNetwork(vmId, networkId);
|
||||
if (guestNic == null) {
|
||||
throw new InvalidParameterValueException("Vm doesn't belong to the network with specified id");
|
||||
}
|
||||
|
||||
|
||||
if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
|
||||
if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
|
||||
throw new InvalidParameterValueException("Unable to create static nat rule; StaticNat service is not " +
|
||||
"supported in network with specified id");
|
||||
}
|
||||
@ -426,7 +429,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipAddress.getVpcId() != null && ipAddress.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.StaticNat, networkId);
|
||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, networkId);
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ networkId + ", so assigning");
|
||||
try {
|
||||
@ -439,7 +442,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
performedIpAssoc = true;
|
||||
}
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
}
|
||||
|
||||
if (ipAddress.getAssociatedWithNetworkId() == null) {
|
||||
@ -512,7 +515,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
Long networkId = oldIP.getAssociatedWithNetworkId();
|
||||
boolean reassignStaticNat = false;
|
||||
if (networkId != null) {
|
||||
Network guestNetwork = _networkMgr.getNetwork(networkId);
|
||||
Network guestNetwork = _networkModel.getNetwork(networkId);
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
reassignStaticNat = true;
|
||||
@ -875,7 +878,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
List<StaticNat> staticNats = new ArrayList<StaticNat>();
|
||||
for (IPAddressVO ip : ips) {
|
||||
// Get nic IP4 address
|
||||
String dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), networkId);
|
||||
String dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), networkId);
|
||||
StaticNatImpl staticNat = new StaticNatImpl(ip.getAllocatedToAccountId(), ip.getAllocatedInDomainId(), networkId, ip.getId(), dstIp, false);
|
||||
staticNats.add(staticNat);
|
||||
}
|
||||
@ -1170,7 +1173,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
|
||||
// if network has elastic IP functionality supported, we first have to disable static nat on old ip in order to
|
||||
// re-enable it on the new one enable static nat takes care of that
|
||||
Network guestNetwork = _networkMgr.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
||||
Network guestNetwork = _networkModel.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
if (offering.getAssociatePublicIP()) {
|
||||
@ -1257,9 +1260,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
|
||||
String dstIp;
|
||||
if (forRevoke) {
|
||||
dstIp = _networkMgr.getIpInNetworkIncludingRemoved(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
dstIp = _networkModel.getIpInNetworkIncludingRemoved(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
} else {
|
||||
dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
}
|
||||
|
||||
return new StaticNatRuleImpl(ruleVO, dstIp);
|
||||
@ -1327,7 +1330,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
|
||||
UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId());
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");
|
||||
ex.addProxyObject(vm, vm.getId(), "vmId");
|
||||
@ -1343,9 +1346,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
|
||||
String dstIp;
|
||||
if (forRevoke) {
|
||||
dstIp = _networkMgr.getIpInNetworkIncludingRemoved(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
dstIp = _networkModel.getIpInNetworkIncludingRemoved(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
} else {
|
||||
dstIp = _networkMgr.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
dstIp = _networkModel.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
}
|
||||
|
||||
StaticNatImpl staticNat = new StaticNatImpl(sourceIp.getAllocatedToAccountId(), sourceIp.getAllocatedInDomainId(),
|
||||
@ -1361,7 +1364,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
// enable static nat if eIp capability is supported
|
||||
List<? extends Nic> nics = _nicDao.listByVmId(vm.getId());
|
||||
for (Nic nic : nics) {
|
||||
Network guestNetwork = _networkMgr.getNetwork(nic.getNetworkId());
|
||||
Network guestNetwork = _networkModel.getNetwork(nic.getNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm);
|
||||
|
||||
@ -66,6 +66,7 @@ import com.cloud.exception.ResourceInUseException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.security.SecurityGroupWork.Step;
|
||||
import com.cloud.network.security.SecurityRule.SecurityRuleType;
|
||||
import com.cloud.network.security.dao.SecurityGroupDao;
|
||||
@ -152,6 +153,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
DomainManager _domainMgr;
|
||||
@ -353,7 +356,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
||||
if (rule.getAllowedNetworkId() != null) {
|
||||
List<SecurityGroupVMMapVO> allowedInstances = _securityGroupVMMapDao.listBySecurityGroup(rule.getAllowedNetworkId(), State.Running);
|
||||
for (SecurityGroupVMMapVO ngmapVO : allowedInstances) {
|
||||
Nic defaultNic = _networkMgr.getDefaultNic(ngmapVO.getInstanceId());
|
||||
Nic defaultNic = _networkModel.getDefaultNic(ngmapVO.getInstanceId());
|
||||
if (defaultNic != null) {
|
||||
String cidr = defaultNic.getIp4Address();
|
||||
cidr = cidr + "/32";
|
||||
@ -1327,8 +1330,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
||||
VirtualMachine vm = _vmDao.findByIdIncludingRemoved(vmId);
|
||||
List<NicProfile> nics = _networkMgr.getNicProfiles(vm);
|
||||
for (NicProfile nic : nics) {
|
||||
Network network = _networkMgr.getNetwork(nic.getNetworkId());
|
||||
if (_networkMgr.isSecurityGroupSupportedInNetwork(network) && vm.getHypervisorType() != HypervisorType.VMware) {
|
||||
Network network = _networkModel.getNetwork(nic.getNetworkId());
|
||||
if (_networkModel.isSecurityGroupSupportedInNetwork(network) && vm.getHypervisorType() != HypervisorType.VMware) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.firewall.NetworkACLService;
|
||||
@ -79,7 +79,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
|
||||
@Inject
|
||||
FirewallRulesDao _firewallDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject
|
||||
|
||||
@ -62,6 +62,7 @@ import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
@ -138,6 +139,8 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
@Inject
|
||||
NetworkManager _ntwkMgr;
|
||||
@Inject
|
||||
NetworkModel _ntwkModel;
|
||||
@Inject
|
||||
NetworkService _ntwkSvc;
|
||||
@Inject
|
||||
IPAddressDao _ipAddressDao;
|
||||
@ -547,12 +550,12 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
|
||||
if (networkDomain == null) {
|
||||
// 1) Get networkDomain from the corresponding account
|
||||
networkDomain = _ntwkMgr.getAccountNetworkDomain(owner.getId(), zoneId);
|
||||
networkDomain = _ntwkModel.getAccountNetworkDomain(owner.getId(), zoneId);
|
||||
|
||||
|
||||
// 2) If null, generate networkDomain using domain suffix from the global config variables
|
||||
if (networkDomain == null) {
|
||||
networkDomain = "cs" + Long.toHexString(owner.getId()) + _ntwkMgr.getDefaultNetworkDomain();
|
||||
networkDomain = "cs" + Long.toHexString(owner.getId()) + _ntwkModel.getDefaultNetworkDomain();
|
||||
}
|
||||
}
|
||||
|
||||
@ -564,7 +567,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
{
|
||||
//the provider has to be enabled at least in one network in the zone
|
||||
for (PhysicalNetwork pNtwk : _pNtwkDao.listByZone(zoneId)) {
|
||||
if (_ntwkMgr.isProviderEnabledInPhysicalNetwork(pNtwk.getId(), Provider.VPCVirtualRouter.getName())) {
|
||||
if (_ntwkModel.isProviderEnabledInPhysicalNetwork(pNtwk.getId(), Provider.VPCVirtualRouter.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -961,7 +964,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
}
|
||||
|
||||
//2) validate network offering attributes
|
||||
List<Service> svcs = _ntwkMgr.listNetworkOfferingServices(guestNtwkOff.getId());
|
||||
List<Service> svcs = _ntwkModel.listNetworkOfferingServices(guestNtwkOff.getId());
|
||||
validateNtwkOffForVpc(guestNtwkOff, svcs);
|
||||
|
||||
//3) Check services/providers against VPC providers
|
||||
@ -977,14 +980,14 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
}
|
||||
|
||||
//4) Only one network in the VPC can support LB
|
||||
if (_ntwkMgr.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.Lb)) {
|
||||
if (_ntwkModel.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.Lb)) {
|
||||
List<? extends Network> networks = getVpcNetworks(vpc.getId());
|
||||
for (Network network : networks) {
|
||||
if (networkId != null && network.getId() == networkId.longValue()) {
|
||||
//skip my own network
|
||||
continue;
|
||||
} else {
|
||||
if (_ntwkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
if (_ntwkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
throw new InvalidParameterValueException("LB service is already supported " +
|
||||
"by network " + network + " in VPC " + vpc);
|
||||
}
|
||||
@ -996,7 +999,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
@Override
|
||||
public void validateNtwkOffForVpc(NetworkOffering guestNtwkOff, List<Service> supportedSvcs) {
|
||||
//1) in current release, only vpc provider is supported by Vpc offering
|
||||
List<Provider> providers = _ntwkMgr.getNtwkOffDistinctProviders(guestNtwkOff.getId());
|
||||
List<Provider> providers = _ntwkModel.getNtwkOffDistinctProviders(guestNtwkOff.getId());
|
||||
for (Provider provider : providers) {
|
||||
if (provider != Provider.VPCVirtualRouter) {
|
||||
throw new InvalidParameterValueException("Only provider of type " + Provider.VPCVirtualRouter.getName()
|
||||
@ -1091,7 +1094,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
|
||||
protected VpcProvider getVpcElement() {
|
||||
if (vpcElement == null) {
|
||||
vpcElement = ((VpcProvider)_ntwkMgr.getElementImplementingProvider(Provider.VPCVirtualRouter.getName()));
|
||||
vpcElement = ((VpcProvider)_ntwkModel.getElementImplementingProvider(Provider.VPCVirtualRouter.getName()));
|
||||
}
|
||||
|
||||
if (vpcElement == null) {
|
||||
@ -1219,7 +1222,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
}
|
||||
|
||||
protected PrivateGateway getPrivateGatewayProfile(VpcGateway gateway) {
|
||||
Network network = _ntwkMgr.getNetwork(gateway.getNetworkId());
|
||||
Network network = _ntwkModel.getNetwork(gateway.getNetworkId());
|
||||
return new PrivateGatewayProfile(gateway, network.getPhysicalNetworkId());
|
||||
}
|
||||
|
||||
@ -1246,7 +1249,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
|
||||
//Validate physical network
|
||||
if (physicalNetworkId == null) {
|
||||
List<? extends PhysicalNetwork> pNtwks = _ntwkMgr.getPhysicalNtwksSupportingTrafficType(vpc.getZoneId(), TrafficType.Guest);
|
||||
List<? extends PhysicalNetwork> pNtwks = _ntwkModel.getPhysicalNtwksSupportingTrafficType(vpc.getZoneId(), TrafficType.Guest);
|
||||
if (pNtwks.isEmpty() || pNtwks.size() != 1) {
|
||||
throw new InvalidParameterValueException("Physical network can't be determined; pass physical network id");
|
||||
}
|
||||
@ -1770,7 +1773,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Account owner = null;
|
||||
|
||||
IpAddress ipToAssoc = _ntwkMgr.getIp(ipId);
|
||||
IpAddress ipToAssoc = _ntwkModel.getIp(ipId);
|
||||
if (ipToAssoc != null) {
|
||||
_accountMgr.checkAccess(caller, null, true, ipToAssoc);
|
||||
owner = _accountMgr.getAccount(ipToAssoc.getAllocatedToAccountId());
|
||||
@ -1829,7 +1832,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||
boolean success = false;
|
||||
try {
|
||||
//unassign ip from the VPC router
|
||||
success = _ntwkMgr.applyIpAssociations(_ntwkMgr.getNetwork(networkId), true);
|
||||
success = _ntwkMgr.applyIpAssociations(_ntwkModel.getNetwork(networkId), true);
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
throw new CloudRuntimeException("Failed to apply ip associations for network id=" + networkId +
|
||||
" as a part of unassigning ip " + ipId + " from vpc", ex);
|
||||
|
||||
@ -42,7 +42,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.RemoteAccessVpnVO;
|
||||
@ -94,7 +94,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
||||
@Inject IPAddressDao _ipAddressDao;
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject DomainManager _domainMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
@Inject RulesManager _rulesMgr;
|
||||
@Inject DomainDao _domainDao;
|
||||
@Inject FirewallRulesDao _rulesDao;
|
||||
|
||||
@ -32,7 +32,7 @@ import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.net.UrlUtil;
|
||||
@ -43,7 +43,7 @@ public abstract class DiscovererBase implements Discoverer {
|
||||
private static final Logger s_logger = Logger.getLogger(DiscovererBase.class);
|
||||
@Inject protected ClusterDao _clusterDao;
|
||||
@Inject protected ConfigurationDao _configDao;
|
||||
@Inject protected NetworkManager _networkMgr;
|
||||
@Inject protected NetworkModel _networkMgr;
|
||||
@Inject protected HostDao _hostDao;
|
||||
|
||||
@Override
|
||||
|
||||
@ -125,7 +125,7 @@ import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuruManager;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Grouping.AllocationState;
|
||||
@ -240,7 +240,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
|
||||
@Inject
|
||||
protected SecondaryStorageVmManager _secStorageMgr;
|
||||
@Inject
|
||||
protected NetworkManager _networkMgr;
|
||||
protected NetworkModel _networkMgr;
|
||||
@Inject
|
||||
protected VolumeDao _volsDao;
|
||||
@Inject
|
||||
|
||||
@ -77,6 +77,7 @@ import com.cloud.keystore.KeystoreManager;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
@ -193,7 +194,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
@Inject
|
||||
protected SwiftManager _swiftMgr;
|
||||
@Inject
|
||||
private NetworkManager _networkMgr;
|
||||
protected NetworkManager _networkMgr;
|
||||
@Inject
|
||||
protected NetworkModel _networkModel;
|
||||
@Inject
|
||||
protected SnapshotDao _snapshotDao;
|
||||
|
||||
@ -380,7 +383,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
allowedCidrs.add(cidr);
|
||||
}
|
||||
}
|
||||
List<? extends Nic> nics = _networkMgr.getNicsForTraffic(secStorageVm.getId(), TrafficType.Management);
|
||||
List<? extends Nic> nics = _networkModel.getNicsForTraffic(secStorageVm.getId(), TrafficType.Management);
|
||||
setupCmd.setAllowedInternalSites(allowedCidrs.toArray(new String[allowedCidrs.size()]));
|
||||
}
|
||||
String copyPasswd = _configDao.getValue("secstorage.copy.password");
|
||||
@ -547,7 +550,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
|
||||
NetworkVO defaultNetwork = defaultNetworks.get(0);
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork, NetworkOfferingVO.SystemStorageNetwork);
|
||||
List<NetworkOfferingVO> 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);
|
||||
|
||||
@ -176,6 +176,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
@Inject
|
||||
protected HostPodDao _podDao = null;
|
||||
@Inject
|
||||
protected NetworkModel _networkModel = null;
|
||||
@Inject
|
||||
protected NetworkManager _networkMgr = null;
|
||||
@Inject
|
||||
protected StorageManager _storageMgr = null;
|
||||
@ -346,14 +348,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vmInstance.getTemplateId());
|
||||
if (template.getEnablePassword()) {
|
||||
Nic defaultNic = _networkMgr.getDefaultNic(vmId);
|
||||
Nic defaultNic = _networkModel.getDefaultNic(vmId);
|
||||
if (defaultNic == null) {
|
||||
s_logger.error("Unable to reset password for vm " + vmInstance + " as the instance doesn't have default nic");
|
||||
return false;
|
||||
}
|
||||
|
||||
Network defaultNetwork = _networkDao.findById(defaultNic.getNetworkId());
|
||||
NicProfile defaultNicProfile = new NicProfile(defaultNic, defaultNetwork, null, null, null, _networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork), _networkMgr.getNetworkTag(template.getHypervisorType(), defaultNetwork));
|
||||
NicProfile defaultNicProfile = new NicProfile(defaultNic, defaultNetwork, null, null, null, _networkModel.isSecurityGroupSupportedInNetwork(defaultNetwork), _networkModel.getNetworkTag(template.getHypervisorType(), defaultNetwork));
|
||||
VirtualMachineProfile<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vmInstance);
|
||||
vmProfile.setParameter(VirtualMachineProfile.Param.VmPassword, password);
|
||||
|
||||
@ -1756,7 +1758,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
private boolean updateUserDataInternal(UserVm vm)
|
||||
throws ResourceUnavailableException, InsufficientCapacityException {
|
||||
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
|
||||
Nic defaultNic = _networkMgr.getDefaultNic(vm.getId());
|
||||
Nic defaultNic = _networkModel.getDefaultNic(vm.getId());
|
||||
if (defaultNic == null) {
|
||||
s_logger.error("Unable to update userdata for vm id=" + vm.getId() + " as the instance doesn't have default nic");
|
||||
return false;
|
||||
@ -1764,12 +1766,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
Network defaultNetwork = _networkDao.findById(defaultNic.getNetworkId());
|
||||
NicProfile defaultNicProfile = new NicProfile(defaultNic, defaultNetwork, null, null, null,
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork),
|
||||
_networkMgr.getNetworkTag(template.getHypervisorType(), defaultNetwork));
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(defaultNetwork),
|
||||
_networkModel.getNetworkTag(template.getHypervisorType(), defaultNetwork));
|
||||
|
||||
VirtualMachineProfile<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>((VMInstanceVO)vm);
|
||||
|
||||
UserDataServiceProvider element = _networkMgr.getUserDataUpdateProvider(defaultNetwork);
|
||||
UserDataServiceProvider element = _networkModel.getUserDataUpdateProvider(defaultNetwork);
|
||||
if (element == null) {
|
||||
throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName() + " provider needed for UserData update");
|
||||
}
|
||||
@ -1994,7 +1996,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
_accountMgr.checkAccess(caller, null, true, owner);
|
||||
|
||||
// Get default guest network in Basic zone
|
||||
Network defaultNetwork = _networkMgr.getExclusiveGuestNetwork(zone.getId());
|
||||
Network defaultNetwork = _networkModel.getExclusiveGuestNetwork(zone.getId());
|
||||
|
||||
if (defaultNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find a default network to start a vm");
|
||||
@ -2006,7 +2008,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
if (securityGroupIdList != null && isVmWare) {
|
||||
throw new InvalidParameterValueException("Security group feature is not supported for vmWare hypervisor");
|
||||
} else if (!isVmWare && _networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork) && _networkMgr.canAddDefaultSecurityGroup()) {
|
||||
} else if (!isVmWare && _networkModel.isSecurityGroupSupportedInNetwork(defaultNetwork) && _networkModel.canAddDefaultSecurityGroup()) {
|
||||
//add the default securityGroup only if no security group is specified
|
||||
if(securityGroupIdList == null || securityGroupIdList.isEmpty()){
|
||||
if (securityGroupIdList == null) {
|
||||
@ -2046,7 +2048,7 @@ 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 = _networkMgr.getNetworkWithSecurityGroupEnabled(zone.getId());
|
||||
NetworkVO networkWithSecurityGroup = _networkModel.getNetworkWithSecurityGroupEnabled(zone.getId());
|
||||
if (networkWithSecurityGroup == null) {
|
||||
throw new InvalidParameterValueException("No network with security enabled is found in zone id=" + zone.getId());
|
||||
}
|
||||
@ -2069,7 +2071,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
throw new InvalidParameterValueException("Unable to find network by id " + networkIdList.get(0).longValue());
|
||||
}
|
||||
|
||||
if (!_networkMgr.isSecurityGroupSupportedInNetwork(network)) {
|
||||
if (!_networkModel.isSecurityGroupSupportedInNetwork(network)) {
|
||||
throw new InvalidParameterValueException("Network is not security group enabled: " + network.getId());
|
||||
}
|
||||
|
||||
@ -2085,7 +2087,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
throw new InvalidParameterValueException("Unable to find network by id " + networkIdList.get(0).longValue());
|
||||
}
|
||||
|
||||
boolean isSecurityGroupEnabled = _networkMgr.isSecurityGroupSupportedInNetwork(network);
|
||||
boolean isSecurityGroupEnabled = _networkModel.isSecurityGroupSupportedInNetwork(network);
|
||||
if (isSecurityGroupEnabled) {
|
||||
if (networkIdList.size() > 1) {
|
||||
throw new InvalidParameterValueException("Can't create a vm with multiple networks one of" +
|
||||
@ -2109,7 +2111,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
|
||||
// if network is security group enabled, and no security group is specified, then add the default security group automatically
|
||||
if (isSecurityGroupEnabledNetworkUsed && !isVmWare && _networkMgr.canAddDefaultSecurityGroup()) {
|
||||
if (isSecurityGroupEnabledNetworkUsed && !isVmWare && _networkModel.canAddDefaultSecurityGroup()) {
|
||||
|
||||
//add the default securityGroup only if no security group is specified
|
||||
if(securityGroupIdList == null || securityGroupIdList.isEmpty()){
|
||||
@ -2163,9 +2165,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
// get Virtual networks
|
||||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
List<NetworkVO> virtualNetworks = _networkModel.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
// Validate physical network
|
||||
PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (physicalNetwork == null) {
|
||||
@ -2207,7 +2209,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
}
|
||||
|
||||
_networkMgr.checkNetworkPermissions(owner, network);
|
||||
_networkModel.checkNetworkPermissions(owner, network);
|
||||
|
||||
//don't allow to use system networks
|
||||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
@ -2376,7 +2378,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(network, profile));
|
||||
|
||||
if (_networkMgr.isSecurityGroupSupportedInNetwork(network)) {
|
||||
if (_networkModel.isSecurityGroupSupportedInNetwork(network)) {
|
||||
securityGroupEnabled = true;
|
||||
}
|
||||
|
||||
@ -2440,7 +2442,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
if (hostNames.contains(hostName)) {
|
||||
throw new InvalidParameterValueException("The vm with hostName " + hostName
|
||||
+ " already exists in the network domain: " + ntwkDomain + "; network="
|
||||
+ _networkMgr.getNetwork(ntwkId));
|
||||
+ _networkModel.getNetwork(ntwkId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2760,7 +2762,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
UserContext ctx = UserContext.current();
|
||||
try {
|
||||
long networkId = ip.getAssociatedWithNetworkId();
|
||||
Network guestNetwork = _networkMgr.getNetwork(networkId);
|
||||
Network guestNetwork = _networkModel.getNetwork(networkId);
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
assert (offering.getAssociatePublicIP() == true) : "User VM should not have system owned public IP associated with it when offering configured not to associate public IP.";
|
||||
_rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true);
|
||||
@ -2815,7 +2817,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
|
||||
//check if vm is security group enabled
|
||||
if (_securityGroupMgr.isVmSecurityGroupEnabled(vmId) && _securityGroupMgr.getSecurityGroupsForVm(vmId).isEmpty() && !_securityGroupMgr.isVmMappedToDefaultSecurityGroup(vmId) && _networkMgr.canAddDefaultSecurityGroup()) {
|
||||
if (_securityGroupMgr.isVmSecurityGroupEnabled(vmId) && _securityGroupMgr.getSecurityGroupsForVm(vmId).isEmpty() && !_securityGroupMgr.isVmMappedToDefaultSecurityGroup(vmId) && _networkModel.canAddDefaultSecurityGroup()) {
|
||||
//if vm is not mapped to security group, create a mapping
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Vm " + vm + " is security group enabled, but not mapped to default security group; creating the mapping automatically");
|
||||
@ -3503,7 +3505,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
List<NetworkVO> networkList = new ArrayList<NetworkVO>();
|
||||
|
||||
// Get default guest network in Basic zone
|
||||
Network defaultNetwork = _networkMgr.getExclusiveGuestNetwork(zone.getId());
|
||||
Network defaultNetwork = _networkModel.getExclusiveGuestNetwork(zone.getId());
|
||||
|
||||
if (defaultNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find a default network to start a vm");
|
||||
@ -3515,7 +3517,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
if (securityGroupIdList != null && isVmWare) {
|
||||
throw new InvalidParameterValueException("Security group feature is not supported for vmWare hypervisor");
|
||||
} else if (!isVmWare && _networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork) && _networkMgr.canAddDefaultSecurityGroup()) {
|
||||
} else if (!isVmWare && _networkModel.isSecurityGroupSupportedInNetwork(defaultNetwork) && _networkModel.canAddDefaultSecurityGroup()) {
|
||||
if (securityGroupIdList == null) {
|
||||
securityGroupIdList = new ArrayList<Long>();
|
||||
}
|
||||
@ -3580,7 +3582,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
throw ex;
|
||||
}
|
||||
|
||||
_networkMgr.checkNetworkPermissions(newAccount, network);
|
||||
_networkModel.checkNetworkPermissions(newAccount, network);
|
||||
|
||||
//don't allow to use system networks
|
||||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
@ -3601,9 +3603,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
// get Virtual networks
|
||||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
List<NetworkVO> virtualNetworks = _networkModel.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
// Validate physical network
|
||||
PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (physicalNetwork == null) {
|
||||
|
||||
@ -109,6 +109,7 @@ import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.hypervisor.HypervisorGuruManager;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
@ -170,6 +171,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
@Inject
|
||||
protected NetworkManager _networkMgr;
|
||||
@Inject
|
||||
protected NetworkModel _networkModel;
|
||||
@Inject
|
||||
protected AgentManager _agentMgr;
|
||||
@Inject
|
||||
protected VMInstanceDao _vmDao;
|
||||
@ -2153,9 +2156,9 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
|
||||
List<NicVO> nics = _nicsDao.listByVmId(profile.getId());
|
||||
for (NicVO nic : nics) {
|
||||
Network network = _networkMgr.getNetwork(nic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(nic.getNetworkId());
|
||||
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null,
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(profile.getHypervisorType(), network));
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(profile.getHypervisorType(), network));
|
||||
profile.addNic(nicProfile);
|
||||
}
|
||||
|
||||
@ -2533,13 +2536,13 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
if (broadcastUri != null) {
|
||||
nic = _nicsDao.findByNetworkIdInstanceIdAndBroadcastUri(network.getId(), vm.getId(), broadcastUri.toString());
|
||||
} else {
|
||||
nic = _networkMgr.getNicInNetwork(vm.getId(), network.getId());
|
||||
nic = _networkModel.getNicInNetwork(vm.getId(), network.getId());
|
||||
}
|
||||
|
||||
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
_networkMgr.getNetworkRate(network.getId(), vm.getId()),
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(network),
|
||||
_networkMgr.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network));
|
||||
_networkModel.getNetworkRate(network.getId(), vm.getId()),
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(network),
|
||||
_networkModel.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network));
|
||||
|
||||
//1) Unplug the nic
|
||||
NicTO nicTO = toNicTO(nicProfile, vmProfile.getVirtualMachine().getHypervisorType());
|
||||
|
||||
183
server/test/com/cloud/network/MockFirewallManagerImpl.java
Normal file
183
server/test/com/cloud/network/MockFirewallManagerImpl.java
Normal file
@ -0,0 +1,183 @@
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.api.commands.ListFirewallRulesCmd;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.firewall.FirewallService;
|
||||
import com.cloud.network.rules.FirewallManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.network.rules.FirewallRule.FirewallRuleType;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
@Local(value = {FirewallManager.class, FirewallService.class})
|
||||
public class MockFirewallManagerImpl implements FirewallManager,
|
||||
FirewallService, Manager {
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule createFirewallRule(FirewallRule rule)
|
||||
throws NetworkRuleConflictException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<? extends FirewallRule>, Integer> listFirewallRules(
|
||||
ListFirewallRulesCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeFirewallRule(long ruleId, boolean apply) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyFirewallRules(long ipId, Account caller)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule getFirewallRule(long ruleId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeRelatedFirewallRule(long ruleId, boolean apply) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectRulesConflict(FirewallRule newRule)
|
||||
throws NetworkRuleConflictException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateFirewallRule(Account caller, IPAddressVO ipAddress,
|
||||
Integer portStart, Integer portEnd, String proto, Purpose purpose,
|
||||
FirewallRuleType type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyRules(List<? extends FirewallRule> rules,
|
||||
boolean continueOnError, boolean updateRulesInDB)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyFirewallRules(List<FirewallRuleVO> rules,
|
||||
boolean continueOnError, Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revokeRule(FirewallRuleVO rule, Account caller, long userId,
|
||||
boolean needUsageEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeFirewallRulesForIp(long ipId, long userId,
|
||||
Account caller) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeFirewallRule(long ruleId, boolean apply,
|
||||
Account caller, long userId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule createFirewallRule(long ipAddrId, Account caller,
|
||||
String xId, Integer portStart, Integer portEnd, String protocol,
|
||||
List<String> sourceCidrList, Integer icmpCode, Integer icmpType,
|
||||
Long relatedRuleId, FirewallRuleType type, long networkId)
|
||||
throws NetworkRuleConflictException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller,
|
||||
Integer startPort, Integer endPort, String protocol,
|
||||
Integer icmpCode, Integer icmpType, Long relatedRuleId,
|
||||
long networkId) throws NetworkRuleConflictException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAllFirewallRulesForNetwork(long networkId,
|
||||
long userId, Account caller) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeFirewallRulesForVm(long vmId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addSystemFirewallRules(IPAddressVO ip, Account acct) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRule(FirewallRule rule) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
295
server/test/com/cloud/network/MockRulesManagerImpl.java
Normal file
295
server/test/com/cloud/network/MockRulesManagerImpl.java
Normal file
@ -0,0 +1,295 @@
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.api.commands.ListPortForwardingRulesCmd;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.RulesService;
|
||||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value = {RulesManager.class, RulesService.class})
|
||||
public class MockRulesManagerImpl implements RulesManager, Manager, RulesService {
|
||||
|
||||
@Override
|
||||
public Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(
|
||||
Long ipId, Long id, Long vmId, Long start, Long size,
|
||||
String accountName, Long domainId, Long projectId,
|
||||
boolean isRecursive, boolean listAll) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortForwardingRule createPortForwardingRule(PortForwardingRule rule,
|
||||
Long vmId, boolean openFirewall)
|
||||
throws NetworkRuleConflictException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokePortForwardingRule(long ruleId, boolean apply) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<? extends PortForwardingRule>, Integer> listPortForwardingRules(
|
||||
ListPortForwardingRulesCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyPortForwardingRules(long ipAdddressId, Account caller)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableStaticNat(long ipAddressId, long vmId, long networkId,
|
||||
boolean isSystemVm) throws NetworkRuleConflictException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortForwardingRule getPortForwardigRule(long ruleId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule getFirewallRule(long ruleId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaticNatRule createStaticNatRule(StaticNatRule rule,
|
||||
boolean openFirewall) throws NetworkRuleConflictException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeStaticNatRule(long ruleId, boolean apply) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNatRules(long ipAdddressId, Account caller)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaticNatRule buildStaticNatRule(FirewallRule rule, boolean forRevoke) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSourceCidrs(long ruleId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableStaticNat(long ipId)
|
||||
throws ResourceUnavailableException, NetworkRuleConflictException,
|
||||
InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyPortForwardingRules(long ipAddressId,
|
||||
boolean continueOnError, Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNatRulesForIp(long sourceIpId,
|
||||
boolean continueOnError, Account caller, boolean forRevoke) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyPortForwardingRulesForNetwork(long networkId,
|
||||
boolean continueOnError, Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNatRulesForNetwork(long networkId,
|
||||
boolean continueOnError, Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkIpAndUserVm(IpAddress ipAddress, UserVm userVm,
|
||||
Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkRuleAndUserVm(FirewallRule rule, UserVm userVm,
|
||||
Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAllPFAndStaticNatRulesForIp(long ipId, long userId,
|
||||
Account caller) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAllPFStaticNatRulesForNetwork(long networkId,
|
||||
long userId, Account caller) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends FirewallRule> listFirewallRulesByIp(long ipAddressId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends PortForwardingRule> listPortForwardingRulesForApplication(
|
||||
long ipId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends PortForwardingRule> gatherPortForwardingRulesForApplication(
|
||||
List<? extends IpAddress> addrs) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokePortForwardingRulesForVm(long vmId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeStaticNatRulesForVm(long vmId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule[] reservePorts(IpAddress ip, String protocol,
|
||||
Purpose purpose, boolean openFirewall, Account caller, int... ports)
|
||||
throws NetworkRuleConflictException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean releasePorts(long ipId, String protocol, Purpose purpose,
|
||||
int... ports) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PortForwardingRuleVO> listByNetworkId(long networkId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNatForIp(long sourceIpId,
|
||||
boolean continueOnError, Account caller, boolean forRevoke) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNatsForNetwork(long networkId,
|
||||
boolean continueOnError, Account caller) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSystemIpAndEnableStaticNatForVm(VirtualMachine vm,
|
||||
boolean getNewIp) throws InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableStaticNat(long ipAddressId, Account caller,
|
||||
long callerUserId, boolean releaseIpIfElastic)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNatForNetwork(long networkId,
|
||||
boolean continueOnError, Account caller, boolean forRevoke) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return "MockRulesManagerImpl";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package com.cloud.network.vpn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.element.RemoteAccessVPNServiceProvider;
|
||||
|
||||
@Local (value = RemoteAccessVPNServiceProvider.class)
|
||||
public class MockRemoteAccessVPNServiceProvider implements
|
||||
RemoteAccessVPNServiceProvider {
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MockRemoteAccessVPNServiceProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] applyVpnUsers(RemoteAccessVpn vpn,
|
||||
List<? extends VpnUser> users) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startVpn(Network network, RemoteAccessVpn vpn)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopVpn(Network network, RemoteAccessVpn vpn)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
91
server/test/com/cloud/network/vpn/RemoteAccessVpnTest.java
Normal file
91
server/test/com/cloud/network/vpn/RemoteAccessVpnTest.java
Normal file
@ -0,0 +1,91 @@
|
||||
package com.cloud.network.vpn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.configuration.DefaultInterceptorLibrary;
|
||||
import com.cloud.configuration.dao.ConfigurationDaoImpl;
|
||||
import com.cloud.domain.dao.DomainDaoImpl;
|
||||
import com.cloud.event.dao.UsageEventDaoImpl;
|
||||
import com.cloud.network.MockFirewallManagerImpl;
|
||||
import com.cloud.network.MockNetworkManagerImpl;
|
||||
import com.cloud.network.MockRulesManagerImpl;
|
||||
import com.cloud.network.dao.FirewallRulesDaoImpl;
|
||||
import com.cloud.network.dao.IPAddressDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.element.RemoteAccessVPNServiceProvider;
|
||||
import com.cloud.user.MockAccountManagerImpl;
|
||||
import com.cloud.user.MockDomainManagerImpl;
|
||||
import com.cloud.user.dao.AccountDaoImpl;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.MockComponentLocator;
|
||||
|
||||
public class RemoteAccessVpnTest {
|
||||
private MockComponentLocator locator;
|
||||
private final static Logger s_logger = Logger.getLogger(RemoteAccessVpnTest.class);
|
||||
|
||||
|
||||
private static void addDaos(MockComponentLocator locator) {
|
||||
locator.addDao("AccountDao", AccountDaoImpl.class);
|
||||
locator.addDao("VpnUserDao", VpnUserDaoImpl.class);
|
||||
locator.addDao("FirewallRulesDao", FirewallRulesDaoImpl.class);
|
||||
locator.addDao("IPAddressDao", IPAddressDaoImpl.class);
|
||||
locator.addDao("DomainDao", DomainDaoImpl.class);
|
||||
locator.addDao("UsageEventDao", UsageEventDaoImpl.class);
|
||||
locator.addDao("RemoteAccessVpnDao", RemoteAccessVpnDaoImpl.class);
|
||||
locator.addDao("ConfigurationDao", ConfigurationDaoImpl.class);
|
||||
|
||||
}
|
||||
|
||||
private static void addManagers(MockComponentLocator locator) {
|
||||
locator.addManager("AccountManager", MockAccountManagerImpl.class);
|
||||
locator.addManager("DomainManager", MockDomainManagerImpl.class);
|
||||
locator.addManager("NetworkManager", MockNetworkManagerImpl.class);
|
||||
locator.addManager("RulesManager", MockRulesManagerImpl.class);
|
||||
locator.addManager("FirewallManager", MockFirewallManagerImpl.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
locator = new MockComponentLocator("management-server");
|
||||
addDaos(locator);
|
||||
addManagers(locator);
|
||||
s_logger.info("Finished setUp");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInjected() throws Exception {
|
||||
List<Pair<String, Class<? extends RemoteAccessVPNServiceProvider>>> list =
|
||||
new ArrayList<Pair<String, Class<? extends RemoteAccessVPNServiceProvider>>>();
|
||||
list.add(new Pair<String, Class<? extends RemoteAccessVPNServiceProvider>>("RemoteAccessVPNServiceProvider", MockRemoteAccessVPNServiceProvider.class));
|
||||
locator.addAdapterChain(RemoteAccessVPNServiceProvider.class, list);
|
||||
s_logger.info("Finished add adapter");
|
||||
locator.makeActive(new DefaultInterceptorLibrary());
|
||||
s_logger.info("Finished make active");
|
||||
RemoteAccessVpnManagerImpl vpnMgr = ComponentLocator.inject(RemoteAccessVpnManagerImpl.class);
|
||||
s_logger.info("Finished inject");
|
||||
Assert.assertTrue(vpnMgr.configure("RemoteAccessVpnMgr",new HashMap<String, Object>()) );
|
||||
Assert.assertTrue(vpnMgr.start());
|
||||
int numProviders = vpnMgr.getRemoteAccessVPNServiceProviders().size();
|
||||
Assert.assertTrue(numProviders > 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user