> +    * Retrieve the virtual machine this volume is attached to, or null if it 
> is
> +    * detached.
> +    * 
> +    * @return The virtual machine this volume is attached to, or null if it 
> is
> +    * not attached.
> +    */
> +   public VirtualMachine getVirtualMachine() {
> +      if ( ATTACHED == valueOf(target.getState()) ) {
> +         RESTLink vmLink = 
> checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_MACHINE),
> +               ValidationErrors.MISSING_REQUIRED_LINK + " " + 
> ParentLinkName.VIRTUAL_MACHINE);
> +         vmLink.setType(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE);
> +         HttpResponse response = context.getApi().get(vmLink);
> +
> +         ParseXMLWithJAXB<VirtualMachineWithNodeExtendedDto> parser = new 
> ParseXMLWithJAXB<VirtualMachineWithNodeExtendedDto>(
> +               context.utils().xml(),
> +               TypeLiteral.get(VirtualMachineWithNodeExtendedDto.class));

I think it is safe to do this (see discussion in the mailing list 
[here](http://markmail.org/message/d76czl4tjm4vsjmi)). This is not performing a 
raw http call, but using a [generic method in the 
AbiquoApi](https://github.com/jclouds/jclouds-labs/blob/master/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java#L119-L122)
 to get the resource pointed by the link.

That api call will be managed as other methods in the delegating apis, so all 
error handling, retry logic, etc, will also apply to this call. The only thing 
that is being done manually is to parse the output if the request succeeds, but 
we already know here which is the returned type, so I think it is safe to do 
this here.

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

Reply via email to