use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getTargetHostPortForReplication.
public static String getTargetHostPortForReplication(DbClient dbClient, URI targetStorageSystemURI, URI targetVarrayURI, URI targetVNasURI) {
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetStorageSystemURI);
String targetHost = targetSystem.getIpAddress();
StringSet targetNasVarraySet = null;
StringSet targetStoragePortSet = null;
if (targetVNasURI != null) {
VirtualNAS targetVNas = dbClient.queryObject(VirtualNAS.class, targetVNasURI);
targetStoragePortSet = targetVNas.getStoragePorts();
targetNasVarraySet = targetVNas.getTaggedVirtualArrays();
} else {
PhysicalNAS pNAS = FileOrchestrationUtils.getSystemPhysicalNAS(dbClient, targetSystem);
targetStoragePortSet = pNAS.getStoragePorts();
targetNasVarraySet = pNAS.getTaggedVirtualArrays();
}
List<String> drPorts = new ArrayList<String>();
for (String nasPort : targetStoragePortSet) {
StoragePort port = dbClient.queryObject(StoragePort.class, URI.create(nasPort));
if (port != null && !port.getInactive()) {
StringSet varraySet = port.getTaggedVirtualArrays();
if (varraySet == null || !varraySet.contains(targetVarrayURI.toString())) {
continue;
}
if (targetNasVarraySet != null) {
if (!targetNasVarraySet.contains(targetVarrayURI.toString())) {
continue;
}
}
targetHost = port.getPortNetworkId();
// iterate until dr port found!!
if (port.getTag() != null) {
ScopedLabelSet portTagSet = port.getTag();
if (portTagSet != null && !portTagSet.isEmpty()) {
for (ScopedLabel tag : portTagSet) {
if ("dr_port".equals(tag.getLabel())) {
_log.info("DR port {} found from storage system {} for replication", port.getPortNetworkId(), targetSystem.getLabel());
drPorts.add(port.getPortNetworkId());
}
}
}
}
}
}
if (!drPorts.isEmpty()) {
Collections.shuffle(drPorts);
return drPorts.get(0);
}
return targetHost;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getVNASServersOfStorageSystemAndVarrayOfVpool.
/**
* Get the list of virtual nas servers from storage system which are part of vpool and project
*
* @param dbClient
* @param storageSystemURI
* @param vpoolURI
* @param projectURI
* @return
*/
public static List<URI> getVNASServersOfStorageSystemAndVarrayOfVpool(DbClient dbClient, URI storageSystemURI, URI vpoolURI, URI projectURI) {
VirtualPool vpool = dbClient.queryObject(VirtualPool.class, vpoolURI);
Project project = null;
if (projectURI != null) {
project = dbClient.queryObject(Project.class, projectURI);
}
StringSet varraySet = vpool.getVirtualArrays();
URIQueryResultList vNasURIs = new URIQueryResultList();
List<URI> vNASURIList = new ArrayList<URI>();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceVirtualNasConstraint(storageSystemURI), vNasURIs);
Iterator<URI> vNasIter = vNasURIs.iterator();
while (vNasIter.hasNext()) {
URI vNasURI = vNasIter.next();
VirtualNAS vNas = dbClient.queryObject(VirtualNAS.class, vNasURI);
if (vNas != null && !vNas.getInactive()) {
// Dont pick the other project nas servers!!!
if (project != null && vNas.getAssociatedProjects() != null && !vNas.getAssociatedProjects().isEmpty()) {
if (!vNas.getAssociatedProjects().contains(project.getId().toString())) {
_log.info("vNas server {} assigned to other project, so ignoring this vNas server", vNas.getNasName());
continue;
}
}
StringSet vNASVarraySet = vNas.getAssignedVirtualArrays();
if (varraySet != null && !varraySet.isEmpty() && vNASVarraySet != null) {
vNASVarraySet.retainAll(varraySet);
if (!vNASVarraySet.isEmpty()) {
vNASURIList.add(vNas.getId());
}
}
}
}
return vNASURIList;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method isIngestUmfsValidForProject.
/**
* Validate vNAS of unmanaged file system association with project
*
* @param project
* @param dbClient
* @param nasUri
* @return true if ingestion is possible for a project against a vNAS; false otherwise
*/
public boolean isIngestUmfsValidForProject(Project project, DbClient dbClient, String nasUri) {
_logger.info("Inside isIngestUmfsValidForProject() project name: {}", project.getLabel());
boolean isIngestValid = true;
if (nasUri != null && "VirtualNAS".equals(URIUtil.getTypeName(nasUri))) {
VirtualNAS virtualNAS = dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
_logger.info("vNAS name: {}", virtualNAS.getNasName());
StringSet projectVNASServerSet = project.getAssignedVNasServers();
if (projectVNASServerSet != null && !projectVNASServerSet.isEmpty()) {
/*
* Step 1: check file system is mounted to VNAS
* Step 2: if project has any associated vNAS
* Step 3: then check nasUri in project associated vNAS list
*/
_logger.debug("Project vNAS server list: {}", projectVNASServerSet);
_logger.debug("vNAS: {} assigned to project? {}", virtualNAS.getNasName(), !virtualNAS.isNotAssignedToProject());
if (!projectVNASServerSet.contains(nasUri) && !virtualNAS.isNotAssignedToProject()) {
_logger.info("vNAS: {} is not associated with project: {}.", virtualNAS.getNasName(), project.getLabel());
isIngestValid = false;
} else {
if (!virtualNAS.isNotAssignedToProject() && !virtualNAS.getAssociatedProjects().contains(project.getId().toString())) {
_logger.info("vNAS: {} is associated with other project.", virtualNAS.getNasName());
isIngestValid = false;
}
}
}
}
_logger.info("Exit isIngestUmfsValidForProject() returning: {}", isIngestValid);
return isIngestValid;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method getIsilonStoragePort.
/**
* This function will return one of the NAS server port which is part of given virtual array
* it return null, if any of the NAS server port is not part of given virtual array
*
* @param umfsStoragePort
* port which is assigned to file system while UMFS discovery
* @param nasUri
* NAS server URI
* @param virtualArray
* virtual array
*/
private StoragePort getIsilonStoragePort(StoragePort umfsStoragePort, String nasUri, URI virtualArray) {
StoragePort sp = null;
NASServer nasServer = null;
if (StringUtils.equals("VirtualNAS", URIUtil.getTypeName(nasUri))) {
nasServer = _dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
} else {
nasServer = _dbClient.queryObject(PhysicalNAS.class, URI.create(nasUri));
}
if (nasServer != null) {
List<URI> virtualArrayPorts = returnAllPortsInVArray(virtualArray);
StringSet virtualArrayPortsSet = new StringSet();
StringSet storagePorts = nasServer.getStoragePorts();
for (URI tempVarrayPort : virtualArrayPorts) {
virtualArrayPortsSet.add(tempVarrayPort.toString());
}
StringSet commonPorts = null;
if (virtualArrayPorts != null && storagePorts != null) {
commonPorts = new StringSet(storagePorts);
commonPorts.retainAll(virtualArrayPortsSet);
}
if (commonPorts != null && !commonPorts.isEmpty()) {
List<String> tempList = new ArrayList<String>(commonPorts);
Collections.shuffle(tempList);
sp = _dbClient.queryObject(StoragePort.class, URI.create(tempList.get(0)));
return sp;
}
}
return null;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class ProjectService method assignVNasServersToProject.
/**
* Assign VNAS Servers to a project
*
* @param id the URN of a ViPR Project
* @param vnasParam Assign virtual NAS server parameters
* @prereq none
* @brief Assign VNAS Servers to a project
* @return No data returned in response body
* @throws BadRequestException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/assign-vnas-servers")
@CheckPermission(roles = { Role.SYSTEM_ADMIN }, acls = { ACL.ALL, ACL.OWN })
public Response assignVNasServersToProject(@PathParam("id") URI id, VirtualNasParam vnasParam) {
checkCompatibleVersion();
Project project = getProjectById(id, true);
StringBuilder errorMsg = new StringBuilder();
StringSet validVNasServers = validateVNasServers(project, vnasParam, errorMsg);
if (validVNasServers != null && !validVNasServers.isEmpty()) {
for (String validNas : validVNasServers) {
URI vnasURI = URI.create(validNas);
VirtualNAS vnas = _permissionsHelper.getObjectById(vnasURI, VirtualNAS.class);
vnas.associateProject(project.getId().toString());
_dbClient.persistObject(vnas);
}
project.setAssignedVNasServers(validVNasServers);
_dbClient.persistObject(project);
_log.info("Successfully assigned {} virtual NAS Servers to project : {} ", validVNasServers.size(), project.getLabel());
}
// Report error, if there are any invalid vnas servers found!!!
if (errorMsg != null && errorMsg.length() > 0) {
_log.error("Failed to assign virtual NAS server(s) to project. Error: {} ", errorMsg.toString());
throw APIException.badRequests.oneOrMorevNasServersNotAssociatedToProject();
}
return Response.ok().build();
}
Aggregations