You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Ignasi Barrera <no...@github.com> on 2013/07/10 22:37:22 UTC

[jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Since Abiquo 2.4, all virtual machines for a user can be retrieved in a single API call.

This change removes the strategy that fetched the details of all virtual appliances first (to then get the virtual machines in them), and updates the CloudService to use the single API call.
You can merge this Pull Request by running:

  git pull https://github.com/nacx/jclouds-labs 182-list-all-vms

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds-labs/pull/14

-- Commit Summary --

  * JCLOUDS-182: List all virtual machines in Abiquo

-- File Changes --

    M abiquo/src/main/java/org/jclouds/abiquo/features/CloudApi.java (14)
    M abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java (15)
    D abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java (117)
    M abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveApiTest.java (7)
    M abiquo/src/test/java/org/jclouds/abiquo/features/CloudApiExpectTest.java (25)
    M abiquo/src/test/java/org/jclouds/abiquo/internal/BaseCloudServiceTest.java (1)
    D abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java (78)
    A abiquo/src/test/resources/payloads/all-vms.xml (27)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/14.patch
https://github.com/jclouds/jclouds-labs/pull/14.diff


Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-pull-requests #14](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/14/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14#issuecomment-20866758

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -44,6 +46,11 @@
>   */
>  @Test(groups = "api", testName = "VirtualMachineLiveApiTest")
>  public class VirtualMachineLiveApiTest extends BaseAbiquoApiLiveApiTest {
> +   public void testListAllVirtualMachines() {
> +      Iterable<VirtualMachine> vms = env.context.getCloudService().listVirtualMachines();
> +      assertTrue(size(vms) > 1);

I agree it is a loose condition. The live tests could be executed on a dirty environment, where the user already had deployed vms, so the number of returned vms is not predictable here. The test's setup creates one, though, so I'll add an assertion to check that the created vm is in the list (although as long as the list method is able to return more than one, we can assume it is working).

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14/files#r5160271

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by jkew <no...@github.com>.
> +                  .endpoint(URI.create("http://localhost/api/cloud/virtualmachines")) //
> +                  .addHeader("Authorization", basicAuth) //
> +                  .addHeader("Accept", normalize(VirtualMachinesWithNodeExtendedDto.MEDIA_TYPE)) //
> +                  .build(),
> +            HttpResponse
> +                  .builder()
> +                  .statusCode(200)
> +                  .payload(
> +                        payloadFromResourceWithContentType("/payloads/all-vms.xml",
> +                              normalize(VirtualMachinesWithNodeExtendedDto.MEDIA_TYPE))) //
> +                  .build());
> +
> +      VirtualMachinesWithNodeExtendedDto vms = api.listAllVirtualMachines();
> +      assertEquals(vms.getCollection().size(), 1);
> +      assertEquals(vms.getCollection().get(0).getId(), Integer.valueOf(1));
> +      assertEquals(vms.getCollection().get(0).getName(), "VM");

Not with testng: http://testng.org/javadoc/org/testng/Assert.html

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14/files#r5154776

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs #193](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/193/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14#issuecomment-20866984

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by Andrew Phillips <no...@github.com>.
> @@ -44,6 +46,11 @@
>   */
>  @Test(groups = "api", testName = "VirtualMachineLiveApiTest")
>  public class VirtualMachineLiveApiTest extends BaseAbiquoApiLiveApiTest {
> +   public void testListAllVirtualMachines() {
> +      Iterable<VirtualMachine> vms = env.context.getCloudService().listVirtualMachines();
> +      assertTrue(size(vms) > 1);

Bit of a loose condition? Don't we know how many we expect to be returned?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14/files#r5154614

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by Ignasi Barrera <no...@github.com>.
Closed #14.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-pull-requests #12](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/12/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14#issuecomment-20772144

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by Andrew Phillips <no...@github.com>.
> @@ -44,6 +46,11 @@
>   */
>  @Test(groups = "api", testName = "VirtualMachineLiveApiTest")
>  public class VirtualMachineLiveApiTest extends BaseAbiquoApiLiveApiTest {
> +   public void testListAllVirtualMachines() {
> +      Iterable<VirtualMachine> vms = env.context.getCloudService().listVirtualMachines();
> +      assertTrue(size(vms) > 1);

> so I'll add an assertion to check that the created vm is in the list

Great, thanks!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14/files#r5172270

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by Andrew Phillips <no...@github.com>.
> +                  .endpoint(URI.create("http://localhost/api/cloud/virtualmachines")) //
> +                  .addHeader("Authorization", basicAuth) //
> +                  .addHeader("Accept", normalize(VirtualMachinesWithNodeExtendedDto.MEDIA_TYPE)) //
> +                  .build(),
> +            HttpResponse
> +                  .builder()
> +                  .statusCode(200)
> +                  .payload(
> +                        payloadFromResourceWithContentType("/payloads/all-vms.xml",
> +                              normalize(VirtualMachinesWithNodeExtendedDto.MEDIA_TYPE))) //
> +                  .build());
> +
> +      VirtualMachinesWithNodeExtendedDto vms = api.listAllVirtualMachines();
> +      assertEquals(vms.getCollection().size(), 1);
> +      assertEquals(vms.getCollection().get(0).getId(), Integer.valueOf(1));
> +      assertEquals(vms.getCollection().get(0).getName(), "VM");

The pattern apparently is [`assertEquals(expected, actual)`](http://junit.sourceforge.net/javadoc/org/junit/Assert.html#assertEquals\(java.lang.Object, java.lang.Object\)), i.e. the other way around. I only mention that because the test failure message is confusing if you keep it this way - it would e.g. say "expected 3 but got 1" when you really mean "expected 1 but got 3".

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14/files#r5154722

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by Andrew Phillips <no...@github.com>.
> +                  .endpoint(URI.create("http://localhost/api/cloud/virtualmachines")) //
> +                  .addHeader("Authorization", basicAuth) //
> +                  .addHeader("Accept", normalize(VirtualMachinesWithNodeExtendedDto.MEDIA_TYPE)) //
> +                  .build(),
> +            HttpResponse
> +                  .builder()
> +                  .statusCode(200)
> +                  .payload(
> +                        payloadFromResourceWithContentType("/payloads/all-vms.xml",
> +                              normalize(VirtualMachinesWithNodeExtendedDto.MEDIA_TYPE))) //
> +                  .build());
> +
> +      VirtualMachinesWithNodeExtendedDto vms = api.listAllVirtualMachines();
> +      assertEquals(vms.getCollection().size(), 1);
> +      assertEquals(vms.getCollection().get(0).getId(), Integer.valueOf(1));
> +      assertEquals(vms.getCollection().get(0).getName(), "VM");

Oh...DOH...of course, thanks. Please ignore the comment ;-)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14/files#r5154915

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs #181](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/181/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14#issuecomment-20771963

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-pull-requests #13](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/13/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14#issuecomment-20866759

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by Ignasi Barrera <no...@github.com>.
Merged

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14#issuecomment-20904947

Re: [jclouds-labs] JCLOUDS-182: List all virtual machines in Abiquo (#14)

Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs #192](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/192/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/14#issuecomment-20866596