You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2014/11/27 15:32:36 UTC
[21/24] jclouds-labs git commit: JCLOUDS-785: Leave only Abiquo
skeleton to start coding Abiquo 3 provider
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java
deleted file mode 100644
index 25b6667..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java
+++ /dev/null
@@ -1,887 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWithTasksWrapper;
-import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions;
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.domain.network.Ip;
-import org.jclouds.abiquo.domain.network.Network;
-import org.jclouds.abiquo.domain.network.UnmanagedNetwork;
-import org.jclouds.abiquo.domain.task.VirtualMachineTask;
-import org.jclouds.abiquo.domain.task.VirtualMachineTemplateTask;
-import org.jclouds.abiquo.domain.util.LinkUtils;
-import org.jclouds.abiquo.features.services.MonitoringService;
-import org.jclouds.abiquo.monitor.VirtualMachineMonitor;
-import org.jclouds.abiquo.predicates.LinkPredicates;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.abiquo.strategy.cloud.ListAttachedNics;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.model.transport.AcceptedRequestDto;
-import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto;
-import com.abiquo.server.core.cloud.VirtualApplianceDto;
-import com.abiquo.server.core.cloud.VirtualDatacenterDto;
-import com.abiquo.server.core.cloud.VirtualMachineInstanceDto;
-import com.abiquo.server.core.cloud.VirtualMachineState;
-import com.abiquo.server.core.cloud.VirtualMachineStateDto;
-import com.abiquo.server.core.cloud.VirtualMachineTaskDto;
-import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
-import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto;
-import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationDto;
-import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationsDto;
-import com.abiquo.server.core.infrastructure.storage.DiskManagementDto;
-import com.abiquo.server.core.infrastructure.storage.DisksManagementDto;
-import com.abiquo.server.core.infrastructure.storage.DvdManagementDto;
-import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
-import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to {@link VirtualMachineWithNodeExtendedDto}.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/VirtualMachineResource">
- * http://community.abiquo.com/display/ABI20/VirtualMachineResource</a>
- */
-public class VirtualMachine extends DomainWithTasksWrapper<VirtualMachineWithNodeExtendedDto> {
- /** The virtual appliance where the virtual machine belongs. */
- private VirtualAppliance virtualAppliance;
-
- /** The virtual machine template of the virtual machine. */
- private VirtualMachineTemplate template;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected VirtualMachine(final ApiContext<AbiquoApi> context, final VirtualMachineWithNodeExtendedDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- /**
- * Delete the virtual machine.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource-Deleteavirtualmachine"
- * > http://community.abiquo.com/display/ABI20/VirtualMachineResource#
- * VirtualMachineResource -Deleteavirtualmachine</a>
- */
- public void delete() {
- context.getApi().getCloudApi().deleteVirtualMachine(target);
- target = null;
- }
-
- /**
- * Create a new virtual machine in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource-Createavirtualmachine"
- * > http://community.abiquo.com/display/ABI20/VirtualMachineResource#
- * VirtualMachineResource-Createavirtualmachine</a>
- */
- public void save() {
- checkNotNull(template, ValidationErrors.NULL_RESOURCE + VirtualMachineTemplate.class);
- checkNotNull(template.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + VirtualMachineTemplate.class);
-
- this.updateLink(target, ParentLinkName.VIRTUAL_MACHINE_TEMPLATE, template.unwrap(), "edit");
-
- target = context.getApi().getCloudApi().createVirtualMachine(virtualAppliance.unwrap(), target);
- }
-
- /**
- * Update virtual machine information in the server with the data from this
- * virtual machine. This is an asynchronous call. This method returns a
- * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track
- * of the task completion. Please refer to the documentation for details.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource-Modifyavirtualmachine"
- * > http://community.abiquo.com/display/ABI20/VirtualMachineResource#
- * VirtualMachineResource-Modifyavirtualmachine</a>
- * @see github: <a href=
- * "https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example"
- * > https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-
- * example</a>
- * @return The task reference or <code>null</code> if the operation completed
- * synchronously.
- */
- public VirtualMachineTask update() {
- AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi().updateVirtualMachine(target);
- return taskRef == null ? null : getTask(taskRef).asVirtualMachineTask();
- }
-
- /**
- * Update virtual machine information in the server with the data from this
- * virtual machine. This is an asynchronous call. This method returns a
- * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track
- * of the task completion. Please refer to the documentation for details.
- *
- * @param force
- * Force update.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource-Modifyavirtualmachine"
- * > http://community.abiquo.com/display/ABI20/VirtualMachineResource#
- * VirtualMachineResource-Modifyavirtualmachine</a>
- * @see github: <a href=
- * "https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example"
- * > https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-
- * example</a>
- * @return The task reference or <code>null</code> if the operation completed
- * synchronously.
- */
- public VirtualMachineTask update(final boolean force) {
- AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi()
- .updateVirtualMachine(target, VirtualMachineOptions.builder().force(force).build());
- return taskRef == null ? null : getTask(taskRef).asVirtualMachineTask();
- }
-
- /**
- * Change the state of the virtual machine. This is an asynchronous call.
- * This method returns a {@link org.jclouds.abiquo.domain.task.AsyncTask}
- * object that keeps track of the task completion. Please refer to the
- * documentation for details.
- *
- * @param state
- * The new state of the virtual machine.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource-Changethestateofavirtualmachine"
- * > http://community.abiquo.com/display/ABI20/VirtualMachineResource#
- * VirtualMachineResource-Changethestateofavirtualmachine</a>
- * @see github: <a href=
- * "https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example"
- * > https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-
- * example</a>
- * @return The task reference or <code>null</code> if the operation completed
- * synchronously.
- */
- public VirtualMachineTask changeState(final VirtualMachineState state) {
- VirtualMachineStateDto dto = new VirtualMachineStateDto();
- dto.setState(state);
-
- AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi().changeVirtualMachineState(target, dto);
-
- return getTask(taskRef).asVirtualMachineTask();
- }
-
- /**
- * Retrieve the state of the virtual machine.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource-Retrievethestateofthevirtualmachine"
- * > http://community.abiquo.com/display/ABI20/VirtualMachineResource#
- * VirtualMachineResource-Retrievethestateofthevirtualmachine</a>
- * @return Current state of the virtual machine.
- */
- public VirtualMachineState getState() {
- VirtualMachineStateDto stateDto = context.getApi().getCloudApi().getVirtualMachineState(target);
- VirtualMachineState state = stateDto.getState();
- target.setState(state);
- target.setIdState(state.id());
- return state;
- }
-
- /**
- * Take a snapshot of the given virtual machine.
- * <p>
- * This will create a new {@link VirtualMachineTemplate} in the appliance
- * library based on the given virtual machine.
- *
- * @param snapshotName
- * The name of the snapshot.
- * @return The task reference to the snapshot process.
- */
- public VirtualMachineTemplateTask snapshot(final String snapshotName) {
- VirtualMachineInstanceDto snapshotConfig = new VirtualMachineInstanceDto();
- snapshotConfig.setInstanceName(snapshotName);
-
- AcceptedRequestDto<String> response = context.getApi().getCloudApi()
- .snapshotVirtualMachine(target, snapshotConfig);
-
- return getTask(response).asVirtualMachineTemplateTask();
- }
-
- // Parent access
-
- /**
- * Retrieve the virtual appliance where this virtual machine is.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualApplianceResource#VirtualApplianceResource-Retrieveavirtualappliance"
- * > http://community.abiquo.com/display/ABI20/VirtualApplianceResource#
- * VirtualApplianceResource-Retrieveavirtualappliance</a>
- * @return The virtual appliance where this virtual machine is.
- */
- public VirtualAppliance getVirtualAppliance() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_APPLIANCE),
- ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.VIRTUAL_APPLIANCE);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<VirtualApplianceDto> parser = new ParseXMLWithJAXB<VirtualApplianceDto>(context.utils().xml(),
- TypeLiteral.get(VirtualApplianceDto.class));
-
- return wrap(context, VirtualAppliance.class, parser.apply(response));
- }
-
- /**
- * Retrieve the virtual datacenter where this virtual machine is.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualDatacenterResource#VirtualDatacenterResource-Retireveavirtualdatacenter"
- * > http://community.abiquo.com/display/ABI20/VirtualDatacenterResource
- * # VirtualDatacenterResource-Retireveavirtualdatacenter</a>
- * @return The virtual datacenter where this virtual machine is.
- */
- public VirtualDatacenter getVirtualDatacenter() {
- Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
- VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
- return wrap(context, VirtualDatacenter.class, dto);
- }
-
- /**
- * Retrieve the enterprise of this virtual machine.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrieveanEnterprise"
- * > http://community.abiquo.com/display/ABI20/EnterpriseResource#
- * EnterpriseResource- RetrieveanEnterprise</a>
- * @return Enterprise of this virtual machine.
- */
- public Enterprise getEnterprise() {
- Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
- EnterpriseDto dto = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId);
- return wrap(context, Enterprise.class, dto);
- }
-
- /**
- * Retrieve the template of this virtual machine.
- *
- * @return Template of this virtual machine.
- */
- public VirtualMachineTemplate getTemplate() {
- VirtualMachineTemplateDto dto = context.getApi().getCloudApi().getVirtualMachineTemplate(target);
- return wrap(context, VirtualMachineTemplate.class, dto);
- }
-
- // Children access
-
- public Iterable<HardDisk> listAttachedHardDisks() {
- refresh();
- DisksManagementDto hardDisks = context.getApi().getCloudApi().listAttachedHardDisks(target);
- return wrap(context, HardDisk.class, hardDisks.getCollection());
- }
-
- public Iterable<Volume> listAttachedVolumes() {
- refresh();
- VolumesManagementDto volumes = context.getApi().getCloudApi().listAttachedVolumes(target);
- return wrap(context, Volume.class, volumes.getCollection());
- }
-
- public Iterable<Ip<?, ?>> listAttachedNics() {
- // The strategy will refresh the vm. There is no need to do it here
- ListAttachedNics strategy = context.utils().injector().getInstance(ListAttachedNics.class);
- return ImmutableList.copyOf(strategy.execute(this));
- }
-
- // Actions
-
- public VirtualMachineTask deploy() {
- return deploy(false);
- }
-
- public VirtualMachineTask deploy(final boolean forceEnterpriseSoftLimits) {
- VirtualMachineTaskDto force = new VirtualMachineTaskDto();
- force.setForceEnterpriseSoftLimits(forceEnterpriseSoftLimits);
-
- AcceptedRequestDto<String> response = context.getApi().getCloudApi().deployVirtualMachine(unwrap(), force);
-
- return getTask(response).asVirtualMachineTask();
- }
-
- public VirtualMachineTask undeploy() {
- return undeploy(false);
- }
-
- public VirtualMachineTask undeploy(final boolean forceUndeploy) {
- VirtualMachineTaskDto force = new VirtualMachineTaskDto();
- force.setForceUndeploy(forceUndeploy);
-
- AcceptedRequestDto<String> response = context.getApi().getCloudApi().undeployVirtualMachine(unwrap(), force);
-
- return getTask(response).asVirtualMachineTask();
- }
-
- /**
- * Reboot a virtual machine. This is an asynchronous call. This method
- * returns a {@link org.jclouds.abiquo.domain.task.AsyncTask} object that
- * keeps track of the task completion. Please refer to the documentation for
- * details.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource-Resetavirtualmachine"
- * > http://community.abiquo.com/display/ABI20/Rack+Resource#/
- * VirtualMachineResource#
- * VirtualMachineResource-Resetavirtualmachine</a>
- * @see github: <a href=
- * "https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example"
- * > https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-
- * example</a>
- * @return The task reference or <code>null</code> if the operation completed
- * synchronously.
- */
- public VirtualMachineTask reboot() {
- AcceptedRequestDto<String> response = context.getApi().getCloudApi().rebootVirtualMachine(unwrap());
-
- return getTask(response).asVirtualMachineTask();
- }
-
- public VirtualMachineTask attachHardDisks(final HardDisk... hardDisks) {
- List<HardDisk> expected = Lists.newArrayList(listAttachedHardDisks());
- expected.addAll(Arrays.asList(hardDisks));
-
- HardDisk[] disks = new HardDisk[expected.size()];
- return setHardDisks(expected.toArray(disks));
- }
-
- public VirtualMachineTask detachAllHardDisks() {
- AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi().detachAllHardDisks(target);
- return taskRef == null ? null : getTask(taskRef).asVirtualMachineTask();
- }
-
- public VirtualMachineTask detachHardDisks(final HardDisk... hardDisks) {
- List<HardDisk> expected = Lists.newArrayList(listAttachedHardDisks());
- Iterables.removeIf(expected, hardDiskIdIn(hardDisks));
-
- HardDisk[] disks = new HardDisk[expected.size()];
- return setHardDisks(expected.toArray(disks));
- }
-
- public VirtualMachineTask setHardDisks(final HardDisk... hardDisks) {
- AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi()
- .replaceHardDisks(target, toHardDiskDto(hardDisks));
- return taskRef == null ? null : getTask(taskRef).asVirtualMachineTask();
- }
-
- public VirtualMachineTask attachVolumes(final Volume... volumes) {
- List<Volume> expected = Lists.newArrayList(listAttachedVolumes());
- expected.addAll(Arrays.asList(volumes));
-
- Volume[] vols = new Volume[expected.size()];
- return setVolumes(true, expected.toArray(vols));
- }
-
- public VirtualMachineTask detachAllVolumes() {
- AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi().detachAllVolumes(target);
- return taskRef == null ? null : getTask(taskRef).asVirtualMachineTask();
- }
-
- public VirtualMachineTask detachVolumes(final Volume... volumes) {
- List<Volume> expected = Lists.newArrayList(listAttachedVolumes());
- Iterables.removeIf(expected, volumeIdIn(volumes));
-
- Volume[] vols = new Volume[expected.size()];
- return setVolumes(true, expected.toArray(vols));
- }
-
- public VirtualMachineTask setVolumes(final Boolean forceSoftLimits, final Volume... volumes) {
- AcceptedRequestDto<String> taskRef = context
- .getApi()
- .getCloudApi()
- .replaceVolumes(target, VirtualMachineOptions.builder().force(forceSoftLimits).build(),
- toVolumeDto(volumes));
-
- return taskRef == null ? null : getTask(taskRef).asVirtualMachineTask();
- }
-
- public VirtualMachineTask setVolumes(final Volume... volumes) {
- return setVolumes(true, volumes);
- }
-
- public VirtualMachineTask setNics(final List<Ip<?, ?>> ips) {
- // By default the network of the first ip will be used as a gateway
- return setNics(ips != null && !ips.isEmpty() ? ips.get(0).getNetwork() : null, ips, null);
- }
-
- public VirtualMachineTask setNics(final List<Ip<?, ?>> ips, final List<UnmanagedNetwork> unmanagedNetworks) {
- // By default the network of the first ip will be used as a gateway
- Network<?> gateway = null;
- if (ips != null && !ips.isEmpty()) {
- gateway = ips.get(0).getNetwork();
- } else if (unmanagedNetworks != null && !unmanagedNetworks.isEmpty()) {
- gateway = unmanagedNetworks.get(0);
- }
-
- return setNics(gateway, ips, unmanagedNetworks);
- }
-
- public VirtualMachineTask setNics(final Network<?> gatewayNetwork, final List<Ip<?, ?>> ips) {
- return setNics(gatewayNetwork, ips, null);
- }
-
- public VirtualMachineTask setNics(final Network<?> gatewayNetwork, final List<Ip<?, ?>> ips,
- final List<UnmanagedNetwork> unmanagedNetworks) {
- // Remove the gateway configuration and the current nics
- Iterables.removeIf(target.getLinks(),
- Predicates.or(LinkPredicates.isNic(), LinkPredicates.rel(ParentLinkName.NETWORK_GATEWAY)));
-
- // Add the given nics in the appropriate order
- int i = 0;
- if (ips != null) {
- for (i = 0; i < ips.size(); i++) {
- RESTLink source = LinkUtils.getSelfLink(ips.get(i).unwrap());
- RESTLink link = new RESTLink("nic" + i, source.getHref());
- link.setType(ips.get(i).unwrap().getBaseMediaType());
- target.addLink(link);
- }
- }
-
- // Add unmanaged network references, if given
- if (unmanagedNetworks != null) {
- for (UnmanagedNetwork unmanaged : unmanagedNetworks) {
- RESTLink source = checkNotNull(unmanaged.unwrap().searchLink("ips"), ValidationErrors.MISSING_REQUIRED_LINK
- + "ips");
-
- RESTLink link = new RESTLink("nic" + i, source.getHref());
- link.setType(UnmanagedIpDto.BASE_MEDIA_TYPE);
- target.addLink(link);
- i++;
- }
- }
-
- VirtualMachineTask task = update(true);
- if (gatewayNetwork == null) {
- return task;
- }
-
- // If there is a gateway network, we have to wait until the network
- // configuration links are
- // available
- if (task != null) {
- VirtualMachineState originalState = target.getState();
- VirtualMachineMonitor monitor = context.utils().injector().getInstance(MonitoringService.class)
- .getVirtualMachineMonitor();
- monitor.awaitState(originalState, this);
- }
-
- // Set the new network configuration
-
- // Refresh virtual machine, to get the new configuration links
- refresh();
-
- VMNetworkConfigurationsDto configs = context.getApi().getCloudApi().listNetworkConfigurations(target);
-
- Iterables.removeIf(target.getLinks(), LinkPredicates.rel(ParentLinkName.NETWORK_GATEWAY));
- for (VMNetworkConfigurationDto config : configs.getCollection()) {
- if (config.getGateway().equalsIgnoreCase(gatewayNetwork.getGateway())) {
- target.addLink(new RESTLink(ParentLinkName.NETWORK_GATEWAY, config.getEditLink().getHref()));
- break;
- }
- }
-
- return update(true);
- }
-
- // TODO: Get current gateway network
-
- public void setGatewayNetwork(final Network<?> network) {
- context.getApi().getCloudApi().setGatewayNetwork(target, network.unwrap());
- refresh(); // First refresh the target and its links
- }
-
- /**
- * Checks if the virtual machine is persistent.
- * <p>
- * Persistent virtual machines have the system disc in an external volume.
- * This way, when the virtual machine is undeployed, the contents of the
- * system disk remain in the storage device and the user can deploy the
- * virtual machine again without losing the data in the system disk.
- *
- * @return Boolean indicating if the virtual machine is persistent.
- */
- public boolean isPersistent() {
- return getTemplate().unwrap().searchLink("volume") != null;
- }
-
- public boolean hasDvd() {
- return target.getDvd() != null;
- }
-
- public void attachDvd() {
- DvdManagementDto dvd = new DvdManagementDto();
- RESTLink link = new RESTLink("image", "");
- dvd.addLink(link);
- target.setDvd(dvd);
- }
-
- public void detachDvd() {
- target.setDvd(null);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final VirtualAppliance virtualAppliance,
- final VirtualMachineTemplate template) {
- return new Builder(context, virtualAppliance, template);
- }
-
- public static class Builder {
- private final ApiContext<AbiquoApi> context;
-
- private VirtualAppliance virtualAppliance;
-
- private final VirtualMachineTemplate template;
-
- private String nameLabel;
-
- private String internalName;
-
- private String description;
-
- private Integer ram;
-
- private Integer cpu;
-
- private Integer vncPort;
-
- private String vncAddress;
-
- private Integer idState;
-
- private Integer idType;
-
- private String password;
-
- private String keymap;
-
- private String uuid;
-
- private boolean dvd;
-
- public Builder(final ApiContext<AbiquoApi> context, final VirtualAppliance virtualAppliance,
- final VirtualMachineTemplate template) {
- super();
- checkNotNull(virtualAppliance, ValidationErrors.NULL_RESOURCE + VirtualAppliance.class);
- this.virtualAppliance = virtualAppliance;
- this.template = template;
- this.context = context;
- }
-
- public Builder nameLabel(final String nameLabel) {
- this.nameLabel = checkNotNull(nameLabel, "nameLabel must not be null");
- return this;
- }
-
- public Builder description(final String description) {
- this.description = description;
- return this;
- }
-
- public Builder ram(final int ram) {
- this.ram = ram;
- return this;
- }
-
- public Builder cpu(final int cpu) {
- this.cpu = cpu;
- return this;
- }
-
- public Builder password(final String password) {
- this.password = password;
- return this;
- }
-
- public Builder keymap(final String keymap) {
- this.keymap = keymap;
- return this;
- }
-
- public Builder dvd(final boolean dvd) {
- this.dvd = dvd;
- return this;
- }
-
- // This methods are used only to build a builder from an existing
- // VirtualMachine but should
- // never be used by the user. This fields are set automatically by Abiquo
-
- private Builder vncPort(final int vdrpPort) {
- this.vncPort = vdrpPort;
- return this;
- }
-
- private Builder vncAddress(final String vdrpIP) {
- this.vncAddress = vdrpIP;
- return this;
- }
-
- private Builder idState(final int idState) {
- this.idState = idState;
- return this;
- }
-
- private Builder idType(final int idType) {
- this.idType = idType;
- return this;
- }
-
- private Builder internalName(final String internalName) {
- this.internalName = internalName;
- return this;
- }
-
- public Builder virtualAppliance(final VirtualAppliance virtualAppliance) {
- checkNotNull(virtualAppliance, ValidationErrors.NULL_RESOURCE + VirtualAppliance.class);
- this.virtualAppliance = virtualAppliance;
- return this;
- }
-
- public VirtualMachine build() {
- VirtualMachineWithNodeExtendedDto dto = new VirtualMachineWithNodeExtendedDto();
- dto.setNodeName(checkNotNull(nameLabel, ValidationErrors.MISSING_REQUIRED_FIELD + "nameLabel"));
- dto.setDescription(description);
- dto.setHdInBytes(template.getHdRequired());
- dto.setVdrpIP(vncAddress);
-
- if (cpu != null) {
- dto.setCpu(cpu);
- }
-
- if (ram != null) {
- dto.setRam(ram);
- }
-
- if (vncPort != null) {
- dto.setVdrpPort(vncPort);
- }
-
- if (idState != null) {
- dto.setIdState(idState);
- }
-
- if (idType != null) {
- dto.setIdType(idType);
- }
-
- if (internalName != null) {
- dto.setName(internalName);
- }
-
- dto.setPassword(password);
- dto.setKeymap(keymap);
- dto.setUuid(uuid);
-
- // DVD
- if (dvd) {
- DvdManagementDto dvd = new DvdManagementDto();
- RESTLink link = new RESTLink("image", "");
- dvd.addLink(link);
- dto.setDvd(dvd);
- }
-
- VirtualMachine virtualMachine = new VirtualMachine(context, dto);
- virtualMachine.virtualAppliance = virtualAppliance;
- virtualMachine.template = template;
-
- return virtualMachine;
- }
-
- public static Builder fromVirtualMachine(final VirtualMachine in) {
- return VirtualMachine.builder(in.context, in.virtualAppliance, in.template).internalName(in.getInternalName())
- .nameLabel(in.getNameLabel()).description(in.getDescription()).ram(in.getRam()).cpu(in.getCpu())
- .vncAddress(in.getVncAddress()).vncPort(in.getVncPort()).idState(in.getIdState()).idType(in.getIdType())
- .password(in.getPassword()).keymap(in.getKeymap()).dvd(in.hasDvd());
- }
- }
-
- // Delegate methods
-
- public Integer getCpu() {
- return target.getCpu();
- }
-
- public String getDescription() {
- return target.getDescription();
- }
-
- // Read-only field. This value is computed from the size of the Template
- public Long getHdInBytes() {
- return target.getHdInBytes();
- }
-
- public Integer getId() {
- return target.getId();
- }
-
- public int getIdState() {
- return target.getIdState();
- }
-
- public int getIdType() {
- return target.getIdType();
- }
-
- public String getNameLabel() {
- return target.getNodeName();
- }
-
- public String getOwnerName() {
- return target.getUserName() + " " + target.getUserSurname();
- }
-
- public String getInternalName() {
- return target.getName();
- }
-
- public String getPassword() {
- return target.getPassword();
- }
-
- public Integer getRam() {
- return target.getRam();
- }
-
- public String getUuid() {
- return target.getUuid();
- }
-
- public String getVncAddress() {
- return target.getVdrpIP();
- }
-
- public int getVncPort() {
- return target.getVdrpPort();
- }
-
- public String getKeymap() {
- return target.getKeymap();
- }
-
- public void setCpu(final int cpu) {
- target.setCpu(cpu);
- }
-
- public void setDescription(final String description) {
- target.setDescription(description);
- }
-
- public void setNameLabel(final String nameLabel) {
- target.setNodeName(nameLabel);
- }
-
- public void setPassword(final String password) {
- target.setPassword(password);
- }
-
- public void setRam(final int ram) {
- target.setRam(ram);
- }
-
- public void setKeymap(final String keymap) {
- target.setKeymap(keymap);
- }
-
- private static VolumeManagementDto[] toVolumeDto(final Volume... volumes) {
- checkNotNull(volumes, "must provide at least one volume");
-
- VolumeManagementDto[] dtos = new VolumeManagementDto[volumes.length];
- for (int i = 0; i < volumes.length; i++) {
- dtos[i] = volumes[i].unwrap();
- }
-
- return dtos;
- }
-
- private static DiskManagementDto[] toHardDiskDto(final HardDisk... hardDisks) {
- checkNotNull(hardDisks, "must provide at least one hard disk");
-
- DiskManagementDto[] dtos = new DiskManagementDto[hardDisks.length];
- for (int i = 0; i < hardDisks.length; i++) {
- dtos[i] = hardDisks[i].unwrap();
- }
-
- return dtos;
- }
-
- private static Predicate<Volume> volumeIdIn(final Volume... volumes) {
- return new Predicate<Volume>() {
- List<Integer> ids = volumeIds(Arrays.asList(volumes));
-
- @Override
- public boolean apply(final Volume input) {
- return ids.contains(input.getId());
- }
- };
- }
-
- private static Predicate<HardDisk> hardDiskIdIn(final HardDisk... hardDisks) {
- return new Predicate<HardDisk>() {
- List<Integer> ids = hardDisksIds(Arrays.asList(hardDisks));
-
- @Override
- public boolean apply(final HardDisk input) {
- return ids.contains(input.getId());
- }
- };
- }
-
- private static List<Integer> volumeIds(final List<Volume> volumes) {
- return Lists.transform(volumes, new Function<Volume, Integer>() {
- @Override
- public Integer apply(final Volume input) {
- return input.getId();
- }
- });
- }
-
- private static List<Integer> hardDisksIds(final List<HardDisk> HardDisk) {
- return Lists.transform(HardDisk, new Function<HardDisk, Integer>() {
- @Override
- public Integer apply(final HardDisk input) {
- return input.getId();
- }
- });
- }
-
- @Override
- public String toString() {
- return "VirtualMachine [id=" + getId() + ", state=" + target.getState().name() + ", cpu=" + getCpu()
- + ", description=" + getDescription() + ", hdInBytes=" + getHdInBytes() + ", idType=" + getIdType()
- + ", nameLabel=" + getNameLabel() + ", internalName=" + getInternalName() + ", password=" + getPassword()
- + ", ram=" + getRam() + ", uuid=" + getUuid() + ", vncAddress=" + getVncAddress() + ", vncPort="
- + getVncPort() + ", keymap=" + getKeymap() + ", dvd=" + hasDvd() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java
deleted file mode 100644
index 30cb26b..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Date;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.cloud.options.ConversionOptions;
-import org.jclouds.abiquo.domain.config.Category;
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.infrastructure.Tier;
-import org.jclouds.abiquo.domain.task.ConversionTask;
-import org.jclouds.abiquo.domain.task.VirtualMachineTemplateTask;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.ConversionState;
-import com.abiquo.model.enumerator.DiskFormatType;
-import com.abiquo.model.enumerator.HypervisorType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.model.transport.AcceptedRequestDto;
-import com.abiquo.server.core.appslibrary.CategoryDto;
-import com.abiquo.server.core.appslibrary.ConversionDto;
-import com.abiquo.server.core.appslibrary.ConversionsDto;
-import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto;
-import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto;
-import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to {@link VirtualMachineTemplateDto}.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource"
- * >
- * http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource
- * </a>
- */
-public class VirtualMachineTemplate extends DomainWrapper<VirtualMachineTemplateDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected VirtualMachineTemplate(final ApiContext<AbiquoApi> context, final VirtualMachineTemplateDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- public void delete() {
- context.getApi().getVirtualMachineTemplateApi().deleteVirtualMachineTemplate(target);
- target = null;
- }
-
- public void update() {
- target = context.getApi().getVirtualMachineTemplateApi().updateVirtualMachineTemplate(target);
- }
-
- public VirtualMachineTemplateTask makePersistent(final VirtualDatacenter vdc, final Volume volume,
- final String persistentTemplateName) {
- RESTLink storageLink = volume.unwrap().getEditLink();
- storageLink.setRel("volume");
- return makePersistent(vdc, storageLink, persistentTemplateName, null);
- }
-
- public VirtualMachineTemplateTask makePersistent(final VirtualDatacenter vdc, final Tier tier,
- final String persistentTemplateName, final String persistentVolumeName) {
- // infrastructure
- RESTLink storageLink = tier.unwrap().getEditLink();
- if (storageLink == null) {
- // cloud
- storageLink = tier.unwrap().searchLink("self");
- }
- storageLink.setRel(ParentLinkName.TIER);
- return makePersistent(vdc, storageLink, persistentTemplateName, persistentVolumeName);
- }
-
- private VirtualMachineTemplateTask makePersistent(final VirtualDatacenter vdc, final RESTLink storageLink,
- final String persistentTemplateName, final String persistentVolumeName) {
- VirtualMachineTemplatePersistentDto persistentData = new VirtualMachineTemplatePersistentDto();
- persistentData.setPersistentTemplateName(persistentTemplateName);
- persistentData.setPersistentVolumeName(persistentVolumeName);
- RESTLink vdcLink = new RESTLink(ParentLinkName.VIRTUAL_DATACENTER, vdc.unwrap().getEditLink().getHref());
- RESTLink templateLink = new RESTLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE, target.getEditLink().getHref());
-
- persistentData.addLink(vdcLink);
- persistentData.addLink(storageLink);
- persistentData.addLink(templateLink);
-
- // SCG:
- // A simple user should not have permissions to obtain a datacenter
- // repository, but at this
- // point we have the datacenter repository and enterprise ids in the own
- // target uri. So we
- // can obtain the path where do the POST
- // Assumption that to create a new object a user needs to get the parent
- // object cannot be
- // applied in this case
- String editUri = getURI().getPath();
- Pattern p = Pattern.compile("\\d+");
- Matcher m = p.matcher(editUri);
- m.find();
- Integer idEnt = Integer.valueOf(m.group());
- m.find();
- Integer idDcRepo = Integer.valueOf(m.group());
-
- AcceptedRequestDto<String> response = context.getApi().getVirtualMachineTemplateApi()
- .createPersistentVirtualMachineTemplate(idEnt, idDcRepo, persistentData);
-
- return getTask(response).asVirtualMachineTemplateTask();
- }
-
- // Children access
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Retrieveacategory"
- * > http://community.abiquo.com/display/ABI20/Category+Resource#
- * CategoryResource- Retrieveacategory</a>
- */
- public Category getCategory() {
- Integer categoryId = target.getIdFromLink(ParentLinkName.CATEGORY);
- CategoryDto category = context.getApi().getConfigApi().getCategory(categoryId);
- return wrap(context, Category.class, category);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/Abiquo/Volume+Resource#VolumeResource-Retrieveavolume"
- * > http://community.abiquo.com/display/Abiquo/Volume+Resource#
- * VolumeResource- Retrieveavolume</a>
- */
- public Volume getVolume() {
- if (this.isPersistent()) {
- HttpResponse rp = checkNotNull(context.getApi().get(target.searchLink("volume")), "volume");
-
- ParseXMLWithJAXB<VolumeManagementDto> parser = new ParseXMLWithJAXB<VolumeManagementDto>(
- context.utils().xml(), TypeLiteral.get(VolumeManagementDto.class));
-
- VolumeManagementDto dto = parser.apply(rp);
- return new Volume(context, dto);
- }
- return null;
- }
-
- public boolean isPersistent() {
- return target.searchLink("volume") != null;
- }
-
- // Parent access
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveanEnterprise"
- * > http://community.abiquo.com/display/ABI20/Enterprise+Resource#
- * EnterpriseResource- RetrieveanEnterprise</a>
- */
- public Enterprise getEnterprise() {
- Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
- return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId));
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Datacenter+Resource#DatacenterResource-RetrieveaDatacenter"
- * > http://community.abiquo.com/display/ABI20/Datacenter+Resource#
- * DatacenterResource- RetrieveaDatacenter</a>
- */
- public Datacenter getDatacenter() {
- Integer repositoryId = target.getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY);
- return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(repositoryId));
- }
-
- /**
- * List all the conversions for the virtual machine template.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-ListConversions"
- * > http://community.abiquo.com/display/ABI20/Conversion+Resource#
- * ConversionResource- ListConversions</a>
- * @return all the conversions of the virtual machine template
- */
- public Iterable<Conversion> listConversions() {
- ConversionsDto convs = context.getApi().getVirtualMachineTemplateApi().listConversions(target);
- return wrap(context, Conversion.class, convs.getCollection());
- }
-
- /**
- * List conversions for a virtual machine template.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-ListConversions"
- * > http://community.abiquo.com/display/ABI20/Conversion+Resource#
- * ConversionResource- ListConversions</a>
- * @param hypervisor
- * , Optionally filter conversions compatible with the provided
- * hypervisor
- * @param state
- * , Optionally filter conversions with the desired state
- * @return all the conversions of the virtual machine template applying the
- * constrains
- */
- public Iterable<Conversion> listConversions(final HypervisorType hypervisor, final ConversionState state) {
- ConversionsDto convs = context
- .getApi()
- .getVirtualMachineTemplateApi()
- .listConversions(target,
- ConversionOptions.builder().hypervisorType(hypervisor).conversionState(state).build());
- return wrap(context, Conversion.class, convs.getCollection());
- }
-
- /**
- * Starts a new conversion for a virtual machine template.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-RequestConversion"
- * > http://community.abiquo.com/display/ABI20/Conversion+Resource#
- * ConversionResource- RequestConversion</a>
- * @param diskFormat
- * , desired target format for the request template
- * @return The task reference to track its progress
- */
- public ConversionTask requestConversion(final DiskFormatType diskFormat) {
- ConversionDto request = new ConversionDto();
- request.setTargetFormat(diskFormat);
-
- AcceptedRequestDto<String> taskRef = context.getApi().getVirtualMachineTemplateApi()
- .requestConversion(target, diskFormat, request);
-
- return taskRef == null ? null : getTask(taskRef).asConversionTask();
- }
-
- // Delegate methods
-
- public Integer getCpuRequired() {
- return target.getCpuRequired();
- }
-
- public Date getCreationDate() {
- return target.getCreationDate();
- }
-
- public String getCreationUser() {
- return target.getCreationUser();
- }
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public Long getDiskFileSize() {
- return target.getDiskFileSize();
- }
-
- public DiskFormatType getDiskFormatType() {
- return DiskFormatType.valueOf(target.getDiskFormatType());
- }
-
- public Long getHdRequired() {
- return target.getHdRequired();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getPath() {
- return target.getPath();
- }
-
- public Integer getRamRequired() {
- return target.getRamRequired();
- }
-
- public boolean isChefEnabled() {
- return target.isChefEnabled();
- }
-
- public void setChefEnabled(final boolean chefEnabled) {
- target.setChefEnabled(chefEnabled);
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getIconUrl() {
- return target.getIconUrl();
- }
-
- @Override
- public String toString() {
- return "VirtualMachineTemplate [id=" + getId() + ", cpuRequired=" + getCpuRequired() + ", creationDate="
- + getCreationDate() + ", creationUser=" + getCreationUser() + ", description=" + getDescription()
- + ", diskFileSize=" + getDiskFileSize() + ", diskFormatType=" + getDiskFormatType() + ", hdRequired="
- + getHdRequired() + ", name=" + getName() + ", path=" + getPath() + ", ramRequired=" + getRamRequired()
- + ", chefEnabled=" + isChefEnabled() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java
deleted file mode 100644
index 3540593..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Wrapper to hold the information of a virtual machine template scoped to a
- * concrete hypervisor type.
- */
-public class VirtualMachineTemplateInVirtualDatacenter {
- private VirtualMachineTemplate template;
-
- private VirtualDatacenter zone;
-
- public VirtualMachineTemplateInVirtualDatacenter(final VirtualMachineTemplate template, final VirtualDatacenter zone) {
- super();
- this.template = checkNotNull(template, "template");
- this.zone = checkNotNull(zone, "zone");
- }
-
- public VirtualMachineTemplate getTemplate() {
- return template;
- }
-
- public VirtualDatacenter getZone() {
- return zone;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java
deleted file mode 100644
index 9c33d1a..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud;
-
-import static com.abiquo.model.enumerator.VolumeState.ATTACHED;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.infrastructure.Tier;
-import org.jclouds.abiquo.domain.task.VirtualMachineTask;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.VolumeState;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.model.transport.AcceptedRequestDto;
-import com.abiquo.server.core.cloud.VirtualDatacenterDto;
-import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
-import com.abiquo.server.core.infrastructure.storage.TierDto;
-import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to {@link VolumeManagementDto}.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/Volume+Resource">
- * http://community.abiquo.com/display/ABI20/Volume+Resource</a>
- */
-public class Volume extends DomainWrapper<VolumeManagementDto> {
- /** The default state for volumes. */
- public static final VolumeState DEFAULT_STATE = VolumeState.DETACHED;
-
- /** The virtual datacenter where the volume belongs. */
- private VirtualDatacenter virtualDatacenter;
-
- /** The tier where the volume belongs. */
- private Tier tier;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected Volume(final ApiContext<AbiquoApi> context, final VolumeManagementDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- public void delete() {
- context.getApi().getCloudApi().deleteVolume(target);
- target = null;
- }
-
- public void save() {
- target = context.getApi().getCloudApi().createVolume(virtualDatacenter.unwrap(), target);
- }
-
- public VirtualMachineTask update() {
- AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi().updateVolume(target);
- return taskRef == null ? null : getTask(taskRef).asVirtualMachineTask();
- }
-
- // Parent access
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource#VirtualDatacenterResource-RetrieveaVirtualDatacenter"
- * > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+
- * Resource# VirtualDatacenterResource-RetrieveaVirtualDatacenter</a>
- */
- public VirtualDatacenter getVirtualDatacenter() {
- Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
- VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
- virtualDatacenter = wrap(context, VirtualDatacenter.class, dto);
- return virtualDatacenter;
- }
-
- /**
- * 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 = context.utils().injector()
- .getInstance(Key.get(new TypeLiteral<ParseXMLWithJAXB<VirtualMachineWithNodeExtendedDto>>(){}));
- return wrap(context, VirtualMachine.class, parser.apply(response));
- }
-
- public Tier getTier() {
- Integer tierId = target.getIdFromLink(ParentLinkName.TIER);
- TierDto dto = context.getApi().getCloudApi().getStorageTier(virtualDatacenter.unwrap(), tierId);
- tier = wrap(context, Tier.class, dto);
- return tier;
- }
-
- // Actions
-
- /**
- * Move the volume to the given virtual datacenter.
- *
- * @param newVirtualDatacenter
- * The destination virtual datacenter.
- */
- public void moveTo(final VirtualDatacenter newVirtualDatacenter) {
- target = context.getApi().getCloudApi().moveVolume(unwrap(), newVirtualDatacenter.unwrap());
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final VirtualDatacenter virtualDatacenter,
- final Tier tier) {
- return new Builder(context, virtualDatacenter, tier);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private String name;
-
- private String description;
-
- private Long sizeInMb;
-
- private VirtualDatacenter virtualDatacenter;
-
- private Tier tier;
-
- public Builder(final ApiContext<AbiquoApi> context, final VirtualDatacenter virtualDatacenter, final Tier tier) {
- super();
- checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class);
- checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class);
- this.context = context;
- this.virtualDatacenter = virtualDatacenter;
- this.tier = tier;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder description(final String description) {
- this.description = description;
- return this;
- }
-
- public Builder sizeInMb(final long sizeInMb) {
- this.sizeInMb = sizeInMb;
- return this;
- }
-
- public Volume build() {
- VolumeManagementDto dto = new VolumeManagementDto();
- dto.setName(name);
- dto.setDescription(description);
- dto.setSizeInMB(sizeInMb);
- dto.setState(DEFAULT_STATE.name());
-
- RESTLink link = tier.unwrap().searchLink("self");
- checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
- dto.addLink(new RESTLink("tier", link.getHref()));
-
- Volume volume = new Volume(context, dto);
- volume.virtualDatacenter = virtualDatacenter;
- volume.tier = tier;
-
- return volume;
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getState() {
- return target.getState();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public long getSizeInMB() {
- return target.getSizeInMB();
- }
-
- public void setSizeInMB(final long sizeInMB) {
- target.setSizeInMB(sizeInMB);
- }
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public void setDescription(final String description) {
- target.setDescription(description);
- }
-
- @Override
- public String toString() {
- return "Volume [id=" + getId() + ", state=" + getState() + ", name=" + getName() + ", sizeInMB=" + getSizeInMB()
- + ", description=" + getDescription() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java
deleted file mode 100644
index 1652fef..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.abiquo.model.enumerator.ConversionState;
-import com.abiquo.model.enumerator.HypervisorType;
-
-/**
- * Available options to filter virtual machine template conversions
- */
-public class ConversionOptions extends BaseHttpRequestOptions {
-
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- ConversionOptions options = new ConversionOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
- private HypervisorType hypervisorType;
-
- private ConversionState conversionState;
-
- /** Only conversions compatible with this hypervisor */
- public Builder hypervisorType(final HypervisorType hypervisorType) {
- this.hypervisorType = hypervisorType;
- return this;
- }
-
- /** Only conversions with the provided state */
- public Builder conversionState(final ConversionState conversionState) {
- this.conversionState = conversionState;
- return this;
- }
-
- public ConversionOptions build() {
- ConversionOptions options = new ConversionOptions();
-
- if (hypervisorType != null) {
- options.queryParameters.put("hypervisor", hypervisorType.name());
- }
- if (conversionState != null) {
- options.queryParameters.put("state", conversionState.name());
- }
-
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java
deleted file mode 100644
index 2cf0a82..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query virtual appliances.
- */
-public class VirtualApplianceOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- VirtualApplianceOptions options = new VirtualApplianceOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
-
- private Boolean available;
-
- public Builder available(final boolean available) {
- this.available = available;
- return this;
- }
-
- public VirtualApplianceOptions build() {
- VirtualApplianceOptions options = new VirtualApplianceOptions();
-
- if (available != null) {
- options.queryParameters.put("available", String.valueOf(available));
- }
-
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java
deleted file mode 100644
index 8d960d4..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query virtual datacenters.
- */
-public class VirtualDatacenterOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- VirtualDatacenterOptions options = new VirtualDatacenterOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
- private Integer datacenterId;
-
- private Integer enterpriseId;
-
- /**
- * Set the optional datacenter.
- */
- public Builder datacenterId(final int datacenterId) {
- this.datacenterId = datacenterId;
- return this;
- }
-
- /**
- * Set the optional enterprise.
- */
- public Builder enterpriseId(final int enterpriseId) {
- this.enterpriseId = enterpriseId;
- return this;
- }
-
- public VirtualDatacenterOptions build() {
- VirtualDatacenterOptions options = new VirtualDatacenterOptions();
-
- if (datacenterId != null) {
- options.queryParameters.put("datacenter", datacenterId.toString());
- }
-
- if (enterpriseId != null) {
- options.queryParameters.put("enterprise", enterpriseId.toString());
- }
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java
deleted file mode 100644
index 5e1d4b6..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud.options;
-
-import org.jclouds.abiquo.domain.options.FilterOptions.BaseFilterOptionsBuilder;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query virtual machine.
- */
-public class VirtualMachineOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- VirtualMachineOptions options = new VirtualMachineOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder extends BaseFilterOptionsBuilder<Builder> {
- private Boolean force;
-
- public Builder force(final Boolean force) {
- this.force = force;
- return this;
- }
-
- public VirtualMachineOptions build() {
- VirtualMachineOptions options = new VirtualMachineOptions();
-
- if (force != null) {
- options.queryParameters.put("force", String.valueOf(force));
- }
-
- return addFilterOptions(options);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java
deleted file mode 100644
index 6743e2c..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud.options;
-
-import org.jclouds.abiquo.domain.config.Category;
-import org.jclouds.abiquo.domain.options.FilterOptions.BaseFilterOptionsBuilder;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.abiquo.model.enumerator.HypervisorType;
-import com.abiquo.model.enumerator.StatefulInclusion;
-
-/**
- * Available options to query virtual machine templates.
- */
-public class VirtualMachineTemplateOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder extends BaseFilterOptionsBuilder<Builder> {
- private StatefulInclusion persistent;
-
- private HypervisorType hypervisorType;
-
- private Category category;
-
- private String categoryName;
-
- private Integer idTemplate;
-
- public Builder persistent(final StatefulInclusion persistent) {
- this.persistent = persistent;
- return this;
- }
-
- public Builder hypervisorType(final HypervisorType hypervisorType) {
- this.hypervisorType = hypervisorType;
- return this;
- }
-
- public Builder category(final Category category) {
- this.category = category;
- return this;
- }
-
- public Builder categoryName(final String categoryName) {
- this.categoryName = categoryName;
- return this;
- }
-
- public Builder idTemplate(final Integer idTemplate) {
- this.idTemplate = idTemplate;
- return this;
- }
-
- public VirtualMachineTemplateOptions build() {
- VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions();
-
- if (persistent != null) {
- options.queryParameters.put("stateful", persistent.name());
- }
- if (hypervisorType != null) {
- options.queryParameters.put("hypervisorTypeName", hypervisorType.name());
- }
- if (category != null) {
- options.queryParameters.put("categoryName", category.getName());
- }
-
- if (category == null && categoryName != null) {
- options.queryParameters.put("categoryName", categoryName);
- }
-
- if (idTemplate != null) {
- options.queryParameters.put("idTemplate", String.valueOf(idTemplate));
- }
-
- return addFilterOptions(options);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java
deleted file mode 100644
index 9740969..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.cloud.options;
-
-import org.jclouds.abiquo.domain.options.FilterOptions.BaseFilterOptionsBuilder;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query volumes.
- */
-public class VolumeOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- VolumeOptions options = new VolumeOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder extends BaseFilterOptionsBuilder<Builder> {
- private Boolean onlyAvailable;
-
- public Builder onlyAvailable(final boolean onlyAvailable) {
- this.onlyAvailable = onlyAvailable;
- return this;
- }
-
- public VolumeOptions build() {
- VolumeOptions options = new VolumeOptions();
-
- if (onlyAvailable != null) {
- options.queryParameters.put("available", String.valueOf(onlyAvailable));
- }
-
- return addFilterOptions(options);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java
deleted file mode 100644
index 2fbf7e3..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.appslibrary.CategoryDto;
-
-/**
- * Adds high level functionality to {@link CategoryDto}.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/Category+Resource">
- * http://community.abiquo.com/display/ABI20/Category+Resource</a>
- */
-
-public class Category extends DomainWrapper<CategoryDto> {
- /** The default value for the default category flag. */
- private static final boolean DEFAULT_DEFAULT_CATEGORY = false;
-
- /** The default value for the erasable flag. */
- private static final boolean DEFAULT_ERASABLE = true;
-
- /**
- * Constructor to be used only by the builder. This resource cannot be
- * created.
- */
- private Category(final ApiContext<AbiquoApi> context, final CategoryDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Deleteacategory"
- * > http://community.abiquo.com/display/ABI20/Category+Resource#
- * CategoryResource-Deleteacategory</a>
- */
- public void delete() {
- context.getApi().getConfigApi().deleteCategory(target);
- target = null;
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Createacategory"
- * > http://community.abiquo.com/display/ABI20/Category+Resource#
- * CategoryResource-Createacategory</a>
- */
- public void save() {
- target = context.getApi().getConfigApi().createCategory(target);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Updateanexistingcategory"
- * > http://community.abiquo.com/display/ABI20/Category+Resource#
- * CategoryResource-Updateanexistingcategory</a>
- */
- public void update() {
- target = context.getApi().getConfigApi().updateCategory(target);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context) {
- return new Builder(context);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private String name;
-
- private Boolean erasable = DEFAULT_ERASABLE;
-
- private Boolean defaultCategory = DEFAULT_DEFAULT_CATEGORY;
-
- public Builder(final ApiContext<AbiquoApi> context) {
- super();
- this.context = context;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder defaultCategory(final boolean defaultCategory) {
- this.defaultCategory = defaultCategory;
- return this;
- }
-
- public Builder erasable(final boolean erasable) {
- this.erasable = erasable;
- return this;
- }
-
- public Category build() {
- CategoryDto dto = new CategoryDto();
- dto.setErasable(erasable);
- dto.setDefaultCategory(defaultCategory);
- dto.setName(name);
- Category category = new Category(context, dto);
-
- return category;
- }
-
- public static Builder fromCategory(final Category in) {
- Builder builder = Category.builder(in.context).name(in.getName()).erasable(in.isErasable())
- .defaultCategory(in.isDefaultCategory());
-
- return builder;
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public boolean isDefaultCategory() {
- return target.isDefaultCategory();
- }
-
- public boolean isErasable() {
- return target.isErasable();
- }
-
- public void setDefaultCategory(final boolean defaultCategory) {
- target.setDefaultCategory(defaultCategory);
- }
-
- public void setErasable(final boolean erasable) {
- target.setErasable(erasable);
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java
deleted file mode 100644
index e926a78..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.config.LicenseDto;
-
-/**
- * Adds high level functionality to {@link LicenseDto}.
- */
-public class License extends DomainWrapper<LicenseDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected License(final ApiContext<AbiquoApi> context, final LicenseDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- public void remove() {
- context.getApi().getConfigApi().removeLicense(target);
- target = null;
- }
-
- public void add() {
- target = context.getApi().getConfigApi().addLicense(target);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final String code) {
- return new Builder(context, code);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private String code;
-
- public Builder(final ApiContext<AbiquoApi> context, final String code) {
- super();
- this.context = context;
- this.code = code;
- }
-
- public Builder code(final String code) {
- this.code = code;
- return this;
- }
-
- public License build() {
- LicenseDto dto = new LicenseDto();
- dto.setCode(code);
-
- License license = new License(context, dto);
- return license;
- }
-
- public static Builder fromLicense(final License in) {
- return License.builder(in.context, in.getCode());
- }
- }
-
- // Delegate methods
-
- public String getCode() {
- return target.getCode();
- }
-
- public String getExpiration() {
- return target.getExpiration();
- }
-
- public Integer getId() {
- return target.getId();
- }
-
- public Integer getNumCores() {
- return target.getNumcores();
- }
-
- @Override
- public String toString() {
- return "License [id=" + getId() + ", code=" + getCode() + ", expiration=" + getExpiration()
- + ", numCores=" + getNumCores() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java
deleted file mode 100644
index 852dbe3..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.enterprise.PrivilegeDto;
-
-/**
- * Adds high level functionality to {@link PrivilegeDto}.
- */
-public class Privilege extends DomainWrapper<PrivilegeDto> {
- /**
- * Constructor to be used only by the builder. This resource cannot be
- * created.
- */
- private Privilege(final ApiContext<AbiquoApi> context, final PrivilegeDto target) {
- super(context, target);
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- @Override
- public String toString() {
- return "Privilege [id=" + getId() + ", name=" + getName() + "]";
- }
-
-}