use of com.cloud.network.Network.Service in project cloudstack by apache.
the class VpcManagerImpl method validateNtwkOffForNtwkInVpc.
@DB
@Override
public void validateNtwkOffForNtwkInVpc(final Long networkId, final long newNtwkOffId, final String newCidr, final String newNetworkDomain, final Vpc vpc, final String gateway, final Account networkOwner, final Long aclId) {
final NetworkOffering guestNtwkOff = _entityMgr.findById(NetworkOffering.class, newNtwkOffId);
if (guestNtwkOff == null) {
throw new InvalidParameterValueException("Can't find network offering by id specified");
}
if (networkId == null) {
// 1) Validate attributes that has to be passed in when create new
// guest network
validateNewVpcGuestNetwork(newCidr, gateway, networkOwner, vpc, newNetworkDomain);
}
// 2) validate network offering attributes
final List<Service> svcs = _ntwkModel.listNetworkOfferingServices(guestNtwkOff.getId());
validateNtwkOffForVpc(guestNtwkOff, svcs);
// 3) Check services/providers against VPC providers
final List<NetworkOfferingServiceMapVO> networkProviders = _ntwkOffServiceDao.listByNetworkOfferingId(guestNtwkOff.getId());
for (final NetworkOfferingServiceMapVO nSvcVO : networkProviders) {
final String pr = nSvcVO.getProvider();
final String service = nSvcVO.getService();
if (_vpcOffServiceDao.findByServiceProviderAndOfferingId(service, pr, vpc.getVpcOfferingId()) == null) {
throw new InvalidParameterValueException("Service/provider combination " + service + "/" + pr + " is not supported by VPC " + vpc);
}
}
// Internal LB can be supported on multiple VPC tiers
if (_ntwkModel.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.Lb) && guestNtwkOff.getPublicLb()) {
final List<? extends Network> networks = getVpcNetworks(vpc.getId());
for (final Network network : networks) {
if (networkId != null && network.getId() == networkId.longValue()) {
// skip my own network
continue;
} else {
final NetworkOffering otherOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
// public lb support
if (_ntwkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb) && otherOff.getPublicLb() && guestNtwkOff.getId() != otherOff.getId()) {
throw new InvalidParameterValueException("Public LB service is already supported " + "by network " + network + " in VPC " + vpc);
}
}
}
}
// network offering
if (aclId != null && !_ntwkModel.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.NetworkACL)) {
throw new InvalidParameterValueException("Cannot apply NetworkACL. Network Offering does not support NetworkACL service");
}
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class VpcManagerImpl method checkCapabilityPerServiceProvider.
protected void checkCapabilityPerServiceProvider(final Set<Provider> providers, final Capability capability, final Service service) {
// TODO Shouldn't it fail it there are no providers?
if (providers != null) {
for (final Provider provider : providers) {
final NetworkElement element = _ntwkModel.getElementImplementingProvider(provider.getName());
final Map<Service, Map<Capability, String>> capabilities = element.getCapabilities();
if (capabilities != null && !capabilities.isEmpty()) {
final Map<Capability, String> connectivityCapabilities = capabilities.get(service);
if (connectivityCapabilities == null || connectivityCapabilities != null && !connectivityCapabilities.keySet().contains(capability)) {
throw new InvalidParameterValueException(String.format("Provider %s does not support %s capability.", provider.getName(), capability.getName()));
}
}
}
}
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class VirtualRouterElementTest method mockMgrs.
/**
* @param networks
* @param offerings
* @throws ConcurrentOperationException
*/
private void mockMgrs() throws ConcurrentOperationException {
final Service service = Service.Connectivity;
testNetwork.setState(Network.State.Implementing);
testNetwork.setTrafficType(TrafficType.Guest);
when(_networkMdl.isProviderEnabledInPhysicalNetwork(0L, "VirtualRouter")).thenReturn(true);
when(_networkMdl.isProviderSupportServiceInNetwork(testNetwork.getId(), service, Network.Provider.VirtualRouter)).thenReturn(true);
when(_networkMdl.isProviderForNetwork(Network.Provider.VirtualRouter, 0L)).thenReturn(true);
when(testVMProfile.getType()).thenReturn(VirtualMachine.Type.User);
when(testVMProfile.getHypervisorType()).thenReturn(HypervisorType.XenServer);
final List<NetworkVO> networks = new ArrayList<NetworkVO>(1);
networks.add(testNetwork);
final List<NetworkOfferingVO> offerings = new ArrayList<NetworkOfferingVO>(1);
offerings.add(testOffering);
doReturn(offerings).when(_networkModel).getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
doReturn(networks).when(_networkMgr).setupNetwork(any(Account.class), any(NetworkOffering.class), any(DeploymentPlan.class), any(String.class), any(String.class), anyBoolean());
// being anti-social and testing my own case first
doReturn(HypervisorType.XenServer).when(_resourceMgr).getDefaultHypervisor(anyLong());
doReturn(new AccountVO()).when(_accountMgr).getAccount(testNetwork.getAccountId());
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class VpcManagerImplTest method prepareVpcManagerForCheckingCapabilityPerService.
protected Set<Network.Provider> prepareVpcManagerForCheckingCapabilityPerService(Service service, Map<Capability, String> capabilities) {
final Set<Network.Provider> providers = new HashSet<>();
providers.add(Provider.VPCVirtualRouter);
final Network.Capability capability = Capability.DistributedRouter;
final boolean regionLevel = true;
final boolean distributedRouter = true;
final NetworkElement nwElement1 = mock(NetworkElement.class);
this.manager._ntwkModel = mock(NetworkModel.class);
when(this.manager._ntwkModel.getElementImplementingProvider(Provider.VPCVirtualRouter.getName())).thenReturn(nwElement1);
final Map<Service, Map<Network.Capability, String>> capabilitiesService1 = new HashMap<>();
when(nwElement1.getCapabilities()).thenReturn(capabilitiesService1);
capabilities.put(Capability.RegionLevelVpc, "");
capabilities.put(Capability.DistributedRouter, "");
capabilitiesService1.put(service, capabilities);
return providers;
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class InternalLbElementTest method verifyApplyIps.
//TEST FOR applyIps METHOD
@Test
public void verifyApplyIps() throws ResourceUnavailableException {
List<PublicIp> ips = new ArrayList<PublicIp>();
boolean result = _lbEl.applyIps(new NetworkVO(), ips, new HashSet<Service>());
assertTrue("Wrong value is returned by applyIps method", result);
}
Aggregations