/**
  * Remove snapshots, which are in a consistency group
  *
  * @param consistencyGroupId The consistency group ID
  * @throws Exception
  */
 public void removeConsistencyGroupSnapshot(String consistencyGroupId) throws Exception {
   String systemId = getSystemId();
   String uri = ScaleIOConstants.getRemoveConsistencyGroupSnapshotsURI(systemId);
   ScaleIORemoveConsistencyGroupSnapshots parm = new ScaleIORemoveConsistencyGroupSnapshots();
   parm.setSnapGroupId(consistencyGroupId);
   post(URI.create(uri), getJsonForEntity(parm));
 }
 /**
  * Expand the volume
  *
  * @param volumeId The volume ID
  * @param newSizeGB The new size of the volume in GB
  * @throws Exception
  */
 public ScaleIOVolume modifyVolumeCapacity(String volumeId, String newSizeGB) throws Exception {
   String uri = ScaleIOConstants.getModifyVolumeSizeURI(volumeId);
   ScaleIOModifyVolumeSize modifyParm = new ScaleIOModifyVolumeSize();
   modifyParm.setSizeInGB(newSizeGB);
   post(URI.create(uri), getJsonForEntity(modifyParm));
   return queryVolume(volumeId);
 }
 /**
  * Unmap the volume
  *
  * @param volumeId The Volume ID
  * @param sdcId The SDC ID
  * @throws Exception
  */
 public void unMapVolumeToSDC(String volumeId, String sdcId) throws Exception {
   String uri = ScaleIOConstants.getUnmapVolumeToSDCURI(volumeId);
   ScaleIOUnmapVolumeToSDC unmapParm = new ScaleIOUnmapVolumeToSDC();
   unmapParm.setSdcId(sdcId);
   unmapParm.setIgnoreScsiInitiators("TRUE");
   post(URI.create(uri), getJsonForEntity(unmapParm));
 }
 /**
  * Map the volume to SCSI Initiator
  *
  * @param volumeId the volume ID
  * @param initiatorId The ScsiInitiator ID
  * @throws Exception
  */
 public void mapVolumeToSCSIInitiator(String volumeId, String initiatorId) throws Exception {
   log.info("mapping to scsi");
   String uri = ScaleIOConstants.getMapVolumeToScsiInitiatorURI(volumeId);
   ScaleIOMapVolumeToScsiInitiator mapParm = new ScaleIOMapVolumeToScsiInitiator();
   mapParm.setScsiInitiatorId(initiatorId);
   mapParm.setAllowMultipleMapp("TRUE");
   post(URI.create(uri), getJsonForEntity(mapParm));
 }
 /**
  * Map volume to SDC
  *
  * @param volumeId The volume ID
  * @param sdcId The SDC ID
  * @throws Exception
  */
 public void mapVolumeToSDC(String volumeId, String sdcId) throws Exception {
   log.info("mapping to sdc");
   String uri = ScaleIOConstants.getMapVolumeToSDCURI(volumeId);
   ScaleIOMapVolumeToSDC mapParm = new ScaleIOMapVolumeToSDC();
   mapParm.setSdcId(sdcId);
   mapParm.setAllowMultipleMappings("TRUE");
   post(URI.create(uri), getJsonForEntity(mapParm));
 }
 /**
  * Create a snapshot of the volume
  *
  * @param volId The volume ID
  * @param snapshotName The snapshot name
  * @param systemId
  * @return
  * @throws Exception
  */
 public ScaleIOSnapshotVolumeResponse snapshotVolume(
     String volId, String snapshotName, String systemId) throws Exception {
   String uri = ScaleIOConstants.getSnapshotVolumesURI(systemId);
   ScaleIOSnapshotVolumes spVol = new ScaleIOSnapshotVolumes();
   spVol.addSnapshot(volId, snapshotName);
   ClientResponse response = post(URI.create(uri), getJsonForEntity(spVol));
   return getResponseObject(ScaleIOSnapshotVolumeResponse.class, response);
 }
 /**
  * Get the detail information for a pool
  *
  * @param poolId The storage pool native Id
  * @return The storage pool information
  * @throws Exception
  */
 public ScaleIOStoragePool queryStoragePool(String poolId) throws Exception {
   ClientResponse response = get(URI.create(ScaleIOConstants.getStoragePoolStatsURI(poolId)));
   ScaleIOStoragePool pool = getResponseObject(ScaleIOStoragePool.class, response);
   ScaleIOStoragePool poolStats = getStoragePoolStats(poolId);
   pool.setCapacityAvailableForVolumeAllocationInKb(
       poolStats.getCapacityAvailableForVolumeAllocationInKb());
   pool.setMaxCapacityInKb(poolStats.getMaxCapacityInKb());
   return pool;
 }
 /**
  * Create multiple snapshots in a consistency group
  *
  * @param id2snapshot Volume ID to snapshotName map
  * @param systemId The system ID
  * @return The result of the snapshots created
  * @throws Exception
  */
 public ScaleIOSnapshotVolumeResponse snapshotMultiVolume(
     Map<String, String> id2snapshot, String systemId) throws Exception {
   String uri = ScaleIOConstants.getSnapshotVolumesURI(systemId);
   ScaleIOSnapshotVolumes spVol = new ScaleIOSnapshotVolumes();
   for (Map.Entry<String, String> entry : id2snapshot.entrySet()) {
     spVol.addSnapshot(entry.getKey(), entry.getValue());
   }
   ClientResponse response = post(URI.create(uri), getJsonForEntity(spVol));
   return getResponseObject(ScaleIOSnapshotVolumeResponse.class, response);
 }
 /**
  * Get the storage pools in the protection domain
  *
  * @param pdId The protection domain ID
  * @return The List of storage pools
  * @throws JSONException
  */
 public List<ScaleIOStoragePool> getProtectionDomainStoragePools(String pdId) throws Exception {
   ClientResponse response =
       get(URI.create(ScaleIOConstants.getProtectionDomainStoragePoolURI(pdId)));
   List<ScaleIOStoragePool> pools = getResponseObjects(ScaleIOStoragePool.class, response);
   for (ScaleIOStoragePool pool : pools) {
     ScaleIOStoragePool poolResult = getStoragePoolStats(pool.getId());
     pool.setCapacityAvailableForVolumeAllocationInKb(
         poolResult.getCapacityAvailableForVolumeAllocationInKb());
     pool.setMaxCapacityInKb(poolResult.getMaxCapacityInKb());
   }
   return pools;
 }
 /**
  * Query the volume details
  *
  * @param volId The Volume ID
  * @return The details of the volume
  * @throws Exception
  */
 public ScaleIOVolume queryVolume(String volId) throws Exception {
   ClientResponse response = get(URI.create(ScaleIOConstants.getVolumeURI(volId)));
   return getResponseObject(ScaleIOVolume.class, response);
 }
 /**
  * Get the Storage Pool detail data
  *
  * @param poolId The storage pool ID
  * @return The details of the storage pool
  * @throws Exception
  */
 public ScaleIOStoragePool getStoragePoolStats(String poolId) throws Exception {
   ClientResponse response = get(URI.create(ScaleIOConstants.getStoragePoolStatsURI(poolId)));
   ScaleIOStoragePool pool = getResponseObject(ScaleIOStoragePool.class, response);
   pool.setId(poolId);
   return pool;
 }
 /**
  * Unmap the volume from SCSI Initiator
  *
  * @param volumeId The volume ID
  * @param initiatorId The ScsiInitiator ID
  * @throws Exception
  */
 public void unMapVolumeFromSCSIInitiator(String volumeId, String initiatorId) throws Exception {
   String uri = ScaleIOConstants.getUnmapVolumeToScsiInitiatorURI(volumeId);
   ScaleIOUnmapVolumeToScsiInitiator unmapParm = new ScaleIOUnmapVolumeToScsiInitiator();
   unmapParm.setScsiInitiatorId(initiatorId);
   post(URI.create(uri), getJsonForEntity(unmapParm));
 }
 /**
  * Remove the volume
  *
  * @param volumeId The volume ID
  * @throws Exception
  */
 public void removeVolume(String volumeId) throws Exception {
   String uri = ScaleIOConstants.getRemoveVolumeURI(volumeId);
   ScaleIORemoveVolume removeParm = new ScaleIORemoveVolume();
   post(URI.create(uri), getJsonForEntity(removeParm));
 }