libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wood...@apache.org
Subject svn commit: r1000529 - /incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/rackspace/RackspaceDriver.java
Date Thu, 23 Sep 2010 16:33:24 GMT
Author: woodser
Date: Thu Sep 23 16:33:24 2010
New Revision: 1000529

URL: http://svn.apache.org/viewvc?rev=1000529&view=rev
Log:
RackspaceDriver improvement from Robert Yokota.

https://issues.apache.org/jira/browse/LIBCLOUD-53

Modified:
    incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/rackspace/RackspaceDriver.java

Modified: incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/rackspace/RackspaceDriver.java
URL: http://svn.apache.org/viewvc/incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/rackspace/RackspaceDriver.java?rev=1000529&r1=1000528&r2=1000529&view=diff
==============================================================================
--- incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/rackspace/RackspaceDriver.java
(original)
+++ incubator/libcloud/sandbox/java/trunk/src/libcloud/providers/rackspace/RackspaceDriver.java
Thu Sep 23 16:33:24 2010
@@ -65,7 +65,14 @@ public class RackspaceDriver extends Nod
 
 		String xml = "<server xmlns=\"http://docs.rackspacecloud.com/servers/api/v1.0\" name=\""
+ name
 				+ "\" imageId=\"" + image.id
-				+ "\" flavorId=\"" + size.id + "\" />";
+				+ "\" flavorId=\"" + size.id + "\">";
+
+        if (auth != null && auth.secret != null) {
+            xml += "<personality><file path=\"/root/.ssh/authorized_keys\">"

+                + auth.secret + "</file></personality>";
+        }
+
+        xml += "</server>";
 		
 		IResponse response = connection.request("POST", "/servers.xml", null, null, xml);
 		RackspaceHandler rh = new RackspaceHandler(response);
@@ -112,6 +119,22 @@ public class RackspaceDriver extends Nod
 		return parseNodes((Document) rh.getParsedObject());
 	}
 
+	/*
+	 * Non-standard extension to list nodes by date.
+	 * 
+	 * @param sinceDate the nodes must be modified after this date
+	 * 
+	 * @return List<INode> are the nodes that were modified after sinceDate
+	 */
+    public List<INode> listNodes(java.util.Date sinceDate) {
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("changes-since", String.valueOf(sinceDate.getTime()));
+       	IResponse response = connection.request("GET", "/servers/detail.xml", null, params,
null);
+        if (response.getStatus() == 304) return new ArrayList<INode>();
+        RackspaceHandler rh = new RackspaceHandler(response);
+        return parseNodes((Document) rh.getParsedObject());
+    }
+
 	public List<NodeSize> listSizes() {
 		IResponse response = connection.request("GET", "/flavors/detail.xml", null, null, null);
 		RackspaceHandler rh = new RackspaceHandler(response);
@@ -123,7 +146,7 @@ public class RackspaceDriver extends Nod
 	private List<NodeImage> parseImages(Document doc) {
 		List<NodeImage> images = new ArrayList<NodeImage>();
 		try {
-			NodeList set = (NodeList) xpath.evaluate("image", doc.getDocumentElement(), XPathConstants.NODESET);
+			NodeList set = (NodeList) xpath.evaluate("//*[local-name()='image']", doc.getDocumentElement(),
XPathConstants.NODESET);
 			for (int i = 0; i < set.getLength(); i++) {
 				images.add(parseImage((Element) set.item(i)));
 			}
@@ -141,7 +164,7 @@ public class RackspaceDriver extends Nod
 	private List<NodeSize> parseSizes(Document doc) {
 		List<NodeSize> sizes = new ArrayList<NodeSize>();
 		try {
-			NodeList set = (NodeList) xpath.evaluate("flavor", doc.getDocumentElement(), XPathConstants.NODESET);
+			NodeList set = (NodeList) xpath.evaluate("//*[local-name()='flavor']", doc.getDocumentElement(),
XPathConstants.NODESET);
 			for (int i = 0; i < set.getLength(); i++) {
 				sizes.add(parseSize((Element) set.item(i)));
 			}
@@ -165,7 +188,7 @@ public class RackspaceDriver extends Nod
 	private List<INode> parseNodes(Document doc) {
 		List<INode> servers = new ArrayList<INode>();
 		try {
-			NodeList set = (NodeList) xpath.evaluate("server", doc.getDocumentElement(), XPathConstants.NODESET);
+			NodeList set = (NodeList) xpath.evaluate("//*[local-name()='server']", doc.getDocumentElement(),
XPathConstants.NODESET);
 			for (int i = 0; i < set.getLength(); i++) {
 				servers.add(parseNode((Element) set.item(i)));
 			}



Mime
View raw message