@Override
public void setupProvisioning(Stack stack) {
MDCBuilder.buildMdcContext(stack);
try {
Storage storage = gccStackUtil.buildStorage((GccCredential) stack.getCredential(), stack);
Compute compute = gccStackUtil.buildCompute((GccCredential) stack.getCredential(), stack.getName());
GccTemplate template = (GccTemplate) stack.getTemplate();
GccCredential credential = (GccCredential) stack.getCredential();
ImageList list = compute.images().list(credential.getProjectId()).execute();
Long time = new Date().getTime();
if (!containsSpecificImage(list)) {
try {
Bucket bucket = new Bucket();
bucket.setName(credential.getProjectId() + time);
bucket.setStorageClass("STANDARD");
Storage.Buckets.Insert ins = storage.buckets().insert(credential.getProjectId(), bucket);
ins.execute();
} catch (GoogleJsonResponseException ex) {
if (ex.getStatusCode() != CONFLICT) {
throw ex;
}
}
Storage.Objects.Copy copy = storage.objects().copy(BUCKET_NAME, TAR_NAME, credential.getProjectId() + time, TAR_NAME,
new StorageObject());
copy.execute();
Image image = new Image();
image.setName(GccImageType.DEBIAN_HACK.getImageName());