@Override public boolean applyStaticRoutesForVpc(final long vpcId) throws ResourceUnavailableException { final Account caller = CallContext.current().getCallingAccount(); final List<? extends StaticRoute> routes = _staticRouteDao.listByVpcId(vpcId); return applyStaticRoutes(routes, caller, true); }
@Override @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_DELETE, eventDescription = "deleting static route") public boolean revokeStaticRoute(final long routeId) throws ResourceUnavailableException { final Account caller = CallContext.current().getCallingAccount(); final StaticRouteVO route = _staticRouteDao.findById(routeId); if (route == null) { throw new InvalidParameterValueException("Unable to find static route by id"); } _accountMgr.checkAccess(caller, null, false, route); markStaticRouteForRevoke(route, caller); return applyStaticRoutesForVpc(route.getVpcId()); }
private void validateConnectivtyServiceCapabilities(final Set<Provider> providers, final Map serviceCapabilitystList) { if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) { final Collection serviceCapabilityCollection = serviceCapabilitystList.values(); final Iterator iter = serviceCapabilityCollection.iterator(); while (iter.hasNext()) { final HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next(); Capability capability = null; final String svc = svcCapabilityMap.get(SERVICE); final String capabilityName = svcCapabilityMap.get(CAPABILITYTYPE); final String capabilityValue = svcCapabilityMap.get(CAPABILITYVALUE); if (capabilityName != null) { capability = Capability.getCapability(capabilityName); } if (capability == null || capabilityValue == null) { throw new InvalidParameterValueException("Invalid capability:" + capabilityName + " capability value:" + capabilityValue); } final Service usedService = Service.getService(svc); checkCapabilityPerServiceProvider(providers, capability, usedService); if (!capabilityValue.equalsIgnoreCase(TRUE_VALUE) && !capabilityValue.equalsIgnoreCase(FALSE_VALUE)) { throw new InvalidParameterValueException("Invalid Capability value:" + capabilityValue + " specified."); } } } }
final Set<Provider> defaultProviders = new HashSet<Provider>(); defaultProviders.add(Provider.VPCVirtualRouter); for (final Service svc : getSupportedServices()) { if (svc == Service.Lb) { final Set<Provider> lbProviders = new HashSet<Provider>(); createVpcOffering(VpcOffering.defaultVPCOfferingName, VpcOffering.defaultVPCOfferingName, svcProviderMap, true, State.Enabled, null, false, false, false); final Set<Provider> defaultProviders = new HashSet<Provider>(); defaultProviders.add(Provider.VPCVirtualRouter); for (final Service svc : getSupportedServices()) { if (svc == Service.Lb) { final Set<Provider> lbProviders = new HashSet<Provider>(); createVpcOffering(VpcOffering.defaultVPCNSOfferingName, VpcOffering.defaultVPCNSOfferingName, svcProviderMap, false, State.Enabled, null, false, false, false); final Set<Provider> defaultProviders = new HashSet<Provider>(); defaultProviders.add(Provider.VPCVirtualRouter); for (final Service svc : getSupportedServices()) { if (svc == Service.Lb) { final Set<Provider> lbProviders = new HashSet<Provider>(); createVpcOffering(VpcOffering.redundantVPCOfferingName, VpcOffering.redundantVPCOfferingName, svcProviderMap, true, State.Enabled, null, false, false, true);
final List<Provider> providersToImplement = getVpcProviders(vo.getVpcId()); final PrivateGateway gateway = getVpcPrivateGateway(gatewayId); for (final VpcProvider provider : getVpcElements()) { if (providersToImplement.contains(provider.getProvider())) { if (!provider.createPrivateGateway(gateway)) { return getVpcPrivateGateway(gatewayId); } else { s_logger.warn("Private gateway " + gateway + " failed to apply on the backend"); if (deletePrivateGatewayFromTheDB(getVpcPrivateGateway(gatewayId))) { s_logger.warn("Successfully destroyed vpc " + vo + " that failed to start"); } else {
validateConnectivtyServiceCapabilities(svcProviderMap.get(Service.Connectivity), serviceCapabilitystList); final boolean supportsDistributedRouter = isVpcOfferingSupportsDistributedRouter(serviceCapabilitystList); final boolean offersRegionLevelVPC = isVpcOfferingForRegionLevelVpc(serviceCapabilitystList); final boolean redundantRouter = isVpcOfferingRedundantRouter(serviceCapabilitystList); final VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false, null, serviceOfferingId, supportsDistributedRouter, offersRegionLevelVPC, redundantRouter); CallContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name);
final Vpc vpc = getActiveVpc(vpcId); if (vpc == null) { final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find Enabled VPC by id specified"); if (!startVpc(vpc, dest, context)) { s_logger.warn("Failed to start vpc " + vpc); result = false; if (destroyVpc(vpc, caller, callerUser.getId())) { s_logger.warn("Successfully destroyed vpc " + vpc + " that failed to start"); } else {
if (!revokeStaticRoutesForVpc(vpcId, caller)) { s_logger.warn("Failed to revoke static routes for vpc " + vpcId + " as a part of cleanup vpc process"); return false; final List<PrivateGateway> gateways = getVpcPrivateGateways(vpcId); if (gateways != null) { for (final PrivateGateway gateway : gateways) { if (gateway != null) { s_logger.debug("Deleting private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup"); if (!deleteVpcPrivateGateway(gateway.getId())) { success = false; s_logger.debug("Failed to delete private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup");
if (!shutdownVpc(vpc.getId())) { s_logger.warn("Failed to shutdown vpc " + vpc + " as a part of vpc destroy process"); return false; if (!cleanupVpcResources(vpc.getId(), caller, callerUserId)) { s_logger.warn("Failed to cleanup resources for vpc " + vpc); return false;
@DB protected boolean revokeStaticRoutesForVpc(final long vpcId, final Account caller) throws ResourceUnavailableException { // get all static routes for the vpc final List<StaticRouteVO> routes = _staticRouteDao.listByVpcId(vpcId); s_logger.debug("Found " + routes.size() + " to revoke for the vpc " + vpcId); if (!routes.isEmpty()) { // mark all of them as revoke Transaction.execute(new TransactionCallbackNoReturn() { @Override public void doInTransactionWithoutResult(final TransactionStatus status) { for (final StaticRouteVO route : routes) { markStaticRouteForRevoke(route, caller); } } }); return applyStaticRoutesForVpc(vpcId); } return true; }
for (final VpcVO vpc : inactiveVpcs) { s_logger.debug("Cleaning up " + vpc); destroyVpc(vpc, _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM);
if (areServicesSupportedByVpcOffering(offering.getId(), supportedServices)) { supportedOfferings.add(offering);
vpcOff.getRedundantRouter()); return createVpc(displayVpc, vpc);
final List<Provider> providersToImplement = getVpcProviders(gatewayVO.getVpcId()); final PrivateGateway gateway = getVpcPrivateGateway(gatewayId); for (final VpcProvider provider : getVpcElements()) { if (providersToImplement.contains(provider.getProvider())) { if (provider.deletePrivateGateway(gateway)) { return deletePrivateGatewayFromTheDB(gateway);
@Override @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "Applying static route", async = true) public boolean applyStaticRoute(final long routeId) throws ResourceUnavailableException { final StaticRoute route = _staticRouteDao.findById(routeId); return applyStaticRoutesForVpc(route.getVpcId()); }
@Override @ActionEvent(eventType = EventTypes.EVENT_VPC_DELETE, eventDescription = "deleting VPC") public boolean deleteVpc(final long vpcId) throws ConcurrentOperationException, ResourceUnavailableException { CallContext.current().setEventDetails(" Id: " + vpcId); final CallContext ctx = CallContext.current(); // Verify vpc id final Vpc vpc = _vpcDao.findById(vpcId); if (vpc == null) { throw new InvalidParameterValueException("unable to find VPC id=" + vpcId); } // verify permissions _accountMgr.checkAccess(ctx.getCallingAccount(), null, false, vpc); _resourceTagDao.removeByIdAndType(vpcId, ResourceObjectType.Vpc); return destroyVpc(vpc, ctx.getCallingAccount(), ctx.getCallingUserId()); }
if (areServicesSupportedByVpcOffering(vpc.getVpcOfferingId(), supportedServices)) { supportedVpcs.add(vpc);
if (!applyStaticRoutes(staticRouteProfiles)) { s_logger.warn("Routes are not completely applied"); return false;