use of com.emc.storageos.db.client.model.StoragePortGroup in project coprhd-controller by CoprHD.
the class VmaxExportOperations method changePortGroupAddPaths.
@Override
public void changePortGroupAddPaths(StorageSystem storage, URI newMaskURI, URI oldMaskURI, URI portGroupURI, TaskCompleter completer) {
try {
ExportOperationContext context = new VmaxExportOperationContext();
// Prime the context object
completer.updateWorkflowStepContext(context);
StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, portGroupURI);
ExportMask newMask = _dbClient.queryObject(ExportMask.class, newMaskURI);
ExportMask oldMask = _dbClient.queryObject(ExportMask.class, oldMaskURI);
// Validate if there is no ports removed from the port group outside of ViPR
ExportMaskValidationContext ctx = new ExportMaskValidationContext();
ctx.setStorage(storage);
ctx.setExportMask(oldMask);
Collection<URI> volumes = null;
StringMap volumeMap = oldMask.getVolumes();
if (volumeMap == null || volumeMap.isEmpty()) {
_log.warn("No volumes in the export mask: {}", oldMask.getId());
} else {
volumes = StringSetUtil.stringSetToUriList(volumeMap.keySet());
}
ctx.setBlockObjects(volumes, _dbClient);
Collection<URI> inits = StringSetUtil.stringSetToUriList(oldMask.getInitiators());
Collection<Initiator> initiators = _dbClient.queryObject(Initiator.class, inits);
ctx.setInitiators(initiators);
ctx.setAllowExceptions(context == null);
Collection<StoragePort> ports = _dbClient.queryObject(StoragePort.class, StringSetUtil.stringSetToUriList(portGroup.getStoragePorts()));
ctx.setPortGroup(portGroup);
ctx.setStoragePorts(ports);
validator.changePortGroupAddPaths(ctx).validate();
String maskName = oldMask.getMaskName();
String storageGroupName = _helper.getStorageGroupForGivenMaskingView(maskName, storage);
CIMObjectPath storageGroupPath = _cimPath.getStorageGroupObjectPath(storageGroupName, storage);
CIMObjectPath igPath = _helper.getInitiatorGroupForGivenMaskingView(maskName, storage);
CIMObjectPath targetPortGroupPath = _cimPath.getMaskingGroupPath(storage, portGroup.getLabel(), SmisConstants.MASKING_GROUP_TYPE.SE_TargetMaskingGroup);
createMaskingView(storage, newMaskURI, newMask.getMaskName(), storageGroupPath, new VolumeURIHLU[0], targetPortGroupPath, igPath, completer);
} catch (Exception e) {
_log.error(String.format("change port group failed %s", oldMaskURI.toString()), e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
}
Aggregations