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 DescribeKeyPairsResult describeKeyPairs(DescribeKeyPairsRequest describeKeyPairsRequest) {
    try {/*from  w  w w . ja  va2  s .com*/
        List<com.xerox.amazonws.ec2.KeyPairInfo> infos = jec2
                .describeKeyPairs(describeKeyPairsRequest.getKeyNames());
        List<KeyPairInfo> keyPairs = new KeyPairInfoConverter().convert(infos);
        return new DescribeKeyPairsResult().withKeyPairs(keyPairs);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public DescribeRegionsResult describeRegions(DescribeRegionsRequest describeRegionsRequest) {
    try {/* w  w  w  . jav a  2 s .c o m*/
        List<RegionInfo> infos = jec2.describeRegions(describeRegionsRequest.getRegionNames());
        List<Region> regions = new RegionConverter().convert(infos);
        return new DescribeRegionsResult().withRegions(regions);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public DescribeSecurityGroupsResult describeSecurityGroups(
        DescribeSecurityGroupsRequest describeSecurityGroupsRequest) {
    try {//from   www  .  jav a  2  s.  c  o  m
        List<GroupDescription> descriptions = jec2
                .describeSecurityGroups(describeSecurityGroupsRequest.getGroupNames());
        List<SecurityGroup> securityGroups = new SecurityGroupConverter().convert(descriptions);
        return new DescribeSecurityGroupsResult().withSecurityGroups(securityGroups);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public DescribeSnapshotsResult describeSnapshots(DescribeSnapshotsRequest describeSnapshotsRequest) {
    try {/*from w  w  w  .  ja  va2s. c o m*/
        List<SnapshotInfo> infos = jec2.describeSnapshots(describeSnapshotsRequest.getSnapshotIds());
        List<Snapshot> snapshots = new SnapshotConverter().convert(infos);
        return new DescribeSnapshotsResult().withSnapshots(snapshots);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public DescribeVolumesResult describeVolumes(DescribeVolumesRequest describeVolumesRequest) {
    try {//  w ww.  jav  a2  s.c  o m
        List<VolumeInfo> infos = jec2.describeVolumes(describeVolumesRequest.getVolumeIds());
        List<Volume> volumes = new VolumeConverter().convert(infos);
        return new DescribeVolumesResult().withVolumes(volumes);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public DetachVolumeResult detachVolume(DetachVolumeRequest detachVolumeRequest) {
    // Device?? /dev/ ?
    String device = detachVolumeRequest.getDevice();
    if (device != null && device.startsWith("/dev/")) {
        device = device.substring("/dev/".length());
    }//  w  ww  .java 2  s  .  c  o m

    boolean force = detachVolumeRequest.isForce() != null ? detachVolumeRequest.isForce().booleanValue()
            : false;

    try {
        AttachmentInfo info = jec2.detachVolume(detachVolumeRequest.getVolumeId(),
                detachVolumeRequest.getInstanceId(), device, force);
        VolumeAttachment attachment = new VolumeAttachmentConverter().convert(info);
        return new DetachVolumeResult().withAttachment(attachment);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public DisassociateAddressResult disassociateAddress(DisassociateAddressRequest disassociateAddressRequest) {
    try {/*from   w w  w .  j a  v a  2  s  .  co m*/
        jec2.disassociateAddress(disassociateAddressRequest.getPublicIp());
        return new DisassociateAddressResult();
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public ReleaseAddressResult releaseAddress(ReleaseAddressRequest releaseAddressRequest) {
    try {//from w  w w. j a  v a 2  s  .com
        jec2.releaseAddress(releaseAddressRequest.getPublicIp());
        return new ReleaseAddressResult();
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public RunInstancesResult runInstances(RunInstancesRequest runInstancesRequest) {
    // InstanceType
    InstanceType type = InstanceType.getTypeFromString(runInstancesRequest.getInstanceType());

    // AvailabilityZone
    String availabilityZone = null;
    if (runInstancesRequest.getPlacement() != null) {
        availabilityZone = runInstancesRequest.getPlacement().getAvailabilityZone();
    }/*from   w w  w .  j  a  v a 2  s. c  om*/

    // UserData
    String userData = runInstancesRequest.getUserData();
    if (userData != null) {
        userData = new String(Base64.decodeBase64(userData.getBytes()));

        // ??3???????
        int len = userData.getBytes().length;
        int mod = len % 3;
        if (mod != 0) {
            for (int i = 0; i < 3 - mod; i++) {
                userData += ';';
            }
        }
    }

    try {
        ReservationDescription description = jec2.runInstances(runInstancesRequest.getImageId(),
                runInstancesRequest.getMinCount(), runInstancesRequest.getMaxCount(),
                runInstancesRequest.getSecurityGroups(), userData, runInstancesRequest.getKeyName(), true, type,
                availabilityZone, runInstancesRequest.getKernelId(), runInstancesRequest.getRamdiskId(), null);
        Reservation reservation = new ReservationConverter().convert(description);
        return new RunInstancesResult().withReservation(reservation);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}

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

License:Open Source License

@Override
public TerminateInstancesResult terminateInstances(TerminateInstancesRequest terminateInstancesRequest) {
    try {//  w  ww  .  jav a 2 s.  co  m
        List<TerminatingInstanceDescription> descriptions = jec2
                .terminateInstances(terminateInstancesRequest.getInstanceIds());
        List<InstanceStateChange> terminatingInstances = new InstanceStateChangeTerminateConverter()
                .convert(descriptions);
        return new TerminateInstancesResult().withTerminatingInstances(terminatingInstances);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}