Search in sources :

Example 11 with VNXeCommandResult

use of com.emc.storageos.vnxe.models.VNXeCommandResult in project coprhd-controller by CoprHD.

the class VNXUnityBlockStorageDevice method doCreateConsistencyGroup.

@Override
public void doCreateConsistencyGroup(StorageSystem storage, URI consistencyGroup, String replicationGroupName, TaskCompleter taskCompleter) throws DeviceControllerException {
    logger.info("creating consistency group, array: {}", storage.getSerialNumber());
    BlockConsistencyGroup consistencyGroupObj = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    String label = null;
    if (NullColumnValueGetter.isNotNullValue(replicationGroupName)) {
        label = replicationGroupName;
    } else {
        label = consistencyGroupObj.getLabel();
    }
    try {
        VNXeCommandResult result = apiClient.createConsistencyGroup(label);
        if (result.getStorageResource() != null) {
            consistencyGroupObj.addSystemConsistencyGroup(storage.getId().toString(), label);
            consistencyGroupObj.addConsistencyGroupTypes(Types.LOCAL.name());
            if (NullColumnValueGetter.isNullURI(consistencyGroupObj.getStorageController())) {
                consistencyGroupObj.setStorageController(storage.getId());
            }
            dbClient.updateObject(consistencyGroupObj);
            taskCompleter.ready(dbClient);
            logger.info("Consistency group {} created", label);
        } else {
            logger.error("No storage resource Id returned");
            BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroupObj, storage.getId(), null, false, dbClient);
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateConsistencyGroup failed");
            taskCompleter.error(dbClient, error);
        }
    } catch (Exception e) {
        logger.error("Exception caught when creating consistency group ", e);
        BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroupObj, storage.getId(), null, false, dbClient);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateConsistencyGroup", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeCommandResult(com.emc.storageos.vnxe.models.VNXeCommandResult) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 12 with VNXeCommandResult

use of com.emc.storageos.vnxe.models.VNXeCommandResult in project coprhd-controller by CoprHD.

the class VNXeApiClient method createQuotaDirectory.

/**
 * create tree quota
 *
 * @param fsID
 *            file system ID
 * @param quotaName
 *            name of quota to be created
 * @param hardLimit
 *            the provided hard limit
 * @param softLimit
 *            the provided soft limit
 * @param softGrace
 *            The provided grace period for soft limit
 * @return VNXeCommandJob
 * @throws VNXeException
 */
public VNXeCommandJob createQuotaDirectory(final String fsID, final String quotaName, final Long hardLimit, final Long softLimit, final long softGrace) throws VNXeException {
    _logger.info("Creating quota directory with path: {} for fs ID: {}", "/" + quotaName, fsID);
    FileSystemQuotaCreateParam param = new FileSystemQuotaCreateParam();
    FileSystemQuotaConfigParam qcParam = new FileSystemQuotaConfigParam();
    if (softGrace > 0) {
        qcParam.setGracePeriod(softGrace);
    }
    param.setPath("/" + quotaName);
    if (hardLimit > 0) {
        param.setHardLimit(hardLimit);
    }
    FileSystemQuotaRequests req = new FileSystemQuotaRequests(_khClient);
    param.setFilesystem(fsID);
    if (softLimit > 0) {
        param.setSoftLimit(softLimit);
    }
    VNXeCommandResult res = req.createFileSystemQuotaSync(param);
    return req.updateFileSystemQuotaConfig(res.getId(), qcParam);
}
Also used : FileSystemQuotaRequests(com.emc.storageos.vnxe.requests.FileSystemQuotaRequests) VNXeCommandResult(com.emc.storageos.vnxe.models.VNXeCommandResult) FileSystemQuotaCreateParam(com.emc.storageos.vnxe.models.FileSystemQuotaCreateParam) FileSystemQuotaConfigParam(com.emc.storageos.vnxe.models.FileSystemQuotaConfigParam)

Example 13 with VNXeCommandResult

use of com.emc.storageos.vnxe.models.VNXeCommandResult in project coprhd-controller by CoprHD.

the class VNXeApiClient method getHosts.

/**
 * get list host instances based on the endpoints
 *
 * @param endpoints
 *            ipAddress, hostname or subnet
 * @return List of host instances
 * @throws VNXeException
 */
