Getting a list of your owned VMs

You can get a list of VMs iterating virtual datacenters, getting the links to each virtual app, then getting the links to its virtual machines.

Instead, you can get a list of your owned VMs (the ones you created) directly. When issuing the login call, the API will return information regarding the user that issued the call:

[root@localhost ~]# curl -u user:xabiquo http://localhost/api/login | xmllint --format -
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<user>
<link rel="edit" type="application/vnd.abiquo.user+xml" href="http://localhost:80/api/admin/enterprises/1/users/2"/>
<link rel="enterprise" type="application/vnd.abiquo.enterprise+xml" href="http://localhost:80/api/admin/enterprises/1"/>
<link rel="role" type="application/vnd.abiquo.role+xml" href="http://localhost:80/api/admin/roles/2"/>
<link rel="virtualmachines" type="application/vnd.abiquo.virtualmachines+xml" href="http://localhost:80/api/admin/enterprises/1/users/2/action/virtualmachines"/>
<active>true</active>
<authType>ABIQUO</authType>
<description>Standard user</description>
<email/>
<id>2</id>
<locale>en_US</locale>
<name>Standard</name>
<nick>user</nick>
<password>c69a39bd64ffb77ea7ee3369dce742f3</password>
<surname>User</surname>
</user>

As you can see, there is a link for virtualmachines. If you follow this link:

[root@localhost ~]# curl -u admin:xabiquo http://localhost:80/api/admin/enterprises/1/users/1/action/virtualmachines | xmllint --format -
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<virtualMachines>
<virtualMachine>
<link rel="configurations" type="application/vnd.abiquo.virtualmachinenetworkconfigurations+xml" href="http://localhost:80/api/cloud/virtualdatacenters/7/virtualappliances/12/virtualmachines/96/network/configurations"/>
<link rel="deploy" type="application/vnd.abiquo.acceptedrequest+xml" href="http://localhost:80/api/cloud/virtualdatacenters/7/virtualappliances/12/virtualmachines/96/action/deploy"/>
<link rel="disks" type="application/vnd.abiquo.harddisks+xml" href="http://localhost:80/api/cloud/virtualdatacenters/7/virtualappliances/12/virtualmachines/96/storage/disks"/>
<link rel="edit" type="application/vnd.abiquo.virtualmachinewithnode+xml" href="http://localhost:80/api/cloud/virtualdatacenters/7/virtualappliances/12/virtualmachines/96"/>
...

You can then use the information in the virtualmachine resources.

0 Comments

Please sign in to leave a comment.