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);
}
}
}
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();
}
Aggregations