* @return
*/
public EC2Snapshot createSnapshot( String volumeId ) {
try {
CloudStackSnapshot snap = getApi().createSnapshot(volumeId, null, null, null);
if (snap == null) {
throw new EC2ServiceException(ServerError.InternalError, "Unable to create snapshot!");
}
EC2Snapshot ec2Snapshot = new EC2Snapshot();
ec2Snapshot.setId(snap.getId());
ec2Snapshot.setName(snap.getName());
ec2Snapshot.setType(snap.getSnapshotType());
ec2Snapshot.setAccountName(snap.getAccountName());
ec2Snapshot.setDomainId(snap.getDomainId());
ec2Snapshot.setCreated(snap.getCreated());
ec2Snapshot.setVolumeId(snap.getVolumeId());
List<CloudStackVolume> vols = getApi().listVolumes(null, null, null, snap.getVolumeId(), null, null, null, null, null, null, null, null);
if(vols.size() > 0) {
assert(vols.get(0).getSize() != null);
Long sizeInGB = vols.get(0).getSize().longValue()/1073741824;
ec2Snapshot.setVolumeSize(sizeInGB);