@Override public void doInTransactionWithoutResult(TransactionStatus status) { VpcOffering offering = _vpcOffDao.findByUniqueName(nuageVPCOfferingName); if (offering == null) { if (s_logger.isDebugEnabled()) { s_logger.debug("Creating default Nuage VPC offering " + nuageVPCOfferingName); } createVpcOffering(nuageVPCOfferingName, nuageVPCOfferingDisplayText, DEFAULT_NUAGE_VSP_VPC_SERVICE_MAP, true, VpcOffering.State.Enabled, null); } else { updateVpcOffering(offering, DEFAULT_NUAGE_VSP_VPC_SERVICE_MAP); } } });
@Override public VpcOffering getVpcOffering(final long vpcOffId) { return _vpcOffDao.findById(vpcOffId); }
private VpcOffering locateVpcOffering() { VpcOffering vpcOffer = _vpcOffDao.findByUniqueName(juniperVPCOfferingName); if (vpcOffer != null) { if (((VpcOfferingVO)vpcOffer).getState() == VpcOffering.State.Enabled) { _vpcOffDao.update(id, (VpcOfferingVO)vpcOffer); return vpcOffer; ((VpcOfferingVO)vpcOffer).setState(VpcOffering.State.Enabled); long id = vpcOffer.getId(); _vpcOffDao.update(id, (VpcOfferingVO)vpcOffer); return _vpcOffDao.findById(id);
final VpcOfferingVO offeringToUpdate = _vpcOffDao.findById(vpcOffId); if (offeringToUpdate == null) { throw new InvalidParameterValueException("Unable to find vpc offering " + vpcOffId); final VpcOfferingVO offering = _vpcOffDao.createForUpdate(vpcOffId); if (_vpcOffDao.update(vpcOffId, offering)) { s_logger.debug("Updated VPC offeirng id=" + vpcOffId); return _vpcOffDao.findById(vpcOffId); } else { return null;
@Override @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_DELETE, eventDescription = "deleting vpc offering") public boolean deleteVpcOffering(final long offId) { CallContext.current().setEventDetails(" Id: " + offId); // Verify vpc offering id final VpcOfferingVO offering = _vpcOffDao.findById(offId); if (offering == null) { throw new InvalidParameterValueException("unable to find vpc offering " + offId); } // Don't allow to delete default vpc offerings if (offering.isDefault() == true) { throw new InvalidParameterValueException("Default network offering can't be deleted"); } // don't allow to delete vpc offering if it's in use by existing vpcs // (the offering can be disabled though) final int vpcCount = _vpcDao.getVpcCountByOfferingId(offId); if (vpcCount > 0) { throw new InvalidParameterValueException("Can't delete vpc offering " + offId + " as its used by " + vpcCount + " vpcs. " + "To make the network offering unavaiable, disable it"); } if (_vpcOffDao.remove(offId)) { return true; } else { return false; } }
private VpcOffering createVpcOfferingInTransaction(String name, String displayText, Multimap<Network.Service, Network.Provider> svcProviderMap, boolean isDefault, VpcOffering.State state, Long serviceOfferingId) { // create vpc offering object VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault, serviceOfferingId, false, false); if (state != null) { offering.setState(state); } if (s_logger.isDebugEnabled()) { s_logger.debug(String.format("Adding vpc offering %s", offering)); } offering = _vpcOffDao.persist(offering); // populate services and providers if (svcProviderMap != null) { for (Map.Entry<Network.Service, Network.Provider> entry : svcProviderMap.entries()) { Network.Service service = entry.getKey(); Network.Provider provider = entry.getValue(); VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider); _vpcOffSvcMapDao.persist(offService); if (s_logger.isTraceEnabled()) { s_logger.trace(String.format("Added service for the vpc offering: %s with provider %s", offService, provider.getName())); } } } return offering; }
final Boolean isDefault, final String keyword, final String state, final Long startIndex, final Long pageSizeVal) { final Filter searchFilter = new Filter(VpcOfferingVO.class, "created", false, null, null); final SearchCriteria<VpcOfferingVO> sc = _vpcOffDao.createSearchCriteria(); final SearchCriteria<VpcOfferingVO> ssc = _vpcOffDao.createSearchCriteria(); ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); final List<VpcOfferingVO> offerings = _vpcOffDao.search(sc, searchFilter);
@Override public VpcOffering doInTransaction(final TransactionStatus status) { // create vpc offering object VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault, serviceOfferingId, supportsDistributedRouter, offersRegionLevelVPC, redundantRouter); if (state != null) { offering.setState(state); } s_logger.debug("Adding vpc offering " + offering); offering = _vpcOffDao.persist(offering); // populate services and providers if (svcProviderMap != null) { for (final Network.Service service : svcProviderMap.keySet()) { final Set<Provider> providers = svcProviderMap.get(service); if (providers != null && !providers.isEmpty()) { for (final Network.Provider provider : providers) { final VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider); _vpcOffSvcMapDao.persist(offService); s_logger.trace("Added service for the vpc offering: " + offService + " with provider " + provider.getName()); } } else { throw new InvalidParameterValueException("Provider is missing for the VPC offering service " + service.getName()); } } } return offering; } });
@Override public void doInTransactionWithoutResult(final TransactionStatus status) { if (_vpcOffDao.findByUniqueName(VpcOffering.defaultVPCOfferingName) == null) { s_logger.debug("Creating default VPC offering " + VpcOffering.defaultVPCOfferingName); if (_vpcOffDao.findByUniqueName(VpcOffering.defaultVPCNSOfferingName) == null) { s_logger.debug("Creating default VPC offering with Netscaler as LB Provider" + VpcOffering.defaultVPCNSOfferingName); final Map<Service, Set<Provider>> svcProviderMap = new HashMap<Service, Set<Provider>>(); if (_vpcOffDao.findByUniqueName(VpcOffering.redundantVPCOfferingName) == null) { s_logger.debug("Creating Redundant VPC offering " + VpcOffering.redundantVPCOfferingName);
public static VpcOffering findVpcOfferingById(long offeringId) { return s_vpcOfferingDao.findById(offeringId); }
boolean forceCleanup = cleanUp; if (!vpc.isRedundant() && makeRedundant) { final VpcOfferingVO redundantOffering = _vpcOffDao.findByUniqueName(VpcOffering.redundantVPCOfferingName);
@Override protected void findServiceOfferingId() { serviceOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId(); if (serviceOfferingId == null) { findDefaultServiceOfferingId(); } }
final VpcOfferingVO vpcOff = _vpcOffDao.findById(vpcOffId); if (vpcOff == null || vpcOff.getState() != State.Enabled) { final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find vpc offering in " + State.Enabled + " state by specified id");