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);
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations