[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] Hello


  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: "Fabio Sbano" <fsbano@xxxxxxxxx>
  • Date: Sat, 5 May 2007 07:30:52 -0300
  • Delivery-date: Sat, 05 May 2007 03:29:06 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=R6ha+8CBxzlgUDWF55Ss/vmjmpTQOdtjaUz1KWTseoQGldeGTqXYHM4tGK92ZlrXJ4APw6OwuDyf9C1v76Nk9/appUs2f+GQ4IyHdE49tedXdpp/+z6CGK7EcUXmlVBf0Ud+1h4lxbVCiOi3jzwFgT/ibUETihROOdCA5A5aQGY=
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

I´m trying get the 'VM.get_record' of all VMs... however I´m not
obtaining Status=Success by uuid

Can help me ?

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

public class xenapi {

        private static XmlRpcClientConfigImpl config;
   private static XmlRpcClient client;

   /**
    * @param args
    */
   public static void main(String[] args) {
       URL url = null;
       try {
           url = new URL("http://10.1.1.21:9363";);
       } catch (MalformedURLException e) {
           System.out.println("Malformed URL?");
           System.exit(-1);
       }
       config = new XmlRpcClientConfigImpl();
       config.setServerURL(url);
       client = new XmlRpcClient();
       client.setConfig(config);
       String username = "any";
       String password = "any";
       Object[] params = new Object[]{username, password};
       HashMap<String, String> result = null;
       try {
        result = (HashMap)
client.execute("session.login_with_password", params);
       } catch (XmlRpcException e) {
           System.out.println("Could not open session");
           System.exit(-1);
       }
       String status = result.get("Status");
       if (status.compareTo("Success") == 0) {
        String uuid = result.get("Value");
           params = new Object[]{uuid};
           try {
               result = (HashMap) client.execute("VM.get_all", params);
               System.out.println(result);
               Object res = result.get("Value");
               if (res.getClass() == Object[].class) {
                Object[] arr = (Object[])res;
                int i;
                for (i = 0; i < arr.length; i++) {
                        System.out.println("VM UUID: " +(String)arr[i]);
                        String s = (String) arr[i];
                        params = new Object[]{s};
                        try {
                                result = (HashMap) 
client.execute("VM.get_record", params);
                                System.out.println(result);
                        } catch (XmlRpcException e) { }
                }
               }
           } catch (XmlRpcException e) {
               System.out.println("Could not get VMs' UUIDs");
               System.exit(-1);
           }
       }
   }
}

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.