Search in sources :

Example 1 with VpcOfferingVO

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);
}
Also used : VpcOfferingVO(com.cloud.network.vpc.VpcOfferingVO) HashMap(java.util.HashMap) VpcOffering(com.cloud.network.vpc.VpcOffering) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList)

Example 2 with VpcOfferingVO

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) VpcOfferingVO(com.cloud.network.vpc.VpcOfferingVO) DB(com.cloud.utils.db.DB)

Example 3 with VpcOfferingVO

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());
}
Also used : VpcOfferingVO(com.cloud.network.vpc.VpcOfferingVO) Test(org.junit.Test)

Example 4 with VpcOfferingVO

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());
}
Also used : VpcOfferingVO(com.cloud.network.vpc.VpcOfferingVO) Test(org.junit.Test)

Aggregations

VpcOfferingVO (com.cloud.network.vpc.VpcOfferingVO)4 Test (org.junit.Test)2 VpcOffering (com.cloud.network.vpc.VpcOffering)1 DB (com.cloud.utils.db.DB)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1