Example usage for com.amazonaws.services.ec2.model BundleTask getBundleId

List of usage examples for com.amazonaws.services.ec2.model BundleTask getBundleId

Introduction

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

Prototype


public String getBundleId() 

Source Link

Document

The ID of the bundle task.

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   www .  ja v a 2  s  . co 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;
}