public VirtualNasServerInfo(VirtualNASRestRep vNasRestRep, boolean isProjectAccessible) { StringBuffer projectListWithIds = new StringBuffer(); this.nasName = vNasRestRep.getNasName(); this.storageDeviceURI = (vNasRestRep.getStorageDeviceURI() != null) ? vNasRestRep.getStorageDeviceURI().toString() : ""; if (isProjectAccessible) { Set<String> associatedProjects = vNasRestRep.getAssociatedProjects(); if (associatedProjects != null && !associatedProjects.isEmpty()) { StringBuffer projectList = new StringBuffer(); for (Iterator<String> iterator = associatedProjects.iterator(); iterator.hasNext(); ) { String projectId = iterator.next(); ProjectRestRep projectRestRep = getViprClient().projects().get(URI.create(projectId)); projectList.append(projectRestRep.getName()).append(", "); projectListWithIds .append(projectRestRep.getName()) .append("+") .append(projectRestRep.getId()) .append(","); } this.project = projectList.substring(0, projectList.length() - 2); } } this.protocols = vNasRestRep.getProtocols(); this.baseDirPath = vNasRestRep.getBaseDirPath(); this.nasTag = vNasRestRep.getTags(); this.nasState = vNasRestRep.getNasState(); this.cifsServers = vNasRestRep.getCifsServers(); this.storagePorts = (vNasRestRep.getStoragePorts() != null) ? vNasRestRep.getStoragePorts().toString() : ""; this.storageDomain = (vNasRestRep.getStorageDomain() != null) ? vNasRestRep.getStorageDomain().toString() : ""; NamedRelatedResourceRep resourceRep = vNasRestRep.getParentNASURI(); if (resourceRep != null) { this.parentNASURI = resourceRep.getName(); } this.registrationStatus = vNasRestRep.getRegistrationStatus(); this.compatibilityStatus = vNasRestRep.getCompatibilityStatus(); this.discoveryStatus = vNasRestRep.getDiscoveryStatus(); this.storageObjects = vNasRestRep.getStorageObjects(); this.storageCapacity = vNasRestRep.getUsedStorageCapacity(); this.avgPercentagebusy = vNasRestRep.getAvgPercentagebusy(); this.percentLoad = vNasRestRep.getPercentLoad(); if (projectListWithIds.length() > 0) { this.id = vNasRestRep.getId().toString() + "~~~" + projectListWithIds.substring(0, projectListWithIds.length() - 1); } else { this.id = vNasRestRep.getId().toString() + "~~~"; } }
public static ComputeVirtualPoolRestRep toComputeVirtualPool( DbClient dbClient, ComputeVirtualPool from, boolean inUse) { if (from == null) { return null; } ComputeVirtualPoolRestRep to = new ComputeVirtualPoolRestRep(); to.setDescription(from.getDescription()); to.setSystemType(from.getSystemType()); to.setMinProcessors(translateDbValueToClientValue(from.getMinProcessors())); to.setMaxProcessors(translateDbValueToClientValue(from.getMaxProcessors())); to.setMinTotalCores(translateDbValueToClientValue(from.getMinTotalCores())); to.setMaxTotalCores(translateDbValueToClientValue(from.getMaxTotalCores())); to.setMinTotalThreads(translateDbValueToClientValue(from.getMinTotalThreads())); to.setMaxTotalThreads(translateDbValueToClientValue(from.getMaxTotalThreads())); to.setMinCpuSpeed(translateDbValueToClientValue(from.getMinCpuSpeed())); to.setMaxCpuSpeed(translateDbValueToClientValue(from.getMaxCpuSpeed())); to.setMinMemory(translateDbValueToClientValue(from.getMinMemory())); to.setMaxMemory(translateDbValueToClientValue(from.getMaxMemory())); to.setMinNics(translateDbValueToClientValue(from.getMinNics())); to.setMaxNics(translateDbValueToClientValue(from.getMaxNics())); to.setMinHbas(translateDbValueToClientValue(from.getMinHbas())); to.setMaxHbas(translateDbValueToClientValue(from.getMaxHbas())); if (from.getVirtualArrays() != null) { for (String varray : from.getVirtualArrays()) { to.getVirtualArrays().add(toRelatedResource(ResourceTypeEnum.VARRAY, URI.create(varray))); } } to.setUseMatchedElements(from.getUseMatchedElements()); to.setInUse(inUse); if (from.getMatchedComputeElements() != null) { for (String ce : from.getMatchedComputeElements()) { to.getMatchedComputeElements() .add(toRelatedResource(ResourceTypeEnum.COMPUTE_ELEMENT, URI.create(ce))); } } if (dbClient != null) { if (from.getServiceProfileTemplates() != null) { for (String spt : from.getServiceProfileTemplates()) { URI sptURI = URI.create(spt); UCSServiceProfileTemplate template = dbClient.queryObject(UCSServiceProfileTemplate.class, sptURI); NamedRelatedResourceRep sptNamedRelatedResource = new NamedRelatedResourceRep(); sptNamedRelatedResource.setId(template.getId()); sptNamedRelatedResource.setName(template.getLabel()); to.getServiceProfileTemplates().add(sptNamedRelatedResource); } } if (from.getMatchedComputeElements() != null) { to.getAvailableMatchedComputeElements() .addAll(getAvailableComputeElements(dbClient, from.getMatchedComputeElements())); } } mapDataObjectFieldsNoLink(from, to); return to; }