Author: jjohnstn
Date: 2010-10-22 15:35:39 -0400 (Fri, 22 Oct 2010)
New Revision: 26007
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
Log:
2010-10-22 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (listProfile): Fix to
wrap the xml result in a StringReader before trying to unmarshal.
(listImages): Ditto.
(listRealms): Ditto.
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getLastImageId): New method.
(setLastImageId): Ditto.
(getLastKeyname): Ditto.
(setLastKeyname): Ditto.
(getImage): Ditto.
(save): Make public.
* src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds): Add code to
get
the last keyname and last imageid used for the cloud.
(saveClouds): Save the last keyname and last imageid used for instance launching.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-10-22 19:24:17
UTC (rev 26006)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-10-22 19:35:39
UTC (rev 26007)
@@ -1,3 +1,19 @@
+2010-10-22 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (listProfile): Fix
to
+ wrap the xml result in a StringReader before trying to unmarshal.
+ (listImages): Ditto.
+ (listRealms): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getLastImageId): New method.
+ (setLastImageId): Ditto.
+ (getLastKeyname): Ditto.
+ (setLastKeyname): Ditto.
+ (getImage): Ditto.
+ (save): Make public.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds): Add code to
get
+ the last keyname and last imageid used for the cloud.
+ (saveClouds): Save the last keyname and last imageid used for instance launching.
+
2010-10-21 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-10-22
19:24:17 UTC (rev 26006)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-10-22
19:35:39 UTC (rev 26007)
@@ -39,6 +39,8 @@
private String username;
private String url;
private String type;
+ private String lastKeyname = "";
+ private String lastImageId = "";
private DeltaCloudClient client;
private ArrayList<DeltaCloudInstance> instances;
private ArrayList<DeltaCloudImage> images;
@@ -131,6 +133,22 @@
return type;
}
+ public String getLastImageId() {
+ return lastImageId;
+ }
+
+ public void setLastImageId(String lastImageId) {
+ this.lastImageId = lastImageId;
+ }
+
+ public String getLastKeyname() {
+ return lastKeyname;
+ }
+
+ public void setLastKeyname(String lastKeyname) {
+ this.lastKeyname = lastKeyname;
+ }
+
public IInstanceFilter getInstanceFilter() {
return instanceFilter;
}
@@ -180,7 +198,7 @@
t.start();
}
- private void save() {
+ public void save() {
// Currently we have to save all clouds instead of just this one
DeltaCloudManager.getDefault().saveClouds();
}
@@ -399,6 +417,18 @@
}
}
+ public DeltaCloudImage getImage(String imageId) {
+ DeltaCloudImage retVal = null;
+ try {
+ Image image = client.listImages(imageId);
+ retVal = new DeltaCloudImage(image);
+ } catch (Exception e) {
+ e.printStackTrace();
+ // do nothing and return null
+ }
+ return retVal;
+ }
+
public boolean testConnection() {
String instanceId = "madeupValue"; //$NON-NLS-1$
try {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2010-10-22
19:24:17 UTC (rev 26006)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java 2010-10-22
19:35:39 UTC (rev 26007)
@@ -64,6 +64,8 @@
Node typeNode = attrs.getNamedItem("type"); // $NON-NLS-1$
Node imageFilterNode = attrs.getNamedItem("imagefilter"); //$NON-NLS-1$
Node instanceFilterNode = attrs.getNamedItem("instancefilter");
//$NON-NLS-1$
+ Node lastKeyNameNode = attrs.getNamedItem("lastkeyname"); //$NON-NLS-1$
+ Node lastImageIdNode = attrs.getNamedItem("lastimage"); //$NON-NLS-1$
String name = nameNode.getNodeValue();
String url = urlNode.getNodeValue();
String username = usernameNode.getNodeValue();
@@ -79,6 +81,12 @@
instanceFilterRules = instanceFilterNode.getNodeValue();
else
instanceFilterRules = IInstanceFilter.ALL_STRING;
+ String lastKeyName = "";
+ if (lastKeyNameNode != null)
+ lastKeyName = lastKeyNameNode.getNodeValue();
+ String lastImageId = "";
+ if (lastImageIdNode != null)
+ lastImageId = lastImageIdNode.getNodeValue();
ISecurePreferences root = SecurePreferencesFactory.getDefault();
ISecurePreferences node = root.node(key);
String password;
@@ -86,6 +94,8 @@
password = node.get("password", null); //$NON-NLS-1$
DeltaCloud cloud = new DeltaCloud(name, url, username, password, type,
false, imageFilterRules, instanceFilterRules);
+ cloud.setLastImageId(lastImageId);
+ cloud.setLastKeyname(lastKeyName);
cloud.loadChildren();
clouds.add(cloud);
} catch (Exception e1) {
@@ -116,10 +126,13 @@
for (DeltaCloud d : clouds) {
p.println("<cloud name=\"" + d.getName() + "\"
url=\"" //$NON-NLS-1$ //$NON-NLS-2$
+ d.getURL() +
- "\" username=\"" + d.getUsername() +
- "\" type=\"" + d.getType() +
- "\" imagefilter=\"" + d.getImageFilter() +
- "\" instancefilter=\"" + d.getInstanceFilter() +
"\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
+ "\" username=\"" + d.getUsername() + //$NON-NLS-1$
//$NON-NLS-2$
+ "\" type=\"" + d.getType() + //$NON-NLS-1$ //$NON-NLS-2$
+ "\" imagefilter=\"" + d.getImageFilter() + //$NON-NLS-1$
//$NON-NLS-2$
+ "\" instancefilter=\"" + d.getInstanceFilter() + //$NON-NLS-1$
//$NON-NLS-2$
+ "\" lastkeyname=\"" + d.getLastKeyname() + //$NON-NLS-1$
//$NON-NLS-2$
+ "\" lastimage=\"" + d.getLastImageId() + //$NON-NLS-1$
//$NON-NLS-2$
+ "\"/>"); //$NON-NLS-1$
}
p.println("</clouds>"); //$NON-NLS-1$
p.close();
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2010-10-22
19:24:17 UTC (rev 26006)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2010-10-22
19:35:39 UTC (rev 26007)
@@ -286,7 +286,7 @@
@Override
public HardwareProfile listProfile(String profileId) throws DeltaCloudClientException {
String request = DCNS.HARDWARE_PROFILES + "/" + profileId;
- return JAXB.unmarshal(sendRequest(request, RequestType.GET), HardwareProfile.class);
+ return JAXB.unmarshal(new StringReader(sendRequest(request, RequestType.GET)),
HardwareProfile.class);
}
@Override
@@ -301,7 +301,7 @@
@Override
public Image listImages(String imageId) throws DeltaCloudClientException {
- return JAXB.unmarshal(sendRequest(DCNS.IMAGES + "/" + imageId,
RequestType.GET), Image.class);
+ return JAXB.unmarshal(new StringReader(sendRequest(DCNS.IMAGES + "/" +
imageId, RequestType.GET)), Image.class);
}
@Override
@@ -322,7 +322,7 @@
@Override
public Realm listRealms(String realmId) throws DeltaCloudClientException {
- return JAXB.unmarshal(sendRequest(DCNS.REALMS + "/" + realmId,
RequestType.GET), Realm.class);
+ return JAXB.unmarshal(new StringReader(sendRequest(DCNS.REALMS + "/" +
realmId, RequestType.GET)), Realm.class);
}
public void createKey(String keyname, String keyStoreLocation) throws
DeltaCloudClientException {