Пример #1
0
  protected boolean canHandle(final Network network, final Service service) {
    s_logger.debug(
        "Checking if OvsElement can handle service "
            + service.getName()
            + " on network "
            + network.getDisplayText());
    if (network.getBroadcastDomainType() != BroadcastDomainType.Vswitch) {
      return false;
    }

    if (!_networkModel.isProviderForNetwork(getProvider(), network.getId())) {
      s_logger.debug("OvsElement is not a provider for network " + network.getDisplayText());
      return false;
    }

    if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(
        network.getId(), service, Network.Provider.Ovs)) {
      s_logger.debug(
          "OvsElement can't provide the "
              + service.getName()
              + " service on network "
              + network.getDisplayText());
      return false;
    }

    return true;
  }
  @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();
  }
Пример #3
0
 @Override
 @DB
 public void persistNetworkServiceProviders(
     long networkId, Map<String, String> serviceProviderMap) {
   TransactionLegacy txn = TransactionLegacy.currentTxn();
   txn.start();
   for (String service : serviceProviderMap.keySet()) {
     NetworkServiceMapVO serviceMap =
         new NetworkServiceMapVO(
             networkId,
             Service.getService(service),
             Provider.getProvider(serviceProviderMap.get(service)));
     _ntwkSvcMap.persist(serviceMap);
   }
   txn.commit();
 }