public boolean isAnnotated() { return StringUtils.isNotBlank(annotation); } }
public IsolationMethod(String prfx, String prvdr) { methodPrefix = prfx; provider = StringUtils.isNotBlank(prvdr)? prvdr : UNKNOWN_PROVIDER; registeredIsolationMethods.add(this); }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { // preconditions to check: // if entity type is null entity uuid can not have a value Preconditions.checkArgument(StringUtils.isNotBlank(entityType) ? ! StringUtils.isNotBlank(uuid) : true, "I can search for an anotation on an entity or for a specific annotation, not both"); // if uuid has a value entity type and entity uuid can not have a value Preconditions.checkArgument(StringUtils.isNotBlank(uuid) ? entityType == null && entityUuid == null : true, "I will either search for a specific annotation or for annotations on an entity, not both"); ListResponse<AnnotationResponse> response = annotationService.searchForAnnotations(this); response.setResponseName(getCommandName()); this.setResponseObject(response); response.setObjectName("annotations"); }
public static boolean remove(String prfx, String prvdr) { prvdr = StringUtils.isNotBlank(prvdr)? prvdr : UNKNOWN_PROVIDER; try { return remove(getIsolationMethod(prfx, prvdr)); } catch (IsolationMethodNotRegistered isolationMethodNotRegistered) { return false; } } public static boolean remove(IsolationMethod method) {
public DiskDef.DiskBus getDiskModelFromVMDetail(final VirtualMachineTO vmTO) { Map<String, String> details = vmTO.getDetails(); if (details == null) { return null; } final String rootDiskController = details.get(VmDetailConstants.ROOT_DISK_CONTROLLER); if (StringUtils.isNotBlank(rootDiskController)) { s_logger.debug("Passed custom disk bus " + rootDiskController); for (final DiskDef.DiskBus bus : DiskDef.DiskBus.values()) { if (bus.toString().equalsIgnoreCase(rootDiskController)) { s_logger.debug("Found matching enum for disk bus " + rootDiskController); return bus; } } } return null; }
public static Pair<String, String> getIpAddressRange(Vlan vlan) { boolean isIpv4 = StringUtils.isNotBlank(vlan.getIpRange()); String[] range = isIpv4 ? vlan.getIpRange().split("-") : vlan.getIp6Range().split("-"); if (range.length == 2) { return Pair.of(range[0], range[1]); } return null; } }
@Override public List<String> getSecondaryIpAddressesForNic(long nicId) { SearchCriteria<NicSecondaryIpVO> sc = AllFieldsSearch.create(); sc.setParameters("nicId", nicId); List<NicSecondaryIpVO> results = search(sc, null); List<String> ips = new ArrayList<String>(results.size()); for (NicSecondaryIpVO result : results) { if (StringUtils.isNotBlank(result.getIp4Address())) { ips.add(result.getIp4Address()); } if (StringUtils.isNotBlank(result.getIp6Address())) { ips.add(result.getIp6Address()); } } return ips; }
protected static String getSwiftObjectCmd(SwiftClientCfg cfg, String swiftCliPath, String operation,String container, String objectName) { String cmd = getSwiftCmd(cfg,swiftCliPath, operation) +" "+ container+" "+objectName; if(StringUtils.isNotBlank(cfg.getStoragePolicy()) && supportsStoragePolicies(operation)){ return cmd + String.format(WITH_STORAGE_POLICY, cfg.getStoragePolicy()); } return cmd; }
@Override public void removeStoragePoolFromCluster(long hostId, String iScsiName, StoragePool storagePool) { final Map<String, String> details = new HashMap<>(); details.put(DeleteStoragePoolCommand.DATASTORE_NAME, iScsiName); details.put(DeleteStoragePoolCommand.IQN, iScsiName); details.put(DeleteStoragePoolCommand.STORAGE_HOST, storagePool.getHostAddress()); details.put(DeleteStoragePoolCommand.STORAGE_PORT, String.valueOf(storagePool.getPort())); final DeleteStoragePoolCommand cmd = new DeleteStoragePoolCommand(); cmd.setDetails(details); cmd.setRemoveDatastore(true); final Answer answer = _agentMgr.easySend(hostId, cmd); if (answer == null || !answer.getResult()) { String errMsg = "Error interacting with host (related to DeleteStoragePoolCommand)" + (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : ""); s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } }
deviceConfig.put("targetIQN", targetiqn); if (StringUtils.isNotBlank(chapInitiatorUsername) && StringUtils.isNotBlank(chapInitiatorPassword)) { deviceConfig.put("chapuser", chapInitiatorUsername); deviceConfig.put("chappassword", chapInitiatorPassword);
String chapInitiatorSecret = details.get(DiskTO.CHAP_INITIATOR_SECRET); if (StringUtils.isNotBlank(chapInitiatorUsername) && StringUtils.isNotBlank(chapInitiatorSecret)) { try {
/** * Tell the underlying storage plug-in to create a new volume, put it in the VAG of the destination cluster, and * send a command to the destination cluster to create an SR and to attach to the SR from all hosts in the cluster. */ private String handleManagedVolumePreMigration(VolumeInfo volumeInfo, StoragePool storagePool, Host destHost) { final PrimaryDataStoreDriver pdsd = (PrimaryDataStoreDriver)volumeInfo.getDataStore().getDriver(); VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_CREATE, Boolean.TRUE.toString(), false); volumeDetailsDao.persist(volumeDetailVo); pdsd.createAsync(volumeInfo.getDataStore(), volumeInfo, null); volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_GRANT_ACCESS, Boolean.TRUE.toString(), false); volumeDetailsDao.persist(volumeDetailVo); pdsd.grantAccess(volumeInfo, destHost, volumeInfo.getDataStore()); final Map<String, String> details = new HashMap<>(); final String iqn = getBasicIqn(volumeInfo.getId()); details.put(CreateStoragePoolCommand.DATASTORE_NAME, iqn); details.put(CreateStoragePoolCommand.IQN, iqn); details.put(CreateStoragePoolCommand.STORAGE_HOST, storagePool.getHostAddress()); details.put(CreateStoragePoolCommand.STORAGE_PORT, String.valueOf(storagePool.getPort())); final CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, storagePool); cmd.setDetails(details); cmd.setCreateDatastore(true); final Answer answer = agentMgr.easySend(destHost.getId(), cmd); if (answer == null || !answer.getResult()) { String errMsg = "Error interacting with host (related to CreateStoragePoolCommand)" + (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : ""); s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } return iqn; }
private void handleManagedVolumesAfterFailedMigration(Map<VolumeInfo, DataStore> volumeToPool, Host destHost) { for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) { VolumeInfo volumeInfo = entry.getKey(); StoragePool storagePool = storagePoolDao.findById(volumeInfo.getPoolId()); if (storagePool.isManaged()) { final Map<String, String> details = new HashMap<>(); details.put(DeleteStoragePoolCommand.DATASTORE_NAME, getBasicIqn(volumeInfo.getId())); final DeleteStoragePoolCommand cmd = new DeleteStoragePoolCommand(); cmd.setDetails(details); cmd.setRemoveDatastore(true); final Answer answer = agentMgr.easySend(destHost.getId(), cmd); if (answer == null || !answer.getResult()) { String errMsg = "Error interacting with host (related to handleManagedVolumesAfterFailedMigration)" + (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : ""); s_logger.error(errMsg); // no need to throw an exception here as the calling code is responsible for doing so // regardless of the success or lack thereof concerning this method return; } final PrimaryDataStoreDriver pdsd = (PrimaryDataStoreDriver)volumeInfo.getDataStore().getDriver(); VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_REVOKE_ACCESS, Boolean.TRUE.toString(), false); volumeDetailsDao.persist(volumeDetailVo); pdsd.revokeAccess(volumeInfo, destHost, volumeInfo.getDataStore()); volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_DELETE_FAILURE, Boolean.TRUE.toString(), false); volumeDetailsDao.persist(volumeDetailVo); pdsd.deleteAsync(volumeInfo.getDataStore(), volumeInfo, null); } } }
if (StringUtils.isNotBlank(ip6Gateway) && StringUtils.isNotBlank(ip6Cidr)) { userNetwork.setIp6Cidr(ip6Cidr); userNetwork.setIp6Gateway(ip6Gateway);
private void verifyAlreadyMigratedTiers(long migratedVpcId, long vpcOfferingId, Map<String, String> networkToOffering) { Vpc migratedVpc = _vpcDao.findById(migratedVpcId); if (migratedVpc.getVpcOfferingId() != vpcOfferingId) { s_logger.error("The vpc is already partially migrated in a previous run. The provided vpc offering is not the same as the one used during the first migration process."); throw new InvalidParameterValueException("Failed to resume migrating VPC as VPC offering does not match previously specified VPC offering (" + migratedVpc.getVpcOfferingId() + ")"); } List<NetworkVO> migratedTiers = _networksDao.listByVpc(migratedVpcId); for (Network tier : migratedTiers) { String tierNetworkOfferingUuid = networkToOffering.get(tier.getUuid()); if (!StringUtils.isNotBlank(tierNetworkOfferingUuid)) { throwInvalidIdException("Failed to resume migrating VPC as the specified tierNetworkOfferings is not complete", String.valueOf(tier.getUuid()), "networkUuid"); } NetworkOfferingVO newNetworkOffering = _networkOfferingDao.findByUuid(tierNetworkOfferingUuid); if (newNetworkOffering == null) { throw new InvalidParameterValueException("Failed to migrate VPC as at least one tier offering in tierNetworkOfferings does not exist."); } if (newNetworkOffering.getId() != tier.getNetworkOfferingId()) { NetworkOfferingVO tierNetworkOffering = _networkOfferingDao.findById(tier.getNetworkOfferingId()); throw new InvalidParameterValueException( "Failed to resume migrating VPC as at least one network offering in tierNetworkOfferings does not match previously specified network offering (network uuid=" + tier.getUuid() + " was previously specified with offering uuid=" + tierNetworkOffering.getUuid() + ")"); } } }
return "checksum algorithm not recognised: " + oldValue.getAlgorithm(); if(StringUtils.isNotBlank(dnld.getChecksum()) && ! oldValue.equals(newValue)) { return "checksum \"" + newValue +"\" didn't match the given value, \"" + oldValue + "\"";
public boolean addNetworkRules(final String vmName, final String vmId, final String guestIP, final String guestIP6, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, final String secIps) { if (!_canBridgeFirewall) { return false; } final String newRules = rules.replace(" ", ";"); final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("add_network_rules"); cmd.add("--vmname", vmName); cmd.add("--vmid", vmId); cmd.add("--vmip", guestIP); if (StringUtils.isNotBlank(guestIP6)) { cmd.add("--vmip6", guestIP6); } cmd.add("--sig", sig); cmd.add("--seq", seq); cmd.add("--vmmac", mac); cmd.add("--vif", vif); cmd.add("--brname", brname); cmd.add("--nicsecips", secIps); if (newRules != null && !newRules.isEmpty()) { cmd.add("--rules", newRules); } final String result = cmd.execute(); if (result != null) { return false; } return true; }
private void handleManagedVolumePostMigration(VolumeInfo volumeInfo, Host srcHost, VolumeObjectTO volumeTO) { final Map<String, String> details = new HashMap<>(); details.put(DeleteStoragePoolCommand.DATASTORE_NAME, volumeInfo.get_iScsiName()); final DeleteStoragePoolCommand cmd = new DeleteStoragePoolCommand(); cmd.setDetails(details); cmd.setRemoveDatastore(true); final Answer answer = agentMgr.easySend(srcHost.getId(), cmd); if (answer == null || !answer.getResult()) { String errMsg = "Error interacting with host (related to DeleteStoragePoolCommand)" + (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : ""); s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } final PrimaryDataStoreDriver pdsd = (PrimaryDataStoreDriver)volumeInfo.getDataStore().getDriver(); pdsd.revokeAccess(volumeInfo, srcHost, volumeInfo.getDataStore()); VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_DELETE, Boolean.TRUE.toString(), false); volumeDetailsDao.persist(volumeDetailVo); pdsd.deleteAsync(volumeInfo.getDataStore(), volumeInfo, null); VolumeVO volumeVO = volDao.findById(volumeInfo.getId()); volumeVO.setPath(volumeTO.getPath()); volDao.update(volumeVO.getId(), volumeVO); }
@Override public SyncNuageVspCmsIdAnswer execute(SyncNuageVspCmsIdCommand cmd, NuageVspResource nuageVspResource) { NuageVspManagerClient client = null; try { client = nuageVspResource.getNuageVspManagerClient(); Pair<Boolean, String> answer; switch (cmd.getSyncType()) { case REGISTER: String registeredNuageVspCmsId = client.registerNuageVspCmsId(); answer = Pair.of(StringUtils.isNotBlank(registeredNuageVspCmsId), registeredNuageVspCmsId); break; case UNREGISTER: boolean success = client.unregisterNuageVspCmsId(cmd.getNuageVspCmsId()); answer = Pair.of(success, cmd.getNuageVspCmsId()); break; default: answer = client.auditNuageVspCmsId(cmd.getNuageVspCmsId(), cmd.getSyncType() == SyncNuageVspCmsIdCommand.SyncType.AUDIT_ONLY); break; } return new SyncNuageVspCmsIdAnswer(answer.getLeft(), answer.getRight(), cmd.getSyncType()); } catch (ConfigurationException|NuageVspException e) { return new SyncNuageVspCmsIdAnswer(cmd, e, cmd.getSyncType()); } } }
if (StringUtils.isNotBlank(vspNetwork.getDomainTemplateName())) { if (network.getVpcId() != null) { saveVpcDetail(network.getVpcId(), NuageVspManager.nuageDomainTemplateDetailName, vspNetwork.getDomainTemplateName());