use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileDeviceController method setVirtualNASinArgs.
/**
* Set is the vNAS entity in args only if vNASURI is not null
*
* @param vNASURI
* the URI of VirtualNAS
* @param args
* instance of FileDeviceInputOutput
*/
private void setVirtualNASinArgs(URI vNASURI, FileDeviceInputOutput args) {
if (vNASURI != null) {
VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
args.setvNAS(vNAS);
}
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileSnapshotPolicyToProjects.
@Override
public void assignFileSnapshotPolicyToProjects(URI storageSystemURI, URI vNASURI, URI filePolicyToAssign, URI vpoolURI, URI projectURI, String opId) throws InternalException {
try {
WorkflowStepCompleter.stepExecuting(opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
Project project = _dbClient.queryObject(Project.class, projectURI);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
if (vNASURI != null) {
VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
args.setvNAS(vNAS);
}
args.setFileProtectionPolicy(filePolicy);
args.setVPool(vpool);
args.setProject(project);
args.setTenantOrg(tenant);
_log.info("Assigning file snapshot policy: {} to vpool {} and project: {}", filePolicyToAssign, vpoolURI, projectURI);
BiosCommandResult result = getDevice(storageObj.getSystemType()).checkFilePolicyExistsOrCreate(storageObj, args);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
if (result.isCommandSuccess()) {
WorkflowStepCompleter.stepSucceded(opId);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileReplicationPolicyToVirtualPools.
@Override
public void assignFileReplicationPolicyToVirtualPools(URI storageSystemURI, URI targetSystemURI, URI sourceVNasURI, URI targetVArrayURI, URI targetVNasURI, URI filePolicyToAssign, URI vpoolURI, String opId) throws ControllerException {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
StorageSystem targetSystem = _dbClient.queryObject(StorageSystem.class, targetSystemURI);
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
VirtualArray targetVarray = _dbClient.queryObject(VirtualArray.class, targetVArrayURI);
VirtualNAS sourceVNAS = null;
VirtualNAS targetVNAS = null;
FileDeviceInputOutput sourceArgs = new FileDeviceInputOutput();
FileDeviceInputOutput targetArgs = new FileDeviceInputOutput();
targetArgs.setVarray(targetVarray);
sourceArgs.setFileProtectionPolicy(filePolicy);
sourceArgs.setVPool(vpool);
if (sourceVNasURI != null) {
sourceVNAS = _dbClient.queryObject(VirtualNAS.class, sourceVNasURI);
sourceArgs.setvNAS(sourceVNAS);
targetArgs.setSourceVNAS(sourceVNAS);
}
targetArgs.setSourceSystem(sourceSystem);
targetArgs.setVPool(vpool);
targetArgs.setTarget(true);
if (targetVNasURI != null) {
targetVNAS = _dbClient.queryObject(VirtualNAS.class, targetVNasURI);
targetArgs.setvNAS(targetVNAS);
}
_log.info("Assigning file replication policy: {} to vpool: {}", filePolicyToAssign, vpoolURI);
BiosCommandResult result = getDevice(sourceSystem.getSystemType()).checkFileReplicationPolicyExistsOrCreate(sourceSystem, targetSystem, sourceArgs, targetArgs);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
if (result.isCommandSuccess()) {
WorkflowStepCompleter.stepSucceded(opId);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileDeviceController method updateNFSAcl.
@Override
public void updateNFSAcl(URI storage, URI fsURI, NfsACLUpdateParams param, String opId) throws InternalException {
ControllerUtils.setThreadLocalLogData(fsURI, opId);
FileObject fsObj = null;
FileDeviceInputOutput args = new FileDeviceInputOutput();
FileShare fs = null;
Snapshot snapshotObj = null;
boolean isFile = false;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
args.setSubDirectory(param.getSubDir());
args.setAllNfsAcls(param);
_log.info("Controller Recieved NfsACLUpdateParams {}", param);
// File
if (URIUtil.isType(fsURI, FileShare.class)) {
isFile = true;
fs = _dbClient.queryObject(FileShare.class, fsURI);
fsObj = fs;
args.addFSFileObject(fs);
args.setFileSystemPath(fs.getPath());
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
} else {
// Snapshot
snapshotObj = _dbClient.queryObject(Snapshot.class, fsURI);
fsObj = snapshotObj;
fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
args.addFileShare(fs);
args.setFileSystemPath(fs.getPath());
args.addSnapshotFileObject(snapshotObj);
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
}
if (fs.getVirtualNAS() != null) {
VirtualNAS vNas = _dbClient.queryObject(VirtualNAS.class, fs.getVirtualNAS());
if (vNas != null && !vNas.getInactive()) {
args.setvNAS(vNas);
}
}
args.setFileOperation(isFile);
args.setOpId(opId);
// Do the Operation on device.
BiosCommandResult result = getDevice(storageObj.getSystemType()).updateNfsACLs(storageObj, args);
if (result.isCommandSuccess()) {
// Update Database
updateNFSACLsInDB(param, fs, args);
WorkflowStepCompleter.stepSucceded(opId);
}
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
// Audit & Update the task status
OperationTypeEnum auditType = null;
auditType = (isFile) ? OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL : OperationTypeEnum.UPDATE_FILE_SNAPSHOT_NFS_ACL;
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
// Monitoring - Event Processing
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
if (isFile) {
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, storageObj);
} else {
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), snapshotObj, fs, storageObj);
}
_dbClient.updateObject(fsObj);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
String[] params = { storage.toString(), fsURI.toString() };
_log.error("Unable to set ACL on file system or snapshot: storage {}, FS/snapshot URI {}", params, e);
_log.error("{}, {} ", e.getMessage(), e);
updateTaskStatus(opId, fsObj, e);
}
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method runUpdateVirtualNasAssociationsProcess.
/**
* This method is responsible for
* Assign the virtual arrays of storage port to virtual nas
*
* @param ports
* @param remPorts
* @param dbClient
* @param coordinator
* @throws IOException
*/
public static void runUpdateVirtualNasAssociationsProcess(Collection<StoragePort> ports, Collection<StoragePort> remPorts, DbClient dbClient) {
try {
List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
if (ports != null && !ports.isEmpty()) {
// for better reading, added a method to group Ports by Network
Map<String, List<NetworkLite>> vNasNetworkMap = getVNasNetworksMap(ports, dbClient);
if (!vNasNetworkMap.isEmpty()) {
for (Map.Entry<String, List<NetworkLite>> vNasEntry : vNasNetworkMap.entrySet()) {
String nativeId = vNasEntry.getKey();
VirtualNAS vNas = findvNasByNativeId(nativeId, dbClient);
if (vNas != null) {
for (NetworkLite network : vNasEntry.getValue()) {
Set<String> varraySet = new HashSet<String>(network.getAssignedVirtualArrays());
if (vNas.getAssignedVirtualArrays() == null) {
vNas.setAssignedVirtualArrays(new StringSet());
}
vNas.getAssignedVirtualArrays().addAll(varraySet);
_log.info("found virtual NAS: {} and varrays: {}", vNas.getNasName(), varraySet.toString());
}
modifiedServers.add(vNas);
}
}
}
}
if (!modifiedServers.isEmpty()) {
dbClient.persistObject(modifiedServers);
}
} catch (Exception e) {
_log.error("Update Port Association process failed", e);
}
}
Aggregations