Example usage for com.amazonaws AmazonClientException AmazonClientException

List of usage examples for com.amazonaws AmazonClientException AmazonClientException

Introduction

In this page you can find the example usage for com.amazonaws AmazonClientException AmazonClientException.

Prototype

public AmazonClientException(Throwable t) 

Source Link

Usage

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public CreateKeyPairResult createKeyPair(CreateKeyPairRequest createKeyPairRequest) {
    try {//w w  w  .  ja v  a  2  s .c  o m
        com.xerox.amazonws.ec2.KeyPairInfo info = jec2.createKeyPair(createKeyPairRequest.getKeyName());
        KeyPair keyPair = new KeyPairConverter().convert(info);
        return new CreateKeyPairResult().withKeyPair(keyPair);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public CreateSnapshotResult createSnapshot(CreateSnapshotRequest createSnapshotRequest) {
    try {//w  ww  .  j a  va  2s  . c  o m
        SnapshotInfo info = jec2.createSnapshot(createSnapshotRequest.getVolumeId());
        Snapshot snapshot = new SnapshotConverter().convert(info);
        return new CreateSnapshotResult().withSnapshot(snapshot);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public CreateVolumeResult createVolume(CreateVolumeRequest createVolumeRequest) {
    String size = createVolumeRequest.getSize() != null ? createVolumeRequest.getSize().toString() : null;

    try {/*w w w. j av  a 2 s .  c o  m*/
        VolumeInfo info = jec2.createVolume(size, createVolumeRequest.getSnapshotId(),
                createVolumeRequest.getAvailabilityZone());
        Volume volume = new VolumeConverter().convert(info);
        return new CreateVolumeResult().withVolume(volume);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DeleteKeyPairResult deleteKeyPair(DeleteKeyPairRequest deleteKeyPairRequest) {
    try {/*from ww  w .j  av  a2 s  . c o  m*/
        jec2.deleteKeyPair(deleteKeyPairRequest.getKeyName());
        return new DeleteKeyPairResult();
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DeleteSnapshotResult deleteSnapshot(DeleteSnapshotRequest deleteSnapshotRequest) {
    try {//www .j a  v a 2s .  c o  m
        jec2.deleteSnapshot(deleteSnapshotRequest.getSnapshotId());
        return new DeleteSnapshotResult();
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DeleteVolumeResult deleteVolume(DeleteVolumeRequest deleteVolumeRequest) {
    try {//from  ww  w .ja v a  2  s. c o m
        jec2.deleteVolume(deleteVolumeRequest.getVolumeId());
        return new DeleteVolumeResult();
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DescribeAddressesResult describeAddresses(DescribeAddressesRequest describeAddressesRequest) {
    List<String> publicIps = describeAddressesRequest.getPublicIps();

    try {//from  w ww .  j a va 2s  .co m
        List<AddressInfo> infos = jec2.describeAddresses(publicIps);

        if (publicIps != null && !publicIps.isEmpty()) {
            // ??????????
            // Eucalyptus?????????
            List<AddressInfo> newInfos = new ArrayList<AddressInfo>();
            for (AddressInfo info : infos) {
                if (publicIps.contains(info.getPublicIp())) {
                    newInfos.add(info);
                }
            }
            infos = newInfos;
        }

        // ??????instanceId??
        // EC2??????Eucalyptus??"available"????
        for (int i = 0; i < infos.size(); i++) {
            AddressInfo info = infos.get(i);
            if ("available".equals(info.getInstanceId())) {
                infos.set(i, new AddressInfo(info.getPublicIp(), ""));
            }
        }

        List<Address> addresses = new AddressConverter().convert(infos);
        return new DescribeAddressesResult().withAddresses(addresses);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DescribeAvailabilityZonesResult describeAvailabilityZones(
        DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest) {
    try {//from w  w  w  .j  a v a  2 s. c o m
        List<com.xerox.amazonws.ec2.AvailabilityZone> zones = jec2
                .describeAvailabilityZones(describeAvailabilityZonesRequest.getZoneNames());
        List<AvailabilityZone> availabilityZones = new AvailabilityZoneConverter().convert(zones);
        return new DescribeAvailabilityZonesResult().withAvailabilityZones(availabilityZones);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DescribeImagesResult describeImages(DescribeImagesRequest describeImagesRequest) {
    try {//w  ww .  j a  v  a 2 s  .  co m
        List<ImageDescription> descriptions = jec2.describeImages(describeImagesRequest.getImageIds(),
                describeImagesRequest.getOwners(), describeImagesRequest.getExecutableUsers(), null);
        List<Image> images = new ImageConverter().convert(descriptions);
        return new DescribeImagesResult().withImages(images);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DescribeInstancesResult describeInstances(DescribeInstancesRequest describeInstancesRequest) {
    try {/*from w w w.  j ava  2  s. c  o m*/
        List<ReservationDescription> descriptions = jec2
                .describeInstances(describeInstancesRequest.getInstanceIds());
        List<Reservation> reservations = new ReservationConverter().convert(descriptions);
        return new DescribeInstancesResult().withReservations(reservations);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}