use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileStorageScheduler method placeFileShareExport.
/**
* Select storage port for exporting file share to the given client. One IP
* transport zone per varray. Selects only one storage port for all exports
* of a file share
*
* @param fs
* file share being exported
* @param protocol
* file storage protocol for this export
* @param clients
* client network address or name
* @return storgaePort
* @throws badRequestException
*/
public StoragePort placeFileShareExport(FileShare fs, String protocol, List<String> clients) {
StoragePort sp;
if (fs.getStoragePort() == null) {
_log.info("Placement for file system {} with no assigned port.", fs.getName());
// if no storage port is selected yet, select one and record the
// selection
List<StoragePort> ports = getStorageSystemPortsInVarray(fs.getStorageDevice(), fs.getVirtualArray());
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
if (Type.isilon.name().equals(storageSystem.getSystemType())) {
if (ports != null && !ports.isEmpty()) {
// Check if these ports are associated with vNAS
for (Iterator<StoragePort> iterator = ports.iterator(); iterator.hasNext(); ) {
StoragePort storagePort = iterator.next();
List<VirtualNAS> vNASList = StoragePortAssociationHelper.getStoragePortVirtualNAS(storagePort, _dbClient);
if (vNASList != null && !vNASList.isEmpty()) {
/*
* Remove the associated port. Because during file system placement,
* storage port will already be assigned to FS. In that case, this block won't
* be executed.
*/
_log.info("Removing port {} as it is assigned to a vNAS.", storagePort.getNativeGuid());
iterator.remove();
}
}
}
}
// required)
if ((null != protocol) && (!protocol.isEmpty())) {
getPortsWithFileSharingProtocol(protocol, ports);
}
if (ports == null || ports.isEmpty()) {
_log.error(MessageFormat.format("There are no active and registered storage ports assigned to virtual array {0}", fs.getVirtualArray()));
throw APIException.badRequests.noStoragePortFoundForVArray(fs.getVirtualArray().toString());
}
Collections.shuffle(ports);
sp = ports.get(0);
// update storage port selections for file share exports
fs.setStoragePort(sp.getId());
fs.setPortName(sp.getPortName());
_dbClient.persistObject(fs);
} else {
// if a storage port is already selected for the fileshare, use that
// port for all exports
sp = _dbClient.queryObject(StoragePort.class, fs.getStoragePort());
_log.info("Placement for file system {} with port {}.", fs.getName(), sp.getPortName());
// verify port supports new request.
if ((null != protocol) && (!protocol.isEmpty())) {
List<StoragePort> ports = new ArrayList<StoragePort>();
ports.add(sp);
getPortsWithFileSharingProtocol(protocol, ports);
if (ports.isEmpty()) {
_log.error(MessageFormat.format("There are no active and registered storage ports assigned to virtual array {0}", fs.getVirtualArray()));
throw APIException.badRequests.noStoragePortFoundForVArray(fs.getVirtualArray().toString());
}
}
}
return sp;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileSnapshotPolicyToVirtualPools.
@Override
public void assignFileSnapshotPolicyToVirtualPools(URI storageSystemURI, URI vNASURI, URI filePolicyToAssign, URI vpoolURI, String opId) throws ControllerException {
StorageSystem storageObj = null;
FilePolicy filePolicy = null;
VirtualNAS vNAS = null;
VirtualPool vpool = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
storageObj = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
if (vNASURI != null) {
vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
args.setvNAS(vNAS);
}
args.setFileProtectionPolicy(filePolicy);
args.setVPool(vpool);
_log.info("Assigning file snapshot policy: {} to vpool: {}", filePolicyToAssign, vpoolURI);
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 checkFilePolicyPathHasResourceLabel.
@Override
public void checkFilePolicyPathHasResourceLabel(URI storage, URI filePolicyURI, URI nasURI, URI vpoolURI, URI projectURI, String opId) {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
FileDeviceInputOutput args = new FileDeviceInputOutput();
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyURI);
args.setFileProtectionPolicy(filePolicy);
if (vpoolURI != null) {
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
args.setVPool(vpool);
}
if (projectURI != null) {
Project project = _dbClient.queryObject(Project.class, projectURI);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
args.setProject(project);
args.setTenantOrg(tenant);
}
if (nasURI != null) {
if (URIUtil.isType(nasURI, VirtualNAS.class)) {
VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, nasURI);
args.setvNAS(vNAS);
}
}
BiosCommandResult result = getDevice(system.getSystemType()).checkFilePolicyPathHasResourceLabel(system, 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 error = DeviceControllerException.errors.jobFailed(e);
_log.error("Error occured while checking policy path has resorce label.", e);
WorkflowStepCompleter.stepFailed(opId, error);
}
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileReplicationPolicyToProjects.
@Override
public void assignFileReplicationPolicyToProjects(URI storageSystemURI, URI targetSystemURI, URI sourceVNasURI, URI targetVArrayURI, URI targetVNasURI, URI filePolicyToAssign, URI vpoolURI, URI projectURI, String opId) throws InternalException {
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);
Project project = _dbClient.queryObject(Project.class, projectURI);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
VirtualArray targetVarray = _dbClient.queryObject(VirtualArray.class, targetVArrayURI);
VirtualNAS sourceVNAS = null;
VirtualNAS targetVNAS = null;
FileDeviceInputOutput sourceArgs = new FileDeviceInputOutput();
FileDeviceInputOutput targetArgs = new FileDeviceInputOutput();
sourceArgs.setFileProtectionPolicy(filePolicy);
sourceArgs.setVPool(vpool);
sourceArgs.setProject(project);
sourceArgs.setTenantOrg(tenant);
targetArgs.setVarray(targetVarray);
if (sourceVNasURI != null) {
sourceVNAS = _dbClient.queryObject(VirtualNAS.class, sourceVNasURI);
sourceArgs.setvNAS(sourceVNAS);
targetArgs.setSourceVNAS(sourceVNAS);
}
targetArgs.setTarget(true);
targetArgs.setSourceSystem(sourceSystem);
targetArgs.setVPool(vpool);
targetArgs.setProject(project);
targetArgs.setTenantOrg(tenant);
if (targetVNasURI != null) {
targetVNAS = _dbClient.queryObject(VirtualNAS.class, targetVNasURI);
targetArgs.setvNAS(targetVNAS);
}
_log.info("Assigning file snapshot policy: {} to vpool {} and project: {}", filePolicyToAssign, vpoolURI, projectURI);
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);
}
}
Aggregations