private void enableProvider(String providerName) { QueryBuilder<PhysicalNetworkServiceProviderVO> q = QueryBuilder.create(PhysicalNetworkServiceProviderVO.class); q.and(q.entity().getProviderName(), SearchCriteria.Op.EQ, providerName); PhysicalNetworkServiceProviderVO provider = q.find(); provider.setState(PhysicalNetworkServiceProvider.State.Enabled); _pNSPDao.update(provider.getId(), provider); }
@Override @ActionEvent(eventType = EventTypes.EVENT_SERVICE_PROVIDER_DELETE, eventDescription = "Deleting physical network ServiceProvider", async = true) public boolean deleteNetworkServiceProvider(Long id) throws ConcurrentOperationException, ResourceUnavailableException { PhysicalNetworkServiceProviderVO provider = _pNSPDao.findById(id); if (provider == null) { throw new InvalidParameterValueException("Network Service Provider id=" + id + "doesn't exist in the system"); } // check if there are networks using this provider List<NetworkVO> networks = _networksDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), provider.getProviderName()); if (networks != null && !networks.isEmpty()) { throw new CloudRuntimeException("Provider is not deletable because there are active networks using this provider, please upgrade these networks to new network offerings"); } User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId()); Account callerAccount = _accountMgr.getActiveAccountById(callerUser.getAccountId()); // shutdown the provider instances ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount); if (s_logger.isDebugEnabled()) { s_logger.debug("Shutting down the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId()); } NetworkElement element = _networkModel.getElementImplementingProvider(provider.getProviderName()); if (element == null) { throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + provider.getProviderName() + "'"); } if (element != null && element.shutdownProviderInstances(provider, context)) { provider.setState(PhysicalNetworkServiceProvider.State.Shutdown); } return _pNSPDao.remove(id); }