Search in sources :

Example 1 with VNXSnapshot

use of com.emc.storageos.vnx.xmlapi.VNXSnapshot in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    // generate checkpoint baseline name
    args.setSnaphotCheckPointBaseline(args.getSnapshotName() + "_baseline");
    args.setSnapshotMountPath("/" + args.getSnapshotName());
    _log.info("FileShare, Snapshot {} {}", args.getFsUUID(), args.getSnapshotId());
    _log.info("FSName: {}", args.getFsName());
    _log.info("SnapShotName: {}", args.getSnapshotName());
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        FileShare fileShare = args.getFs();
        result = vnxComm.createSnapshot(storage, args.getFsName(), args.getSnapshotName(), fileShare);
        _log.info("createSnapshot call result : {}", result.isCommandSuccess());
        if (result.isCommandSuccess()) {
            VNXSnapshot vnxSnap = (VNXSnapshot) result.getObject();
            args.setSnapNativeId(String.valueOf(vnxSnap.getId()));
            String path = "/" + args.getSnapshotName();
            // Set path & mountpath
            args.setSnapshotMountPath(path);
            args.setSnapshotPath(path);
        }
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    _log.info("Status of the result {}", (result != null) ? result.isCommandSuccess() : result);
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSnapshot(result.getMessage()));
    }
    return cmdResult;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 2 with VNXSnapshot

use of com.emc.storageos.vnx.xmlapi.VNXSnapshot in project coprhd-controller by CoprHD.

the class VNXFileCommApi method createSnapshot.

public XMLApiResult createSnapshot(final StorageSystem system, final String fsName, final String snapshotName, final FileShare fileShare) throws VNXException {
    _log.info("Create Snap for file sys : {} snap name : {}", fsName, snapshotName);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        // get the data mover
        StorageHADomain dataMover = this.getDataMover(fileShare);
        if (null != dataMover) {
            sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
            Map<String, String> existingMounts = sshApi.getFsMountpathMap(dataMover.getAdapterName());
            if (existingMounts.get(fileShare.getName()) == null) {
                String mountCmdArgs = sshApi.formatMountCmd(dataMover.getAdapterName(), fileShare.getName(), fileShare.getMountPath());
                result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_MOUNT_CMD, mountCmdArgs);
                _log.info("filesystem mount is successful for filesystem: {} mount path: {}", fileShare.getName(), fileShare.getMountPath());
            }
        } else {
            Exception e = new Exception("VNX File snapshot creation failed because suitable Data mover to mount the File System not found");
            throw VNXException.exceptions.createExportFailed("VNX File Snapshot create is Failed", e);
        }
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        reqAttributeMap.put(VNXFileConstants.SNAPSHOT_NAME, snapshotName);
        _provExecutor.setKeyMap(reqAttributeMap);
        _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_CREATE_SNAP));
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (cmdResult != null && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            String snapId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.SNAPSHOT_ID);
            String fsysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
            if (snapId != null) {
                int fsId = Integer.parseInt(fsysId);
                int snId = Integer.parseInt(snapId);
                VNXSnapshot vnxSnap = new VNXSnapshot(snapshotName, -1, fsId);
                vnxSnap.setId(snId);
                result.setObject(vnxSnap);
                result.setCommandSuccess();
            } else {
                result.setCommandFailed();
                result.setMessage((String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_MSG));
            }
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_MSG);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return result;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Aggregations

VNXException (com.emc.storageos.vnx.xmlapi.VNXException)2 VNXSnapshot (com.emc.storageos.vnx.xmlapi.VNXSnapshot)2 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)2 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 FileObject (com.emc.storageos.db.client.model.FileObject)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)1 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)1 URISyntaxException (java.net.URISyntaxException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1