use of com.cloud.network.Network.Service in project cloudstack by apache.
the class VpcVirtualRouterElement method applyIps.
@Override
public boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Service> services) throws ResourceUnavailableException {
boolean canHandle = true;
for (final Service service : services) {
if (!canHandle(network, service)) {
canHandle = false;
break;
}
}
boolean result = true;
if (canHandle) {
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual " + "router doesn't exist in the network " + network.getId());
return false;
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.associatePublicIP(network, ipAddress, domainRouterVO);
}
}
return result;
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class NetworkOfferingServiceMapDaoImpl method areServicesSupportedByNetworkOffering.
@Override
public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
SearchCriteria<NetworkOfferingServiceMapVO> sc = MultipleServicesSearch.create();
sc.setParameters("networkOfferingId", networkOfferingId);
if (services != null) {
String[] servicesStr = new String[services.length];
int i = 0;
for (Service service : services) {
servicesStr[i] = service.getName();
i++;
}
sc.setParameters("service", (Object[]) servicesStr);
}
List<NetworkOfferingServiceMapVO> offeringServices = listBy(sc);
if (services != null) {
if (offeringServices.size() == services.length) {
return true;
}
} else if (!offeringServices.isEmpty()) {
return true;
}
return false;
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class ContrailManagerImpl method locatePublicNetworkOffering.
private NetworkOffering locatePublicNetworkOffering(String offeringName, String offeringDisplayText, Provider provider) {
List<? extends NetworkOffering> offerList = _configService.listNetworkOfferings(TrafficType.Public, false);
for (NetworkOffering offer : offerList) {
if (offer.getName().equals(offeringName)) {
if (offer.getState() != NetworkOffering.State.Enabled) {
return EnableNetworkOffering(offer.getId());
}
return offer;
}
}
Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Service, Set<Provider>>();
Set<Provider> providerSet = new HashSet<Provider>();
providerSet.add(provider);
final Service[] services = { Service.Connectivity, Service.Dhcp, Service.NetworkACL, Service.StaticNat, Service.SourceNat };
for (Service svc : services) {
serviceProviderMap.put(svc, providerSet);
}
ConfigurationManager configMgr = (ConfigurationManager) _configService;
NetworkOfferingVO voffer = configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Public, null, true, Availability.Optional, null, serviceProviderMap, true, Network.GuestType.Shared, false, null, false, null, true, false, null, true, null, false);
voffer.setState(NetworkOffering.State.Enabled);
long id = voffer.getId();
_networkOfferingDao.update(id, voffer);
return _networkOfferingDao.findById(id);
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class NuageVspElement method implementVpc.
@Override
public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
List<VpcOfferingServiceMapVO> vpcOfferingServices = _vpcOfferingSrvcDao.listByVpcOffId(vpc.getVpcOfferingId());
Map<Network.Service, Set<Network.Provider>> supportedVpcServices = NuageVspManagerImpl.NUAGE_VSP_VPC_SERVICE_MAP;
for (VpcOfferingServiceMapVO vpcOfferingService : vpcOfferingServices) {
Network.Service service = Network.Service.getService(vpcOfferingService.getService());
if (!supportedVpcServices.containsKey(service)) {
s_logger.warn(String.format("NuageVsp doesn't support service %s for VPCs", service.getName()));
return false;
}
Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
if (!supportedVpcServices.get(service).contains(provider)) {
s_logger.warn(String.format("NuageVsp doesn't support provider %s for service %s for VPCs", provider.getName(), service.getName()));
return false;
}
}
return true;
}
use of com.cloud.network.Network.Service in project cloudstack by apache.
the class ApiResponseHelper method createVpcResponse.
@Override
public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) {
VpcResponse response = new VpcResponse();
response.setId(vpc.getUuid());
response.setName(vpc.getName());
response.setDisplayText(vpc.getDisplayText());
response.setState(vpc.getState().name());
VpcOffering voff = ApiDBUtils.findVpcOfferingById(vpc.getVpcOfferingId());
if (voff != null) {
response.setVpcOfferingId(voff.getUuid());
}
response.setCidr(vpc.getCidr());
response.setRestartRequired(vpc.isRestartRequired());
response.setNetworkDomain(vpc.getNetworkDomain());
response.setForDisplay(vpc.isDisplay());
response.setUsesDistributedRouter(vpc.usesDistributedRouter());
response.setRedundantRouter(vpc.isRedundant());
response.setRegionLevelVpc(vpc.isRegionLevelVpc());
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId());
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
for (Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet()) {
Service service = entry.getKey();
Set<Provider> serviceProviders = entry.getValue();
ServiceResponse svcRsp = new ServiceResponse();
// skip gateway service
if (service == Service.Gateway) {
continue;
}
svcRsp.setName(service.getName());
List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
for (Provider provider : serviceProviders) {
if (provider != null) {
ProviderResponse providerRsp = new ProviderResponse();
providerRsp.setName(provider.getName());
providers.add(providerRsp);
}
}
svcRsp.setProviders(providers);
serviceResponses.add(svcRsp);
}
List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
List<? extends Network> networks = ApiDBUtils.listVpcNetworks(vpc.getId());
for (Network network : networks) {
NetworkResponse ntwkRsp = createNetworkResponse(view, network);
networkResponses.add(ntwkRsp);
}
DataCenter zone = ApiDBUtils.findZoneById(vpc.getZoneId());
if (zone != null) {
response.setZoneId(zone.getUuid());
response.setZoneName(zone.getName());
}
response.setNetworks(networkResponses);
response.setServices(serviceResponses);
populateOwner(response, vpc);
// set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.Vpc, vpc.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
for (ResourceTag tag : tags) {
ResourceTagResponse tagResponse = createResourceTagResponse(tag, true);
CollectionUtils.addIgnoreNull(tagResponses, tagResponse);
}
response.setTags(tagResponses);
response.setObjectName("vpc");
return response;
}
Aggregations