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:33 UTC
[18/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/infrastructure/Rack.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java
deleted file mode 100644
index 881e357..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java
+++ /dev/null
@@ -1,336 +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.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.MachineDto;
-import com.abiquo.server.core.infrastructure.MachinesDto;
-import com.abiquo.server.core.infrastructure.RackDto;
-
-/**
- * Adds high level functionality to {@link RackDto}. Represents unmanaged racks
- * in the Abiquo platform.
- *
- * @see API: <a href="http://community.abiquo.com/display/ABI20/RackResource">
- * http://community.abiquo.com/display/ABI20/RackResource</a>
- */
-public class Rack extends DomainWrapper<RackDto> {
- /** The default minimum VLAN id. */
- private static final int DEFAULT_VLAN_ID_MIN = 2;
-
- /** The default maximum VLAN id. */
- private static final int DEFAULT_VLAN_ID_MAX = 4094;
-
- /** The default maximum VLAN per virtual datacenter. */
- private static final int DEFAULT_VLAN_PER_VDC = 1;
-
- /** The default nrsq factor. */
- private static final int DEFAULT_NRSQ = 10;
-
- /** The datacenter where the rack belongs. */
- private Datacenter datacenter;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected Rack(final ApiContext<AbiquoApi> context, final RackDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- /**
- * Delete the unmanaged rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-DeleteaRack"
- * >
- * http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource
- * #RackResource- DeleteaRack</a>
- */
- public void delete() {
- context.getApi().getInfrastructureApi().deleteRack(target);
- target = null;
- }
-
- /**
- * Create a new unmanaged rack in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-CreateanewRack"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * -CreateanewRack</a>
- */
- public void save() {
- target = context.getApi().getInfrastructureApi().createRack(datacenter.unwrap(), target);
- }
-
- /**
- * Update rack information in the server with the data from this rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-UpdateanexistingRack"
- * >
- * http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * UpdateanexistingRack </a>
- */
- public void update() {
- target = context.getApi().getInfrastructureApi().updateRack(target);
- }
-
- // Parent access
- /**
- * Retrieve the datacenter where this rack is.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrieveadatacenter</a>
- */
- public Datacenter getDatacenter() {
- Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
- return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(datacenterId));
- }
-
- // Children access
-
- /**
- * Retrieve the list of physical machines in this rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- RetrievealistofMachines</a>
- */
- public Iterable<Machine> listMachines() {
- MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target);
- return wrap(context, Machine.class, machines.getCollection());
- }
-
- /**
- * Retrieve a single physical machine.
- *
- * @param id
- * Unique ID of the physical machine in this rack.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveaMachine"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource-RetrieveaMachine </a>
- * @return Unmanaged rack with the given id or <code>null</code> if it does
- * not exist.
- */
- public Machine getMachine(final Integer id) {
- MachineDto machine = context.getApi().getInfrastructureApi().getMachine(target, id);
- return wrap(context, Machine.class, machine);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- return new Builder(context, datacenter);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Integer id;
-
- private String name;
-
- private String shortDescription;
-
- private boolean haEnabled = false;
-
- private Integer nrsq = DEFAULT_NRSQ;
-
- private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX;
-
- private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN;
-
- private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC;
-
- private String vlansIdAvoided;
-
- private Datacenter datacenter;
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- super();
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- this.context = context;
- }
-
- public Builder id(final Integer id) {
- this.id = id;
- return this;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder shortDescription(final String shortDescription) {
- this.shortDescription = shortDescription;
- return this;
- }
-
- public Builder haEnabled(final boolean haEnabled) {
- this.haEnabled = haEnabled;
- return this;
- }
-
- public Builder nrsq(final int nrsq) {
- this.nrsq = nrsq;
- return this;
- }
-
- public Builder vlanIdMax(final int vlanIdMax) {
- this.vlanIdMax = vlanIdMax;
- return this;
- }
-
- public Builder vlanIdMin(final int vlanIdMin) {
- this.vlanIdMin = vlanIdMin;
- return this;
- }
-
- public Builder vlanPerVdcReserved(final int vlanPerVdcExpected) {
- this.vlanPerVdcReserved = vlanPerVdcExpected;
- return this;
- }
-
- public Builder vlansIdAvoided(final String vlansIdAvoided) {
- this.vlansIdAvoided = vlansIdAvoided;
- return this;
- }
-
- public Builder datacenter(final Datacenter datacenter) {
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- return this;
- }
-
- public Rack build() {
- RackDto dto = new RackDto();
- dto.setId(id);
- dto.setName(name);
- dto.setShortDescription(shortDescription);
- dto.setHaEnabled(haEnabled);
- dto.setNrsq(nrsq);
- dto.setVlanIdMax(vlanIdMax);
- dto.setVlanIdMin(vlanIdMin);
- dto.setVlanPerVdcReserved(vlanPerVdcReserved);
- dto.setVlansIdAvoided(vlansIdAvoided);
- Rack rack = new Rack(context, dto);
- rack.datacenter = datacenter;
- return rack;
- }
-
- public static Builder fromRack(final Rack in) {
- return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName())
- .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq())
- .vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin())
- .vlanPerVdcReserved(in.getVlanPerVdcReserved()).vlansIdAvoided(in.getVlansIdAvoided());
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getShortDescription() {
- return target.getShortDescription();
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public void setShortDescription(final String description) {
- target.setShortDescription(description);
- }
-
- public void setHaEnabled(final boolean haEnabled) {
- target.setHaEnabled(haEnabled);
- }
-
- public boolean isHaEnabled() {
- return target.isHaEnabled();
- }
-
- public Integer getNrsq() {
- return target.getNrsq();
- }
-
- public Integer getVlanIdMax() {
- return target.getVlanIdMax();
- }
-
- public Integer getVlanIdMin() {
- return target.getVlanIdMin();
- }
-
- public Integer getVlanPerVdcReserved() {
- return target.getVlanPerVdcReserved();
- }
-
- public String getVlansIdAvoided() {
- return target.getVlansIdAvoided();
- }
-
- public void setNrsq(final Integer nrsq) {
- target.setNrsq(nrsq);
- }
-
- public void setVlanIdMax(final Integer vlanIdMax) {
- target.setVlanIdMax(vlanIdMax);
- }
-
- public void setVlanIdMin(final Integer vlanIdMin) {
- target.setVlanIdMin(vlanIdMin);
- }
-
- public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved) {
- target.setVlanPerVdcReserved(vlanPerVdcReserved);
- }
-
- public void setVlansIdAvoided(final String vlansIdAvoided) {
- target.setVlansIdAvoided(vlansIdAvoided);
- }
-
- @Override
- public String toString() {
- return "Rack [id=" + getId() + ", name=" + getName() + ", description=" + getShortDescription() + ", haEnabled="
- + isHaEnabled() + ", nrsq=" + getNrsq() + ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin=" + getVlanIdMin()
- + ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided=" + getVlansIdAvoided() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java
deleted file mode 100644
index 5c0c8ef..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java
+++ /dev/null
@@ -1,243 +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.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.RemoteServiceType;
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.RemoteServiceDto;
-
-/**
- * Adds high level functionality to {@link RemoteServiceDto}. The Remote Service
- * resource offers the functionality of managing the remote services of a
- * datacenter in a logical way.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/RemoteServiceResource">
- * http://community.abiquo.com/display/ABI20/RemoteServiceResource</a>
- */
-public class RemoteService extends DomainWrapper<RemoteServiceDto> {
- /** The default status. */
- private static final int DEFAULT_STATUS = 0;
-
- /** The datacenter using the remote service. */
- private Datacenter datacenter;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected RemoteService(final ApiContext<AbiquoApi> context, final RemoteServiceDto target) {
- super(context, target);
- }
-
- /**
- * Delete the remote service.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-DeleteaRemoteService"
- * > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
- * RemoteServiceResource- DeleteaRemoteService</a>
- */
- public void delete() {
- context.getApi().getInfrastructureApi().deleteRemoteService(target);
- target = null;
- }
-
- /**
- * Create the remote service.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-CreateaRemoteService"
- * > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
- * RemoteServiceResource- CreateaRemoteService</a>
- */
- public void save() {
- target = context.getApi().getInfrastructureApi().createRemoteService(datacenter.unwrap(), target);
- }
-
- /**
- * Update remote service information in the server with the data from this
- * remote service.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-UpdateanexistingRemoteService"
- * > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
- * RemoteServiceResource- UpdateanexistingRemoteService</a>
- */
- public void update() {
- target = context.getApi().getInfrastructureApi().updateRemoteService(target);
- }
-
- /**
- * Check remote service availability.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-CheckthestatusofaRemoteService"
- * > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
- * RemoteServiceResource- CheckthestatusofaRemoteService</a>
- */
- public boolean isAvailable() {
- // If the remote service can not be checked, assume it is available
- return !getType().canBeChecked() ? true : context.getApi().getInfrastructureApi().isAvailable(target);
- }
-
- // Parent access
-
- /**
- * Retrieve the datacenter using this remotes service.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrieveadatacenter</a>
- */
- public Datacenter getDatacenter() {
- Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
- DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
- datacenter = wrap(context, Datacenter.class, dto);
- return datacenter;
- }
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- return new Builder(context, datacenter);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Integer id;
-
- private Datacenter datacenter;
-
- private String ip;
-
- private Integer port;
-
- private RemoteServiceType type;
-
- private Integer status = DEFAULT_STATUS;
-
- // To be used only internally by the builder
- private String uri;
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- super();
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- this.context = context;
- }
-
- public Builder datacenter(final Datacenter datacenter) {
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- return this;
- }
-
- public Builder status(final int status) {
- this.status = status;
- return this;
- }
-
- public Builder type(final RemoteServiceType type) {
- this.type = type;
- return this;
- }
-
- public Builder ip(final String ip) {
- this.ip = ip;
- return this;
- }
-
- public Builder port(final int port) {
- this.port = port;
- return this;
- }
-
- private String generateUri(final String ip, final Integer port, final RemoteServiceType type) {
- return type.getDefaultProtocol() + ip + ":" + port + "/" + type.getServiceMapping();
- }
-
- public RemoteService build() {
- if (uri == null) {
- checkNotNull(ip, ValidationErrors.MISSING_REQUIRED_FIELD + "ip");
- checkNotNull(type, ValidationErrors.MISSING_REQUIRED_FIELD + "type");
-
- uri = generateUri(ip, port == null ? type.getDefaultPort() : port, type);
- }
-
- RemoteServiceDto dto = new RemoteServiceDto();
- dto.setId(id);
- dto.setType(type);
- dto.setUri(uri);
- dto.setStatus(status);
- RemoteService remoteservice = new RemoteService(context, dto);
- remoteservice.datacenter = datacenter;
- return remoteservice;
- }
-
- public static Builder fromRemoteService(final RemoteService in) {
- Builder builder = RemoteService.builder(in.context, in.getDatacenter()).status(in.getStatus())
- .type(in.getType());
- builder.uri = in.getUri();
- return builder;
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public RemoteServiceType getType() {
- return target.getType();
- }
-
- public int getStatus() {
- return target.getStatus();
- }
-
- public String getUri() {
- return target.getUri();
- }
-
- public void setStatus(final int status) {
- target.setStatus(status);
- }
-
- public void setType(final RemoteServiceType type) {
- target.setType(type);
- }
-
- public void setUri(final String uri) {
- target.setUri(uri);
- }
-
- @Override
- public String toString() {
- return "RemoteService [id=" + getId() + ", available=" + isAvailable() + ", type=" + getType() + ", status="
- + getStatus() + ", uri" + getUri() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java
deleted file mode 100644
index 03d1456..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java
+++ /dev/null
@@ -1,369 +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.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto;
-import com.abiquo.server.core.infrastructure.storage.StoragePoolDto;
-import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto;
-import com.abiquo.server.core.infrastructure.storage.TiersDto;
-
-/**
- * Adds high level functionality to {@link StorageDeviceDto}. The Storage Device
- * Resource offers the functionality of managing the external storage.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/StorageDeviceResource">
- * http://community.abiquo.com/display/ABI20/StorageDeviceResource</a>
- */
-public class StorageDevice extends DomainWrapper<StorageDeviceDto> {
- /** The datacenter where the storage device is. */
- private Datacenter datacenter;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected StorageDevice(final ApiContext<AbiquoApi> context, final StorageDeviceDto target) {
- super(context, target);
- }
-
- /**
- * Delete the storage device.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Deleteastoragedevice"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Deleteastoragedevice</a>
- */
- public void delete() {
- context.getApi().getInfrastructureApi().deleteStorageDevice(target);
- target = null;
- }
-
- /**
- * Create a new storage device.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Createastoragedevice"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Createastoragedevice</a>
- */
- public void save() {
- target = context.getApi().getInfrastructureApi().createStorageDevice(datacenter.unwrap(), target);
- }
-
- /**
- * Update storage device information in the server with the data from this
- * device.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Updateastoragedevice"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Updateastoragedevice</a>
- */
- public void update() {
- target = context.getApi().getInfrastructureApi().updateStorageDevice(target);
- }
-
- // Parent access
-
- /**
- * Retrieve the datacenter where this storage device is.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrieveadatacenter</a>
- */
- public Datacenter getDatacenter() {
- Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
- DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
- datacenter = wrap(context, Datacenter.class, dto);
- return datacenter;
- }
-
- // Children access
-
- /**
- * Retrieve the list of storage pools in this device (synchronized with the
- * device).
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return Synchronized list of storage pools in this device.
- */
- public Iterable<StoragePool> listRemoteStoragePools() {
- StoragePoolsDto storagePools = context.getApi().getInfrastructureApi()
- .listStoragePools(target, StoragePoolOptions.builder().sync(true).build());
-
- Iterable<StoragePool> storagePoolList = wrap(context, StoragePool.class, storagePools.getCollection());
-
- for (StoragePool storagePool : storagePoolList) {
- storagePool.storageDevice = this;
- }
-
- return storagePoolList;
- }
-
- /**
- * Retrieve the list of storage pools in this device from Abiquo database
- * (may not be synchronized with the device).
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return Unsynchronized list of storage pools in this device.
- */
- public Iterable<StoragePool> listStoragePools() {
- StoragePoolsDto storagePools = context.getApi().getInfrastructureApi()
- .listStoragePools(target, StoragePoolOptions.builder().sync(false).build());
- return wrap(context, StoragePool.class, storagePools.getCollection());
- }
-
- /**
- * Retrieve a single storage pool in this device from Abiquo database.
- *
- * @param id
- * Unique ID of the storage device in this datacenter.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievearegisteredpool"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievearegisteredpool</a>
- * @return Storage pool with the given id or <code>null</code> if it does not
- * exist.
- */
- public StoragePool getStoragePool(final String id) {
- StoragePoolDto storagePool = context.getApi().getInfrastructureApi().getStoragePool(target, id);
- return wrap(context, StoragePool.class, storagePool);
- }
-
- /**
- * Retrieve the list of tiers in the datacenter using this device.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers"
- * >
- * http://community.abiquo.com/display/ABI20/TierResource#TierResource-
- * Retrievethelistoftiers </a>
- * @return List of tiers in the datacenter using this device.
- */
- public Iterable<Tier> listTiersFromDatacenter() {
- DatacenterDto datacenter;
-
- if (this.datacenter == null) {
- datacenter = new DatacenterDto();
- datacenter.setId(target.getIdFromLink(ParentLinkName.DATACENTER));
- } else {
- datacenter = this.getDatacenter().unwrap();
- }
-
- TiersDto dto = context.getApi().getInfrastructureApi().listTiers(datacenter);
- return DomainWrapper.wrap(context, Tier.class, dto.getCollection());
- }
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- return new Builder(context, datacenter);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Datacenter datacenter;
-
- private String iscsiIp;
-
- private Integer iscsiPort;
-
- private String managementIp;
-
- private Integer managementPort;
-
- private String name;
-
- private String password;
-
- private String type;
-
- private String username;
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- super();
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- this.context = context;
- }
-
- public Builder datacenter(final Datacenter datacenter) {
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- return this;
- }
-
- public Builder iscsiIp(final String iscsiIp) {
- this.iscsiIp = iscsiIp;
- return this;
- }
-
- public Builder iscsiPort(final int iscsiPort) {
- this.iscsiPort = iscsiPort;
- return this;
- }
-
- public Builder password(final String password) {
- this.password = password;
- return this;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder managementPort(final int managementPort) {
- this.managementPort = managementPort;
- return this;
- }
-
- public Builder managementIp(final String managementIp) {
- this.managementIp = managementIp;
- return this;
- }
-
- public Builder type(final String type) {
- this.type = type;
- return this;
- }
-
- public Builder username(final String username) {
- this.username = username;
- return this;
- }
-
- public StorageDevice build() {
- StorageDeviceDto dto = new StorageDeviceDto();
- dto.setIscsiIp(iscsiIp);
- dto.setIscsiPort(iscsiPort);
- dto.setManagementIp(managementIp);
- dto.setManagementPort(managementPort);
- dto.setName(name);
- dto.setPassword(password);
- dto.setStorageTechnology(type);
- dto.setUsername(username);
- StorageDevice storageDevice = new StorageDevice(context, dto);
- storageDevice.datacenter = datacenter;
- return storageDevice;
- }
-
- public static Builder fromStorageDevice(final StorageDevice in) {
- Builder builder = StorageDevice.builder(in.context, in.getDatacenter()).iscsiIp(in.getIscsiIp())
- .iscsiPort(in.getIscsiPort()).managementIp(in.getManagementIp()).managementPort(in.getManagementPort())
- .name(in.getName()).password(in.getPassword()).type(in.getType()).username(in.getUsername());
-
- return builder;
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getIscsiIp() {
- return target.getIscsiIp();
- }
-
- public int getIscsiPort() {
- return target.getIscsiPort();
- }
-
- public String getManagementIp() {
- return target.getManagementIp();
- }
-
- public int getManagementPort() {
- return target.getManagementPort();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getPassword() {
- return target.getPassword();
- }
-
- public String getType() {
- return target.getStorageTechnology();
- }
-
- public String getUsername() {
- return target.getUsername();
- }
-
- public void setIscsiIp(final String iscsiIp) {
- target.setIscsiIp(iscsiIp);
- }
-
- public void setIscsiPort(final int iscsiPort) {
- target.setIscsiPort(iscsiPort);
- }
-
- public void setManagementIp(final String managementIp) {
- target.setManagementIp(managementIp);
- }
-
- public void setManagementPort(final int managementPort) {
- target.setManagementPort(managementPort);
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public void setPassword(final String password) {
- target.setPassword(password);
- }
-
- public void setType(final String type) {
- target.setStorageTechnology(type);
- }
-
- public void setUsername(final String username) {
- target.setUsername(username);
- }
-
- @Override
- public String toString() {
- return "StorageDevice [id=" + getId() + ", iscsiIp=" + getIscsiIp() + ", iscsiPort=" + getIscsiPort()
- + ", managementIp=" + getManagementIp() + ", managementPort=" + getManagementPort() + ", name=" + getName()
- + ", password=" + getPassword() + ", type=" + getType() + ", user=" + getUsername() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java
deleted file mode 100644
index 7690b3c..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java
+++ /dev/null
@@ -1,54 +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.infrastructure;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.storage.StorageDeviceMetadataDto;
-
-/**
- * metadata describing a Storage Device.
- */
-public class StorageDeviceMetadata extends DomainWrapper<StorageDeviceMetadataDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected StorageDeviceMetadata(final ApiContext<AbiquoApi> context, final StorageDeviceMetadataDto target) {
- super(context, target);
- }
-
- // Delegate methods
-
- public String getType() {
- return target.getType();
- }
-
- public int getDefaultManagementPort() {
- return target.getDefaultManagementPort();
- }
-
- public int getDefaultIscsiPort() {
- return target.getDefaultIscsiPort();
- }
-
- public boolean requiresAuthentication() {
- return target.isRequiresAuthentication();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java
deleted file mode 100644
index 0c639b3..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java
+++ /dev/null
@@ -1,248 +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.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.config.Privilege;
-import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
-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.rest.RESTLink;
-import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto;
-import com.abiquo.server.core.infrastructure.storage.StoragePoolDto;
-import com.abiquo.server.core.infrastructure.storage.TierDto;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to {@link StoragePoolDto}. The Storage Pool
- * Resource allows you to perform any administrative task for remote pools.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/StoragePoolResource">
- * http://community.abiquo.com/display/ABI20/StoragePoolResource</a>
- */
-public class StoragePool extends DomainWrapper<StoragePoolDto> {
-
- /** The datacenter where the storage device is. */
- // Package protected to allow the storage device to be set automatically when
- // discovering the
- // pools in a device.
- StorageDevice storageDevice;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected StoragePool(final ApiContext<AbiquoApi> context, final StoragePoolDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- /**
- * Delete the storage pool.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Deleteastoragepool"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Deleteastoragepool</a>
- */
- public void delete() {
- context.getApi().getInfrastructureApi().deleteStoragePool(target);
- target = null;
- }
-
- /**
- * Create a storage pool. Create a storage pool means registering an existing
- * storage pool obtained from {@link StorageDevice#listRemoteStoragePools}
- * method and saving it. The Storage Pools must be associated with a Tier
- * using {@link #setTier}.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Createastoragepoolwithatierlink"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Createastoragepoolwithatierlink</a>
- */
- public void save() {
- target = context.getApi().getInfrastructureApi().createStoragePool(storageDevice.unwrap(), target);
- }
-
- /**
- * Update pool information in the server with the data from this pool.
- * Storage pool parameters cannot be updated by a user, so the parameters are
- * only a representation of the remote pool. Although the whole storage pool
- * entity is sent to the API in the update call, the only thing a user can
- * change is the tier that the pool belongs to by calling {@link #setTier}.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Storage+Pool+Resource#StoragePoolResource-UpdateaStoragePool"
- * > http://community.abiquo.com/display/ABI20/Storage+Pool+Resource#
- * StoragePoolResource- UpdateaStoragePool</a>
- */
- public void update() {
- target = context.getApi().getInfrastructureApi().updateStoragePool(target);
- }
-
- @Override
- public void refresh() {
- target = context.getApi().getInfrastructureApi()
- .refreshStoragePool(target, StoragePoolOptions.builder().sync(true).build());
- }
-
- /**
- * Define the tier in which the pool will be added.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Createastoragepoolwithatierlink"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Createastoragepoolwithatierlink</a>
- */
- public void setTier(final Tier tier) {
- checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Privilege.class);
- checkNotNull(tier.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Tier.class);
-
- this.updateLink(target, ParentLinkName.TIER, tier.unwrap(), "edit");
- }
-
- // Parent access
-
- /**
- * Get the device where the pool belongs.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrieveastoragedevice"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Retrieveastoragedevice</a>
- */
- public StorageDevice getStorageDevice() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.STORAGE_DEVICE),
- ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.STORAGE_DEVICE);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<StorageDeviceDto> parser = new ParseXMLWithJAXB<StorageDeviceDto>(context.utils().xml(),
- TypeLiteral.get(StorageDeviceDto.class));
-
- return wrap(context, StorageDevice.class, parser.apply(response));
- }
-
- // Children access
-
- /**
- * Get the tier assigned to the pool. The storage pool needs to be persisted
- * in Abiquo first.
- *
- * @return The tier assigned to this storage pool.
- */
- public Tier getTier() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.TIER), ValidationErrors.MISSING_REQUIRED_LINK + " "
- + ParentLinkName.TIER);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<TierDto> parser = new ParseXMLWithJAXB<TierDto>(context.utils().xml(),
- TypeLiteral.get(TierDto.class));
-
- return wrap(context, Tier.class, parser.apply(response));
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final StorageDevice storageDevice) {
- return new Builder(context, storageDevice);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
- private StorageDevice storageDevice;
- private String name;
- private Long totalSizeInMb;
-
- public Builder(final ApiContext<AbiquoApi> context, final StorageDevice storageDevice) {
- super();
- checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class);
- this.storageDevice = storageDevice;
- this.context = context;
- }
-
- public Builder storageDevice(final StorageDevice storageDevice) {
- checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class);
- this.storageDevice = storageDevice;
- return this;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder totalSizeInMb(final long totalSizeInMb) {
- this.totalSizeInMb = totalSizeInMb;
- return this;
- }
-
- public StoragePool build() {
- StoragePoolDto dto = new StoragePoolDto();
- dto.setName(name);
- dto.setTotalSizeInMb(totalSizeInMb);
- StoragePool storagePool = new StoragePool(context, dto);
- storagePool.storageDevice = storageDevice;
- return storagePool;
- }
-
- public static Builder fromStoragePool(final StoragePool in) {
- Builder builder = StoragePool.builder(in.context, in.getStorageDevice()).totalSizeInMb(in.getTotalSizeInMb());
-
- return builder;
- }
- }
-
- // Delegate methods
-
- public String getName() {
- return target.getName();
- }
-
- public long getTotalSizeInMb() {
- return target.getTotalSizeInMb();
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public void setTotalSizeInMb(final long totalSizeInMb) {
- target.setTotalSizeInMb(totalSizeInMb);
- }
-
- // Readonly property
- public String getUUID() {
- return target.getIdStorage();
- }
-
- @Override
- public String toString() {
- return "StoragePool [name=" + getName() + ", totalSizeInMb=" + getTotalSizeInMb() + ", uuid=" + getUUID() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java
deleted file mode 100644
index 5858e1c..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java
+++ /dev/null
@@ -1,130 +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.infrastructure;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto;
-import com.abiquo.server.core.infrastructure.storage.TierDto;
-
-/**
- * Adds high level functionality to {@link TierDto}. The Tier Resource offers
- * the functionality of managing the logic of QoS volume management. These are
- * only logical levels of QoS and the real QoS (networking speed, volume
- * replication, availability) must be configured manually in the infrastructure.
- *
- * @see API: <a href="http://community.abiquo.com/display/ABI20/TierResource">
- * http://community.abiquo.com/display/ABI20/TierResource</a>
- */
-public class Tier extends DomainWrapper<TierDto> {
- /** The datacenter where the tier belongs. */
- private Datacenter datacenter;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected Tier(final ApiContext<AbiquoApi> context, final TierDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- /**
- * Update tier information in the server with the data from this tier.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Updateatier"
- * >
- * http://community.abiquo.com/display/ABI20/TierResource#TierResource-
- * Updateatier</a>
- */
- public void update() {
- target = context.getApi().getInfrastructureApi().updateTier(target);
- }
-
- /**
- * Retrieve the list of storage pools in this tier.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return List of storage pools in this tier.
- */
- public Iterable<StoragePool> listStoragePools() {
- StoragePoolsDto storagePools = context.getApi().getInfrastructureApi().listStoragePools(target);
- return wrap(context, StoragePool.class, storagePools.getCollection());
- }
-
- // Parent access
-
- /**
- * Retrieve the datacenter where this tier is.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrieveadatacenter</a>
- */
- public Datacenter getDatacenter() {
- Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
- DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
- datacenter = wrap(context, Datacenter.class, dto);
- return datacenter;
- }
-
- // Delegate methods
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public boolean getEnabled() {
- return target.getEnabled();
- }
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public void setDescription(final String description) {
- target.setDescription(description);
- }
-
- public void setEnabled(final boolean enabled) {
- target.setEnabled(enabled);
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- @Override
- public String toString() {
- return "Tier [id=" + getId() + ", description=" + getDescription() + ", enabled=" + getEnabled() + ", name="
- + getName() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java
deleted file mode 100644
index 528480a..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.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.infrastructure.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query datacenters.
- */
-public class DatacenterOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- DatacenterOptions options = new DatacenterOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
- private String ip;
-
- public Builder ip(final String ip) {
- this.ip = ip;
- return this;
- }
-
- public DatacenterOptions build() {
- DatacenterOptions options = new DatacenterOptions();
- if (ip != null) {
- options.queryParameters.put("ip", ip);
- }
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java
deleted file mode 100644
index 9d77c98..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java
+++ /dev/null
@@ -1,56 +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.infrastructure.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query ipmi config.
- */
-public class IpmiOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- IpmiOptions options = new IpmiOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
- private Integer port;
-
- /**
- * Set the optional hypervisor port.
- */
- public Builder port(final int port) {
- this.port = port;
- return this;
- }
-
- public IpmiOptions build() {
- IpmiOptions options = new IpmiOptions();
- if (port != null) {
- options.queryParameters.put("port", port.toString());
- }
-
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java
deleted file mode 100644
index f008a70..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.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.infrastructure.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query machines.
- */
-public class MachineOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- MachineOptions options = new MachineOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
- private Integer port;
-
- private Boolean sync;
-
- /**
- * Set the optional hypervisor port.
- */
- public Builder port(final int port) {
- this.port = port;
- return this;
- }
-
- /**
- * Set the optional sync param.
- */
- public Builder sync(final boolean sync) {
- this.sync = sync;
- return this;
- }
-
- public MachineOptions build() {
- MachineOptions options = new MachineOptions();
- if (port != null) {
- options.queryParameters.put("port", port.toString());
- }
-
- if (sync != null) {
- options.queryParameters.put("sync", sync.toString());
- }
-
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java
deleted file mode 100644
index abe6fe7..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java
+++ /dev/null
@@ -1,57 +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.infrastructure.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query storage pools.
- */
-
-public class StoragePoolOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- StoragePoolOptions options = new StoragePoolOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
- private Boolean sync;
-
- /**
- * Set the optional sync param.
- */
- public Builder sync(final boolean sync) {
- this.sync = sync;
- return this;
- }
-
- public StoragePoolOptions build() {
- StoragePoolOptions options = new StoragePoolOptions();
- if (sync != null) {
- options.queryParameters.put("sync", sync.toString());
- }
-
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java
deleted file mode 100644
index 28849b1..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java
+++ /dev/null
@@ -1,53 +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.network;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.network.AbstractInfrastructureIpDto;
-
-/**
- * Adds generic high level functionality to {@link AbstractInfrastructureIpDto}.
- */
-public abstract class AbstractPublicIp<T extends AbstractInfrastructureIpDto, N extends Network<?>> extends Ip<T, N> {
- /**
- * Constructor to be used only by the builder.
- */
- protected AbstractPublicIp(final ApiContext<AbiquoApi> context, final T target) {
- super(context, target);
- }
-
- // Delegate methods
-
- public boolean isAvailable() {
- return target.isAvailable();
- }
-
- public boolean isQuarantine() {
- return target.isQuarantine();
- }
-
- public void setAvailable(final boolean available) {
- target.setAvailable(available);
- }
-
- public void setQuarantine(final boolean quarantine) {
- target.setQuarantine(quarantine);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java
deleted file mode 100644
index 42ba2db..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java
+++ /dev/null
@@ -1,72 +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.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-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.NetworkType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.infrastructure.network.ExternalIpDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds generic high level functionality to {@link ExternalIpDto}.
- */
-public class ExternalIp extends AbstractPublicIp<ExternalIpDto, ExternalNetwork> {
- /**
- * Constructor to be used only by the builder.
- */
- protected ExternalIp(final ApiContext<AbiquoApi> context, final ExternalIpDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- @Override
- public ExternalNetwork getNetwork() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.EXTERNAL_NETWORK),
- ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.EXTERNAL_NETWORK);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<VLANNetworkDto> parser = new ParseXMLWithJAXB<VLANNetworkDto>(context.utils().xml(),
- TypeLiteral.get(VLANNetworkDto.class));
-
- return wrap(context, ExternalNetwork.class, parser.apply(response));
- }
-
- @Override
- public NetworkType getNetworkType() {
- return NetworkType.EXTERNAL;
- }
-
- @Override
- public String toString() {
- return "ExternalIp [networkType=" + getNetworkType() + ", available=" + isAvailable() + ", quarantine="
- + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName()
- + ", networkName=" + getNetworkName() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java
deleted file mode 100644
index b481ef2..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java
+++ /dev/null
@@ -1,231 +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.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.NetworkType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.network.ExternalIpDto;
-import com.abiquo.server.core.infrastructure.network.ExternalIpsDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.common.base.Optional;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to external {@link VLANNetworkDto}.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/Public+Network+Resource"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource</a>
- */
-public class ExternalNetwork extends Network<ExternalIp> {
- /** The datacenter where the network belongs. */
- private Datacenter datacenter;
-
- /** The enterprise where the network belongs. */
- private Enterprise enterprise;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected ExternalNetwork(final ApiContext<AbiquoApi> context, final VLANNetworkDto target) {
- super(context, target);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-DeleteanExternalNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -DeleteanExternalNetwork</a>
- */
- @Override
- public void delete() {
- context.getApi().getInfrastructureApi().deleteNetwork(target);
- target = null;
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-CreateanewExternalNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -CreateanewExternalNetwork</a>
- */
- @Override
- public void save() {
- this.addEnterpriseLink();
- target = context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target);
- }
-
- /**
- * @see API: <a href=
- * " http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-UpdateanExternalNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -UpdateanExternalNetwork</a>
- */
- @Override
- public void update() {
- target = context.getApi().getInfrastructureApi().updateNetwork(target);
- }
-
- @Override
- public Iterable<ExternalIp> listIps() {
- PagedIterable<ExternalIpDto> ips = context.getApi().getInfrastructureApi().listExternalIps(target);
- return wrap(context, ExternalIp.class, ips.concat());
- }
-
- @Override
- public Iterable<ExternalIp> listIps(final IpOptions options) {
- PaginatedCollection<ExternalIpDto, ExternalIpsDto> ips = context.getApi().getInfrastructureApi()
- .listExternalIps(target, options);
- return wrap(context, ExternalIp.class, ips.toPagedIterable().concat());
- }
-
- @Override
- public ExternalIp getIp(final Integer id) {
- ExternalIpDto ip = context.getApi().getInfrastructureApi().getExternalIp(target, id);
- return wrap(context, ExternalIp.class, ip);
- }
-
- // Parent access
-
- public Enterprise getEnterprise() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.ENTERPRISE), ValidationErrors.MISSING_REQUIRED_LINK
- + " " + ParentLinkName.ENTERPRISE);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<EnterpriseDto> parser = new ParseXMLWithJAXB<EnterpriseDto>(context.utils().xml(),
- TypeLiteral.get(EnterpriseDto.class));
-
- enterprise = wrap(context, Enterprise.class, parser.apply(response));
- return enterprise;
- }
-
- public Datacenter getDatacenter() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.DATACENTER), ValidationErrors.MISSING_REQUIRED_LINK
- + " " + ParentLinkName.DATACENTER);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<DatacenterDto> parser = new ParseXMLWithJAXB<DatacenterDto>(context.utils().xml(),
- TypeLiteral.get(DatacenterDto.class));
-
- datacenter = wrap(context, Datacenter.class, parser.apply(response));
- return datacenter;
- }
-
- private void addEnterpriseLink() {
- checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
- checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class);
-
- RESTLink link = enterprise.unwrap().getEditLink();
- checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
-
- target.addLink(new RESTLink("enterprise", link.getHref()));
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter,
- final Enterprise enterprise) {
- return new Builder(context, datacenter, enterprise);
- }
-
- public static class Builder extends NetworkBuilder<Builder> {
- private Datacenter datacenter;
-
- private Enterprise enterprise;
-
- private Optional<NetworkServiceType> networkServiceType = Optional.absent();
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter, final Enterprise enterprise) {
- super(context);
- this.datacenter = checkNotNull(datacenter,
- ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName());
- this.enterprise = checkNotNull(enterprise,
- ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName());
- this.context = context;
- }
-
- public Builder datacenter(final Datacenter datacenter) {
- this.datacenter = checkNotNull(datacenter,
- ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName());
- return this;
- }
-
- public Builder enterprise(final Enterprise enterprise) {
- this.enterprise = checkNotNull(enterprise,
- ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName());
- return this;
- }
-
- public Builder networkServiceType(final NetworkServiceType networkServiceType) {
- this.networkServiceType = Optional.of(networkServiceType);
- return this;
- }
-
- public ExternalNetwork build() {
- VLANNetworkDto dto = new VLANNetworkDto();
- dto.setName(name);
- dto.setTag(tag);
- dto.setGateway(gateway);
- dto.setAddress(address);
- dto.setMask(mask);
- dto.setPrimaryDNS(primaryDNS);
- dto.setSecondaryDNS(secondaryDNS);
- dto.setSufixDNS(suffixDNS);
- dto.setDefaultNetwork(defaultNetwork == null ? Boolean.FALSE : defaultNetwork);
- dto.setUnmanaged(Boolean.FALSE);
- dto.setType(NetworkType.EXTERNAL);
-
- NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType());
- dto.addLink(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref()));
-
- ExternalNetwork network = new ExternalNetwork(context, dto);
- network.datacenter = datacenter;
- network.enterprise = enterprise;
-
- return network;
- }
-
- public static Builder fromExternalNetwork(final ExternalNetwork in) {
- return ExternalNetwork.builder(in.context, in.datacenter, in.enterprise).name(in.getName()).tag(in.getTag())
- .gateway(in.getGateway()).address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS())
- .secondaryDNS(in.getSecondaryDNS()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork());
- }
- }
-
- @Override
- public String toString() {
- return "External " + super.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java
deleted file mode 100644
index b39d088..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.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.network;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.NetworkType;
-import com.abiquo.server.core.infrastructure.network.AbstractIpDto;
-
-/**
- * Adds generic high level functionality to {@link AbstractIpDto}.
- */
-public abstract class Ip<T extends AbstractIpDto, N extends Network<?>> extends DomainWrapper<T> {
- /**
- * Constructor to be used only by the builder.
- */
- protected Ip(final ApiContext<AbiquoApi> context, final T target) {
- super(context, target);
- }
-
- // Domain operations
-
- public abstract N getNetwork();
-
- public abstract NetworkType getNetworkType();
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getIp() {
- return target.getIp();
- }
-
- public String getMac() {
- return target.getMac();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getNetworkName() {
- return target.getNetworkName();
- }
-
- @Override
- public String toString() {
- return "Ip [id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName() + ", networkName="
- + getNetworkName() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java
deleted file mode 100644
index f9646b6..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java
+++ /dev/null
@@ -1,306 +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.network;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-
-import java.util.List;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.predicates.IpPredicates;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.NetworkType;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.common.base.Function;
-
-/**
- * Adds generic high level functionality to {@link VLANNetworkDto}.
- */
-public abstract class Network<T extends Ip<?, ?>> extends DomainWrapper<VLANNetworkDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected Network(final ApiContext<AbiquoApi> context, final VLANNetworkDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- public abstract void save();
-
- public abstract void update();
-
- public abstract void delete();
-
- public abstract Iterable<T> listIps();
-
- public abstract Iterable<T> listIps(IpOptions options);
-
- public abstract T getIp(Integer id);
-
- public Iterable<T> listUnusedIps() {
- return filter(listIps(), IpPredicates.<T> notUsed());
- }
-
- // Builder
-
- public static class NetworkBuilder<T extends NetworkBuilder<T>> {
- protected ApiContext<AbiquoApi> context;
-
- protected String name;
-
- protected Integer tag;
-
- protected String gateway;
-
- protected String address;
-
- protected Integer mask;
-
- protected String primaryDNS;
-
- protected String secondaryDNS;
-
- protected String suffixDNS;
-
- protected Boolean defaultNetwork;
-
- public NetworkBuilder(final ApiContext<AbiquoApi> context) {
- super();
- this.context = context;
- }
-
- @SuppressWarnings("unchecked")
- public T name(final String name) {
- this.name = name;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T tag(final Integer tag) {
- this.tag = tag;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T gateway(final String gateway) {
- this.gateway = gateway;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T address(final String address) {
- this.address = address;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T mask(final int mask) {
- this.mask = mask;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T primaryDNS(final String primaryDNS) {
- this.primaryDNS = primaryDNS;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T secondaryDNS(final String secondaryDNS) {
- this.secondaryDNS = secondaryDNS;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T suffixDNS(final String suffixDNS) {
- this.suffixDNS = suffixDNS;
- return (T) this;
- }
-
- @SuppressWarnings("unchecked")
- public T defaultNetwork(final Boolean defaultNetwork) {
- this.defaultNetwork = defaultNetwork;
- return (T) this;
- }
- }
-
- public PrivateNetwork toPrivateNetwork() {
- checkArgument(target.getType().equals(NetworkType.INTERNAL),
- ValidationErrors.INVALID_NETWORK_TYPE + target.getType());
-
- return wrap(context, PrivateNetwork.class, target);
-
- }
-
- public ExternalNetwork toExternalNetwork() {
- checkArgument(target.getType().equals(NetworkType.EXTERNAL),
- ValidationErrors.INVALID_NETWORK_TYPE + target.getType());
-
- return wrap(context, ExternalNetwork.class, target);
-
- }
-
- public PublicNetwork toPublicNetwork() {
- checkArgument(target.getType().equals(NetworkType.PUBLIC),
- ValidationErrors.INVALID_NETWORK_TYPE + target.getType());
-
- return wrap(context, PublicNetwork.class, target);
-
- }
-
- public UnmanagedNetwork toUnmanagedNetwork() {
- checkArgument(target.getType().equals(NetworkType.UNMANAGED),
- ValidationErrors.INVALID_NETWORK_TYPE + target.getType());
-
- return wrap(context, UnmanagedNetwork.class, target);
-
- }
-
- // Delegate methods
-
- public String getAddress() {
- return target.getAddress();
- }
-
- public Boolean getDefaultNetwork() {
- return target.getDefaultNetwork();
- }
-
- public String getGateway() {
- return target.getGateway();
- }
-
- public Integer getId() {
- return target.getId();
- }
-
- public Integer getMask() {
- return target.getMask();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getPrimaryDNS() {
- return target.getPrimaryDNS();
- }
-
- public String getSecondaryDNS() {
- return target.getSecondaryDNS();
- }
-
- public String getSuffixDNS() {
- return target.getSufixDNS();
- }
-
- public Integer getTag() {
- return target.getTag();
- }
-
- public NetworkType getType() {
- return target.getType();
- }
-
- public void setAddress(final String address) {
- target.setAddress(address);
- }
-
- public void setDefaultNetwork(final Boolean defaultNetwork) {
- target.setDefaultNetwork(defaultNetwork);
- }
-
- public void setGateway(final String gateway) {
- target.setGateway(gateway);
- }
-
- public void setMask(final Integer mask) {
- target.setMask(mask);
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public void setPrimaryDNS(final String primaryDNS) {
- target.setPrimaryDNS(primaryDNS);
- }
-
- public void setSecondaryDNS(final String secondaryDNS) {
- target.setSecondaryDNS(secondaryDNS);
- }
-
- public void setSuffixDNS(final String suffixDNS) {
- target.setSufixDNS(suffixDNS);
- }
-
- public void setTag(final Integer tag) {
- target.setTag(tag);
- }
-
- @Override
- public String toString() {
- return "Network [id=" + getId() + ", address=" + getAddress() + ", defaultNetwork=" + getDefaultNetwork()
- + ", gateway=" + getGateway() + ", mask=" + getMask() + ", name=" + getName() + ", primaryDNS="
- + getPrimaryDNS() + ", secondaryDNS=" + getSecondaryDNS() + ", suffixDNS=" + getSuffixDNS() + ", tag="
- + getTag() + ", type=" + getType() + "]";
- }
-
- public static Network<?> wrapNetwork(final ApiContext<AbiquoApi> context, final VLANNetworkDto dto) {
- if (dto == null) {
- return null;
- }
-
- Network<?> network = null;
-
- switch (dto.getType()) {
- case EXTERNAL:
- network = wrap(context, ExternalNetwork.class, dto);
- break;
- case EXTERNAL_UNMANAGED:
- // TODO: How do we manage External && unmanaged networks ?
- throw new UnsupportedOperationException("EXTERNAL_UNMANAGED networks not supported yet");
- case INTERNAL:
- network = wrap(context, PrivateNetwork.class, dto);
- break;
- case PUBLIC:
- network = wrap(context, PublicNetwork.class, dto);
- break;
- case UNMANAGED:
- network = wrap(context, UnmanagedNetwork.class, dto);
- break;
- }
-
- return network;
- }
-
- public static Iterable<Network<?>> wrapNetworks(final ApiContext<AbiquoApi> context, final List<VLANNetworkDto> dtos) {
- return transform(dtos, new Function<VLANNetworkDto, Network<?>>() {
- @Override
- public Network<?> apply(VLANNetworkDto input) {
- return wrapNetwork(context, input);
- }
- });
- }
-}