Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding a description field to cloud client listing for future grid

  • Loading branch information...
commit 9b9a4ebcd17ba696f3bdf8a29364900c2964047a 1 parent 9d079f9
@buzztroll buzztroll authored
View
14 service/client/java/source/src/org/globus/workspace/cloud/client/AllArgs.java
@@ -130,6 +130,8 @@ public AllArgs(Print print) {
private boolean common_image = false;
private boolean nospinner = false;
+ private String imageDescString = null;
+
// ------------------------------------
private String metadata_mountAs;
@@ -523,6 +525,14 @@ public void intakeCmdlineOptions(String[] args)
this.gotCmdLine(Opts.COMMON_OPT_STRING, "enabled");
}
+ if (line.hasOption(Opts.IMAGE_DESC_OPT_STRING))
+ {
+ final String imageDescString =
+ line.getOptionValue(Opts.IMAGE_DESC_OPT_STRING);
+ this.imageDescString = imageDescString;
+ this.gotCmdLine(Opts.IMAGE_DESC_OPT_STRING, imageDescString);
+ }
+
if (line.hasOption(Opts.NOSPINNER_OPT_STRING)) {
this.nospinner = true;
this.gotCmdLine(Opts.NOSPINNER_OPT_STRING, "enabled");
@@ -1253,6 +1263,10 @@ public void setCommonVMSet(boolean b) {
this.common_image = b;
}
+ public String getVMDescription() {
+ return this.imageDescString;
+ }
+
public boolean getNoSpinner() {
return this.nospinner;
}
View
6 service/client/java/source/src/org/globus/workspace/cloud/client/Opts.java
@@ -168,6 +168,11 @@
public final Option COMMON_OPT =
OptionBuilder.withLongOpt(COMMON_OPT_STRING).create();
+
+ public static final String IMAGE_DESC_OPT_STRING = "imagedesc";
+ public final Option IMAGE_DESC_OPT =
+ OptionBuilder.withLongOpt(IMAGE_DESC_OPT_STRING).create();
+
public static final String NOSPINNER_OPT_STRING = "nospinner";
public final Option NOSPINNER_OPT =
OptionBuilder.withLongOpt(NOSPINNER_OPT_STRING).create();
@@ -267,6 +272,7 @@
this.DEBUG_OPT,
this.TIMEOUT_OPT,
this.COMMON_OPT,
+ this.IMAGE_DESC_OPT,
this.NOSPINNER_OPT,
this.SSH_FILE_OPT,
this.POLL_INTERVAL_OPT,
View
69 service/client/java/source/src/org/globus/workspace/cloud/client/util/CumulusTask.java
@@ -40,11 +40,7 @@
import org.jets3t.service.utils.ObjectUtils;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
@@ -510,6 +506,7 @@ public void flush()
public static final int UPLOAD_TASK = 2;
public static final int DOWNLOAD_TASK = 3;
public static final int LIST_TASK = 4;
+ public static final String descSuffix = ".description";
private int task = -1;
@@ -604,6 +601,7 @@ private void makeBucket(
public void uploadVM(
String localfile,
String vmName,
+ String description,
PrintStream info,
PrintStream debug)
throws ExecutionProblem
@@ -611,6 +609,7 @@ public void uploadVM(
S3Service s3Service = null;
try
{
+ AccessControlList acl = null;
String awsAccessKey = this.args.getXferS3ID();
s3Service = this.getService();
@@ -652,7 +651,7 @@ public void uploadVM(
if (pr != null) {
pr.println("Setting permissions for common use.");
}
- AccessControlList acl = AccessControlList.REST_CANNED_PUBLIC_READ;
+ acl = AccessControlList.REST_CANNED_PUBLIC_READ;
s3Object.setAcl(acl);
}
s3Service.putObject(baseBucketName, s3Object);
@@ -660,6 +659,17 @@ public void uploadVM(
s3Object.closeDataInputStream();
cis.close();
+ if(description != null)
+ {
+ String descObjName = key + this.descSuffix;
+ S3Object descObj = new S3Object(descObjName, description);
+ if (acl != null)
+ {
+ descObj.setAcl(acl);
+ }
+ s3Service.putObject(baseBucketName, descObj);
+ }
+
if (pr != null) {
pr.println("");
pr.println("");
@@ -982,6 +992,49 @@ public String getImagePath(
}
}
+ private String s3DownloadImageDescription(String name, boolean rw)
+ throws ExecutionProblem
+ {
+ String description = null;
+ String descriptionName = name + this.descSuffix;
+ S3Service s3Service = null;
+
+ try
+ {
+ String baseBucketName = this.args.getS3Bucket();
+ String ID = "common";
+ if(rw)
+ {
+ ID = this.args.getXferCanonicalID();
+ }
+ String baseKey = this.args.getXferS3BaseKey();
+ String key = baseKey + "/" + ID + "/" + descriptionName;
+
+ s3Service = this.getService();
+ S3Object s3Object = s3Service.getObject(baseBucketName, key);
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(s3Object.getDataInputStream()));
+
+ String data;
+ StringBuffer sb = new StringBuffer();
+ while ((data = reader.readLine()) != null)
+ {
+ sb.append(data);
+ }
+ description = sb.toString();
+ }
+ catch(Exception s3ex)
+ {
+ //throw new ExecutionProblem(s3ex.toString());
+ }
+ finally
+ {
+ this.shutdownService(s3Service);
+ }
+
+ return description;
+ }
+
private void s3ObjToFileList(
ArrayList files,
S3Object [] s3Objs,
@@ -1011,6 +1064,9 @@ private void s3ObjToFileList(
fl.setReadWrite(rw);
fl.setOwner(s3Objs[i].getOwner().getDisplayName());
+ String desc = this.s3DownloadImageDescription(name, rw);
+ fl.setDescription(desc);
+
files.add(fl);
}
}
@@ -1085,6 +1141,7 @@ public Object call() throws Exception
this.uploadVM(
this.localfile,
this.vmName,
+ this.args.getVMDescription(),
this.info,
this.debug);
break;
View
10 service/client/java/source/src/org/globus/workspace/cloud/client/util/FileListing.java
@@ -29,6 +29,7 @@
private String date;
private String time;
private String owner;
+ private String desc = null;
// -------------------------------------------------------------------------
// GET/SET
@@ -89,4 +90,13 @@ public String getOwner() {
public void setOwner(String owner) {
this.owner = owner;
}
+
+ public void setDescription(String desc) {
+ this.desc = desc;
+ }
+
+ public String getDescription()
+ {
+ return this.desc;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.