Example usage for com.amazonaws.services.ec2.model BundleInstanceRequest BundleInstanceRequest

List of usage examples for com.amazonaws.services.ec2.model BundleInstanceRequest BundleInstanceRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model BundleInstanceRequest BundleInstanceRequest.

Prototype

public BundleInstanceRequest() 

Source Link

Document

Default constructor for BundleInstanceRequest object.

Usage

From source file:com.zotoh.cloudapi.aws.AMImage.java

License:Open Source License

@Override
public AsynchronousTask<String> imageVirtualMachineToStorage(String vmId, String name, String desc,
        String directory) throws CloudException, InternalException {
    tstEStrArg("directory", directory);
    tstEStrArg("name", name);
    tstEStrArg("instance-id", vmId);
    Properties props = _svc.getCloud().getContext().getCustomProperties();
    String uid = props.getProperty(P_ID);
    String pwd = props.getProperty(P_PWD);
    S3UploadPolicy p = new S3UploadPolicy(uid, pwd, directory, name, 60 * 12);
    S3Storage s3 = new S3Storage().withAWSAccessKeyId(uid).withBucket(directory).withPrefix(name)
            .withUploadPolicy(p.getPolicyString()).withUploadPolicySignature(p.getPolicySignature());
    BundleInstanceResult res = _svc.getCloud().getEC2().bundleInstance(
            new BundleInstanceRequest().withInstanceId(vmId).withStorage(new Storage().withS3(s3)));
    BundleTask t = res == null ? null : res.getBundleTask();
    final String bid = t == null ? null : t.getBundleId();
    if (isEmpty(bid)) {
        throw new CloudException("Bundle Id is empty");
    }//from   w w w  . j  ava  2  s.  c o m
    final AsynchronousTask<String> task = new AsynchronousTask<String>();
    final String manifest = (directory + "/" + name + ".manifest.xml");
    asyncExec(new Runnable() {
        public void run() {
            try {
                waitForBundle(bid, manifest, task);
            } catch (Throwable t) {
                task.complete(t);
            }
        }
    });
    return task;
}