use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockVolumes method unlinkTargetSnapshot.
public static void unlinkTargetSnapshot(String sessionId, String volumeId, Boolean deleteOption) {
ViPRCoreClient client = BourneUtil.getViprClient();
SnapshotSessionUnlinkTargetsParam sessionTargets = new SnapshotSessionUnlinkTargetsParam();
List<SnapshotSessionUnlinkTargetParam> targetLists = Lists.newArrayList();
List<RelatedResourceRep> targets = client.blockSnapshotSessions().get(uri(sessionId)).getLinkedTarget();
List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByRefs(targets);
for (BlockSnapshotRestRep snap : snapshots) {
SnapshotSessionUnlinkTargetParam targetList = new SnapshotSessionUnlinkTargetParam();
targetList.setId(snap.getId());
targetList.setDeleteTarget(deleteOption);
targetLists.add(targetList);
}
if (!targetLists.isEmpty()) {
sessionTargets.setLinkedTargets(targetLists);
Task<BlockSnapshotSessionRestRep> tasks = client.blockSnapshotSessions().unlinkTargets(uri(sessionId), sessionTargets);
flash.put("info", MessagesUtils.get("resources.snapshot.session.unlink.success", sessionId));
} else {
flash.error(MessagesUtils.get(NOTARGET, sessionId));
}
volume(volumeId, null);
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class VirtualArrays method findByInitiators.
/**
* Finds the list of virtual arrays connected to any of the given initiators, optionally filtering the results.
*
* @param initiators
* the initiators.
* @param filter
* the resource filter to apply to the results as they are returned (optional).
* @return the list of connected virtual arrays.
*/
public List<VirtualArrayRestRep> findByInitiators(Collection<InitiatorRestRep> initiators, ResourceFilter<VirtualArrayRestRep> filter) {
// Collect unique virtual array refs before fetching
Set<RelatedResourceRep> virtualArrayRefs = new TreeSet<RelatedResourceRep>(new RelatedResourceComparator());
for (InitiatorRestRep initiator : initiators) {
String port = initiator.getInitiatorPort();
virtualArrayRefs.addAll(performSearchBy(SearchConstants.INITIATOR_PORT_PARAM, port));
}
return getByRefs(virtualArrayRefs, filter);
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class ApiTest method updateAllIsilonPorts.
/**
* Update the discovered Isilon storage ports to set the transport zone.
*
* @param isilonDevice : Isilon Device.
*/
private void updateAllIsilonPorts(StorageSystemRestRep isilonDevice) {
// Register all the discovered storage ports .
StoragePortList portList = rZAdmin.path(String.format("/vdc/storage-systems/%s/storage-ports", isilonDevice.getId()).toString()).get(StoragePortList.class);
List<NamedRelatedResourceRep> portURIList = portList.getPorts();
for (RelatedResourceRep portURI : portURIList) {
updateStoragePortTZ(isilonDevice.getId(), portURI);
}
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class ComputeVirtualPoolTest method testComputeVirtualPoolCrud.
// @Test
// public void testComputeVirtualPoolGet() throws Exception {
//
// // long timestamp = System.currentTimeMillis();
//
// System.out.println("-Running testComputeVirtualPoolGet");
//
// ComputeVirtualPoolList cvpResp = rSys.path("/compute/vpools")
// .get(ComputeVirtualPoolList.class);
// List<NamedRelatedResourceRep> cvpList = cvpResp.getComputeVirtualPool();
// Assert.assertTrue(cvpList.size() > 0);
//
// }
@Test
public void testComputeVirtualPoolCrud() throws Exception {
long timestamp = System.currentTimeMillis();
System.out.println("-Running testComputeVirtualPool");
// Create vArray (neighborhood) for test
VirtualArrayCreateParam neighborhoodParam = new VirtualArrayCreateParam();
neighborhoodParam.setLabel("nb1-temp" + String.valueOf(timestamp));
// VirtualArrayRestRep n1 =
// rSys.path("/vdc/varrays").header(RequestProcessingUtils.AUTH_TOKEN_HEADER,
// _rootToken).post(VirtualArrayRestRep.class, neighborhoodParam);
VirtualArrayRestRep n1 = rSys.path("/vdc/varrays").post(VirtualArrayRestRep.class, neighborhoodParam);
Assert.assertNotNull(n1.getId());
System.out.println("-Newly created vArray id - " + n1.getId().toString());
// Create Compute Virtual Pool
ComputeVirtualPoolCreateParam createParams = new ComputeVirtualPoolCreateParam();
createParams.setDescription("VCP created by Unit Test");
createParams.setName("VCP-Unit-Test-1");
createParams.setSystemType("Cisco_UCSM");
createParams.setMinCpuSpeed(2500);
createParams.setMaxCpuSpeed(8000);
createParams.setMinTotalCores(1);
Integer newMaxCores = 8;
createParams.setMaxTotalCores(newMaxCores);
Set<String> vArrays = new HashSet<String>();
vArrays.add(n1.getId().toString());
createParams.setVarrays(vArrays);
ComputeVirtualPoolRestRep cvpCreateResp = rSys.path("/compute/vpools").post(ComputeVirtualPoolRestRep.class, createParams);
URI newId = cvpCreateResp.getId();
Assert.assertNotNull(newId);
System.out.println("-Newly created Compute Virtual Pool id - " + newId.toString());
System.out.println("---max cores - " + cvpCreateResp.getMaxTotalCores());
Assert.assertTrue(cvpCreateResp.getMaxTotalCores() == newMaxCores);
// Get list of virtual pools
ComputeVirtualPoolList cvpResp = rSys.path("/compute/vpools").get(ComputeVirtualPoolList.class);
List<NamedRelatedResourceRep> cvpList = cvpResp.getComputeVirtualPool();
Assert.assertTrue(!cvpList.isEmpty());
// Get details of newly created Compute Virtual Pool
ComputeVirtualPoolRestRep cvpGetResp = rSys.path("/compute/vpools/" + newId.toString()).get(ComputeVirtualPoolRestRep.class);
Assert.assertNotNull(cvpGetResp.getId());
System.out.println("id - " + cvpGetResp.getId().toString());
System.out.println("name - " + cvpGetResp.getName());
System.out.println("description - " + cvpGetResp.getDescription());
List<RelatedResourceRep> vArrayResp = cvpGetResp.getVirtualArrays();
Assert.assertTrue(!vArrayResp.isEmpty());
// Get Matching Compute Elements
ClientResponse ceResp = rSys.path("/compute/vpools/" + newId.toString() + "/matched-compute-elements").get(ClientResponse.class);
// List<ComputeElementRestRep> ceList = ceResp.getList();
Assert.assertTrue(ceResp.getStatus() == 200);
// Update CVP
System.out.println("- Updating - " + newId.toString());
ComputeVirtualPoolUpdateParam updParams = new ComputeVirtualPoolUpdateParam();
Integer updMaxCores = 4;
updParams.setMaxTotalCores(updMaxCores);
ComputeVirtualPoolRestRep updateResp = rSys.path("/compute/vpools/" + newId.toString()).put(ComputeVirtualPoolRestRep.class, updParams);
System.out.println("---max cores - " + updateResp.getMaxTotalCores());
Assert.assertTrue(updateResp.getMaxTotalCores() == updMaxCores);
// Delete CVP
ClientResponse delCvpResp = rSys.path("/compute/vpools/" + newId.toString() + "/deactivate").post(ClientResponse.class);
Assert.assertTrue(delCvpResp != null);
Assert.assertTrue(delCvpResp.getStatus() == 200);
// Delete vArray
ClientResponse deleteResp = rSys.path("/vdc/varrays/" + n1.getId().toString() + "/deactivate").post(ClientResponse.class);
Assert.assertTrue(deleteResp != null);
Assert.assertTrue(deleteResp.getStatus() == 200);
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockMapper method map.
public static UnManagedExportMaskRestRep map(UnManagedExportMask from) {
if (from == null) {
return null;
}
UnManagedExportMaskRestRep to = new UnManagedExportMaskRestRep();
mapDataObjectFields(from, to);
to.setNativeId(from.getNativeId());
to.setMaskName(from.getMaskName());
to.setStorageSystem(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageSystemUri()));
if ((from.getKnownInitiatorUris() != null) && (!from.getKnownInitiatorUris().isEmpty())) {
List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
for (String uri : from.getKnownInitiatorUris()) {
reps.add(toRelatedResource(ResourceTypeEnum.INITIATOR, URI.create(uri)));
}
to.setKnownInitiatorUris(reps);
}
if ((from.getKnownStoragePortUris() != null) && (!from.getKnownStoragePortUris().isEmpty())) {
List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
for (String uri : from.getKnownStoragePortUris()) {
reps.add(toRelatedResource(ResourceTypeEnum.STORAGE_PORT, URI.create(uri)));
}
to.setKnownStoragePortUris(reps);
}
if ((from.getKnownVolumeUris() != null) && (!from.getKnownVolumeUris().isEmpty())) {
List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
for (String uri : from.getKnownVolumeUris()) {
reps.add(toRelatedResource(ResourceTypeEnum.VOLUME, URI.create(uri)));
}
to.setKnownStorageVolumeUris(reps);
}
if ((from.getUnmanagedVolumeUris() != null) && (!from.getUnmanagedVolumeUris().isEmpty())) {
List<RelatedResourceRep> reps = new ArrayList<RelatedResourceRep>();
for (String uri : from.getUnmanagedVolumeUris()) {
reps.add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, URI.create(uri)));
}
to.setUnmanagedVolumeUris(reps);
}
to.setUnmanagedInitiatorNetworkIds(from.getUnmanagedInitiatorNetworkIds());
to.setUnmanagedStoragePortNetworkIds(from.getUnmanagedStoragePortNetworkIds());
return to;
}
Aggregations