> + /**
> + * Retrieve the virtual machine this volume is attached to.
> + *
> + * @return The virtual machine this volume is attached to, or null if it
> is
> + * not attached.
> + */
> + public VirtualMachine getVirtualMachine() {
> + checkState(ATTACHED == VolumeState.valueOf(target.getState()), "Volume
> is not attached to a VM");
> + 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));
> Personally, I think it is cleaner to use the method to get a generic link and
> manually call the parser to parse the result, than parsing
> the URI of the link to call a concrete method of the specific api class
Makes sense to me...and certainly I'm not the expert on the Abiquo API who
could have a firm opinion here ;-) But getting the parser from the injector
rather than trying to construct it ourselves certainly seems like an
improvement.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/31/files#r7361221