private List<VNXeBase> getHosts(List<String> endpoints) throws VNXeException {
    List<VNXeBase> hosts = null;
    if (endpoints != null) {
        hosts = new ArrayList<VNXeBase>();
        for (String endpoint : endpoints) {
            String ipAddress = null;
            boolean isSubnet = false;
            String netMask = null;
            boolean isValid = true;
            try {
                if (VNXeUtils.isHostType(endpoint)) {
                    ipAddress = VNXeUtils.getHostIp(endpoint);
                } else if (VNXeUtils.isIPV4Type(endpoint) || VNXeUtils.isIPV6Type(endpoint)) {
                    ipAddress = endpoint;
                } else {
                    // check if subnet
                    String[] ends = endpoint.split("/");
                    if (ends != null && ends.length == 2) {
                        ipAddress = ends[0];
                        endpoint = ipAddress;
                        String mask = ends[1];
                        try {
                            // CIDR format?
                            int cidr = Integer.parseInt(mask);
                            netMask = VNXeUtils.convertCIDRToNetmask(cidr);
                            isSubnet = true;
                        } catch (NumberFormatException e) {
                            if (VNXeUtils.isIPV4Type(mask) || VNXeUtils.isIPV6Type(mask)) {
                                netMask = mask;
                                isSubnet = true;
                            } else {
                                isValid = false;
                            }
                        }
                    } else {
                        isValid = false;
                    }
                }
            } catch (UnknownHostException e) {
                _logger.error("Could not resolve the host: " + endpoint);
                throw VNXeException.exceptions.vnxeCommandFailed("Could not resolve the host: " + endpoint);
            }
            if (!isValid) {
                _logger.error("Unsupported endpoint type: " + endpoint);
                throw VNXeException.exceptions.vnxeCommandFailed("Unsupported endpoint type: " + endpoint);
            }
            HostIpPortRequests ipReq = new HostIpPortRequests(_khClient);
            VNXeHostIpPort ipPort = ipReq.getIpPortByIpAddress(ipAddress);
            VNXeBase host = null;
            if (ipPort != null) {
                // HostIPPort found
                host = ipPort.getHost();
                hosts.add(host);
            } else {
                // create host and ipPort
                HostListRequest hostReq = new HostListRequest(_khClient);
                HostCreateParam hostCreateParm = new HostCreateParam();
                hostCreateParm.setName(endpoint);
                if (isSubnet) {
                    hostCreateParm.setType(HostTypeEnum.SUBNET.getValue());
                } else {
                    hostCreateParm.setType(HostTypeEnum.HOSTMANUAL.getValue());
                }
                VNXeCommandResult result = hostReq.createHost(hostCreateParm);
                String hostId = result.getId();
                if (hostId != null) {
                    HostIpPortRequests ipReq2 = new HostIpPortRequests(_khClient);
                    HostIpPortCreateParam ipCreateParm = new HostIpPortCreateParam();
                    host = new VNXeBase(hostId);
                    ipCreateParm.setHost(host);
                    ipCreateParm.setAddress(ipAddress);
                    if (isSubnet) {
                        ipCreateParm.setSubnetMask(netMask);
                    }
                    ipReq2.createHostIpPort(ipCreateParm);
                    hosts.add(host);
                }
            }
        }
    }
    return hosts;
}
Also used : UnknownHostException(java.net.UnknownHostException) HostListRequest(com.emc.storageos.vnxe.requests.HostListRequest) HostIpPortCreateParam(com.emc.storageos.vnxe.models.HostIpPortCreateParam) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) HostIpPortRequests(com.emc.storageos.vnxe.requests.HostIpPortRequests) HostCreateParam(com.emc.storageos.vnxe.models.HostCreateParam) VNXeCommandResult(com.emc.storageos.vnxe.models.VNXeCommandResult) VNXeHostIpPort(com.emc.storageos.vnxe.models.VNXeHostIpPort)

Example 14 with VNXeCommandResult

use of com.emc.storageos.vnxe.models.VNXeCommandResult in project coprhd-controller by CoprHD.

the class BlockLunRequests method modifyLunSync.

/**
 * modify lun, export/unexport/expand, etc
 *
 * @param param
 * @param resourceId
 * @return
 */
public VNXeCommandResult modifyLunSync(LunModifyParam param, String resourceId) {
    StringBuilder urlBld = new StringBuilder(URL_RESOURCE);
    urlBld.append(resourceId);
    urlBld.append(URL_LUN_MODIFY_ACTION);
    _url = urlBld.toString();
    VNXeCommandResult result = postRequestSync(param);
    result.setSuccess(true);
    return result;
}
Also used : VNXeCommandResult(com.emc.storageos.vnxe.models.VNXeCommandResult)

Example 15 with VNXeCommandResult

use of com.emc.storageos.vnxe.models.VNXeCommandResult in project coprhd-controller by CoprHD.

the class DeleteHostInitiatorRequest method deleteHostInitiatorSync.

private VNXeCommandResult deleteHostInitiatorSync(String id) {
    _url = URL + id;
    deleteRequest(null);
    VNXeCommandResult result = new VNXeCommandResult();
    result.setSuccess(true);
    return result;
}
Also used : VNXeCommandResult(com.emc.storageos.vnxe.models.VNXeCommandResult)

Aggregations

VNXeCommandResult (com.emc.storageos.vnxe.models.VNXeCommandResult)23 HostCreateParam (com.emc.storageos.vnxe.models.HostCreateParam)4 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)3 HostListRequest (com.emc.storageos.vnxe.requests.HostListRequest)3 Test (org.junit.Test)3 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)2 VNXeException (com.emc.storageos.vnxe.VNXeException)2 HostIpPortCreateParam (com.emc.storageos.vnxe.models.HostIpPortCreateParam)2 VNXeHostInitiator (com.emc.storageos.vnxe.models.VNXeHostInitiator)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 ArrayList (java.util.ArrayList)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 DeleteStorageResourceParam (com.emc.storageos.vnxe.models.DeleteStorageResourceParam)1 FileSystemQuotaConfigParam (com.emc.storageos.vnxe.models.FileSystemQuotaConfigParam)1 FileSystemQuotaCreateParam (com.emc.storageos.vnxe.models.FileSystemQuotaCreateParam)1 HostInitiatorCreateParam (com.emc.storageos.vnxe.models.HostInitiatorCreateParam)1