Search in sources :

Example 21 with UnsupportedServiceException

use of com.cloud.exception.UnsupportedServiceException in project cloudstack by apache.

the class RulesManagerImpl method applyUserDataIfNeeded.

protected void applyUserDataIfNeeded(long vmId, Network network, Nic guestNic) throws ResourceUnavailableException {
    UserDataServiceProvider element = null;
    try {
        element = _networkModel.getUserDataUpdateProvider(network);
    } catch (UnsupportedServiceException ex) {
        s_logger.info(String.format("%s is not supported by network %s, skipping.", Service.UserData.getName(), network));
        return;
    }
    if (element == null) {
        s_logger.error("Can't find network element for " + Service.UserData.getName() + " provider needed for UserData update");
    } else {
        UserVmVO vm = _vmDao.findById(vmId);
        try {
            VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
            NicProfile nicProfile = new NicProfile(guestNic, network, null, null, null, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(template.getHypervisorType(), network));
            VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(vm);
            if (!element.saveUserData(network, nicProfile, vmProfile)) {
                s_logger.error("Failed to update userdata for vm " + vm + " and nic " + guestNic);
            }
        } catch (Exception e) {
            s_logger.error("Failed to update userdata for vm " + vm + " and nic " + guestNic + " due to " + e.getMessage(), e);
        }
    }
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) VMTemplateVO(com.cloud.storage.VMTemplateVO) NicProfile(com.cloud.vm.NicProfile) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) TransactionCallbackWithException(com.cloud.utils.db.TransactionCallbackWithException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 22 with UnsupportedServiceException

use of com.cloud.exception.UnsupportedServiceException 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)

Aggregations

UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)22 NetworkElement (com.cloud.network.element.NetworkElement)12 HashMap (java.util.HashMap)12 Service (com.cloud.network.Network.Service)11 Map (java.util.Map)10 Capability (com.cloud.network.Network.Capability)9 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 Provider (com.cloud.network.Network.Provider)7 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)6 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)6 ArrayList (java.util.ArrayList)4 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)3 HashSet (java.util.HashSet)3 ResourceOwnerType (com.cloud.configuration.Resource.ResourceOwnerType)2 ResourceType (com.cloud.configuration.Resource.ResourceType)2 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)2 NetworkOfferingServiceMapVO (com.cloud.offerings.NetworkOfferingServiceMapVO)2 ResourceLimitService (com.cloud.user.ResourceLimitService)2