use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeApiClient method removeLunsFromLunGroup.
/**
* Remove luns from the lun group
*
* @param lunGroupId
* lun group id
* @param luns
* list of lun IDs
* @return
*/
public VNXeCommandResult removeLunsFromLunGroup(String lunGroupId, List<String> luns) {
LunGroupModifyParam param = new LunGroupModifyParam();
List<LunAddParam> lunRemoves = new ArrayList<LunAddParam>();
for (String lunId : luns) {
VNXeBase lun = new VNXeBase(lunId);
LunAddParam lunAdd = new LunAddParam();
lunAdd.setLun(lun);
lunRemoves.add(lunAdd);
}
param.setLunRemove(lunRemoves);
LunGroupRequests req = new LunGroupRequests(_khClient);
return req.modifyLunGroupSync(lunGroupId, param);
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeApiClient method createSnap.
/**
* Create snapshot for VNX Unity
*
* @param resourceID
* lun or consistency group id
* @param name
* snapshot name
* @param isReadOnly
* @return VNXeCommandJob
*/
public VNXeCommandJob createSnap(String resourceID, String name, Boolean isReadOnly) {
_logger.info("creating snap for :" + resourceID);
SnapCreateParam parm = new SnapCreateParam();
parm.setStorageResource(new VNXeBase(resourceID));
parm.setName(name);
if (isReadOnly != null) {
parm.setIsReadOnly(isReadOnly);
}
SnapRequests req = new SnapRequests(_khClient);
return req.createSnap(parm);
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeExportOperations method createExportMask.
@Override
public void createExportMask(StorageSystem storage, URI exportMask, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_logger.info("{} createExportMask START...", storage.getSerialNumber());
VNXeApiClient apiClient = getVnxeClient(storage);
List<URI> mappedVolumes = new ArrayList<URI>();
ExportMask mask = null;
try {
_logger.info("createExportMask: Export mask id: {}", exportMask);
_logger.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
_logger.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
_logger.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
ExportOperationContext context = new VNXeExportOperationContext();
taskCompleter.updateWorkflowStepContext(context);
mask = _dbClient.queryObject(ExportMask.class, exportMask);
if (mask == null || mask.getInactive()) {
throw new DeviceControllerException("Invalid ExportMask URI: " + exportMask);
}
Set<String> processedCGs = new HashSet<String>();
Collection<VNXeHostInitiator> initiators = prepareInitiators(initiatorList).values();
VNXeBase host = apiClient.prepareHostsForExport(initiators);
validateInitiators(_dbClient, initiatorList, apiClient, host.getId());
String opId = taskCompleter.getOpId();
for (VolumeURIHLU volURIHLU : volumeURIHLUs) {
URI volUri = volURIHLU.getVolumeURI();
String hlu = volURIHLU.getHLU();
_logger.info(String.format("hlu %s", hlu));
BlockObject blockObject = BlockObject.fetch(_dbClient, volUri);
String nativeId = blockObject.getNativeId();
VNXeExportResult result = null;
Integer newhlu = -1;
if (hlu != null && !hlu.isEmpty() && !hlu.equals(ExportGroup.LUN_UNASSIGNED_STR)) {
newhlu = Integer.valueOf(hlu);
}
String cgName = VNXeUtils.getBlockObjectCGName(blockObject, _dbClient);
if (cgName != null && !processedCGs.contains(cgName)) {
processedCGs.add(cgName);
VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
}
if (URIUtil.isType(volUri, Volume.class)) {
result = apiClient.exportLun(host, nativeId, newhlu);
mask.addVolume(volUri, result.getHlu());
if (result.isNewAccess()) {
mappedVolumes.add(volUri);
}
} else if (URIUtil.isType(volUri, BlockSnapshot.class)) {
if (BlockObject.checkForRP(_dbClient, volUri)) {
_logger.info(String.format("BlockObject %s is a RecoverPoint bookmark. Exporting associated lun %s instead of snap.", volUri, nativeId));
result = apiClient.exportLun(host, nativeId, newhlu);
} else {
result = apiClient.exportSnap(host, nativeId, newhlu);
setSnapWWN(apiClient, blockObject, nativeId);
}
mask.addVolume(volUri, result.getHlu());
if (result.isNewAccess()) {
mappedVolumes.add(volUri);
}
}
}
ExportOperationContext.insertContextOperation(taskCompleter, VNXeExportOperationContext.OPERATION_ADD_VOLUMES_TO_HOST_EXPORT, mappedVolumes);
mask.setNativeId(host.getId());
_dbClient.updateObject(mask);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_logger.error("Unexpected error: createExportMask failed.", e);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("createExportMask", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_logger.info("{} createExportMask END...", storage.getSerialNumber());
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeExportOperations method getHostIdFromInitiators.
private String getHostIdFromInitiators(Collection<Initiator> initiators, VNXeApiClient apiClient) throws Exception {
// all initiator on ViPR host should be on single host
String vnxeHostId = null;
for (Initiator initiator : initiators) {
_logger.info("Processing initiator {}", initiator.getLabel());
String initiatorId = initiator.getInitiatorPort();
if (Protocol.FC.name().equals(initiator.getProtocol())) {
initiatorId = initiator.getInitiatorNode() + ":" + initiatorId;
}
// query initiator on array
VNXeHostInitiator vnxeInitiator = apiClient.getInitiatorByWWN(initiatorId);
if (vnxeInitiator != null) {
VNXeBase parentHost = vnxeInitiator.getParentHost();
if (parentHost != null) {
if (vnxeHostId == null) {
vnxeHostId = parentHost.getId();
} else if (!vnxeHostId.equals(parentHost.getId())) {
String msg = String.format("Initiator %s belongs to %s, but other initiator belongs to %s. Please move initiator to the correct host", initiator.getInitiatorPort(), parentHost.getId(), vnxeHostId);
_logger.error(msg);
throw new DeviceControllerException(msg);
}
}
}
}
if (vnxeHostId == null) {
_logger.warn("No host found");
}
return vnxeHostId;
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXUnityArrayAffinityDiscoverer method getHostURIs.
/**
* Find host URIs that a LUN is exported to
*
* @param lun
* @param apiClient
* @param dbClient
* @param hostIdToHostURIMap
* @return set of host URIs
*/
private Set<URI> getHostURIs(VNXeLun lun, VNXeApiClient apiClient, DbClient dbClient, Map<String, URI> hostIdToHostURIMap) {
Set<URI> hostURIs = new HashSet<URI>();
List<BlockHostAccess> accesses = lun.getHostAccess();
if (accesses != null && !accesses.isEmpty()) {
for (BlockHostAccess access : accesses) {
if (access != null) {
VNXeBase hostId = access.getHost();
if (hostId != null) {
hostURIs.add(getHostURI(apiClient, hostId.getId(), dbClient, hostIdToHostURIMap));
}
}
}
}
return hostURIs;
}
Aggregations