use of com.cloud.network.vpc.VpcOfferingVO in project cloudstack by apache.
the class ContrailManagerImpl method locateVpcOffering.
private VpcOffering locateVpcOffering() {
VpcOffering vpcOffer = _vpcOffDao.findByUniqueName(juniperVPCOfferingName);
if (vpcOffer != null) {
if (((VpcOfferingVO) vpcOffer).getState() == VpcOffering.State.Enabled) {
return vpcOffer;
}
((VpcOfferingVO) vpcOffer).setState(VpcOffering.State.Enabled);
long id = vpcOffer.getId();
_vpcOffDao.update(id, (VpcOfferingVO) vpcOffer);
return vpcOffer;
}
Map<String, List<String>> serviceProviderMap = new HashMap<String, List<String>>();
List<String> providerSet = new ArrayList<String>();
providerSet.add(Provider.JuniperContrailVpcRouter.getName());
final List<String> services = new ArrayList<String>();
services.add(Service.Connectivity.getName());
services.add(Service.Dhcp.getName());
services.add(Service.NetworkACL.getName());
services.add(Service.StaticNat.getName());
services.add(Service.SourceNat.getName());
services.add(Service.Gateway.getName());
services.add(Service.Lb.getName());
for (String svc : services) {
if (svc.equals(Service.Lb.getName())) {
List<String> lbProviderSet = new ArrayList<String>();
lbProviderSet.add(Provider.InternalLbVm.getName());
serviceProviderMap.put(svc, lbProviderSet);
continue;
}
serviceProviderMap.put(svc, providerSet);
}
vpcOffer = _vpcProvSvc.createVpcOffering(juniperVPCOfferingName, juniperVPCOfferingDisplayText, services, serviceProviderMap, null, null);
((VpcOfferingVO) vpcOffer).setState(VpcOffering.State.Enabled);
long id = vpcOffer.getId();
_vpcOffDao.update(id, (VpcOfferingVO) vpcOffer);
return _vpcOffDao.findById(id);
}
use of com.cloud.network.vpc.VpcOfferingVO in project cloudstack by apache.
the class VpcOfferingDaoImpl method remove.
@Override
@DB
public boolean remove(Long vpcOffId) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
VpcOfferingVO offering = findById(vpcOffId);
offering.setUniqueName(null);
update(vpcOffId, offering);
boolean result = super.remove(vpcOffId);
txn.commit();
return result;
}
use of com.cloud.network.vpc.VpcOfferingVO in project cloudstack by apache.
the class VpcRouterDeploymentDefinitionTest method testFindOfferingIdFromVPC.
@Test
public void testFindOfferingIdFromVPC() {
// Prepare
final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering);
when(vpcOffering.getServiceOfferingId()).thenReturn(VPC_OFFERING_ID);
// Test
deployment.findServiceOfferingId();
// Assert
assertEquals("Service offering id not matching the one associated with VPC offering", VPC_OFFERING_ID, deployment.serviceOfferingId.longValue());
}
use of com.cloud.network.vpc.VpcOfferingVO in project cloudstack by apache.
the class VpcRouterDeploymentDefinitionTest method testFindOfferingIdDefault.
@Test
public void testFindOfferingIdDefault() {
// Prepare
final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering);
when(vpcOffering.getServiceOfferingId()).thenReturn(null);
when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO);
when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID);
// Execute
deployment.findServiceOfferingId();
// Assert
assertEquals("Since there is no service offering associated with VPC offering, offering id should have matched default one", DEFAULT_OFFERING_ID, deployment.serviceOfferingId.longValue());
}
Aggregations