public List<String> getAccountNames() { if (accountNames != null && projectIds != null) { throw new InvalidParameterValueException("Accounts and projectIds can't be specified together"); } return accountNames; }
private DomainVO getDomain(Long domainId) { DomainVO domain = _domainDao.findById(domainId); if (domain == null) { throw new InvalidParameterValueException("Unable to find domain by specified id"); } return domain; }
public void checkNameForRFCCompliance(String name) { if (!NetUtils.verifyDomainNameLabel(name, true)) { throw new InvalidParameterValueException("Invalid name. Vm name can contain ASCII letters 'a' through 'z', the digits '0' through '9', " + "and the hyphen ('-'), must be between 1 and 63 characters long, and can't start or end with \"-\" and can't start with digit"); } }
void verifyTemplateId(Long id) { // Don't allow to modify system template if (id.equals(Long.valueOf(1))) { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id"); ex.addProxyObject(String.valueOf(id), "templateId"); throw ex; } }
private void checkForUnattachedVolumes(long vmId, List<VolumeVO> volumes) { StringBuilder sb = new StringBuilder(); for (VolumeVO volume : volumes) { if (volume.getInstanceId() == null || vmId != volume.getInstanceId()) { sb.append(volume.toString() + "; "); } } if (!StringUtils.isEmpty(sb.toString())) { throw new InvalidParameterValueException("The following supplied volumes are not attached to the VM: " + sb.toString()); } }
private void checkIfHostOfVMIsInPrepareForMaintenanceState(Long hostId, Long vmId, String operation) { HostVO host = _hostDao.findById(hostId); if (host.getResourceState() != ResourceState.PrepareForMaintenance) { return; } s_logger.debug("Host is in PrepareForMaintenance state - " + operation + " VM operation on the VM id: " + vmId + " is not allowed"); throw new InvalidParameterValueException(operation + " VM operation on the VM id: " + vmId + " is not allowed as host is preparing for maintenance mode"); }
@Override public Long getSyncObjId() { GlobalLoadBalancerRule gslb = _gslbService.findById(id); if (gslb == null) { throw new InvalidParameterValueException("Unable to find load balancer rule: " + id); } return gslb.getId(); } }
private long getNetworkId() { Nic nic = _entityMgr.findById(Nic.class, nicId); if (nic == null) { throw new InvalidParameterValueException("Can't find network id for specified nic"); } return nic.getNetworkId(); }
/** * Searches for a user with the given userId. If no user is found we throw an {@link InvalidParameterValueException}. */ protected UserVO retrieveAndValidateUser(UpdateUserCmd updateUserCmd) { Long userId = updateUserCmd.getId(); UserVO user = _userDao.getUser(userId); if (user == null) { throw new InvalidParameterValueException("Unable to find user with id: " + userId); } return user; }
protected boolean doDeleteCustomerGateway(Site2SiteCustomerGateway gw) { long id = gw.getId(); List<Site2SiteVpnConnectionVO> vpnConnections = _vpnConnectionDao.listByCustomerGatewayId(id); if (vpnConnections != null && vpnConnections.size() != 0) { throw new InvalidParameterValueException("Unable to delete VPN customer gateway with id " + id + " because there is still related VPN connections!"); } _customerGatewayDao.remove(id); return true; }
private Long getHostId() { Volume volume = _entityMgr.findById(Volume.class, getVolumeId()); if (volume == null) { throw new InvalidParameterValueException("Unable to find volume by id"); } return _snapshotService.getHostIdForSnapshotOperation(volume); }
@Override public long getEntityOwnerId() { LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getLbRuleId()); if (lb == null) { throw new InvalidParameterValueException("Unable to find loadbalancer by lbRuleId"); } return lb.getAccountId(); }
@Override public List<? extends PortableIp> listPortableIps(final long id) { final PortableIpRangeVO portableIpRange = _portableIpRangeDao.findById(id); if (portableIpRange == null) { throw new InvalidParameterValueException("Please specify a valid portable IP range id."); } return _portableIpDao.listByRangeId(portableIpRange.getId()); }
@Override public Long getSyncObjId() { VpcGateway gateway = _vpcService.getVpcPrivateGateway(getId()); if (gateway == null) { throw new InvalidParameterValueException("Invalid private gateway id"); } return gateway.getVpcId(); }
@Override public long getEntityOwnerId() { VirtualRouter vm = _entityMgr.findById(VirtualRouter.class, getId()); if (vm != null && vm.getRole() == Role.NETSCALER_VM) { return vm.getAccountId(); } else { throw new InvalidParameterValueException("Unable to find NetScaler vm by id"); } }
@Override public VirtualRouter stopInternalLbVm(final long vmId, final boolean forced, final Account caller, final long callerUserId) throws ConcurrentOperationException, ResourceUnavailableException { final DomainRouterVO internalLbVm = _internalLbVmDao.findById(vmId); if (internalLbVm == null || internalLbVm.getRole() != Role.INTERNAL_LB_VM) { throw new InvalidParameterValueException("Can't find internal lb vm by id specified"); } //check permissions _accountMgr.checkAccess(caller, null, true, internalLbVm); return stopInternalLbVm(internalLbVm, forced, caller, callerUserId); }
@Override public VirtualRouter startInternalLbVm(final long internalLbVmId, final Account caller, final long callerUserId) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { final DomainRouterVO internalLbVm = _internalLbVmDao.findById(internalLbVmId); if (internalLbVm == null || internalLbVm.getRole() != Role.INTERNAL_LB_VM) { throw new InvalidParameterValueException("Can't find internal lb vm by id specified"); } //check permissions _accountMgr.checkAccess(caller, null, true, internalLbVm); return startInternalLbVm(internalLbVm, caller, callerUserId, null); } }
private void checkOverlapPublicIpRange(final Long zoneId, final String startIp, final String endIp) { final long privateStartIp = NetUtils.ip2Long(startIp); final long privateEndIp = NetUtils.ip2Long(endIp); final List<IPAddressVO> existingPublicIPs = _publicIpAddressDao.listByDcId(zoneId); for (final IPAddressVO publicIPVO : existingPublicIPs) { final long publicIP = NetUtils.ip2Long(publicIPVO.getAddress().addr()); if (publicIP >= privateStartIp && publicIP <= privateEndIp) { throw new InvalidParameterValueException("The Start IP and endIP address range overlap with Public IP :" + publicIPVO.getAddress().addr()); } } }
@Override @ActionEvent(eventType = EventTypes.EVENT_VLAN_IP_RANGE_DELETE, eventDescription = "deleting vlan ip range", async = false) public boolean deleteVlanIpRange(final DeleteVlanIpRangeCmd cmd) { final Long vlanDbId = cmd.getId(); final VlanVO vlan = _vlanDao.findById(vlanDbId); if (vlan == null) { throw new InvalidParameterValueException("Please specify a valid IP range id."); } return deleteVlanAndPublicIpRange(CallContext.current().getCallingUserId(), vlanDbId, CallContext.current().getCallingAccount()); }
private void checkDestinationHypervisorType(StoragePool destPool, VMInstanceVO vm) { HypervisorType destHypervisorType = destPool.getHypervisor(); if (destHypervisorType == null) { destHypervisorType = _clusterDao.findById( destPool.getClusterId()).getHypervisorType(); } if (vm.getHypervisorType() != destHypervisorType && destHypervisorType != HypervisorType.Any) { throw new InvalidParameterValueException("hypervisor is not compatible: dest: " + destHypervisorType.toString() + ", vm: " + vm.getHypervisorType().toString()); } }