Search in sources :

Example 1 with VpcServiceMapVO

use of com.cloud.network.vpc.VpcServiceMapVO in project cloudstack by apache.

the class VpcServiceMapDaoImpl method getProviderForServiceInVpc.

@Override
public String getProviderForServiceInVpc(long vpcId, Service service) {
    SearchCriteria<VpcServiceMapVO> sc = AllFieldsSearch.create();
    sc.setParameters("vpcId", vpcId);
    sc.setParameters("service", service.getName());
    VpcServiceMapVO ntwkSvc = findOneBy(sc);
    if (ntwkSvc == null) {
        throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in the vpc id=" + vpcId);
    }
    return ntwkSvc.getProvider();
}
Also used : UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) VpcServiceMapVO(com.cloud.network.vpc.VpcServiceMapVO)

Example 2 with VpcServiceMapVO

use of com.cloud.network.vpc.VpcServiceMapVO in project cloudstack by apache.

the class VpcDaoImpl method persistVpcServiceProviders.

@Override
@DB
public void persistVpcServiceProviders(long vpcId, Map<String, List<String>> serviceProviderMap) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    for (String service : serviceProviderMap.keySet()) {
        for (String provider : serviceProviderMap.get(service)) {
            VpcServiceMapVO serviceMap = new VpcServiceMapVO(vpcId, Network.Service.getService(service), Network.Provider.getProvider(provider));
            _vpcSvcMap.persist(serviceMap);
        }
    }
    txn.commit();
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) VpcServiceMapVO(com.cloud.network.vpc.VpcServiceMapVO) DB(com.cloud.utils.db.DB)

Aggregations

VpcServiceMapVO (com.cloud.network.vpc.VpcServiceMapVO)2 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)1 DB (com.cloud.utils.db.DB)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1