use of com.emc.storageos.model.vnas.VirtualNASRestRep in project coprhd-controller by CoprHD.
the class SystemsMapper method map.
public static VirtualNASRestRep map(VirtualNAS from, DbClient dbClient) {
if (from == null) {
return null;
}
VirtualNASRestRep to = new VirtualNASRestRep();
mapDiscoveredDataObjectFields(from, to);
to.setAssignedVirtualArrays(from.getAssignedVirtualArrays());
to.setBaseDirPath(from.getBaseDirPath());
to.setCompatibilityStatus(from.getCompatibilityStatus());
to.setConnectedVirtualArrays(from.getConnectedVirtualArrays());
to.setDiscoveryStatus(from.getDiscoveryStatus());
to.setNasName(from.getNasName());
to.setName(from.getNasName());
to.setNasState(from.getNasState());
to.setNasTag(from.getNAStag());
if (from.getParentNasUri() != null) {
PhysicalNAS pNAS = dbClient.queryObject(PhysicalNAS.class, from.getParentNasUri());
// Self link will be empty as there is no Resource Type available
// for PhysicalNAS
to.setParentNASURI(toNamedRelatedResource(pNAS, pNAS.getNasName()));
}
to.setAssociatedProjects(from.getAssociatedProjects());
to.setProtocols(from.getProtocols());
to.setRegistrationStatus(from.getRegistrationStatus());
Set<String> cifsServers = new HashSet<String>();
Set<String> cifsDomains = new HashSet<String>();
if (from.getCifsServersMap() != null && !from.getCifsServersMap().isEmpty()) {
Set<Entry<String, NasCifsServer>> nasCifsServers = from.getCifsServersMap().entrySet();
for (Entry<String, NasCifsServer> nasCifsServer : nasCifsServers) {
String serverDomain = nasCifsServer.getKey();
NasCifsServer cifsServer = nasCifsServer.getValue();
if (cifsServer.getDomain() != null) {
serverDomain = serverDomain + " = " + cifsServer.getDomain();
cifsDomains.add(cifsServer.getDomain());
}
cifsServers.add(serverDomain);
}
if (cifsServers != null && !cifsServers.isEmpty()) {
to.setCifsServers(cifsServers);
to.setStorageDomain(cifsDomains);
}
}
for (String port : from.getStoragePorts()) {
to.getStoragePorts().add(toRelatedResource(ResourceTypeEnum.STORAGE_PORT, URI.create(port)));
}
to.setTaggedVirtualArrays(from.getTaggedVirtualArrays());
to.setStorageDeviceURI(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageDeviceURI()));
DecimalFormat df = new DecimalFormat("0.00");
// Set the metrics!!!
Double maxStorageCapacity = MetricsKeys.getDouble(MetricsKeys.maxStorageCapacity, from.getMetrics()) / GBsINKB;
to.setMaxStorageCapacity(df.format(maxStorageCapacity));
to.setMaxStorageObjects(MetricsKeys.getLong(MetricsKeys.maxStorageObjects, from.getMetrics()).toString());
to.setStorageObjects(MetricsKeys.getLong(MetricsKeys.storageObjects, from.getMetrics()).toString());
Double usedStorageCapacity = MetricsKeys.getDouble(MetricsKeys.usedStorageCapacity, from.getMetrics()) / GBsINKB;
to.setUsedStorageCapacity(df.format(usedStorageCapacity));
Double percentLoad = MetricsKeys.getDoubleOrNull(MetricsKeys.percentLoad, from.getMetrics());
if (percentLoad != null) {
to.setPercentLoad(df.format(percentLoad));
}
to.setIsOverloaded(MetricsKeys.getBoolean(MetricsKeys.overLoaded, from.getMetrics()));
Double percentBusy = MetricsKeys.getDoubleOrNull(MetricsKeys.emaPercentBusy, from.getMetrics());
if (percentBusy != null) {
to.setAvgEmaPercentagebusy(df.format(percentBusy));
}
percentBusy = MetricsKeys.getDoubleOrNull(MetricsKeys.avgPortPercentBusy, from.getMetrics());
if (percentBusy != null) {
to.setAvgPercentagebusy(df.format(percentBusy));
}
return to;
}
use of com.emc.storageos.model.vnas.VirtualNASRestRep in project coprhd-controller by CoprHD.
the class StorageSystems method virtualNasServersJson.
public static void virtualNasServersJson(String storageId) {
List<VirtualNasServerInfo> results = Lists.newArrayList();
List<VirtualNASRestRep> vNasServers = getViprClient().virtualNasServers().getByStorageSystem(uri(storageId));
boolean isProjectAccessible = false;
if (isTenantAdmin() || isProjectAdmin()) {
isProjectAccessible = true;
}
for (VirtualNASRestRep vNasServer : vNasServers) {
results.add(new VirtualNasServerInfo(vNasServer, isProjectAccessible));
}
renderArgs.put("storageId", storageId);
renderArgs.put("expectedGeoVersion", VCenterUtils.checkCompatibleVDCVersion(EXPECTED_GEO_VERSION_FOR_VNAS_SUPPORT));
renderJSON(DataTablesSupport.createJSON(results, params));
}
use of com.emc.storageos.model.vnas.VirtualNASRestRep in project coprhd-controller by CoprHD.
the class StorageSystems method vNasMoreDetails.
public static void vNasMoreDetails(String id) {
List<URI> ids = Lists.newArrayList();
ids.add(uri(id));
List<VirtualNASRestRep> vNasRep = getViprClient().virtualNasServers().getByIds(ids);
VirtualNASRestRep vNas = new VirtualNASRestRep();
if (!vNasRep.isEmpty()) {
vNas = vNasRep.get(0);
}
render(vNas);
}
use of com.emc.storageos.model.vnas.VirtualNASRestRep in project coprhd-controller by CoprHD.
the class VirtualNasServers method getVirtualNasServerAssocProjects.
public static void getVirtualNasServerAssocProjects(String vNasId) {
List<String> projectOptions = Lists.newArrayList();
if (StringUtils.isNotBlank(vNasId)) {
VirtualNASRestRep vNasRestRep = getViprClient().virtualNasServers().get(uri(vNasId));
Set<String> associatedProjects = vNasRestRep.getAssociatedProjects();
if (associatedProjects != null && !associatedProjects.isEmpty()) {
List<URI> projectIdList = Lists.newArrayList();
for (String associatedProjectId : associatedProjects) {
projectIdList.add(URI.create(associatedProjectId));
}
List<ProjectRestRep> projectRestRepList = getViprClient().projects().getByIds(projectIdList);
for (ProjectRestRep projectRestRep : projectRestRepList) {
projectOptions.add(projectRestRep.getId().toString() + "~~~" + projectRestRep.getName());
}
}
}
renderJSON(projectOptions);
}
use of com.emc.storageos.model.vnas.VirtualNASRestRep in project coprhd-controller by CoprHD.
the class VirtualNasServers method getVirtualNasServers.
private static List<VirtualNasServerInfo> getVirtualNasServers(String projectId) {
if (projectId == null) {
return Collections.EMPTY_LIST;
}
List<VirtualNasServerInfo> vNasServers = Lists.newArrayList();
ProjectRestRep projRestRep = getViprClient().projects().get(uri(projectId));
Set<String> vNasIds = projRestRep.getAssignedVNasServers();
List<URI> vNasUris = Lists.newArrayList();
if (vNasIds != null) {
for (String id : vNasIds) {
vNasUris.add(uri(id));
}
if (!vNasUris.isEmpty()) {
List<VirtualNASRestRep> vNas = getViprClient().virtualNasServers().getByIds(vNasUris);
for (VirtualNASRestRep vNasServer : vNas) {
vNasServers.add(new VirtualNasServerInfo(vNasServer, true));
}
}
}
return vNasServers;
}
Aggregations