Author: jjohnstn
Date: 2010-08-04 18:23:48 -0400 (Wed, 04 Aug 2010)
New Revision: 23929
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java
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/client/DeltaCloudClient.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java
Log:
2010-08-04 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java: New file.
* src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java: New file.
* src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java (getArchitecture):
Return
the value instead of using toString method.
(getNamedProperty): Verify that properties is not null before accessing.
(getCPU): Return value instead of using toString.
* src/org/jboss/tools/deltacloud/core/client/Property.java (Range.Range): New class.
(getRange): New method.
(Range.getLast): Ditto.
(Range.getFirst): Ditto.
(getEnums): Ditto.
(toString): Fix to not include unit if it is "label".
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getProfiles): New method.
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
(buildHardwareProfile): Fix
bug with getting enum properties.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-08-04 22:15:49
UTC (rev 23928)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-08-04 22:23:48
UTC (rev 23929)
@@ -1,5 +1,23 @@
2010-08-04 Jeff Johnston <jjohnstn(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java (getArchitecture):
Return
+ the value instead of using toString method.
+ (getNamedProperty): Verify that properties is not null before accessing.
+ (getCPU): Return value instead of using toString.
+ * src/org/jboss/tools/deltacloud/core/client/Property.java (Range.Range): New class.
+ (getRange): New method.
+ (Range.getLast): Ditto.
+ (Range.getFirst): Ditto.
+ (getEnums): Ditto.
+ (toString): Fix to not include unit if it is "label".
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getProfiles): New method.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
(buildHardwareProfile): Fix
+ bug with getting enum properties.
+
+2010-08-04 Jeff Johnston <jjohnstn(a)redhat.com>
+
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudAuthException.java: New file.
* src/org/jboss/tools/deltacloud/core/DeltaCloudException.java: New file.
* src/org/jboss/tools/deltacloud/core/DeltaCloudRealm.java: New file.
@@ -14,7 +32,7 @@
printing stack trace.
(getImages): Ditto.
(getRealms): New method.
- (testConnection): Ditto.
+ (testConnection): Ditto.
2010-08-03 Jeff Johnston <jjohnstn(a)redhat.com>
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-08-04
22:15:49 UTC (rev 23928)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-08-04
22:23:48 UTC (rev 23929)
@@ -10,6 +10,7 @@
import org.jboss.tools.deltacloud.core.client.DeltaCloudAuthException;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClient;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
+import org.jboss.tools.deltacloud.core.client.HardwareProfile;
import org.jboss.tools.deltacloud.core.client.Image;
import org.jboss.tools.deltacloud.core.client.Instance;
import org.jboss.tools.deltacloud.core.client.Realm;
@@ -88,6 +89,22 @@
notifyInstanceListListeners(instanceArray);
return instanceArray;
}
+
+ public DeltaCloudHardwareProfile[] getProfiles() {
+ ArrayList<DeltaCloudHardwareProfile> profiles = new
ArrayList<DeltaCloudHardwareProfile>();
+ try {
+ List<HardwareProfile> list = client.listProfiles();
+ for (Iterator<HardwareProfile> i = list.iterator(); i.hasNext();) {
+ DeltaCloudHardwareProfile profile = new DeltaCloudHardwareProfile(i.next());
+ profiles.add(profile);
+ }
+ } catch (DeltaCloudClientException e) {
+ Activator.log(e);
+ }
+ DeltaCloudHardwareProfile[] profileArray = new
DeltaCloudHardwareProfile[profiles.size()];
+ profileArray = profiles.toArray(profileArray);
+ return profileArray;
+ }
public DeltaCloudImage[] getImages() {
ArrayList<DeltaCloudImage> images = new ArrayList<DeltaCloudImage>();
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java 2010-08-04
22:23:48 UTC (rev 23929)
@@ -0,0 +1,44 @@
+package org.jboss.tools.deltacloud.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.deltacloud.core.client.HardwareProfile;
+import org.jboss.tools.deltacloud.core.client.Property;
+
+public class DeltaCloudHardwareProfile {
+
+ private HardwareProfile profile;
+
+ public DeltaCloudHardwareProfile(HardwareProfile profile) {
+ this.profile = profile;
+ }
+
+ public String getId() {
+ return profile.getId();
+ }
+
+ public String getArchitecture() {
+ return profile.getArchitecture();
+ }
+
+ public List<DeltaCloudHardwareProperty> getProperties() {
+ ArrayList<DeltaCloudHardwareProperty> properties = new
ArrayList<DeltaCloudHardwareProperty>();
+ List<Property> clientProperties = profile.getProperties();
+ for (Property p : clientProperties) {
+ DeltaCloudHardwareProperty hwp = new DeltaCloudHardwareProperty(p);
+ properties.add(hwp);
+ }
+ return properties;
+ }
+
+ public DeltaCloudHardwareProperty getNamedProperty(String name) {
+ List<Property> clientProperties = profile.getProperties();
+ for (Property p : clientProperties) {
+ if (p.getName().equals(name))
+ return new DeltaCloudHardwareProperty(p);
+ }
+ return null;
+ }
+
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java 2010-08-04
22:23:48 UTC (rev 23929)
@@ -0,0 +1,59 @@
+package org.jboss.tools.deltacloud.core;
+
+import java.util.List;
+
+import org.jboss.tools.deltacloud.core.client.Property;
+
+public class DeltaCloudHardwareProperty {
+
+ public static enum Kind {FIXED, RANGE, ENUM};
+
+ private Property property;
+
+ public class Range {
+ private String first;
+ private String last;
+
+ public Range(String first, String last) {
+ this.first = first;
+ this.last = last;
+ }
+
+ public String getFirst() {
+ return first;
+ }
+
+ public String getLast() {
+ return last;
+ }
+ }
+
+ public DeltaCloudHardwareProperty(Property property) {
+ this.property = property;
+ }
+
+ public Kind getKind() {
+ return Kind.valueOf(property.getKind());
+ }
+
+ public Range getRange() {
+ return new Range(property.getRange().getFirst(), property.getRange().getLast());
+ }
+
+ public String getUnit() {
+ return property.getUnit();
+ }
+
+ public String getName() {
+ return property.getName();
+ }
+
+ public String getValue() {
+ return property.getValue();
+ }
+
+ public List<String> getEnums() {
+ return property.getEnums();
+ }
+
+}
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-08-04
22:15:49 UTC (rev 23928)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2010-08-04
22:23:48 UTC (rev 23929)
@@ -323,7 +323,11 @@
NodeList enumChildren = child.getChildNodes();
for (int j = 0; j < enumChildren.getLength(); ++j) {
Node enumChild = enumChildren.item(j);
- enums.add(enumChild.getAttributes().getNamedItem("value").getNodeValue());
//$NON-NLS-1$
+ if (enumChild.getNodeName().equals("entry")) {
+ NamedNodeMap attrs = enumChild.getAttributes();
+ Node x = attrs.getNamedItem("value");
+ enums.add(enumChild.getAttributes().getNamedItem("value").getNodeValue());
//$NON-NLS-1$
+ }
}
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java 2010-08-04
22:15:49 UTC (rev 23928)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java 2010-08-04
22:23:48 UTC (rev 23929)
@@ -20,9 +20,11 @@
}
private Property getNamedProperty(String name) {
- for (Property p : properties) {
- if (p.getName().equals(name))
- return p;
+ if (properties != null) {
+ for (Property p : properties) {
+ if (p.getName().equals(name))
+ return p;
+ }
}
return null;
}
@@ -31,7 +33,7 @@
{
Property p = getNamedProperty("architecture");
if (p != null)
- return p.toString();
+ return p.getValue();
return null;
}
@@ -55,7 +57,7 @@
{
Property p = getNamedProperty("cpu");
if (p != null)
- return p.toString();
+ return p.getValue();
return null;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java 2010-08-04
22:15:49 UTC (rev 23928)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java 2010-08-04
22:23:48 UTC (rev 23929)
@@ -10,6 +10,24 @@
public static enum Kind {FIXED, RANGE, ENUM};
+ public class Range {
+ private String first;
+ private String last;
+
+ public Range(String first, String last) {
+ this.first = first;
+ this.last = last;
+ }
+
+ public String getFirst() {
+ return first;
+ }
+
+ public String getLast() {
+ return last;
+ }
+ }
+
public Property()
{
}
@@ -49,6 +67,14 @@
return value;
}
+ public Range getRange() {
+ return new Range(first, last);
+ }
+
+ public List<String> getEnums() {
+ return enums;
+ }
+
public void setName(String name) {
this.name = name;
}
@@ -87,7 +113,7 @@
return s;
}
// must be "fixed"
- return value += " " + unit;
+ return value += " " + (unit.equals("label") ? "" :
unit);
}
}
Show replies by date