mirror of https://github.com/apache/jclouds.git
Formatted code following jclouds guidelines
This commit formats all the Abiquo provider following the jclouds formatting guidelines. It uses the Eclipse default formatting configuration and a 3 spaces indentation and a line wrap fo 120 characters.
This commit is contained in:
parent
97004c7f32
commit
875563d0f1
|
@ -42,60 +42,59 @@ import org.jclouds.rest.annotations.Delegate;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface AbiquoApi
|
public interface AbiquoApi {
|
||||||
{
|
/**
|
||||||
/**
|
* Provides synchronous access to Admin features.
|
||||||
* Provides synchronous access to Admin features.
|
*/
|
||||||
*/
|
@Delegate
|
||||||
@Delegate
|
AdminApi getAdminApi();
|
||||||
AdminApi getAdminApi();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Infrastructure features.
|
* Provides synchronous access to Infrastructure features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
InfrastructureApi getInfrastructureApi();
|
InfrastructureApi getInfrastructureApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Cloud features.
|
* Provides synchronous access to Cloud features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
CloudApi getCloudApi();
|
CloudApi getCloudApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Apps library features.
|
* Provides synchronous access to Apps library features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
VirtualMachineTemplateApi getVirtualMachineTemplateApi();
|
VirtualMachineTemplateApi getVirtualMachineTemplateApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Enterprise features.
|
* Provides synchronous access to Enterprise features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
EnterpriseApi getEnterpriseApi();
|
EnterpriseApi getEnterpriseApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to configuration features.
|
* Provides synchronous access to configuration features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
ConfigApi getConfigApi();
|
ConfigApi getConfigApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to task asynchronous features.
|
* Provides synchronous access to task asynchronous features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
TaskApi getTaskApi();
|
TaskApi getTaskApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Event features.
|
* Provides synchronous access to Event features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
EventApi getEventApi();
|
EventApi getEventApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Pricing features.
|
* Provides synchronous access to Pricing features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
PricingApi getPricingApi();
|
PricingApi getPricingApi();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,82 +43,70 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class AbiquoApiMetadata extends BaseRestApiMetadata
|
public class AbiquoApiMetadata extends BaseRestApiMetadata {
|
||||||
{
|
/** Serial UID. */
|
||||||
/** Serial UID. */
|
private static final long serialVersionUID = -8355533493674898171L;
|
||||||
private static final long serialVersionUID = -8355533493674898171L;
|
|
||||||
|
|
||||||
/** The token describing the rest api context. */
|
/** The token describing the rest api context. */
|
||||||
public static final TypeToken<RestContext<AbiquoApi, AbiquoAsyncApi>> CONTEXT_TOKEN =
|
public static final TypeToken<RestContext<AbiquoApi, AbiquoAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<AbiquoApi, AbiquoAsyncApi>>() {
|
||||||
new TypeToken<RestContext<AbiquoApi, AbiquoAsyncApi>>()
|
private static final long serialVersionUID = -5070937833892503232L;
|
||||||
{
|
};
|
||||||
private static final long serialVersionUID = -5070937833892503232L;
|
|
||||||
};
|
|
||||||
|
|
||||||
public AbiquoApiMetadata()
|
public AbiquoApiMetadata() {
|
||||||
{
|
this(new Builder());
|
||||||
this(new Builder());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected AbiquoApiMetadata(final Builder builder)
|
protected AbiquoApiMetadata(final Builder builder) {
|
||||||
{
|
super(builder);
|
||||||
super(builder);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static Properties defaultProperties()
|
public static Properties defaultProperties() {
|
||||||
{
|
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
// By default redirects will be handled in the domain objects
|
||||||
// By default redirects will be handled in the domain objects
|
properties.setProperty(PROPERTY_MAX_REDIRECTS, "0");
|
||||||
properties.setProperty(PROPERTY_MAX_REDIRECTS, "0");
|
// The default polling delay between AsyncTask monitor requests
|
||||||
// The default polling delay between AsyncTask monitor requests
|
properties.setProperty(ASYNC_TASK_MONITOR_DELAY, "5000");
|
||||||
properties.setProperty(ASYNC_TASK_MONITOR_DELAY, "5000");
|
// By default the provided credential is not a token
|
||||||
// By default the provided credential is not a token
|
properties.setProperty(CREDENTIAL_IS_TOKEN, "false");
|
||||||
properties.setProperty(CREDENTIAL_IS_TOKEN, "false");
|
return properties;
|
||||||
return properties;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder toBuilder()
|
public Builder toBuilder() {
|
||||||
{
|
return new Builder().fromApiMetadata(this);
|
||||||
return new Builder().fromApiMetadata(this);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder extends BaseRestApiMetadata.Builder
|
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||||
{
|
private static final String DOCUMENTATION_ROOT = "http://community.abiquo.com/display/ABI"
|
||||||
private static final String DOCUMENTATION_ROOT = "http://community.abiquo.com/display/ABI"
|
|
||||||
+ CharMatcher.DIGIT.retainFrom(AbiquoAsyncApi.API_VERSION);
|
+ CharMatcher.DIGIT.retainFrom(AbiquoAsyncApi.API_VERSION);
|
||||||
|
|
||||||
protected Builder()
|
protected Builder() {
|
||||||
{
|
super(AbiquoApi.class, AbiquoAsyncApi.class);
|
||||||
super(AbiquoApi.class, AbiquoAsyncApi.class);
|
id("abiquo")
|
||||||
id("abiquo")
|
.name("Abiquo API")
|
||||||
.name("Abiquo API")
|
.identityName("API Username")
|
||||||
.identityName("API Username")
|
.credentialName("API Password")
|
||||||
.credentialName("API Password")
|
.documentation(URI.create(DOCUMENTATION_ROOT + "/API+Reference"))
|
||||||
.documentation(URI.create(DOCUMENTATION_ROOT + "/API+Reference"))
|
.defaultEndpoint("http://localhost/api")
|
||||||
.defaultEndpoint("http://localhost/api")
|
.version(AbiquoAsyncApi.API_VERSION)
|
||||||
.version(AbiquoAsyncApi.API_VERSION)
|
.buildVersion(AbiquoAsyncApi.BUILD_VERSION)
|
||||||
.buildVersion(AbiquoAsyncApi.BUILD_VERSION)
|
.view(TypeToken.of(AbiquoContext.class))
|
||||||
.view(TypeToken.of(AbiquoContext.class))
|
.defaultProperties(AbiquoApiMetadata.defaultProperties())
|
||||||
.defaultProperties(AbiquoApiMetadata.defaultProperties())
|
.defaultModules(
|
||||||
.defaultModules(
|
ImmutableSet.<Class<? extends Module>> of(AbiquoRestClientModule.class,
|
||||||
ImmutableSet.<Class< ? extends Module>> of(AbiquoRestClientModule.class,
|
AbiquoComputeServiceContextModule.class, ScheduledExecutorServiceModule.class));
|
||||||
AbiquoComputeServiceContextModule.class,
|
}
|
||||||
ScheduledExecutorServiceModule.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbiquoApiMetadata build()
|
public AbiquoApiMetadata build() {
|
||||||
{
|
return new AbiquoApiMetadata(this);
|
||||||
return new AbiquoApiMetadata(this);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder fromApiMetadata(final ApiMetadata in)
|
public Builder fromApiMetadata(final ApiMetadata in) {
|
||||||
{
|
super.fromApiMetadata(in);
|
||||||
super.fromApiMetadata(in);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,69 +40,68 @@ import com.abiquo.model.transport.SingleResourceTransportDto;
|
||||||
* @see InfrastructureAsyncApi
|
* @see InfrastructureAsyncApi
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public interface AbiquoAsyncApi
|
public interface AbiquoAsyncApi {
|
||||||
{
|
/**
|
||||||
/**
|
* The version of the supported Abiquo API.
|
||||||
* The version of the supported Abiquo API.
|
*/
|
||||||
*/
|
public static final String API_VERSION = SingleResourceTransportDto.API_VERSION;
|
||||||
public static final String API_VERSION = SingleResourceTransportDto.API_VERSION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The supported build version of the Abiquo Api.
|
* The supported build version of the Abiquo Api.
|
||||||
*/
|
*/
|
||||||
public static final String BUILD_VERSION = "7bbfe95-158721b";
|
public static final String BUILD_VERSION = "7bbfe95-158721b";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Admin features.
|
* Provides asynchronous access to Admin features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
AdminAsyncApi getAdminApi();
|
AdminAsyncApi getAdminApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Infrastructure features.
|
* Provides asynchronous access to Infrastructure features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
InfrastructureAsyncApi getInfrastructureApi();
|
InfrastructureAsyncApi getInfrastructureApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Cloud features.
|
* Provides asynchronous access to Cloud features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
CloudAsyncApi getCloudApi();
|
CloudAsyncApi getCloudApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Apps library features.
|
* Provides asynchronous access to Apps library features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
VirtualMachineTemplateAsyncApi getVirtualMachineTemplateApi();
|
VirtualMachineTemplateAsyncApi getVirtualMachineTemplateApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Enterprise features.
|
* Provides asynchronous access to Enterprise features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
EnterpriseAsyncApi getEnterpriseApi();
|
EnterpriseAsyncApi getEnterpriseApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to configuration features.
|
* Provides asynchronous access to configuration features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
ConfigAsyncApi getConfigApi();
|
ConfigAsyncApi getConfigApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to task asynchronous features.
|
* Provides asynchronous access to task asynchronous features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
TaskAsyncApi getTaskApi();
|
TaskAsyncApi getTaskApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Event features.
|
* Provides asynchronous access to Event features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
EventAsyncApi getEventApi();
|
EventAsyncApi getEventApi();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Pricing features.
|
* Provides asynchronous access to Pricing features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
PricingAsyncApi getPricingApi();
|
PricingAsyncApi getPricingApi();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,59 +32,62 @@ import org.jclouds.rest.RestContext;
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abiquo {@link ComputeServiceContext} implementation to expose high level Abiquo functionalities.
|
* Abiquo {@link ComputeServiceContext} implementation to expose high level
|
||||||
|
* Abiquo functionalities.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(AbiquoContextImpl.class)
|
@ImplementedBy(AbiquoContextImpl.class)
|
||||||
public interface AbiquoContext extends ComputeServiceContext
|
public interface AbiquoContext extends ComputeServiceContext {
|
||||||
{
|
/**
|
||||||
/**
|
* Returns the Abiquo API context, providing direct access to the Abiquo Rest
|
||||||
* Returns the Abiquo API context, providing direct access to the Abiquo Rest API.
|
* API.
|
||||||
*
|
*
|
||||||
* @return The Abiquo API context.
|
* @return The Abiquo API context.
|
||||||
*/
|
*/
|
||||||
RestContext<AbiquoApi, AbiquoAsyncApi> getApiContext();
|
RestContext<AbiquoApi, AbiquoAsyncApi> getApiContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the administration service.
|
* Returns the administration service.
|
||||||
* <p>
|
* <p>
|
||||||
* This service provides an entry point to infrastructure administration tasks.
|
* This service provides an entry point to infrastructure administration
|
||||||
*/
|
* tasks.
|
||||||
AdministrationService getAdministrationService();
|
*/
|
||||||
|
AdministrationService getAdministrationService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cloud service.
|
* Returns the cloud service.
|
||||||
* <p>
|
* <p>
|
||||||
* This service provides an entry point to cloud management tasks.
|
* This service provides an entry point to cloud management tasks.
|
||||||
*/
|
*/
|
||||||
CloudService getCloudService();
|
CloudService getCloudService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the search service.
|
* Returns the search service.
|
||||||
* <p>
|
* <p>
|
||||||
* This service provides an entry point to listing and filtering tasks.
|
* This service provides an entry point to listing and filtering tasks.
|
||||||
*/
|
*/
|
||||||
SearchService getSearchService();
|
SearchService getSearchService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the monitoring service.
|
* Returns the monitoring service.
|
||||||
* <p>
|
* <p>
|
||||||
* This service provides an entry point to asynchronous task monitoring tasks.
|
* This service provides an entry point to asynchronous task monitoring
|
||||||
*/
|
* tasks.
|
||||||
MonitoringService getMonitoringService();
|
*/
|
||||||
|
MonitoringService getMonitoringService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the event service.
|
* Returns the event service.
|
||||||
* <p>
|
* <p>
|
||||||
* This service provides an entry point to event management tasks.
|
* This service provides an entry point to event management tasks.
|
||||||
*/
|
*/
|
||||||
EventService getEventService();
|
EventService getEventService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the pricing service.
|
* Returns the pricing service.
|
||||||
* <p>
|
* <p>
|
||||||
* This service provides an entry point to pricing management tasks.
|
* This service provides an entry point to pricing management tasks.
|
||||||
*/
|
*/
|
||||||
PricingService getPricingService();
|
PricingService getPricingService();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,23 +34,20 @@ import org.jclouds.rest.Binder;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AppendToPath implements Binder
|
public class AppendToPath implements Binder {
|
||||||
{
|
@SuppressWarnings("unchecked")
|
||||||
@SuppressWarnings("unchecked")
|
@Override
|
||||||
@Override
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
// Append the parameter to the request URI
|
||||||
{
|
String valueToAppend = getValue(request, checkNotNull(input, "input"));
|
||||||
// Append the parameter to the request URI
|
URI path = URI.create(request.getEndpoint().toString() + "/" + valueToAppend);
|
||||||
String valueToAppend = getValue(request, checkNotNull(input, "input"));
|
return (R) request.toBuilder().endpoint(path).build();
|
||||||
URI path = URI.create(request.getEndpoint().toString() + "/" + valueToAppend);
|
}
|
||||||
return (R) request.toBuilder().endpoint(path).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value that will be appended to the request URI.
|
* Get the value that will be appended to the request URI.
|
||||||
*/
|
*/
|
||||||
protected <R extends HttpRequest> String getValue(final R request, final Object input)
|
protected <R extends HttpRequest> String getValue(final R request, final Object input) {
|
||||||
{
|
return input.toString();
|
||||||
return input.toString();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,13 @@ import com.abiquo.model.rest.RESTLink;
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindLinkToPath extends BindToPath
|
public class BindLinkToPath extends BindToPath {
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input)
|
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof RESTLink, "this binder is only valid for RESTLink objects");
|
||||||
checkArgument(checkNotNull(input, "input") instanceof RESTLink,
|
|
||||||
"this binder is only valid for RESTLink objects");
|
|
||||||
|
|
||||||
return ((RESTLink) input).getHref();
|
return ((RESTLink) input).getHref();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,20 +35,16 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindLinkToPathAndAcceptHeader extends BindLinkToPath
|
public class BindLinkToPathAndAcceptHeader extends BindLinkToPath {
|
||||||
{
|
@Override
|
||||||
@Override
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
R updatedRequest = super.bindToRequest(request, input);
|
||||||
{
|
return addHeader(updatedRequest, HttpHeaders.ACCEPT, ((RESTLink) input).getType());
|
||||||
R updatedRequest = super.bindToRequest(request, input);
|
}
|
||||||
return addHeader(updatedRequest, HttpHeaders.ACCEPT, ((RESTLink) input).getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
<R extends HttpRequest> R addHeader(final R request, final String header, final String value)
|
<R extends HttpRequest> R addHeader(final R request, final String header, final String value) {
|
||||||
{
|
return (R) request.toBuilder().replaceHeader(HttpHeaders.ACCEPT, checkNotNull(value, "value")).build();
|
||||||
return (R) request.toBuilder()
|
}
|
||||||
.replaceHeader(HttpHeaders.ACCEPT, checkNotNull(value, "value")).build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,37 +37,32 @@ import com.abiquo.model.transport.SingleResourceTransportDto;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public abstract class BindRefsToPayload extends BindToXMLPayload
|
public abstract class BindRefsToPayload extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindRefsToPayload(final XMLParser xmlParser) {
|
||||||
public BindRefsToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract String getRelToUse(final Object input);
|
protected abstract String getRelToUse(final Object input);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto[],
|
||||||
checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto[],
|
|
||||||
"this binder is only valid for SingleResourceTransportDto arrays");
|
"this binder is only valid for SingleResourceTransportDto arrays");
|
||||||
|
|
||||||
SingleResourceTransportDto[] dtos = (SingleResourceTransportDto[]) input;
|
SingleResourceTransportDto[] dtos = (SingleResourceTransportDto[]) input;
|
||||||
LinksDto refs = new LinksDto();
|
LinksDto refs = new LinksDto();
|
||||||
|
|
||||||
for (SingleResourceTransportDto dto : dtos)
|
for (SingleResourceTransportDto dto : dtos) {
|
||||||
{
|
RESTLink editLink = checkNotNull(dto.getEditLink(), "entity must have an edit link");
|
||||||
RESTLink editLink = checkNotNull(dto.getEditLink(), "entity must have an edit link");
|
|
||||||
|
|
||||||
// Do not add repeated references
|
// Do not add repeated references
|
||||||
if (refs.searchLinkByHref(editLink.getHref()) == null)
|
if (refs.searchLinkByHref(editLink.getHref()) == null) {
|
||||||
{
|
refs.addLink(new RESTLink(getRelToUse(input), editLink.getHref()));
|
||||||
refs.addLink(new RESTLink(getRelToUse(input), editLink.getHref()));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.bindToRequest(request, refs);
|
return super.bindToRequest(request, refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,114 +46,101 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindToPath implements Binder
|
public class BindToPath implements Binder {
|
||||||
{
|
@Override
|
||||||
@Override
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||||
{
|
|
||||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
|
||||||
"this binder is only valid for GeneratedHttpRequests");
|
"this binder is only valid for GeneratedHttpRequests");
|
||||||
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
||||||
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
||||||
|
|
||||||
// Update the request URI with the configured link URI
|
// Update the request URI with the configured link URI
|
||||||
String newEndpoint = getNewEndpoint(gRequest, input);
|
String newEndpoint = getNewEndpoint(gRequest, input);
|
||||||
return bindToPath(request, newEndpoint);
|
return bindToPath(request, newEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the new endpoint to use.
|
* Get the new endpoint to use.
|
||||||
*
|
*
|
||||||
* @param gRequest The request.
|
* @param gRequest
|
||||||
* @param input The input parameter.
|
* The request.
|
||||||
* @return The new endpoint to use.
|
* @param input
|
||||||
*/
|
* The input parameter.
|
||||||
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input)
|
* @return The new endpoint to use.
|
||||||
{
|
*/
|
||||||
SingleResourceTransportDto dto = checkValidInput(input);
|
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) {
|
||||||
return getLinkToUse(gRequest, dto).getHref();
|
SingleResourceTransportDto dto = checkValidInput(input);
|
||||||
}
|
return getLinkToUse(gRequest, dto).getHref();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the link to be used to build the request URI.
|
* Get the link to be used to build the request URI.
|
||||||
*
|
*
|
||||||
* @param request The current request.
|
* @param request
|
||||||
* @param payload The object containing the link.
|
* The current request.
|
||||||
* @return The link to be used to build the request URI.
|
* @param payload
|
||||||
*/
|
* The object containing the link.
|
||||||
static RESTLink getLinkToUse(final GeneratedHttpRequest request,
|
* @return The link to be used to build the request URI.
|
||||||
final SingleResourceTransportDto payload)
|
*/
|
||||||
{
|
static RESTLink getLinkToUse(final GeneratedHttpRequest request, final SingleResourceTransportDto payload) {
|
||||||
int argIndex = request.getArgs().indexOf(payload);
|
int argIndex = request.getArgs().indexOf(payload);
|
||||||
Annotation[] annotations = request.getJavaMethod().getParameterAnnotations()[argIndex];
|
Annotation[] annotations = request.getJavaMethod().getParameterAnnotations()[argIndex];
|
||||||
|
|
||||||
EndpointLink linkName =
|
EndpointLink linkName = (EndpointLink) Iterables.find(Arrays.asList(annotations),
|
||||||
(EndpointLink) Iterables.find(Arrays.asList(annotations),
|
Predicates.instanceOf(EndpointLink.class), null);
|
||||||
Predicates.instanceOf(EndpointLink.class), null);
|
|
||||||
|
|
||||||
if (linkName == null)
|
if (linkName == null) {
|
||||||
{
|
throw new BindException(request, "Expected a EndpointLink annotation but not found in the parameter");
|
||||||
throw new BindException(request,
|
}
|
||||||
"Expected a EndpointLink annotation but not found in the parameter");
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkNotNull(payload.searchLink(linkName.value()),
|
return checkNotNull(payload.searchLink(linkName.value()), "No link was found in object with rel: " + linkName);
|
||||||
"No link was found in object with rel: " + linkName);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind the given link to the request URI.
|
* Bind the given link to the request URI.
|
||||||
*
|
*
|
||||||
* @param request The request to modify.
|
* @param request
|
||||||
* @param endpoint The endpoint to use as the request URI.
|
* The request to modify.
|
||||||
* @return The updated request.
|
* @param endpoint
|
||||||
*/
|
* The endpoint to use as the request URI.
|
||||||
@SuppressWarnings("unchecked")
|
* @return The updated request.
|
||||||
static <R extends HttpRequest> R bindToPath(final R request, final String endpoint)
|
*/
|
||||||
{
|
@SuppressWarnings("unchecked")
|
||||||
// Preserve current query and matrix parameters
|
static <R extends HttpRequest> R bindToPath(final R request, final String endpoint) {
|
||||||
String newEndpoint = endpoint + getParameterString(request);
|
// Preserve current query and matrix parameters
|
||||||
|
String newEndpoint = endpoint + getParameterString(request);
|
||||||
|
|
||||||
// Replace the URI with the edit link in the DTO
|
// Replace the URI with the edit link in the DTO
|
||||||
URI path = URI.create(newEndpoint);
|
URI path = URI.create(newEndpoint);
|
||||||
return (R) request.toBuilder().endpoint(path).build();
|
return (R) request.toBuilder().endpoint(path).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static SingleResourceTransportDto checkValidInput(final Object input)
|
protected static SingleResourceTransportDto checkValidInput(final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto,
|
||||||
checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto,
|
|
||||||
"this binder is only valid for SingleResourceTransportDto objects");
|
"this binder is only valid for SingleResourceTransportDto objects");
|
||||||
|
|
||||||
return (SingleResourceTransportDto) input;
|
return (SingleResourceTransportDto) input;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <R extends HttpRequest> String getParameterString(final R request)
|
protected static <R extends HttpRequest> String getParameterString(final R request) {
|
||||||
{
|
String endpoint = request.getEndpoint().toString();
|
||||||
String endpoint = request.getEndpoint().toString();
|
|
||||||
|
|
||||||
int query = endpoint.indexOf('?');
|
int query = endpoint.indexOf('?');
|
||||||
int matrix = endpoint.indexOf(';');
|
int matrix = endpoint.indexOf(';');
|
||||||
|
|
||||||
if (query == -1 && matrix == -1)
|
if (query == -1 && matrix == -1) {
|
||||||
{
|
// No parameters
|
||||||
// No parameters
|
return "";
|
||||||
return "";
|
} else if (query != -1 && matrix != -1) {
|
||||||
}
|
// Both parameter types
|
||||||
else if (query != -1 && matrix != -1)
|
return endpoint.substring(query < matrix ? query : matrix);
|
||||||
{
|
} else if (query != -1) {
|
||||||
// Both parameter types
|
// Only request parameters
|
||||||
return endpoint.substring(query < matrix ? query : matrix);
|
return endpoint.substring(query);
|
||||||
}
|
} else {
|
||||||
else if (query != -1)
|
// Only matrix parameters
|
||||||
{
|
return endpoint.substring(matrix);
|
||||||
// Only request parameters
|
}
|
||||||
return endpoint.substring(query);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Only matrix parameters
|
|
||||||
return endpoint.substring(matrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,48 +35,47 @@ import org.jclouds.xml.XMLParser;
|
||||||
import com.abiquo.model.transport.SingleResourceTransportDto;
|
import com.abiquo.model.transport.SingleResourceTransportDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds teh given object to the payload and extracts the path parameters from the edit link.
|
* Binds teh given object to the payload and extracts the path parameters from
|
||||||
|
* the edit link.
|
||||||
* <p>
|
* <p>
|
||||||
* This method should be used in {@link PUT} methods to automatically extract the path parameters
|
* This method should be used in {@link PUT} methods to automatically extract
|
||||||
* from the edit link of the updated object.
|
* the path parameters from the edit link of the updated object.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindToXMLPayloadAndPath extends BindToXMLPayload
|
public class BindToXMLPayloadAndPath extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindToXMLPayloadAndPath(final XMLParser xmlParser) {
|
||||||
public BindToXMLPayloadAndPath(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object payload)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object payload) {
|
||||||
{
|
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
|
||||||
"this binder is only valid for GeneratedHttpRequests");
|
"this binder is only valid for GeneratedHttpRequests");
|
||||||
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
||||||
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
||||||
|
|
||||||
// Update the request URI with the configured link URI
|
// Update the request URI with the configured link URI
|
||||||
String newEndpoint = getNewEndpoint(gRequest, payload);
|
String newEndpoint = getNewEndpoint(gRequest, payload);
|
||||||
R updatedRequest = BindToPath.bindToPath(request, newEndpoint);
|
R updatedRequest = BindToPath.bindToPath(request, newEndpoint);
|
||||||
|
|
||||||
// Add the payload
|
// Add the payload
|
||||||
return super.bindToRequest(updatedRequest, payload);
|
return super.bindToRequest(updatedRequest, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the new endpoint to use.
|
* Get the new endpoint to use.
|
||||||
*
|
*
|
||||||
* @param gRequest The request.
|
* @param gRequest
|
||||||
* @param input The input parameter.
|
* The request.
|
||||||
* @return The new endpoint to use.
|
* @param input
|
||||||
*/
|
* The input parameter.
|
||||||
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input)
|
* @return The new endpoint to use.
|
||||||
{
|
*/
|
||||||
SingleResourceTransportDto dto = BindToPath.checkValidInput(input);
|
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) {
|
||||||
return BindToPath.getLinkToUse(gRequest, dto).getHref();
|
SingleResourceTransportDto dto = BindToPath.checkValidInput(input);
|
||||||
}
|
return BindToPath.getLinkToUse(gRequest, dto).getHref();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,23 +28,21 @@ import org.jclouds.xml.XMLParser;
|
||||||
import com.abiquo.server.core.infrastructure.storage.DiskManagementDto;
|
import com.abiquo.server.core.infrastructure.storage.DiskManagementDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind multiple {@link DiskManagementDto} objects to the payload of the request as a list of links.
|
* Bind multiple {@link DiskManagementDto} objects to the payload of the request
|
||||||
|
* as a list of links.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindHardDiskRefsToPayload extends BindRefsToPayload
|
public class BindHardDiskRefsToPayload extends BindRefsToPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindHardDiskRefsToPayload(final XMLParser xmlParser) {
|
||||||
public BindHardDiskRefsToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getRelToUse(final Object input)
|
protected String getRelToUse(final Object input) {
|
||||||
{
|
return "disk";
|
||||||
return "disk";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,27 +39,23 @@ import com.abiquo.server.core.infrastructure.network.AbstractIpDto;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindIpRefToPayload extends BindToXMLPayload
|
public class BindIpRefToPayload extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindIpRefToPayload(final XMLParser xmlParser) {
|
||||||
public BindIpRefToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto,
|
||||||
checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto,
|
|
||||||
"this binder is only valid for AbstractIpDto objects");
|
"this binder is only valid for AbstractIpDto objects");
|
||||||
|
|
||||||
AbstractIpDto ip = (AbstractIpDto) input;
|
AbstractIpDto ip = (AbstractIpDto) input;
|
||||||
RESTLink selfLink =
|
RESTLink selfLink = checkNotNull(ip.searchLink("self"), "AbstractIpDto must have an self link");
|
||||||
checkNotNull(ip.searchLink("self"), "AbstractIpDto must have an self link");
|
|
||||||
|
|
||||||
LinksDto refs = new LinksDto();
|
LinksDto refs = new LinksDto();
|
||||||
refs.addLink(new RESTLink(selfLink.getTitle(), selfLink.getHref()));
|
refs.addLink(new RESTLink(selfLink.getTitle(), selfLink.getHref()));
|
||||||
|
|
||||||
return super.bindToRequest(request, refs);
|
return super.bindToRequest(request, refs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,36 +40,29 @@ import com.abiquo.server.core.infrastructure.network.AbstractIpDto;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindIpRefsToPayload extends BindToXMLPayload
|
public class BindIpRefsToPayload extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindIpRefsToPayload(final XMLParser xmlParser) {
|
||||||
public BindIpRefsToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto[],
|
||||||
checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto[],
|
|
||||||
"this binder is only valid for AbstractIpDto arrays");
|
"this binder is only valid for AbstractIpDto arrays");
|
||||||
|
|
||||||
AbstractIpDto[] ips = (AbstractIpDto[]) input;
|
AbstractIpDto[] ips = (AbstractIpDto[]) input;
|
||||||
LinksDto refs = new LinksDto();
|
LinksDto refs = new LinksDto();
|
||||||
|
|
||||||
for (AbstractIpDto ip : ips)
|
for (AbstractIpDto ip : ips) {
|
||||||
{
|
RESTLink selfLink = checkNotNull(LinkUtils.getSelfLink(ip), "AbstractIpDto must have an edit or self link");
|
||||||
RESTLink selfLink =
|
if (refs.searchLinkByHref(selfLink.getHref()) == null) {
|
||||||
checkNotNull(LinkUtils.getSelfLink(ip),
|
RESTLink ref = new RESTLink(selfLink.getTitle(), selfLink.getHref());
|
||||||
"AbstractIpDto must have an edit or self link");
|
ref.setType(selfLink.getType());
|
||||||
if (refs.searchLinkByHref(selfLink.getHref()) == null)
|
refs.addLink(ref);
|
||||||
{
|
}
|
||||||
RESTLink ref = new RESTLink(selfLink.getTitle(), selfLink.getHref());
|
}
|
||||||
ref.setType(selfLink.getType());
|
|
||||||
refs.addLink(ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.bindToRequest(request, refs);
|
return super.bindToRequest(request, refs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,20 +33,17 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class BindMoveVolumeToPath extends BindToPath
|
public class BindMoveVolumeToPath extends BindToPath {
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input)
|
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof VolumeManagementDto,
|
||||||
checkArgument(checkNotNull(input, "input") instanceof VolumeManagementDto,
|
|
||||||
"this binder is only valid for VolumeManagementDto objects");
|
"this binder is only valid for VolumeManagementDto objects");
|
||||||
|
|
||||||
VolumeManagementDto volume = (VolumeManagementDto) input;
|
VolumeManagementDto volume = (VolumeManagementDto) input;
|
||||||
RESTLink editLink =
|
RESTLink editLink = checkNotNull(volume.getEditLink(), "VolumeManagementDto must have an edit link");
|
||||||
checkNotNull(volume.getEditLink(), "VolumeManagementDto must have an edit link");
|
|
||||||
|
|
||||||
return editLink.getHref() + "/action/move";
|
return editLink.getHref() + "/action/move";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,36 +44,30 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindNetworkConfigurationRefToPayload extends BindToXMLPayload
|
public class BindNetworkConfigurationRefToPayload extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindNetworkConfigurationRefToPayload(final XMLParser xmlParser) {
|
||||||
public BindNetworkConfigurationRefToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
|
||||||
"this binder is only valid for GeneratedHttpRequests");
|
"this binder is only valid for GeneratedHttpRequests");
|
||||||
checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
|
checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
|
||||||
"this binder is only valid for VLANNetworkDto");
|
"this binder is only valid for VLANNetworkDto");
|
||||||
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
||||||
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
||||||
|
|
||||||
VLANNetworkDto network = (VLANNetworkDto) input;
|
VLANNetworkDto network = (VLANNetworkDto) input;
|
||||||
VirtualMachineDto vm =
|
VirtualMachineDto vm = (VirtualMachineDto) Iterables.find(gRequest.getArgs(),
|
||||||
(VirtualMachineDto) Iterables.find(gRequest.getArgs(),
|
Predicates.instanceOf(VirtualMachineDto.class));
|
||||||
Predicates.instanceOf(VirtualMachineDto.class));
|
|
||||||
|
|
||||||
RESTLink configLink =
|
RESTLink configLink = checkNotNull(vm.searchLink("configurations"), "missing required link");
|
||||||
checkNotNull(vm.searchLink("configurations"), "missing required link");
|
|
||||||
|
|
||||||
LinksDto dto = new LinksDto();
|
LinksDto dto = new LinksDto();
|
||||||
dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/"
|
dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" + network.getId()));
|
||||||
+ network.getId()));
|
|
||||||
|
|
||||||
return super.bindToRequest(request, dto);
|
return super.bindToRequest(request, dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,45 +39,40 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindNetworkRefToPayload extends BindToXMLPayload
|
public class BindNetworkRefToPayload extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindNetworkRefToPayload(final XMLParser xmlParser) {
|
||||||
public BindNetworkRefToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
|
||||||
checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
|
|
||||||
"this binder is only valid for VLANNetworkDto objects");
|
"this binder is only valid for VLANNetworkDto objects");
|
||||||
|
|
||||||
VLANNetworkDto network = (VLANNetworkDto) input;
|
VLANNetworkDto network = (VLANNetworkDto) input;
|
||||||
RESTLink editLink =
|
RESTLink editLink = checkNotNull(network.getEditLink(), "VLANNetworkDto must have an edit link");
|
||||||
checkNotNull(network.getEditLink(), "VLANNetworkDto must have an edit link");
|
|
||||||
|
|
||||||
LinksDto refs = new LinksDto();
|
LinksDto refs = new LinksDto();
|
||||||
switch (network.getType())
|
switch (network.getType()) {
|
||||||
{
|
case INTERNAL:
|
||||||
case INTERNAL:
|
refs.addLink(new RESTLink("internalnetwork", editLink.getHref()));
|
||||||
refs.addLink(new RESTLink("internalnetwork", editLink.getHref()));
|
break;
|
||||||
break;
|
case EXTERNAL:
|
||||||
case EXTERNAL:
|
refs.addLink(new RESTLink("externalnetwork", editLink.getHref()));
|
||||||
refs.addLink(new RESTLink("externalnetwork", editLink.getHref()));
|
break;
|
||||||
break;
|
case PUBLIC:
|
||||||
case PUBLIC:
|
refs.addLink(new RESTLink("publicnetwork", editLink.getHref()));
|
||||||
refs.addLink(new RESTLink("publicnetwork", editLink.getHref()));
|
break;
|
||||||
break;
|
case UNMANAGED:
|
||||||
case UNMANAGED:
|
refs.addLink(new RESTLink("unmanagednetwork", editLink.getHref()));
|
||||||
refs.addLink(new RESTLink("unmanagednetwork", editLink.getHref()));
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
// TODO: EXTERNAL_UNMANAGED network type
|
||||||
// TODO: EXTERNAL_UNMANAGED network type
|
throw new IllegalArgumentException("Unsupported network type");
|
||||||
throw new IllegalArgumentException("Unsupported network type");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.bindToRequest(request, refs);
|
return super.bindToRequest(request, refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,30 +41,25 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindUnmanagedIpRefToPayload extends BindToXMLPayload
|
public class BindUnmanagedIpRefToPayload extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindUnmanagedIpRefToPayload(final XMLParser xmlParser) {
|
||||||
public BindUnmanagedIpRefToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
|
||||||
checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
|
|
||||||
"this binder is only valid for VLANNetworkDto objects");
|
"this binder is only valid for VLANNetworkDto objects");
|
||||||
|
|
||||||
VLANNetworkDto network = (VLANNetworkDto) input;
|
VLANNetworkDto network = (VLANNetworkDto) input;
|
||||||
checkArgument(network.getType() == NetworkType.UNMANAGED,
|
checkArgument(network.getType() == NetworkType.UNMANAGED, "this binder is only valid for UNMANAGED networks");
|
||||||
"this binder is only valid for UNMANAGED networks");
|
|
||||||
|
|
||||||
RESTLink ipsLink =
|
RESTLink ipsLink = checkNotNull(network.searchLink("ips"), "VLANNetworkDto must have an ips link");
|
||||||
checkNotNull(network.searchLink("ips"), "VLANNetworkDto must have an ips link");
|
|
||||||
|
|
||||||
LinksDto refs = new LinksDto();
|
LinksDto refs = new LinksDto();
|
||||||
refs.addLink(new RESTLink("unmanagedip", ipsLink.getHref()));
|
refs.addLink(new RESTLink("unmanagedip", ipsLink.getHref()));
|
||||||
|
|
||||||
return super.bindToRequest(request, refs);
|
return super.bindToRequest(request, refs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,33 +35,29 @@ import com.abiquo.server.core.cloud.VirtualDatacenterDto;
|
||||||
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind multiple {@link VolumeManagementDto} objects to the payload of the request as a list of
|
* Bind multiple {@link VolumeManagementDto} objects to the payload of the
|
||||||
* links.
|
* request as a list of links.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindVirtualDatacenterRefToPayload extends BindToXMLPayload
|
public class BindVirtualDatacenterRefToPayload extends BindToXMLPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindVirtualDatacenterRefToPayload(final XMLParser xmlParser) {
|
||||||
public BindVirtualDatacenterRefToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof VirtualDatacenterDto,
|
||||||
checkArgument(checkNotNull(input, "input") instanceof VirtualDatacenterDto,
|
|
||||||
"this binder is only valid for VirtualDatacenterDto objects");
|
"this binder is only valid for VirtualDatacenterDto objects");
|
||||||
|
|
||||||
VirtualDatacenterDto vdc = (VirtualDatacenterDto) input;
|
VirtualDatacenterDto vdc = (VirtualDatacenterDto) input;
|
||||||
RESTLink editLink =
|
RESTLink editLink = checkNotNull(vdc.getEditLink(), "VirtualDatacenterDto must have an edit link");
|
||||||
checkNotNull(vdc.getEditLink(), "VirtualDatacenterDto must have an edit link");
|
LinksDto refs = new LinksDto();
|
||||||
LinksDto refs = new LinksDto();
|
refs.addLink(new RESTLink("virtualdatacenter", editLink.getHref()));
|
||||||
refs.addLink(new RESTLink("virtualdatacenter", editLink.getHref()));
|
|
||||||
|
|
||||||
return super.bindToRequest(request, refs);
|
return super.bindToRequest(request, refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,24 +28,21 @@ import org.jclouds.xml.XMLParser;
|
||||||
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind multiple {@link VolumeManagementDto} objects to the payload of the request as a list of
|
* Bind multiple {@link VolumeManagementDto} objects to the payload of the
|
||||||
* links.
|
* request as a list of links.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindVolumeRefsToPayload extends BindRefsToPayload
|
public class BindVolumeRefsToPayload extends BindRefsToPayload {
|
||||||
{
|
@Inject
|
||||||
@Inject
|
public BindVolumeRefsToPayload(final XMLParser xmlParser) {
|
||||||
public BindVolumeRefsToPayload(final XMLParser xmlParser)
|
super(xmlParser);
|
||||||
{
|
}
|
||||||
super(xmlParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getRelToUse(final Object input)
|
protected String getRelToUse(final Object input) {
|
||||||
{
|
return "volume";
|
||||||
return "volume";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,21 +33,18 @@ import org.jclouds.http.HttpRequest;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AppendMachineIdToPath extends AppendToPath
|
public class AppendMachineIdToPath extends AppendToPath {
|
||||||
{
|
private ParseMachineId parser;
|
||||||
private ParseMachineId parser;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AppendMachineIdToPath(final ParseMachineId parser)
|
public AppendMachineIdToPath(final ParseMachineId parser) {
|
||||||
{
|
super();
|
||||||
super();
|
this.parser = parser;
|
||||||
this.parser = parser;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <R extends HttpRequest> String getValue(final R request, final Object input)
|
protected <R extends HttpRequest> String getValue(final R request, final Object input) {
|
||||||
{
|
return parser.apply(input);
|
||||||
return parser.apply(input);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,26 +29,24 @@ import org.jclouds.http.HttpRequest;
|
||||||
/**
|
/**
|
||||||
* Append the {@link RemoteServiceType} service to the request URI.
|
* Append the {@link RemoteServiceType} service to the request URI.
|
||||||
* <p>
|
* <p>
|
||||||
* This method assumes that the input object is a {@link RemoteServiceType} enumeration.
|
* This method assumes that the input object is a {@link RemoteServiceType}
|
||||||
|
* enumeration.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AppendRemoteServiceTypeToPath extends AppendToPath
|
public class AppendRemoteServiceTypeToPath extends AppendToPath {
|
||||||
{
|
private ParseRemoteServiceType parser;
|
||||||
private ParseRemoteServiceType parser;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AppendRemoteServiceTypeToPath(final ParseRemoteServiceType parser)
|
public AppendRemoteServiceTypeToPath(final ParseRemoteServiceType parser) {
|
||||||
{
|
super();
|
||||||
super();
|
this.parser = parser;
|
||||||
this.parser = parser;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <R extends HttpRequest> String getValue(final R request, final Object input)
|
protected <R extends HttpRequest> String getValue(final R request, final Object input) {
|
||||||
{
|
return parser.apply(input);
|
||||||
return parser.apply(input);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,11 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindSupportedDevicesLinkToPath extends BindToPath
|
public class BindSupportedDevicesLinkToPath extends BindToPath {
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input)
|
protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) {
|
||||||
{
|
return super.getNewEndpoint(gRequest, input) + "/action/supported";
|
||||||
return super.getNewEndpoint(gRequest, input) + "/action/supported";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,24 +30,22 @@ import org.jclouds.rest.Binder;
|
||||||
import com.abiquo.server.core.infrastructure.LogicServerDto;
|
import com.abiquo.server.core.infrastructure.LogicServerDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds logic server query parameters to request. This method assumes that the input object is a
|
* Binds logic server query parameters to request. This method assumes that the
|
||||||
* {@link LogicServerDto}.
|
* input object is a {@link LogicServerDto}.
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindLogicServerParameters implements Binder
|
public class BindLogicServerParameters implements Binder {
|
||||||
{
|
@SuppressWarnings("unchecked")
|
||||||
@SuppressWarnings("unchecked")
|
@Override
|
||||||
@Override
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
checkArgument(checkNotNull(input, "input") instanceof LogicServerDto,
|
||||||
{
|
|
||||||
checkArgument(checkNotNull(input, "input") instanceof LogicServerDto,
|
|
||||||
"this binder is only valid for LogicServerDto objects");
|
"this binder is only valid for LogicServerDto objects");
|
||||||
|
|
||||||
LogicServerDto server = (LogicServerDto) input;
|
LogicServerDto server = (LogicServerDto) input;
|
||||||
|
|
||||||
return (R) request.toBuilder().addQueryParam("lsName", server.getName()).build();
|
return (R) request.toBuilder().addQueryParam("lsName", server.getName()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,25 +30,23 @@ import org.jclouds.rest.Binder;
|
||||||
import com.abiquo.server.core.infrastructure.OrganizationDto;
|
import com.abiquo.server.core.infrastructure.OrganizationDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds organization query parameters to request. This method assumes that the input object is a
|
* Binds organization query parameters to request. This method assumes that the
|
||||||
* {@link OrganizationDto}.
|
* input object is a {@link OrganizationDto}.
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindOrganizationParameters implements Binder
|
public class BindOrganizationParameters implements Binder {
|
||||||
{
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(final R request, final Object input)
|
public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
|
||||||
{
|
checkArgument(checkNotNull(input, "input") instanceof OrganizationDto,
|
||||||
checkArgument(checkNotNull(input, "input") instanceof OrganizationDto,
|
|
||||||
"this binder is only valid for OrganizationDto objects");
|
"this binder is only valid for OrganizationDto objects");
|
||||||
|
|
||||||
OrganizationDto org = (OrganizationDto) input;
|
OrganizationDto org = (OrganizationDto) input;
|
||||||
|
|
||||||
return (R) request.toBuilder().addQueryParam("org", org.getDn()).build();
|
return (R) request.toBuilder().addQueryParam("org", org.getDn()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,38 +51,29 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class AbiquoComputeServiceContextModule
|
public class AbiquoComputeServiceContextModule
|
||||||
extends
|
extends
|
||||||
ComputeServiceAdapterContextModule<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter>
|
ComputeServiceAdapterContextModule<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter> {
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure()
|
protected void configure() {
|
||||||
{
|
super.configure();
|
||||||
super.configure();
|
bind(
|
||||||
bind(
|
new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter>>() {
|
||||||
new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter>>()
|
|
||||||
{
|
|
||||||
}).to(AbiquoComputeServiceAdapter.class);
|
}).to(AbiquoComputeServiceAdapter.class);
|
||||||
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>()
|
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
|
||||||
{
|
}).to(VirtualMachineToNodeMetadata.class);
|
||||||
}).to(VirtualMachineToNodeMetadata.class);
|
bind(new TypeLiteral<Function<VirtualMachineTemplate, Image>>() {
|
||||||
bind(new TypeLiteral<Function<VirtualMachineTemplate, Image>>()
|
}).to(VirtualMachineTemplateToImage.class);
|
||||||
{
|
bind(new TypeLiteral<Function<VirtualMachineTemplateInVirtualDatacenter, Hardware>>() {
|
||||||
}).to(VirtualMachineTemplateToImage.class);
|
}).to(VirtualMachineTemplateInVirtualDatacenterToHardware.class);
|
||||||
bind(new TypeLiteral<Function<VirtualMachineTemplateInVirtualDatacenter, Hardware>>()
|
bind(new TypeLiteral<Function<Datacenter, Location>>() {
|
||||||
{
|
}).to(DatacenterToLocation.class);
|
||||||
}).to(VirtualMachineTemplateInVirtualDatacenterToHardware.class);
|
bind(new TypeLiteral<Function<VirtualDatacenter, Location>>() {
|
||||||
bind(new TypeLiteral<Function<Datacenter, Location>>()
|
}).to(VirtualDatacenterToLocation.class);
|
||||||
{
|
bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
|
||||||
}).to(DatacenterToLocation.class);
|
bind(TemplateOptions.class).to(AbiquoTemplateOptions.class);
|
||||||
bind(new TypeLiteral<Function<VirtualDatacenter, Location>>()
|
install(new LocationsFromComputeServiceAdapterModule<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter>() {
|
||||||
{
|
});
|
||||||
}).to(VirtualDatacenterToLocation.class);
|
}
|
||||||
bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
|
|
||||||
bind(TemplateOptions.class).to(AbiquoTemplateOptions.class);
|
|
||||||
install(new LocationsFromComputeServiceAdapterModule<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter>()
|
|
||||||
{
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,22 +38,19 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DatacenterToLocation implements Function<Datacenter, Location>
|
public class DatacenterToLocation implements Function<Datacenter, Location> {
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location apply(final Datacenter datacenter)
|
public Location apply(final Datacenter datacenter) {
|
||||||
{
|
LocationBuilder builder = new LocationBuilder();
|
||||||
LocationBuilder builder = new LocationBuilder();
|
builder.id(datacenter.getId().toString());
|
||||||
builder.id(datacenter.getId().toString());
|
builder.description(datacenter.getName() + " [" + datacenter.getLocation() + "]");
|
||||||
builder.description(datacenter.getName() + " [" + datacenter.getLocation() + "]");
|
builder.metadata(ImmutableMap.<String, Object> of());
|
||||||
builder.metadata(ImmutableMap.<String, Object> of());
|
builder.scope(LocationScope.REGION);
|
||||||
builder.scope(LocationScope.REGION);
|
builder.iso3166Codes(ImmutableSet.<String> of());
|
||||||
builder.iso3166Codes(ImmutableSet.<String> of());
|
|
||||||
|
|
||||||
builder.parent(new LocationBuilder().scope(LocationScope.PROVIDER).id("abiquo")
|
builder.parent(new LocationBuilder().scope(LocationScope.PROVIDER).id("abiquo").description("abiquo").build());
|
||||||
.description("abiquo").build());
|
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,40 +42,37 @@ import com.google.common.collect.ImmutableSet;
|
||||||
/**
|
/**
|
||||||
* Converts a {@link VirtualDatacenter} to a {@link Location} one.
|
* Converts a {@link VirtualDatacenter} to a {@link Location} one.
|
||||||
* <p>
|
* <p>
|
||||||
* Virtual datacenters will be considered zones, since images will be deployed in a virtual
|
* Virtual datacenters will be considered zones, since images will be deployed
|
||||||
* datacenter. Each zone will be scoped into a physical datacenter (region).
|
* in a virtual datacenter. Each zone will be scoped into a physical datacenter
|
||||||
|
* (region).
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VirtualDatacenterToLocation implements Function<VirtualDatacenter, Location>
|
public class VirtualDatacenterToLocation implements Function<VirtualDatacenter, Location> {
|
||||||
{
|
private final Function<Datacenter, Location> datacenterToLocation;
|
||||||
private final Function<Datacenter, Location> datacenterToLocation;
|
|
||||||
|
|
||||||
private final Supplier<Map<Integer, Datacenter>> regionMap;
|
private final Supplier<Map<Integer, Datacenter>> regionMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VirtualDatacenterToLocation(final Function<Datacenter, Location> datacenterToLocation,
|
public VirtualDatacenterToLocation(final Function<Datacenter, Location> datacenterToLocation,
|
||||||
@Memoized final Supplier<Map<Integer, Datacenter>> regionMap)
|
@Memoized final Supplier<Map<Integer, Datacenter>> regionMap) {
|
||||||
{
|
this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation");
|
||||||
this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation");
|
this.regionMap = checkNotNull(regionMap, "regionMap");
|
||||||
this.regionMap = checkNotNull(regionMap, "regionMap");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location apply(final VirtualDatacenter vdc)
|
public Location apply(final VirtualDatacenter vdc) {
|
||||||
{
|
LocationBuilder builder = new LocationBuilder();
|
||||||
LocationBuilder builder = new LocationBuilder();
|
builder.id(vdc.getId().toString());
|
||||||
builder.id(vdc.getId().toString());
|
builder.description(vdc.getName());
|
||||||
builder.description(vdc.getName());
|
builder.metadata(ImmutableMap.<String, Object> of());
|
||||||
builder.metadata(ImmutableMap.<String, Object> of());
|
builder.scope(LocationScope.ZONE);
|
||||||
builder.scope(LocationScope.ZONE);
|
builder.iso3166Codes(ImmutableSet.<String> of());
|
||||||
builder.iso3166Codes(ImmutableSet.<String> of());
|
|
||||||
|
|
||||||
Datacenter parent =
|
Datacenter parent = regionMap.get().get(vdc.unwrap().getIdFromLink(ParentLinkName.DATACENTER));
|
||||||
regionMap.get().get(vdc.unwrap().getIdFromLink(ParentLinkName.DATACENTER));
|
builder.parent(datacenterToLocation.apply(parent));
|
||||||
builder.parent(datacenterToLocation.apply(parent));
|
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,27 +32,24 @@ import com.google.common.base.Function;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VirtualMachineStateToNodeState implements Function<VirtualMachineState, Status>
|
public class VirtualMachineStateToNodeState implements Function<VirtualMachineState, Status> {
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Status apply(final VirtualMachineState state)
|
public Status apply(final VirtualMachineState state) {
|
||||||
{
|
switch (state) {
|
||||||
switch (state)
|
case ALLOCATED:
|
||||||
{
|
case LOCKED:
|
||||||
case ALLOCATED:
|
case CONFIGURED:
|
||||||
case LOCKED:
|
case NOT_ALLOCATED:
|
||||||
case CONFIGURED:
|
return Status.PENDING;
|
||||||
case NOT_ALLOCATED:
|
case ON:
|
||||||
return Status.PENDING;
|
return Status.RUNNING;
|
||||||
case ON:
|
case OFF:
|
||||||
return Status.RUNNING;
|
case PAUSED:
|
||||||
case OFF:
|
return Status.SUSPENDED;
|
||||||
case PAUSED:
|
case UNKNOWN:
|
||||||
return Status.SUSPENDED;
|
default:
|
||||||
case UNKNOWN:
|
return Status.UNRECOGNIZED;
|
||||||
default:
|
}
|
||||||
return Status.UNRECOGNIZED;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,61 +41,56 @@ import com.google.common.base.Function;
|
||||||
/**
|
/**
|
||||||
* Transforms a {@link VirtualMachineTemplate} into an {@link Hardware}.
|
* Transforms a {@link VirtualMachineTemplate} into an {@link Hardware}.
|
||||||
* <p>
|
* <p>
|
||||||
* Each {@link Image} ({@link VirtualMachineTemplate}) will have one {@link Hardware} entity for
|
* Each {@link Image} ({@link VirtualMachineTemplate}) will have one
|
||||||
* each zone (scoped to a virtualization technology) supported by the image.
|
* {@link Hardware} entity for each zone (scoped to a virtualization technology)
|
||||||
|
* supported by the image.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VirtualMachineTemplateInVirtualDatacenterToHardware implements
|
public class VirtualMachineTemplateInVirtualDatacenterToHardware implements
|
||||||
Function<VirtualMachineTemplateInVirtualDatacenter, Hardware>
|
Function<VirtualMachineTemplateInVirtualDatacenter, Hardware> {
|
||||||
{
|
/** The default core speed, 2.0Ghz. */
|
||||||
/** The default core speed, 2.0Ghz. */
|
public static final double DEFAULT_CORE_SPEED = 2.0;
|
||||||
public static final double DEFAULT_CORE_SPEED = 2.0;
|
|
||||||
|
|
||||||
private final Function<VirtualDatacenter, Location> virtualDatacenterToLocation;
|
private final Function<VirtualDatacenter, Location> virtualDatacenterToLocation;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VirtualMachineTemplateInVirtualDatacenterToHardware(
|
public VirtualMachineTemplateInVirtualDatacenterToHardware(
|
||||||
final Function<VirtualDatacenter, Location> virtualDatacenterToLocation)
|
final Function<VirtualDatacenter, Location> virtualDatacenterToLocation) {
|
||||||
{
|
this.virtualDatacenterToLocation = checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation");
|
||||||
this.virtualDatacenterToLocation =
|
}
|
||||||
checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Hardware apply(
|
public Hardware apply(final VirtualMachineTemplateInVirtualDatacenter templateInVirtualDatacenter) {
|
||||||
final VirtualMachineTemplateInVirtualDatacenter templateInVirtualDatacenter)
|
VirtualMachineTemplate template = templateInVirtualDatacenter.getTemplate();
|
||||||
{
|
VirtualDatacenter virtualDatacenter = templateInVirtualDatacenter.getZone();
|
||||||
VirtualMachineTemplate template = templateInVirtualDatacenter.getTemplate();
|
|
||||||
VirtualDatacenter virtualDatacenter = templateInVirtualDatacenter.getZone();
|
|
||||||
|
|
||||||
HardwareBuilder builder = new HardwareBuilder();
|
HardwareBuilder builder = new HardwareBuilder();
|
||||||
builder.providerId(template.getId().toString());
|
builder.providerId(template.getId().toString());
|
||||||
builder.id(template.getId().toString() + "/" + virtualDatacenter.getId());
|
builder.id(template.getId().toString() + "/" + virtualDatacenter.getId());
|
||||||
builder.uri(template.getURI());
|
builder.uri(template.getURI());
|
||||||
|
|
||||||
builder.name(template.getName());
|
builder.name(template.getName());
|
||||||
builder.processor(new Processor(template.getCpuRequired(), DEFAULT_CORE_SPEED));
|
builder.processor(new Processor(template.getCpuRequired(), DEFAULT_CORE_SPEED));
|
||||||
builder.ram(template.getRamRequired());
|
builder.ram(template.getRamRequired());
|
||||||
|
|
||||||
// Location information
|
// Location information
|
||||||
builder.location(virtualDatacenterToLocation.apply(virtualDatacenter));
|
builder.location(virtualDatacenterToLocation.apply(virtualDatacenter));
|
||||||
builder.hypervisor(virtualDatacenter.getHypervisorType().name());
|
builder.hypervisor(virtualDatacenter.getHypervisorType().name());
|
||||||
builder.supportsImage(ImagePredicates.idEquals(template.getId().toString()));
|
builder.supportsImage(ImagePredicates.idEquals(template.getId().toString()));
|
||||||
|
|
||||||
VolumeBuilder volumeBuilder = new VolumeBuilder();
|
VolumeBuilder volumeBuilder = new VolumeBuilder();
|
||||||
volumeBuilder.bootDevice(true);
|
volumeBuilder.bootDevice(true);
|
||||||
volumeBuilder.size(toGb(template.getHdRequired()));
|
volumeBuilder.size(toGb(template.getHdRequired()));
|
||||||
volumeBuilder.type(Volume.Type.LOCAL);
|
volumeBuilder.type(Volume.Type.LOCAL);
|
||||||
volumeBuilder.durable(false);
|
volumeBuilder.durable(false);
|
||||||
builder.volume(volumeBuilder.build());
|
builder.volume(volumeBuilder.build());
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float toGb(final long bytes)
|
private static float toGb(final long bytes) {
|
||||||
{
|
return bytes / 1024 / 1024 / (float) 1024;
|
||||||
return bytes / 1024 / 1024 / (float) 1024;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,45 +49,43 @@ import com.google.common.base.Supplier;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VirtualMachineTemplateToImage implements Function<VirtualMachineTemplate, Image>
|
public class VirtualMachineTemplateToImage implements Function<VirtualMachineTemplate, Image> {
|
||||||
{
|
private final Function<Datacenter, Location> datacenterToLocation;
|
||||||
private final Function<Datacenter, Location> datacenterToLocation;
|
|
||||||
|
|
||||||
private final Supplier<Map<Integer, Datacenter>> regionMap;
|
private final Supplier<Map<Integer, Datacenter>> regionMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VirtualMachineTemplateToImage(final Function<Datacenter, Location> datacenterToLocation,
|
public VirtualMachineTemplateToImage(final Function<Datacenter, Location> datacenterToLocation,
|
||||||
@Memoized final Supplier<Map<Integer, Datacenter>> reginoMap)
|
@Memoized final Supplier<Map<Integer, Datacenter>> reginoMap) {
|
||||||
{
|
this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation");
|
||||||
this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation");
|
this.regionMap = checkNotNull(reginoMap, "reginoMap");
|
||||||
this.regionMap = checkNotNull(reginoMap, "reginoMap");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image apply(final VirtualMachineTemplate template)
|
public Image apply(final VirtualMachineTemplate template) {
|
||||||
{
|
ImageBuilder builder = new ImageBuilder();
|
||||||
ImageBuilder builder = new ImageBuilder();
|
builder.ids(template.getId().toString());
|
||||||
builder.ids(template.getId().toString());
|
builder.name(template.getName());
|
||||||
builder.name(template.getName());
|
builder.description(template.getDescription());
|
||||||
builder.description(template.getDescription());
|
|
||||||
|
|
||||||
// Location information
|
// Location information
|
||||||
Datacenter region =
|
Datacenter region = regionMap.get().get(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER));
|
||||||
regionMap.get().get(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER));
|
builder.location(datacenterToLocation.apply(region));
|
||||||
builder.location(datacenterToLocation.apply(region));
|
|
||||||
|
|
||||||
// Only conversions have a status
|
// Only conversions have a status
|
||||||
builder.status(Status.AVAILABLE);
|
builder.status(Status.AVAILABLE);
|
||||||
builder.backendStatus(Status.AVAILABLE.name()); // Abiquo images do not have a status
|
builder.backendStatus(Status.AVAILABLE.name()); // Abiquo images do not
|
||||||
|
// have a status
|
||||||
|
|
||||||
RESTLink downloadLink = template.unwrap().searchLink("diskfile");
|
RESTLink downloadLink = template.unwrap().searchLink("diskfile");
|
||||||
builder.uri(downloadLink == null ? null : URI.create(downloadLink.getHref()));
|
builder.uri(downloadLink == null ? null : URI.create(downloadLink.getHref()));
|
||||||
|
|
||||||
// TODO: Operating system not implemented in Abiquo Templates
|
// TODO: Operating system not implemented in Abiquo Templates
|
||||||
// TODO: Image credentials still not present in Abiquo template metadata
|
// TODO: Image credentials still not present in Abiquo template metadata
|
||||||
// Will be added in Abiquo 2.4: http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647
|
// Will be added in Abiquo 2.4:
|
||||||
builder.operatingSystem(OperatingSystem.builder().description(template.getName()).build());
|
// http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647
|
||||||
|
builder.operatingSystem(OperatingSystem.builder().description(template.getName()).build());
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,98 +55,87 @@ import com.google.common.collect.Lists;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, NodeMetadata>
|
public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, NodeMetadata> {
|
||||||
{
|
@Resource
|
||||||
@Resource
|
protected Logger logger = Logger.NULL;
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
private final VirtualMachineTemplateToImage virtualMachineTemplateToImage;
|
private final VirtualMachineTemplateToImage virtualMachineTemplateToImage;
|
||||||
|
|
||||||
private final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware;
|
private final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware;
|
||||||
|
|
||||||
private final VirtualMachineStateToNodeState virtualMachineStateToNodeState;
|
private final VirtualMachineStateToNodeState virtualMachineStateToNodeState;
|
||||||
|
|
||||||
private final Function<VirtualDatacenter, Location> virtualDatacenterToLocation;
|
private final Function<VirtualDatacenter, Location> virtualDatacenterToLocation;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VirtualMachineToNodeMetadata(
|
public VirtualMachineToNodeMetadata(final VirtualMachineTemplateToImage virtualMachineTemplateToImage,
|
||||||
final VirtualMachineTemplateToImage virtualMachineTemplateToImage,
|
final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware,
|
||||||
final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware,
|
final VirtualMachineStateToNodeState virtualMachineStateToNodeState,
|
||||||
final VirtualMachineStateToNodeState virtualMachineStateToNodeState,
|
final Function<VirtualDatacenter, Location> virtualDatacenterToLocation) {
|
||||||
final Function<VirtualDatacenter, Location> virtualDatacenterToLocation)
|
this.virtualMachineTemplateToImage = checkNotNull(virtualMachineTemplateToImage, "virtualMachineTemplateToImage");
|
||||||
{
|
this.virtualMachineTemplateToHardware = checkNotNull(virtualMachineTemplateToHardware,
|
||||||
this.virtualMachineTemplateToImage =
|
"virtualMachineTemplateToHardware");
|
||||||
checkNotNull(virtualMachineTemplateToImage, "virtualMachineTemplateToImage");
|
this.virtualMachineStateToNodeState = checkNotNull(virtualMachineStateToNodeState,
|
||||||
this.virtualMachineTemplateToHardware =
|
"virtualMachineStateToNodeState");
|
||||||
checkNotNull(virtualMachineTemplateToHardware, "virtualMachineTemplateToHardware");
|
this.virtualDatacenterToLocation = checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation");
|
||||||
this.virtualMachineStateToNodeState =
|
}
|
||||||
checkNotNull(virtualMachineStateToNodeState, "virtualMachineStateToNodeState");
|
|
||||||
this.virtualDatacenterToLocation =
|
|
||||||
checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata apply(final VirtualMachine vm)
|
public NodeMetadata apply(final VirtualMachine vm) {
|
||||||
{
|
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
builder.ids(vm.getId().toString());
|
||||||
builder.ids(vm.getId().toString());
|
builder.uri(vm.getURI());
|
||||||
builder.uri(vm.getURI());
|
builder.name(vm.getNameLabel());
|
||||||
builder.name(vm.getNameLabel());
|
builder.group(vm.getVirtualAppliance().getName());
|
||||||
builder.group(vm.getVirtualAppliance().getName());
|
|
||||||
|
|
||||||
// TODO: Node credentials still not present in Abiquo template metadata
|
// TODO: Node credentials still not present in Abiquo template metadata
|
||||||
// Will be added in Abiquo 2.4: http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647
|
// Will be added in Abiquo 2.4:
|
||||||
|
// http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647
|
||||||
|
|
||||||
// Location details
|
// Location details
|
||||||
VirtualDatacenter vdc = vm.getVirtualDatacenter();
|
VirtualDatacenter vdc = vm.getVirtualDatacenter();
|
||||||
builder.location(virtualDatacenterToLocation.apply(vdc));
|
builder.location(virtualDatacenterToLocation.apply(vdc));
|
||||||
|
|
||||||
// Image details
|
// Image details
|
||||||
VirtualMachineTemplate template = vm.getTemplate();
|
VirtualMachineTemplate template = vm.getTemplate();
|
||||||
Image image = virtualMachineTemplateToImage.apply(template);
|
Image image = virtualMachineTemplateToImage.apply(template);
|
||||||
builder.imageId(image.getId().toString());
|
builder.imageId(image.getId().toString());
|
||||||
builder.operatingSystem(image.getOperatingSystem());
|
builder.operatingSystem(image.getOperatingSystem());
|
||||||
|
|
||||||
// Hardware details
|
// Hardware details
|
||||||
Hardware defaultHardware =
|
Hardware defaultHardware = virtualMachineTemplateToHardware.apply(new VirtualMachineTemplateInVirtualDatacenter(
|
||||||
virtualMachineTemplateToHardware
|
template, vdc));
|
||||||
.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc));
|
|
||||||
|
|
||||||
Hardware hardware =
|
Hardware hardware = HardwareBuilder
|
||||||
HardwareBuilder
|
.fromHardware(defaultHardware)
|
||||||
.fromHardware(defaultHardware)
|
.ram(vm.getRam())
|
||||||
.ram(vm.getRam())
|
.processors(
|
||||||
.processors(
|
Lists.newArrayList(new Processor(vm.getCpu(),
|
||||||
Lists.newArrayList(new Processor(vm.getCpu(),
|
|
||||||
VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED))) //
|
VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED))) //
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
builder.hardware(hardware);
|
builder.hardware(hardware);
|
||||||
|
|
||||||
// Networking configuration
|
// Networking configuration
|
||||||
List<Ip< ? , ? >> nics = vm.listAttachedNics();
|
List<Ip<?, ?>> nics = vm.listAttachedNics();
|
||||||
builder.privateAddresses(ips(filter(nics, Predicates.instanceOf(PrivateIp.class))));
|
builder.privateAddresses(ips(filter(nics, Predicates.instanceOf(PrivateIp.class))));
|
||||||
builder.publicAddresses(ips(filter(nics,
|
builder.publicAddresses(ips(filter(nics, Predicates.not(Predicates.instanceOf(PrivateIp.class)))));
|
||||||
Predicates.not(Predicates.instanceOf(PrivateIp.class)))));
|
|
||||||
|
|
||||||
// Node state
|
// Node state
|
||||||
VirtualMachineState state = vm.getState();
|
VirtualMachineState state = vm.getState();
|
||||||
builder.status(virtualMachineStateToNodeState.apply(state));
|
builder.status(virtualMachineStateToNodeState.apply(state));
|
||||||
builder.backendStatus(state.name());
|
builder.backendStatus(state.name());
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Iterable<String> ips(final Iterable<Ip< ? , ? >> nics)
|
private static Iterable<String> ips(final Iterable<Ip<?, ?>> nics) {
|
||||||
{
|
return transform(nics, new Function<Ip<?, ?>, String>() {
|
||||||
return transform(nics, new Function<Ip< ? , ? >, String>()
|
@Override
|
||||||
{
|
public String apply(final Ip<?, ?> nic) {
|
||||||
@Override
|
return nic.getIp();
|
||||||
public String apply(final Ip< ? , ? > nic)
|
}
|
||||||
{
|
});
|
||||||
return nic.getIp();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,119 +25,105 @@ import org.jclouds.compute.options.TemplateOptions;
|
||||||
/**
|
/**
|
||||||
* Contains options supported by the
|
* Contains options supported by the
|
||||||
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
|
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
|
||||||
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} operations on the
|
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)}
|
||||||
* <em>Abiquo</em> provider.
|
* operations on the <em>Abiquo</em> provider.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class AbiquoTemplateOptions extends TemplateOptions implements Cloneable
|
public class AbiquoTemplateOptions extends TemplateOptions implements Cloneable {
|
||||||
{
|
public static final AbiquoTemplateOptions NONE = new AbiquoTemplateOptions();
|
||||||
public static final AbiquoTemplateOptions NONE = new AbiquoTemplateOptions();
|
|
||||||
|
|
||||||
private Integer overrideCores;
|
private Integer overrideCores;
|
||||||
|
|
||||||
private Integer overrideRam;
|
private Integer overrideRam;
|
||||||
|
|
||||||
private String vncPassword;
|
private String vncPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateOptions clone()
|
public TemplateOptions clone() {
|
||||||
{
|
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
||||||
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
copyTo(options);
|
||||||
copyTo(options);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyTo(final TemplateOptions to)
|
public void copyTo(final TemplateOptions to) {
|
||||||
{
|
super.copyTo(to);
|
||||||
super.copyTo(to);
|
if (to instanceof AbiquoTemplateOptions) {
|
||||||
if (to instanceof AbiquoTemplateOptions)
|
AbiquoTemplateOptions options = AbiquoTemplateOptions.class.cast(to);
|
||||||
{
|
options.overrideCores(overrideCores);
|
||||||
AbiquoTemplateOptions options = AbiquoTemplateOptions.class.cast(to);
|
options.overrideRam(overrideRam);
|
||||||
options.overrideCores(overrideCores);
|
options.vncPassword(vncPassword);
|
||||||
options.overrideRam(overrideRam);
|
}
|
||||||
options.vncPassword(vncPassword);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the number of cores set by the hardware profile.
|
* Override the number of cores set by the hardware profile.
|
||||||
*
|
*
|
||||||
* @return The template options with the number of cores.
|
* @return The template options with the number of cores.
|
||||||
*/
|
*/
|
||||||
public AbiquoTemplateOptions overrideCores(final Integer overrideCores)
|
public AbiquoTemplateOptions overrideCores(final Integer overrideCores) {
|
||||||
{
|
this.overrideCores = overrideCores;
|
||||||
this.overrideCores = overrideCores;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getOverrideCores()
|
public Integer getOverrideCores() {
|
||||||
{
|
return overrideCores;
|
||||||
return overrideCores;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the amount of ram set by the hardware profile.
|
* Override the amount of ram set by the hardware profile.
|
||||||
*
|
*
|
||||||
* @return The template options with the amount of ram.
|
* @return The template options with the amount of ram.
|
||||||
*/
|
*/
|
||||||
public AbiquoTemplateOptions overrideRam(final Integer overrideRam)
|
public AbiquoTemplateOptions overrideRam(final Integer overrideRam) {
|
||||||
{
|
this.overrideRam = overrideRam;
|
||||||
this.overrideRam = overrideRam;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getOverrideRam()
|
public Integer getOverrideRam() {
|
||||||
{
|
return overrideRam;
|
||||||
return overrideRam;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the VNC password to access the virtual machine.
|
* Set the VNC password to access the virtual machine.
|
||||||
* <p>
|
* <p>
|
||||||
* By default virtual machines does not have VNC access password protected.
|
* By default virtual machines does not have VNC access password protected.
|
||||||
*
|
*
|
||||||
* @return The template options with the VNC password.
|
* @return The template options with the VNC password.
|
||||||
*/
|
*/
|
||||||
public AbiquoTemplateOptions vncPassword(final String vncPassword)
|
public AbiquoTemplateOptions vncPassword(final String vncPassword) {
|
||||||
{
|
this.vncPassword = vncPassword;
|
||||||
this.vncPassword = vncPassword;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getVncPassword()
|
public String getVncPassword() {
|
||||||
{
|
return vncPassword;
|
||||||
return vncPassword;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
/**
|
||||||
/**
|
* @see AbiquoTemplateOptions#overrideCores(int)
|
||||||
* @see AbiquoTemplateOptions#overrideCores(int)
|
*/
|
||||||
*/
|
public static AbiquoTemplateOptions overrideCores(final Integer overrideCores) {
|
||||||
public static AbiquoTemplateOptions overrideCores(final Integer overrideCores)
|
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
||||||
{
|
return options.overrideCores(overrideCores);
|
||||||
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
}
|
||||||
return options.overrideCores(overrideCores);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AbiquoTemplateOptions#overrideRam(int)
|
* @see AbiquoTemplateOptions#overrideRam(int)
|
||||||
*/
|
*/
|
||||||
public static AbiquoTemplateOptions overrideRam(final Integer overrideRam)
|
public static AbiquoTemplateOptions overrideRam(final Integer overrideRam) {
|
||||||
{
|
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
||||||
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
return options.overrideRam(overrideRam);
|
||||||
return options.overrideRam(overrideRam);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AbiquoTemplateOptions#vncPassword(String)
|
* @see AbiquoTemplateOptions#vncPassword(String)
|
||||||
*/
|
*/
|
||||||
public static AbiquoTemplateOptions vncPassword(final String vncPassword)
|
public static AbiquoTemplateOptions vncPassword(final String vncPassword) {
|
||||||
{
|
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
||||||
AbiquoTemplateOptions options = new AbiquoTemplateOptions();
|
return options.vncPassword(vncPassword);
|
||||||
return options.vncPassword(vncPassword);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,223 +66,195 @@ import com.google.common.collect.Lists;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the connection between the {@link AbiquoApi} implementation and the jclouds
|
* Defines the connection between the {@link AbiquoApi} implementation and the
|
||||||
* {@link ComputeService}.
|
* jclouds {@link ComputeService}.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AbiquoComputeServiceAdapter
|
public class AbiquoComputeServiceAdapter
|
||||||
implements
|
implements
|
||||||
ComputeServiceAdapter<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter>
|
ComputeServiceAdapter<VirtualMachine, VirtualMachineTemplateInVirtualDatacenter, VirtualMachineTemplate, VirtualDatacenter> {
|
||||||
{
|
@Resource
|
||||||
@Resource
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
protected Logger logger = Logger.NULL;
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
private final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
private final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
|
|
||||||
private final AdministrationService adminService;
|
private final AdministrationService adminService;
|
||||||
|
|
||||||
private final CloudService cloudService;
|
private final CloudService cloudService;
|
||||||
|
|
||||||
private final MonitoringService monitoringService;
|
private final MonitoringService monitoringService;
|
||||||
|
|
||||||
private final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters;
|
private final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters;
|
||||||
|
|
||||||
private final Supplier<Map<Integer, Datacenter>> regionMap;
|
private final Supplier<Map<Integer, Datacenter>> regionMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AbiquoComputeServiceAdapter(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public AbiquoComputeServiceAdapter(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final AdministrationService adminService, final CloudService cloudService,
|
final AdministrationService adminService, final CloudService cloudService,
|
||||||
final MonitoringService monitoringService,
|
final MonitoringService monitoringService,
|
||||||
final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters,
|
final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters,
|
||||||
@Memoized final Supplier<Map<Integer, Datacenter>> regionMap)
|
@Memoized final Supplier<Map<Integer, Datacenter>> regionMap) {
|
||||||
{
|
this.context = checkNotNull(context, "context");
|
||||||
this.context = checkNotNull(context, "context");
|
this.adminService = checkNotNull(adminService, "adminService");
|
||||||
this.adminService = checkNotNull(adminService, "adminService");
|
this.cloudService = checkNotNull(cloudService, "cloudService");
|
||||||
this.cloudService = checkNotNull(cloudService, "cloudService");
|
this.monitoringService = checkNotNull(monitoringService, "monitoringService");
|
||||||
this.monitoringService = checkNotNull(monitoringService, "monitoringService");
|
this.compatibleVirtualDatacenters = checkNotNull(compatibleVirtualDatacenters, "compatibleVirtualDatacenters");
|
||||||
this.compatibleVirtualDatacenters =
|
this.regionMap = checkNotNull(regionMap, "regionMap");
|
||||||
checkNotNull(compatibleVirtualDatacenters, "compatibleVirtualDatacenters");
|
}
|
||||||
this.regionMap = checkNotNull(regionMap, "regionMap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeAndInitialCredentials<VirtualMachine> createNodeWithGroupEncodedIntoName(
|
public NodeAndInitialCredentials<VirtualMachine> createNodeWithGroupEncodedIntoName(final String tag,
|
||||||
final String tag, final String name, final Template template)
|
final String name, final Template template) {
|
||||||
{
|
AbiquoTemplateOptions options = template.getOptions().as(AbiquoTemplateOptions.class);
|
||||||
AbiquoTemplateOptions options = template.getOptions().as(AbiquoTemplateOptions.class);
|
Enterprise enterprise = adminService.getCurrentEnterprise();
|
||||||
Enterprise enterprise = adminService.getCurrentEnterprise();
|
|
||||||
|
|
||||||
// Get the region where the template is available
|
// Get the region where the template is available
|
||||||
Datacenter datacenter =
|
Datacenter datacenter = regionMap.get().get(Integer.valueOf(template.getImage().getLocation().getId()));
|
||||||
regionMap.get().get(Integer.valueOf(template.getImage().getLocation().getId()));
|
|
||||||
|
|
||||||
// Load the template
|
// Load the template
|
||||||
VirtualMachineTemplate virtualMachineTemplate =
|
VirtualMachineTemplate virtualMachineTemplate = enterprise.getTemplateInRepository(datacenter,
|
||||||
enterprise.getTemplateInRepository(datacenter,
|
Integer.valueOf(template.getImage().getId()));
|
||||||
Integer.valueOf(template.getImage().getId()));
|
|
||||||
|
|
||||||
// Get the zone where the template will be deployed
|
// Get the zone where the template will be deployed
|
||||||
VirtualDatacenter vdc =
|
VirtualDatacenter vdc = cloudService.getVirtualDatacenter(Integer.valueOf(template.getHardware().getLocation()
|
||||||
cloudService.getVirtualDatacenter(Integer.valueOf(template.getHardware().getLocation()
|
.getId()));
|
||||||
.getId()));
|
|
||||||
|
|
||||||
// Load the virtual appliance or create it if it does not exist
|
// Load the virtual appliance or create it if it does not exist
|
||||||
VirtualAppliance vapp = vdc.findVirtualAppliance(VirtualAppliancePredicates.name(tag));
|
VirtualAppliance vapp = vdc.findVirtualAppliance(VirtualAppliancePredicates.name(tag));
|
||||||
if (vapp == null)
|
if (vapp == null) {
|
||||||
{
|
vapp = VirtualAppliance.builder(context, vdc).name(tag).build();
|
||||||
vapp = VirtualAppliance.builder(context, vdc).name(tag).build();
|
vapp.save();
|
||||||
vapp.save();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Integer overrideCores = options.getOverrideCores();
|
Integer overrideCores = options.getOverrideCores();
|
||||||
Integer overrideRam = options.getOverrideRam();
|
Integer overrideRam = options.getOverrideRam();
|
||||||
|
|
||||||
VirtualMachine vm = VirtualMachine.builder(context, vapp, virtualMachineTemplate) //
|
VirtualMachine vm = VirtualMachine.builder(context, vapp, virtualMachineTemplate) //
|
||||||
.nameLabel(name) //
|
.nameLabel(name) //
|
||||||
.cpu(overrideCores != null ? overrideCores : totalCores(template.getHardware())) //
|
.cpu(overrideCores != null ? overrideCores : totalCores(template.getHardware())) //
|
||||||
.ram(overrideRam != null ? overrideRam : template.getHardware().getRam()) //
|
.ram(overrideRam != null ? overrideRam : template.getHardware().getRam()) //
|
||||||
.password(options.getVncPassword()) // Can be null
|
.password(options.getVncPassword()) // Can be null
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
vm.save();
|
vm.save();
|
||||||
|
|
||||||
// Once the virtual machine is created, override the default network settings if needed
|
// Once the virtual machine is created, override the default network
|
||||||
// If no public ip is available in the virtual datacenter, the virtual machine will be
|
// settings if needed
|
||||||
// assigned by default an ip address in the default private VLAN for the virtual datacenter
|
// If no public ip is available in the virtual datacenter, the virtual
|
||||||
PublicIp publicIp = vdc.findPurchasedPublicIp(IpPredicates.<PublicIp> notUsed());
|
// machine will be assigned by default an ip address in the default
|
||||||
if (publicIp != null)
|
// private VLAN for the virtual datacenter
|
||||||
{
|
PublicIp publicIp = vdc.findPurchasedPublicIp(IpPredicates.<PublicIp> notUsed());
|
||||||
List<PublicIp> ips = Lists.newArrayList();
|
if (publicIp != null) {
|
||||||
ips.add(publicIp);
|
List<PublicIp> ips = Lists.newArrayList();
|
||||||
vm.setNics(ips);
|
ips.add(publicIp);
|
||||||
}
|
vm.setNics(ips);
|
||||||
|
}
|
||||||
|
|
||||||
// This is an async operation, but jclouds already waits until the node is RUNNING, so there
|
// This is an async operation, but jclouds already waits until the node is
|
||||||
// is no need to block here
|
// RUNNING, so there is no need to block here
|
||||||
vm.deploy();
|
vm.deploy();
|
||||||
|
|
||||||
return new NodeAndInitialCredentials<VirtualMachine>(vm, vm.getId().toString(), null);
|
return new NodeAndInitialCredentials<VirtualMachine>(vm, vm.getId().toString(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<VirtualMachineTemplateInVirtualDatacenter> listHardwareProfiles()
|
public Iterable<VirtualMachineTemplateInVirtualDatacenter> listHardwareProfiles() {
|
||||||
{
|
// In Abiquo, images are scoped to a region (physical datacenter), and
|
||||||
// In Abiquo, images are scoped to a region (physical datacenter), and hardware profiles are
|
// hardware profiles are scoped to a zone (a virtual datacenter in the
|
||||||
// scoped to a zone (a virtual datacenter in the region, with a concrete virtualization
|
// region, with a concrete virtualization technology)
|
||||||
// technology)
|
|
||||||
|
|
||||||
return concat(transform(listImages(),
|
return concat(transform(listImages(),
|
||||||
new Function<VirtualMachineTemplate, Iterable<VirtualMachineTemplateInVirtualDatacenter>>()
|
new Function<VirtualMachineTemplate, Iterable<VirtualMachineTemplateInVirtualDatacenter>>() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public Iterable<VirtualMachineTemplateInVirtualDatacenter> apply(final VirtualMachineTemplate template) {
|
||||||
public Iterable<VirtualMachineTemplateInVirtualDatacenter> apply(
|
Iterable<VirtualDatacenter> compatibleZones = compatibleVirtualDatacenters.execute(template);
|
||||||
final VirtualMachineTemplate template)
|
|
||||||
{
|
|
||||||
Iterable<VirtualDatacenter> compatibleZones =
|
|
||||||
compatibleVirtualDatacenters.execute(template);
|
|
||||||
|
|
||||||
return transform(compatibleZones,
|
return transform(compatibleZones,
|
||||||
new Function<VirtualDatacenter, VirtualMachineTemplateInVirtualDatacenter>()
|
new Function<VirtualDatacenter, VirtualMachineTemplateInVirtualDatacenter>() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public VirtualMachineTemplateInVirtualDatacenter apply(final VirtualDatacenter vdc) {
|
||||||
public VirtualMachineTemplateInVirtualDatacenter apply(final VirtualDatacenter vdc)
|
return new VirtualMachineTemplateInVirtualDatacenter(template, vdc);
|
||||||
{
|
}
|
||||||
return new VirtualMachineTemplateInVirtualDatacenter(template, vdc);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<VirtualMachineTemplate> listImages()
|
public Iterable<VirtualMachineTemplate> listImages() {
|
||||||
{
|
Enterprise enterprise = adminService.getCurrentEnterprise();
|
||||||
Enterprise enterprise = adminService.getCurrentEnterprise();
|
return enterprise.listTemplates();
|
||||||
return enterprise.listTemplates();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VirtualMachineTemplate getImage(final String id)
|
public VirtualMachineTemplate getImage(final String id) {
|
||||||
{
|
Enterprise enterprise = adminService.getCurrentEnterprise();
|
||||||
Enterprise enterprise = adminService.getCurrentEnterprise();
|
return enterprise.findTemplate(VirtualMachineTemplatePredicates.id(Integer.valueOf(id)));
|
||||||
return enterprise.findTemplate(VirtualMachineTemplatePredicates.id(Integer.valueOf(id)));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<VirtualDatacenter> listLocations()
|
public Iterable<VirtualDatacenter> listLocations() {
|
||||||
{
|
return cloudService.listVirtualDatacenters();
|
||||||
return cloudService.listVirtualDatacenters();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VirtualMachine getNode(final String id)
|
public VirtualMachine getNode(final String id) {
|
||||||
{
|
return cloudService.findVirtualMachine(vmId(id));
|
||||||
return cloudService.findVirtualMachine(vmId(id));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyNode(final String id)
|
public void destroyNode(final String id) {
|
||||||
{
|
VirtualMachine vm = getNode(id);
|
||||||
VirtualMachine vm = getNode(id);
|
vm.delete();
|
||||||
vm.delete();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rebootNode(final String id)
|
public void rebootNode(final String id) {
|
||||||
{
|
VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
|
||||||
VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
|
VirtualMachine vm = getNode(id);
|
||||||
VirtualMachine vm = getNode(id);
|
vm.reboot();
|
||||||
vm.reboot();
|
monitor.awaitState(VirtualMachineState.ON, vm);
|
||||||
monitor.awaitState(VirtualMachineState.ON, vm);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resumeNode(final String id)
|
public void resumeNode(final String id) {
|
||||||
{
|
VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
|
||||||
VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
|
VirtualMachine vm = getNode(id);
|
||||||
VirtualMachine vm = getNode(id);
|
vm.changeState(VirtualMachineState.ON);
|
||||||
vm.changeState(VirtualMachineState.ON);
|
monitor.awaitState(VirtualMachineState.ON, vm);
|
||||||
monitor.awaitState(VirtualMachineState.ON, vm);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void suspendNode(final String id)
|
public void suspendNode(final String id) {
|
||||||
{
|
VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
|
||||||
VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
|
VirtualMachine vm = getNode(id);
|
||||||
VirtualMachine vm = getNode(id);
|
vm.changeState(VirtualMachineState.PAUSED);
|
||||||
vm.changeState(VirtualMachineState.PAUSED);
|
monitor.awaitState(VirtualMachineState.PAUSED, vm);
|
||||||
monitor.awaitState(VirtualMachineState.PAUSED, vm);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<VirtualMachine> listNodes()
|
public Iterable<VirtualMachine> listNodes() {
|
||||||
{
|
return cloudService.listVirtualMachines();
|
||||||
return cloudService.listVirtualMachines();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static Predicate<VirtualMachine> vmId(final String id)
|
private static Predicate<VirtualMachine> vmId(final String id) {
|
||||||
{
|
return new Predicate<VirtualMachine>() {
|
||||||
return new Predicate<VirtualMachine>()
|
@Override
|
||||||
{
|
public boolean apply(final VirtualMachine input) {
|
||||||
@Override
|
return Integer.valueOf(id).equals(input.getId());
|
||||||
public boolean apply(final VirtualMachine input)
|
}
|
||||||
{
|
};
|
||||||
return Integer.valueOf(id).equals(input.getId());
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int totalCores(final Hardware hardware)
|
private static int totalCores(final Hardware hardware) {
|
||||||
{
|
double cores = 0;
|
||||||
double cores = 0;
|
for (Processor processor : hardware.getProcessors()) {
|
||||||
for (Processor processor : hardware.getProcessors())
|
cores += processor.getCores();
|
||||||
{
|
}
|
||||||
cores += processor.getCores();
|
return Double.valueOf(cores).intValue();
|
||||||
}
|
}
|
||||||
return Double.valueOf(cores).intValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all virtual datacenters where the given {@link VirtualMachineTemplate} can be deployed.
|
* Finds all virtual datacenters where the given {@link VirtualMachineTemplate}
|
||||||
|
* can be deployed.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(FindCompatibleVirtualDatacentersForImageAndConversions.class)
|
@ImplementedBy(FindCompatibleVirtualDatacentersForImageAndConversions.class)
|
||||||
public interface FindCompatibleVirtualDatacenters
|
public interface FindCompatibleVirtualDatacenters {
|
||||||
{
|
Iterable<VirtualDatacenter> execute(VirtualMachineTemplate template);
|
||||||
Iterable<VirtualDatacenter> execute(VirtualMachineTemplate template);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,43 +40,40 @@ import org.jclouds.rest.RestContext;
|
||||||
import com.abiquo.server.core.infrastructure.DatacenterDto;
|
import com.abiquo.server.core.infrastructure.DatacenterDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation for the {@link FindCompatibleVirtualDatacenters} strategy.
|
* Default implementation for the {@link FindCompatibleVirtualDatacenters}
|
||||||
|
* strategy.
|
||||||
* <p>
|
* <p>
|
||||||
* This strategy assumes that the datacenter will have different hypervisor technologies, and images
|
* This strategy assumes that the datacenter will have different hypervisor
|
||||||
* will have conversions to each of them.
|
* technologies, and images will have conversions to each of them.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class FindCompatibleVirtualDatacentersForImageAndConversions implements
|
public class FindCompatibleVirtualDatacentersForImageAndConversions implements FindCompatibleVirtualDatacenters {
|
||||||
FindCompatibleVirtualDatacenters
|
private final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
{
|
|
||||||
private final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private final CloudService cloudService;
|
private final CloudService cloudService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FindCompatibleVirtualDatacentersForImageAndConversions(
|
public FindCompatibleVirtualDatacentersForImageAndConversions(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CloudService cloudService)
|
final CloudService cloudService) {
|
||||||
{
|
this.context = checkNotNull(context, "context");
|
||||||
this.context = checkNotNull(context, "context");
|
this.cloudService = checkNotNull(cloudService, "cloudService");
|
||||||
this.cloudService = checkNotNull(cloudService, "cloudService");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<VirtualDatacenter> execute(final VirtualMachineTemplate template)
|
public Iterable<VirtualDatacenter> execute(final VirtualMachineTemplate template) {
|
||||||
{
|
// Build the transport object with the available information to avoid
|
||||||
// Build the transport object with the available information to avoid making an unnecessary
|
// making an unnecessary call to the target API (we only need the id of
|
||||||
// call to the target API (we only need the id of the datacenter, and it is present in the
|
// the datacenter, and it is present in the link).
|
||||||
// link).
|
DatacenterDto datacenterDto = new DatacenterDto();
|
||||||
DatacenterDto datacenterDto = new DatacenterDto();
|
datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY));
|
||||||
datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY));
|
Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto);
|
||||||
Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto);
|
|
||||||
|
|
||||||
Iterable<VirtualDatacenter> vdcs =
|
Iterable<VirtualDatacenter> vdcs = cloudService.listVirtualDatacenters(VirtualDatacenterPredicates
|
||||||
cloudService.listVirtualDatacenters(VirtualDatacenterPredicates.datacenter(datacenter));
|
.datacenter(datacenter));
|
||||||
|
|
||||||
return filter(vdcs, compatibleWithTemplateOrConversions(template));
|
return filter(vdcs, compatibleWithTemplateOrConversions(template));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,54 +41,49 @@ import com.abiquo.server.core.infrastructure.DatacenterDto;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for the {@link FindCompatibleVirtualDatacenters} strategy to be used in
|
* Implementation for the {@link FindCompatibleVirtualDatacenters} strategy to
|
||||||
* homogeneous datacenters.
|
* be used in homogeneous datacenters.
|
||||||
* <p>
|
* <p>
|
||||||
* For providers that only have one hypervisor technology in the physical datacenter and use
|
* For providers that only have one hypervisor technology in the physical
|
||||||
* compatible images, there is no need to check if the images have conversions to other formats.
|
* datacenter and use compatible images, there is no need to check if the images
|
||||||
|
* have conversions to other formats.
|
||||||
* <p>
|
* <p>
|
||||||
* This strategy will only consider the base disk format of the image.
|
* This strategy will only consider the base disk format of the image.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class FindCompatibleVirtualDatacentersForImageBaseFormat implements
|
public class FindCompatibleVirtualDatacentersForImageBaseFormat implements FindCompatibleVirtualDatacenters {
|
||||||
FindCompatibleVirtualDatacenters
|
private final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
{
|
|
||||||
private final RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private final CloudService cloudService;
|
private final CloudService cloudService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FindCompatibleVirtualDatacentersForImageBaseFormat(
|
public FindCompatibleVirtualDatacentersForImageBaseFormat(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CloudService cloudService)
|
final CloudService cloudService) {
|
||||||
{
|
this.context = checkNotNull(context, "context");
|
||||||
this.context = checkNotNull(context, "context");
|
this.cloudService = checkNotNull(cloudService, "cloudService");
|
||||||
this.cloudService = checkNotNull(cloudService, "cloudService");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<VirtualDatacenter> execute(final VirtualMachineTemplate template)
|
public Iterable<VirtualDatacenter> execute(final VirtualMachineTemplate template) {
|
||||||
{
|
// Build the transport object with the available information to avoid
|
||||||
// Build the transport object with the available information to avoid making an unnecessary
|
// making an unnecessary call to the target API (we only need the id of
|
||||||
// call to the target API (we only need the id of the datacenter, and it is present in the
|
// the datacenter, and it is present in the link).
|
||||||
// link).
|
DatacenterDto datacenterDto = new DatacenterDto();
|
||||||
DatacenterDto datacenterDto = new DatacenterDto();
|
datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY));
|
||||||
datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY));
|
Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto);
|
||||||
Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto);
|
|
||||||
|
|
||||||
Iterable<VirtualDatacenter> vdcs =
|
Iterable<VirtualDatacenter> vdcs = cloudService.listVirtualDatacenters(VirtualDatacenterPredicates
|
||||||
cloudService.listVirtualDatacenters(VirtualDatacenterPredicates.datacenter(datacenter));
|
.datacenter(datacenter));
|
||||||
|
|
||||||
return filter(vdcs, new Predicate<VirtualDatacenter>()
|
return filter(vdcs, new Predicate<VirtualDatacenter>() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public boolean apply(final VirtualDatacenter vdc) {
|
||||||
public boolean apply(final VirtualDatacenter vdc)
|
HypervisorType type = vdc.getHypervisorType();
|
||||||
{
|
return type.isCompatible(template.getDiskFormatType());
|
||||||
HypervisorType type = vdc.getHypervisorType();
|
}
|
||||||
return type.isCompatible(template.getDiskFormatType());
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ package org.jclouds.abiquo.config;
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public enum AbiquoEdition
|
public enum AbiquoEdition {
|
||||||
{
|
ENTERPRISE, COMMUNITY;
|
||||||
ENTERPRISE, COMMUNITY;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,20 +26,19 @@ import org.jclouds.abiquo.features.services.MonitoringService;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public interface AbiquoProperties
|
public interface AbiquoProperties {
|
||||||
{
|
/**
|
||||||
/**
|
* Boolean property indicating if the provided credential is an api token.
|
||||||
* Boolean property indicating if the provided credential is an api token.
|
* <p>
|
||||||
* <p>
|
* Default value: false
|
||||||
* Default value: false
|
*/
|
||||||
*/
|
public static final String CREDENTIAL_IS_TOKEN = "abiquo.credential-is-token";
|
||||||
public static final String CREDENTIAL_IS_TOKEN = "abiquo.credential-is-token";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The delay (in ms) used between requests by the {@link MonitoringService} when monitoring
|
* The delay (in ms) used between requests by the {@link MonitoringService}
|
||||||
* asynchronous task state.
|
* when monitoring asynchronous task state.
|
||||||
* <p>
|
* <p>
|
||||||
* Default value: 5000 ms
|
* Default value: 5000 ms
|
||||||
*/
|
*/
|
||||||
public static final String ASYNC_TASK_MONITOR_DELAY = "abiquo.monitor-delay";
|
public static final String ASYNC_TASK_MONITOR_DELAY = "abiquo.monitor-delay";
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,131 +83,103 @@ import com.google.inject.Singleton;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
public class AbiquoRestClientModule extends RestClientModule<AbiquoApi, AbiquoAsyncApi>
|
public class AbiquoRestClientModule extends RestClientModule<AbiquoApi, AbiquoAsyncApi> {
|
||||||
{
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder() //
|
||||||
public static final Map<Class< ? >, Class< ? >> DELEGATE_MAP = ImmutableMap
|
.put(InfrastructureApi.class, InfrastructureAsyncApi.class) //
|
||||||
.<Class< ? >, Class< ? >> builder() //
|
.put(EnterpriseApi.class, EnterpriseAsyncApi.class) //
|
||||||
.put(InfrastructureApi.class, InfrastructureAsyncApi.class) //
|
.put(AdminApi.class, AdminAsyncApi.class) //
|
||||||
.put(EnterpriseApi.class, EnterpriseAsyncApi.class) //
|
.put(ConfigApi.class, ConfigAsyncApi.class) //
|
||||||
.put(AdminApi.class, AdminAsyncApi.class) //
|
.put(CloudApi.class, CloudAsyncApi.class) //
|
||||||
.put(ConfigApi.class, ConfigAsyncApi.class) //
|
.put(VirtualMachineTemplateApi.class, VirtualMachineTemplateAsyncApi.class) //
|
||||||
.put(CloudApi.class, CloudAsyncApi.class) //
|
.put(TaskApi.class, TaskAsyncApi.class) //
|
||||||
.put(VirtualMachineTemplateApi.class, VirtualMachineTemplateAsyncApi.class) //
|
.put(EventApi.class, EventAsyncApi.class) //
|
||||||
.put(TaskApi.class, TaskAsyncApi.class) //
|
.put(PricingApi.class, PricingAsyncApi.class) //
|
||||||
.put(EventApi.class, EventAsyncApi.class) //
|
.build();
|
||||||
.put(PricingApi.class, PricingAsyncApi.class) //
|
|
||||||
.build();
|
|
||||||
|
|
||||||
public AbiquoRestClientModule()
|
public AbiquoRestClientModule() {
|
||||||
{
|
super(DELEGATE_MAP);
|
||||||
super(DELEGATE_MAP);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bindAsyncClient()
|
protected void bindAsyncClient() {
|
||||||
{
|
super.bindAsyncClient();
|
||||||
super.bindAsyncClient();
|
BinderUtils.bindAsyncClient(binder(), AbiquoHttpAsyncClient.class);
|
||||||
BinderUtils.bindAsyncClient(binder(), AbiquoHttpAsyncClient.class);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bindClient()
|
protected void bindClient() {
|
||||||
{
|
super.bindClient();
|
||||||
super.bindClient();
|
BinderUtils.bindClient(binder(), AbiquoHttpClient.class, AbiquoHttpAsyncClient.class,
|
||||||
BinderUtils.bindClient(binder(), AbiquoHttpClient.class, AbiquoHttpAsyncClient.class,
|
ImmutableMap.<Class<?>, Class<?>> of(AbiquoHttpClient.class, AbiquoHttpAsyncClient.class));
|
||||||
ImmutableMap.<Class< ? >, Class< ? >> of(AbiquoHttpClient.class,
|
}
|
||||||
AbiquoHttpAsyncClient.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure()
|
protected void configure() {
|
||||||
{
|
super.configure();
|
||||||
super.configure();
|
bind(Utils.class).to(ExtendedUtils.class);
|
||||||
bind(Utils.class).to(ExtendedUtils.class);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bindErrorHandlers()
|
protected void bindErrorHandlers() {
|
||||||
{
|
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AbiquoErrorHandler.class);
|
||||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AbiquoErrorHandler.class);
|
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AbiquoErrorHandler.class);
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AbiquoErrorHandler.class);
|
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AbiquoErrorHandler.class);
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AbiquoErrorHandler.class);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Memoized
|
@Memoized
|
||||||
public Supplier<User> getCurrentUser(
|
public Supplier<User> getCurrentUser(final AtomicReference<AuthorizationException> authException,
|
||||||
final AtomicReference<AuthorizationException> authException,
|
@Named(PROPERTY_SESSION_INTERVAL) final long seconds, final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) final long seconds,
|
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, new Supplier<User>() {
|
||||||
final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
@Override
|
||||||
{
|
public User get() {
|
||||||
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
|
return wrap(context, User.class, context.getApi().getAdminApi().getCurrentUser());
|
||||||
new Supplier<User>()
|
}
|
||||||
{
|
}, seconds, TimeUnit.SECONDS);
|
||||||
@Override
|
}
|
||||||
public User get()
|
|
||||||
{
|
@Provides
|
||||||
return wrap(context, User.class, context.getApi().getAdminApi()
|
@Singleton
|
||||||
.getCurrentUser());
|
@Memoized
|
||||||
}
|
public Supplier<Enterprise> getCurrentEnterprise(final AtomicReference<AuthorizationException> authException,
|
||||||
|
@Named(PROPERTY_SESSION_INTERVAL) final long seconds, final @Memoized Supplier<User> currentUser) {
|
||||||
|
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
|
||||||
|
new Supplier<Enterprise>() {
|
||||||
|
@Override
|
||||||
|
public Enterprise get() {
|
||||||
|
return currentUser.get().getEnterprise();
|
||||||
|
}
|
||||||
}, seconds, TimeUnit.SECONDS);
|
}, seconds, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Memoized
|
@Memoized
|
||||||
public Supplier<Enterprise> getCurrentEnterprise(
|
public Supplier<Map<Integer, Datacenter>> getAvailableRegionsIndexedById(
|
||||||
final AtomicReference<AuthorizationException> authException,
|
final AtomicReference<AuthorizationException> authException,
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) final long seconds,
|
@Named(PROPERTY_SESSION_INTERVAL) final long seconds, @Memoized final Supplier<Enterprise> currentEnterprise) {
|
||||||
final @Memoized Supplier<User> currentUser)
|
Supplier<Map<Integer, Datacenter>> availableRegionsMapSupplier = Suppliers2.compose(
|
||||||
{
|
new Function<List<Datacenter>, Map<Integer, Datacenter>>() {
|
||||||
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
|
@Override
|
||||||
new Supplier<Enterprise>()
|
public Map<Integer, Datacenter> apply(final List<Datacenter> datacenters) {
|
||||||
{
|
// Index available regions by id
|
||||||
@Override
|
return Maps.uniqueIndex(datacenters, new Function<Datacenter, Integer>() {
|
||||||
public Enterprise get()
|
@Override
|
||||||
{
|
public Integer apply(final Datacenter input) {
|
||||||
return currentUser.get().getEnterprise();
|
return input.getId();
|
||||||
}
|
}
|
||||||
}, seconds, TimeUnit.SECONDS);
|
});
|
||||||
}
|
}
|
||||||
|
}, new Supplier<List<Datacenter>>() {
|
||||||
@Provides
|
@Override
|
||||||
@Singleton
|
public List<Datacenter> get() {
|
||||||
@Memoized
|
// Get the list of regions available for the user's tenant
|
||||||
public Supplier<Map<Integer, Datacenter>> getAvailableRegionsIndexedById(
|
return currentEnterprise.get().listAllowedDatacenters();
|
||||||
final AtomicReference<AuthorizationException> authException,
|
}
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) final long seconds,
|
|
||||||
@Memoized final Supplier<Enterprise> currentEnterprise)
|
|
||||||
{
|
|
||||||
Supplier<Map<Integer, Datacenter>> availableRegionsMapSupplier =
|
|
||||||
Suppliers2.compose(new Function<List<Datacenter>, Map<Integer, Datacenter>>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Map<Integer, Datacenter> apply(final List<Datacenter> datacenters)
|
|
||||||
{
|
|
||||||
// Index available regions by id
|
|
||||||
return Maps.uniqueIndex(datacenters, new Function<Datacenter, Integer>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Integer apply(final Datacenter input)
|
|
||||||
{
|
|
||||||
return input.getId();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, new Supplier<List<Datacenter>>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public List<Datacenter> get()
|
|
||||||
{
|
|
||||||
// Get the list of regions available for the user's tenant
|
|
||||||
return currentEnterprise.get().listAllowedDatacenters();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
|
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
|
||||||
availableRegionsMapSupplier, seconds, TimeUnit.SECONDS);
|
availableRegionsMapSupplier, seconds, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain;
|
package org.jclouds.abiquo.domain;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
@ -28,168 +26,136 @@ import org.jclouds.rest.RestContext;
|
||||||
import com.abiquo.model.transport.SingleResourceWithLimitsDto;
|
import com.abiquo.model.transport.SingleResourceWithLimitsDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to decorate transport objects that have limits with high level functionality.
|
* This class is used to decorate transport objects that have limits with high
|
||||||
|
* level functionality.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public abstract class DomainWithLimitsWrapper<T extends SingleResourceWithLimitsDto> extends
|
public abstract class DomainWithLimitsWrapper<T extends SingleResourceWithLimitsDto> extends DomainWrapper<T> {
|
||||||
DomainWrapper<T>
|
|
||||||
{
|
|
||||||
|
|
||||||
protected DomainWithLimitsWrapper(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final T target)
|
protected DomainWithLimitsWrapper(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final T target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public int getCpuCountHardLimit()
|
public int getCpuCountHardLimit() {
|
||||||
{
|
return target.getCpuCountHardLimit();
|
||||||
return target.getCpuCountHardLimit();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getCpuCountSoftLimit()
|
public int getCpuCountSoftLimit() {
|
||||||
{
|
return target.getCpuCountSoftLimit();
|
||||||
return target.getCpuCountSoftLimit();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getHdHardLimitInMb()
|
public long getHdHardLimitInMb() {
|
||||||
{
|
return target.getHdHardLimitInMb();
|
||||||
return target.getHdHardLimitInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getHdSoftLimitInMb()
|
public long getHdSoftLimitInMb() {
|
||||||
{
|
return target.getHdSoftLimitInMb();
|
||||||
return target.getHdSoftLimitInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getPublicIpsHard()
|
public long getPublicIpsHard() {
|
||||||
{
|
return target.getPublicIpsHard();
|
||||||
return target.getPublicIpsHard();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getPublicIpsSoft()
|
public long getPublicIpsSoft() {
|
||||||
{
|
return target.getPublicIpsSoft();
|
||||||
return target.getPublicIpsSoft();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getRamHardLimitInMb()
|
public int getRamHardLimitInMb() {
|
||||||
{
|
return target.getRamHardLimitInMb();
|
||||||
return target.getRamHardLimitInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getRamSoftLimitInMb()
|
public int getRamSoftLimitInMb() {
|
||||||
{
|
return target.getRamSoftLimitInMb();
|
||||||
return target.getRamSoftLimitInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getStorageHard()
|
public long getStorageHard() {
|
||||||
{
|
return target.getStorageHard();
|
||||||
return target.getStorageHard();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getStorageSoft()
|
public long getStorageSoft() {
|
||||||
{
|
return target.getStorageSoft();
|
||||||
return target.getStorageSoft();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getVlansHard()
|
public long getVlansHard() {
|
||||||
{
|
return target.getVlansHard();
|
||||||
return target.getVlansHard();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getVlansSoft()
|
public long getVlansSoft() {
|
||||||
{
|
return target.getVlansSoft();
|
||||||
return target.getVlansSoft();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setCpuCountHardLimit(final int cpuCountHardLimit)
|
public void setCpuCountHardLimit(final int cpuCountHardLimit) {
|
||||||
{
|
target.setCpuCountHardLimit(cpuCountHardLimit);
|
||||||
target.setCpuCountHardLimit(cpuCountHardLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setCpuCountLimits(final int softLimit, final int hardLimit)
|
public void setCpuCountLimits(final int softLimit, final int hardLimit) {
|
||||||
{
|
target.setCpuCountLimits(softLimit, hardLimit);
|
||||||
target.setCpuCountLimits(softLimit, hardLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setCpuCountSoftLimit(final int cpuCountSoftLimit)
|
public void setCpuCountSoftLimit(final int cpuCountSoftLimit) {
|
||||||
{
|
target.setCpuCountSoftLimit(cpuCountSoftLimit);
|
||||||
target.setCpuCountSoftLimit(cpuCountSoftLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setHdHardLimitInMb(final long hdHardLimitInMb)
|
public void setHdHardLimitInMb(final long hdHardLimitInMb) {
|
||||||
{
|
target.setHdHardLimitInMb(hdHardLimitInMb);
|
||||||
target.setHdHardLimitInMb(hdHardLimitInMb);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setHdLimitsInMb(final long softLimit, final long hardLimit)
|
public void setHdLimitsInMb(final long softLimit, final long hardLimit) {
|
||||||
{
|
target.setHdLimitsInMb(softLimit, hardLimit);
|
||||||
target.setHdLimitsInMb(softLimit, hardLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setHdSoftLimitInMb(final long hdSoftLimitInMb)
|
public void setHdSoftLimitInMb(final long hdSoftLimitInMb) {
|
||||||
{
|
target.setHdSoftLimitInMb(hdSoftLimitInMb);
|
||||||
target.setHdSoftLimitInMb(hdSoftLimitInMb);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicIPLimits(final long softLimit, final long hardLimit)
|
public void setPublicIPLimits(final long softLimit, final long hardLimit) {
|
||||||
{
|
target.setPublicIPLimits(softLimit, hardLimit);
|
||||||
target.setPublicIPLimits(softLimit, hardLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicIpsHard(final long publicIpsHard)
|
public void setPublicIpsHard(final long publicIpsHard) {
|
||||||
{
|
target.setPublicIpsHard(publicIpsHard);
|
||||||
target.setPublicIpsHard(publicIpsHard);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicIpsSoft(final long publicIpsSoft)
|
public void setPublicIpsSoft(final long publicIpsSoft) {
|
||||||
{
|
target.setPublicIpsSoft(publicIpsSoft);
|
||||||
target.setPublicIpsSoft(publicIpsSoft);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setRamHardLimitInMb(final int ramHardLimitInMb)
|
public void setRamHardLimitInMb(final int ramHardLimitInMb) {
|
||||||
{
|
target.setRamHardLimitInMb(ramHardLimitInMb);
|
||||||
target.setRamHardLimitInMb(ramHardLimitInMb);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setRamLimitsInMb(final int softLimit, final int hardLimit)
|
public void setRamLimitsInMb(final int softLimit, final int hardLimit) {
|
||||||
{
|
target.setRamLimitsInMb(softLimit, hardLimit);
|
||||||
target.setRamLimitsInMb(softLimit, hardLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setRamSoftLimitInMb(final int ramSoftLimitInMb)
|
public void setRamSoftLimitInMb(final int ramSoftLimitInMb) {
|
||||||
{
|
target.setRamSoftLimitInMb(ramSoftLimitInMb);
|
||||||
target.setRamSoftLimitInMb(ramSoftLimitInMb);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setStorageHard(final long storageHard)
|
public void setStorageHard(final long storageHard) {
|
||||||
{
|
target.setStorageHard(storageHard);
|
||||||
target.setStorageHard(storageHard);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setStorageLimits(final long softLimit, final long hardLimit)
|
public void setStorageLimits(final long softLimit, final long hardLimit) {
|
||||||
{
|
target.setStorageLimits(softLimit, hardLimit);
|
||||||
target.setStorageLimits(softLimit, hardLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setStorageSoft(final long storageSoft)
|
public void setStorageSoft(final long storageSoft) {
|
||||||
{
|
target.setStorageSoft(storageSoft);
|
||||||
target.setStorageSoft(storageSoft);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVlansHard(final long vlansHard)
|
public void setVlansHard(final long vlansHard) {
|
||||||
{
|
target.setVlansHard(vlansHard);
|
||||||
target.setVlansHard(vlansHard);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVlansLimits(final long softLimit, final long hardLimit)
|
public void setVlansLimits(final long softLimit, final long hardLimit) {
|
||||||
{
|
target.setVlansLimits(softLimit, hardLimit);
|
||||||
target.setVlansLimits(softLimit, hardLimit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVlansSoft(final long vlansSoft)
|
public void setVlansSoft(final long vlansSoft) {
|
||||||
{
|
target.setVlansSoft(vlansSoft);
|
||||||
target.setVlansSoft(vlansSoft);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,45 +39,37 @@ import com.google.common.collect.Ordering;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to decorate transport objects that are owners of some {@link TaskDto}
|
* This class is used to decorate transport objects that are owners of some
|
||||||
|
* {@link TaskDto}
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public abstract class DomainWithTasksWrapper<T extends SingleResourceTransportDto> extends
|
public abstract class DomainWithTasksWrapper<T extends SingleResourceTransportDto> extends DomainWrapper<T> {
|
||||||
DomainWrapper<T>
|
|
||||||
{
|
|
||||||
|
|
||||||
protected DomainWithTasksWrapper(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected DomainWithTasksWrapper(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final T target) {
|
||||||
final T target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AsyncTask> listTasks()
|
public List<AsyncTask> listTasks() {
|
||||||
{
|
TasksDto result = context.getApi().getTaskApi().listTasks(target);
|
||||||
TasksDto result = context.getApi().getTaskApi().listTasks(target);
|
List<AsyncTask> tasks = wrap(context, AsyncTask.class, result.getCollection());
|
||||||
List<AsyncTask> tasks = wrap(context, AsyncTask.class, result.getCollection());
|
|
||||||
|
|
||||||
// Return the most recent task first
|
// Return the most recent task first
|
||||||
Collections.sort(tasks, new Ordering<AsyncTask>()
|
Collections.sort(tasks, new Ordering<AsyncTask>() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public int compare(final AsyncTask left, final AsyncTask right) {
|
||||||
public int compare(final AsyncTask left, final AsyncTask right)
|
return Longs.compare(left.getTimestamp(), right.getTimestamp());
|
||||||
{
|
}
|
||||||
return Longs.compare(left.getTimestamp(), right.getTimestamp());
|
}.reverse());
|
||||||
}
|
|
||||||
}.reverse());
|
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AsyncTask> listTasks(final Predicate<AsyncTask> filter)
|
public List<AsyncTask> listTasks(final Predicate<AsyncTask> filter) {
|
||||||
{
|
return Lists.newLinkedList(filter(listTasks(), filter));
|
||||||
return Lists.newLinkedList(filter(listTasks(), filter));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public AsyncTask findTask(final Predicate<AsyncTask> filter)
|
public AsyncTask findTask(final Predicate<AsyncTask> filter) {
|
||||||
{
|
return Iterables.getFirst(filter(listTasks(), filter), null);
|
||||||
return Iterables.getFirst(filter(listTasks(), filter), null);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,198 +44,173 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to decorate transport objects with high level functionality.
|
* This class is used to decorate transport objects with high level
|
||||||
|
* functionality.
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public abstract class DomainWrapper<T extends SingleResourceTransportDto>
|
public abstract class DomainWrapper<T extends SingleResourceTransportDto> {
|
||||||
{
|
/** The rest context. */
|
||||||
/** The rest context. */
|
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
/** The wrapped object. */
|
/** The wrapped object. */
|
||||||
protected T target;
|
protected T target;
|
||||||
|
|
||||||
protected DomainWrapper(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected DomainWrapper(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final T target) {
|
||||||
final T target)
|
super();
|
||||||
{
|
this.context = checkNotNull(context, "context");
|
||||||
super();
|
this.target = checkNotNull(target, "target");
|
||||||
this.context = checkNotNull(context, "context");
|
}
|
||||||
this.target = checkNotNull(target, "target");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the URI that identifies the transport object
|
* Returns the URI that identifies the transport object
|
||||||
*
|
*
|
||||||
* @return The URI identifying the transport object
|
* @return The URI identifying the transport object
|
||||||
*/
|
*/
|
||||||
public URI getURI()
|
public URI getURI() {
|
||||||
{
|
RESTLink link = LinkUtils.getSelfLink(target);
|
||||||
RESTLink link = LinkUtils.getSelfLink(target);
|
return link == null ? null : URI.create(link.getHref());
|
||||||
return link == null ? null : URI.create(link.getHref());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the wrapped object.
|
* Returns the wrapped object.
|
||||||
*/
|
*/
|
||||||
public T unwrap()
|
public T unwrap() {
|
||||||
{
|
return target;
|
||||||
return target;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the ID of the parent resource from the given link.
|
* Read the ID of the parent resource from the given link.
|
||||||
*
|
*
|
||||||
* @param parentLinkRel The link to the parent resource.
|
* @param parentLinkRel
|
||||||
* @return The ID of the parent resource.
|
* The link to the parent resource.
|
||||||
*/
|
* @return The ID of the parent resource.
|
||||||
protected Integer getParentId(final String parentLinkRel)
|
*/
|
||||||
{
|
protected Integer getParentId(final String parentLinkRel) {
|
||||||
return target.getIdFromLink(parentLinkRel);
|
return target.getIdFromLink(parentLinkRel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps an object in the given wrapper class.
|
* Wraps an object in the given wrapper class.
|
||||||
*/
|
*/
|
||||||
public static <T extends SingleResourceTransportDto, W extends DomainWrapper<T>> W wrap(
|
public static <T extends SingleResourceTransportDto, W extends DomainWrapper<T>> W wrap(
|
||||||
final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Class<W> wrapperClass,
|
final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Class<W> wrapperClass, final T target) {
|
||||||
final T target)
|
if (target == null) {
|
||||||
{
|
return null;
|
||||||
if (target == null)
|
}
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
Constructor<W> cons = wrapperClass.getDeclaredConstructor(RestContext.class, target.getClass());
|
||||||
Constructor<W> cons =
|
if (!cons.isAccessible()) {
|
||||||
wrapperClass.getDeclaredConstructor(RestContext.class, target.getClass());
|
cons.setAccessible(true);
|
||||||
if (!cons.isAccessible())
|
}
|
||||||
{
|
return cons.newInstance(context, target);
|
||||||
cons.setAccessible(true);
|
} catch (Exception ex) {
|
||||||
}
|
throw new WrapperException(wrapperClass, target, ex);
|
||||||
return cons.newInstance(context, target);
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new WrapperException(wrapperClass, target, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a collection of objects to the given wrapper class.
|
* Wrap a collection of objects to the given wrapper class.
|
||||||
*/
|
*/
|
||||||
public static <T extends SingleResourceTransportDto, W extends DomainWrapper<T>> List<W> wrap(
|
public static <T extends SingleResourceTransportDto, W extends DomainWrapper<T>> List<W> wrap(
|
||||||
final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Class<W> wrapperClass,
|
final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Class<W> wrapperClass, final Iterable<T> targets) {
|
||||||
final Iterable<T> targets)
|
if (targets == null) {
|
||||||
{
|
return null;
|
||||||
if (targets == null)
|
}
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Lists.newLinkedList(transform(targets, new Function<T, W>()
|
return Lists.newLinkedList(transform(targets, new Function<T, W>() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public W apply(final T input) {
|
||||||
public W apply(final T input)
|
return wrap(context, wrapperClass, input);
|
||||||
{
|
}
|
||||||
return wrap(context, wrapperClass, input);
|
}));
|
||||||
}
|
}
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unwrap a collection of objects.
|
* Unwrap a collection of objects.
|
||||||
*/
|
*/
|
||||||
public static <T extends SingleResourceTransportDto, W extends DomainWrapper<T>> List<T> unwrap(
|
public static <T extends SingleResourceTransportDto, W extends DomainWrapper<T>> List<T> unwrap(
|
||||||
final Iterable<W> targets)
|
final Iterable<W> targets) {
|
||||||
{
|
return Lists.newLinkedList(transform(targets, new Function<W, T>() {
|
||||||
return Lists.newLinkedList(transform(targets, new Function<W, T>()
|
@Override
|
||||||
{
|
public T apply(final W input) {
|
||||||
@Override
|
return input.unwrap();
|
||||||
public T apply(final W input)
|
}
|
||||||
{
|
}));
|
||||||
return input.unwrap();
|
}
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update or creates a link of "target" with the uri of a link from "source".
|
* Update or creates a link of "target" with the uri of a link from "source".
|
||||||
*/
|
*/
|
||||||
protected <T1 extends SingleResourceTransportDto, T2 extends SingleResourceTransportDto> void updateLink(
|
protected <T1 extends SingleResourceTransportDto, T2 extends SingleResourceTransportDto> void updateLink(
|
||||||
final T1 target, final String targetLinkRel, final T2 source, final String sourceLinkRel)
|
final T1 target, final String targetLinkRel, final T2 source, final String sourceLinkRel) {
|
||||||
{
|
RESTLink parent = null;
|
||||||
RESTLink parent = null;
|
|
||||||
|
|
||||||
checkNotNull(source.searchLink(sourceLinkRel), ValidationErrors.MISSING_REQUIRED_LINK);
|
checkNotNull(source.searchLink(sourceLinkRel), ValidationErrors.MISSING_REQUIRED_LINK);
|
||||||
|
|
||||||
// Insert
|
// Insert
|
||||||
if ((parent = target.searchLink(targetLinkRel)) == null)
|
if ((parent = target.searchLink(targetLinkRel)) == null) {
|
||||||
{
|
target.addLink(new RESTLink(targetLinkRel, source.searchLink(sourceLinkRel).getHref()));
|
||||||
target.addLink(new RESTLink(targetLinkRel, source.searchLink(sourceLinkRel).getHref()));
|
}
|
||||||
}
|
// Replace
|
||||||
// Replace
|
else {
|
||||||
else
|
parent.setHref(source.searchLink(sourceLinkRel).getHref());
|
||||||
{
|
}
|
||||||
parent.setHref(source.searchLink(sourceLinkRel).getHref());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Join a collection of {@link WrapperDto} objects in a single collection with all the elements
|
* Join a collection of {@link WrapperDto} objects in a single collection
|
||||||
* of each wrapper object.
|
* with all the elements of each wrapper object.
|
||||||
*/
|
*/
|
||||||
public static <T extends SingleResourceTransportDto> Iterable<T> join(
|
public static <T extends SingleResourceTransportDto> Iterable<T> join(
|
||||||
final Iterable< ? extends WrapperDto<T>> collection)
|
final Iterable<? extends WrapperDto<T>> collection) {
|
||||||
{
|
List<T> dtos = Lists.newLinkedList();
|
||||||
List<T> dtos = Lists.newLinkedList();
|
for (WrapperDto<T> wrapper : collection) {
|
||||||
for (WrapperDto<T> wrapper : collection)
|
dtos.addAll(wrapper.getCollection());
|
||||||
{
|
}
|
||||||
dtos.addAll(wrapper.getCollection());
|
return dtos;
|
||||||
}
|
}
|
||||||
return dtos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to get an {@link AsyncTask} given an {@link AcceptedRequestDto}.
|
* Utility method to get an {@link AsyncTask} given an
|
||||||
*
|
* {@link AcceptedRequestDto}.
|
||||||
* @param acceptedRequest The accepted request dto.
|
*
|
||||||
* @return The async task.
|
* @param acceptedRequest
|
||||||
*/
|
* The accepted request dto.
|
||||||
protected AsyncTask getTask(final AcceptedRequestDto<String> acceptedRequest)
|
* @return The async task.
|
||||||
{
|
*/
|
||||||
RESTLink taskLink = acceptedRequest.getStatusLink();
|
protected AsyncTask getTask(final AcceptedRequestDto<String> acceptedRequest) {
|
||||||
checkNotNull(taskLink, ValidationErrors.MISSING_REQUIRED_LINK + AsyncTask.class);
|
RESTLink taskLink = acceptedRequest.getStatusLink();
|
||||||
|
checkNotNull(taskLink, ValidationErrors.MISSING_REQUIRED_LINK + AsyncTask.class);
|
||||||
|
|
||||||
// This will return null on untrackable tasks
|
// This will return null on untrackable tasks
|
||||||
TaskDto task = context.getApi().getTaskApi().getTask(taskLink);
|
TaskDto task = context.getApi().getTaskApi().getTask(taskLink);
|
||||||
return wrap(context, AsyncTask.class, task);
|
return wrap(context, AsyncTask.class, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to get all {@link AsyncTask} related to an {@link AcceptedRequestDto}.
|
* Utility method to get all {@link AsyncTask} related to an
|
||||||
*
|
* {@link AcceptedRequestDto}.
|
||||||
* @param acceptedRequest The accepted request dto.
|
*
|
||||||
* @return The async task array.
|
* @param acceptedRequest
|
||||||
*/
|
* The accepted request dto.
|
||||||
protected AsyncTask[] getTasks(final AcceptedRequestDto<String> acceptedRequest)
|
* @return The async task array.
|
||||||
{
|
*/
|
||||||
List<AsyncTask> tasks = new ArrayList<AsyncTask>();
|
protected AsyncTask[] getTasks(final AcceptedRequestDto<String> acceptedRequest) {
|
||||||
|
List<AsyncTask> tasks = new ArrayList<AsyncTask>();
|
||||||
|
|
||||||
for (RESTLink link : acceptedRequest.getLinks())
|
for (RESTLink link : acceptedRequest.getLinks()) {
|
||||||
{
|
// This will return null on untrackable tasks
|
||||||
// This will return null on untrackable tasks
|
TaskDto task = context.getApi().getTaskApi().getTask(link);
|
||||||
TaskDto task = context.getApi().getTaskApi().getTask(link);
|
if (task != null) {
|
||||||
if (task != null)
|
tasks.add(wrap(context, AsyncTask.class, task));
|
||||||
{
|
}
|
||||||
tasks.add(wrap(context, AsyncTask.class, task));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AsyncTask[] taskArr = new AsyncTask[tasks.size()];
|
AsyncTask[] taskArr = new AsyncTask[tasks.size()];
|
||||||
return tasks.toArray(taskArr);
|
return tasks.toArray(taskArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,82 +23,76 @@ package org.jclouds.abiquo.domain.builder;
|
||||||
* Base class for all builders that represent limits.
|
* Base class for all builders that represent limits.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @param <T> The type of the target builder.
|
* @param <T>
|
||||||
|
* The type of the target builder.
|
||||||
*/
|
*/
|
||||||
public abstract class LimitsBuilder<T extends LimitsBuilder<T>>
|
public abstract class LimitsBuilder<T extends LimitsBuilder<T>> {
|
||||||
{
|
/** The default limits for enterprises (unlimited). */
|
||||||
/** The default limits for enterprises (unlimited). */
|
protected static final int DEFAULT_LIMITS = 0;
|
||||||
protected static final int DEFAULT_LIMITS = 0;
|
|
||||||
|
|
||||||
protected Integer ramSoftLimitInMb = DEFAULT_LIMITS;
|
protected Integer ramSoftLimitInMb = DEFAULT_LIMITS;
|
||||||
|
|
||||||
protected Integer ramHardLimitInMb = DEFAULT_LIMITS;
|
protected Integer ramHardLimitInMb = DEFAULT_LIMITS;
|
||||||
|
|
||||||
protected Integer cpuCountSoftLimit = DEFAULT_LIMITS;
|
protected Integer cpuCountSoftLimit = DEFAULT_LIMITS;
|
||||||
|
|
||||||
protected Integer cpuCountHardLimit = DEFAULT_LIMITS;
|
protected Integer cpuCountHardLimit = DEFAULT_LIMITS;
|
||||||
|
|
||||||
protected Long hdSoftLimitInMb = Long.valueOf(DEFAULT_LIMITS);
|
protected Long hdSoftLimitInMb = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long hdHardLimitInMb = Long.valueOf(DEFAULT_LIMITS);
|
protected Long hdHardLimitInMb = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long storageSoft = Long.valueOf(DEFAULT_LIMITS);
|
protected Long storageSoft = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long storageHard = Long.valueOf(DEFAULT_LIMITS);
|
protected Long storageHard = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long vlansSoft = Long.valueOf(DEFAULT_LIMITS);
|
protected Long vlansSoft = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long vlansHard = Long.valueOf(DEFAULT_LIMITS);
|
protected Long vlansHard = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long publicIpsSoft = Long.valueOf(DEFAULT_LIMITS);
|
protected Long publicIpsSoft = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long publicIpsHard = Long.valueOf(DEFAULT_LIMITS);
|
protected Long publicIpsHard = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T ramLimits(final int soft, final int hard)
|
public T ramLimits(final int soft, final int hard) {
|
||||||
{
|
this.ramSoftLimitInMb = soft;
|
||||||
this.ramSoftLimitInMb = soft;
|
this.ramHardLimitInMb = hard;
|
||||||
this.ramHardLimitInMb = hard;
|
return (T) this;
|
||||||
return (T) this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T cpuCountLimits(final int soft, final int hard)
|
public T cpuCountLimits(final int soft, final int hard) {
|
||||||
{
|
this.cpuCountSoftLimit = soft;
|
||||||
this.cpuCountSoftLimit = soft;
|
this.cpuCountHardLimit = hard;
|
||||||
this.cpuCountHardLimit = hard;
|
return (T) this;
|
||||||
return (T) this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T hdLimitsInMb(final long soft, final long hard)
|
public T hdLimitsInMb(final long soft, final long hard) {
|
||||||
{
|
this.hdSoftLimitInMb = soft;
|
||||||
this.hdSoftLimitInMb = soft;
|
this.hdHardLimitInMb = hard;
|
||||||
this.hdHardLimitInMb = hard;
|
return (T) this;
|
||||||
return (T) this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T storageLimits(final long soft, final long hard)
|
public T storageLimits(final long soft, final long hard) {
|
||||||
{
|
this.storageSoft = soft;
|
||||||
this.storageSoft = soft;
|
this.storageHard = hard;
|
||||||
this.storageHard = hard;
|
return (T) this;
|
||||||
return (T) this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T vlansLimits(final long soft, final long hard)
|
public T vlansLimits(final long soft, final long hard) {
|
||||||
{
|
this.vlansSoft = soft;
|
||||||
this.vlansSoft = soft;
|
this.vlansHard = hard;
|
||||||
this.vlansHard = hard;
|
return (T) this;
|
||||||
return (T) this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T publicIpsLimits(final long soft, final long hard)
|
public T publicIpsLimits(final long soft, final long hard) {
|
||||||
{
|
this.publicIpsSoft = soft;
|
||||||
this.publicIpsSoft = soft;
|
this.publicIpsHard = hard;
|
||||||
this.publicIpsHard = hard;
|
return (T) this;
|
||||||
return (T) this;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,118 +46,100 @@ import com.google.inject.TypeLiteral;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Conversion+Resource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/Conversion+Resource">
|
||||||
* http://community.abiquo.com/display/ABI20/Conversion+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Conversion+Resource</a>
|
||||||
*/
|
*/
|
||||||
public class Conversion extends DomainWithTasksWrapper<ConversionDto>
|
public class Conversion extends DomainWithTasksWrapper<ConversionDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected Conversion(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final ConversionDto target) {
|
||||||
protected Conversion(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
super(context, target);
|
||||||
final ConversionDto target)
|
}
|
||||||
{
|
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain methods
|
// Domain methods
|
||||||
|
|
||||||
public void refresh()
|
public void refresh() {
|
||||||
{
|
RESTLink link = checkNotNull(target.searchLink("edit"), ValidationErrors.MISSING_REQUIRED_LINK + "edit");
|
||||||
RESTLink link =
|
|
||||||
checkNotNull(target.searchLink("edit"), ValidationErrors.MISSING_REQUIRED_LINK + "edit");
|
|
||||||
|
|
||||||
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
||||||
HttpResponse response = checkNotNull(utils.getAbiquoHttpClient().get(link), "conversion");
|
HttpResponse response = checkNotNull(utils.getAbiquoHttpClient().get(link), "conversion");
|
||||||
|
|
||||||
ParseXMLWithJAXB<ConversionDto> parser =
|
ParseXMLWithJAXB<ConversionDto> parser = new ParseXMLWithJAXB<ConversionDto>(utils.getXml(),
|
||||||
new ParseXMLWithJAXB<ConversionDto>(utils.getXml(),
|
TypeLiteral.get(ConversionDto.class));
|
||||||
TypeLiteral.get(ConversionDto.class));
|
|
||||||
|
|
||||||
target = parser.apply(response);
|
target = parser.apply(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource" >
|
* "http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource"
|
||||||
* http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource</a>
|
* > http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+
|
||||||
*/
|
* Resource</a>
|
||||||
public VirtualMachineTemplate getVirtualMachineTemplate()
|
*/
|
||||||
{
|
public VirtualMachineTemplate getVirtualMachineTemplate() {
|
||||||
RESTLink link =
|
RESTLink link = checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE),
|
||||||
checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE),
|
ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.VIRTUAL_MACHINE_TEMPLATE);
|
||||||
ValidationErrors.MISSING_REQUIRED_LINK + " "
|
|
||||||
+ ParentLinkName.VIRTUAL_MACHINE_TEMPLATE);
|
|
||||||
|
|
||||||
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
||||||
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
||||||
|
|
||||||
ParseXMLWithJAXB<VirtualMachineTemplateDto> parser =
|
ParseXMLWithJAXB<VirtualMachineTemplateDto> parser = new ParseXMLWithJAXB<VirtualMachineTemplateDto>(
|
||||||
new ParseXMLWithJAXB<VirtualMachineTemplateDto>(utils.getXml(),
|
utils.getXml(), TypeLiteral.get(VirtualMachineTemplateDto.class));
|
||||||
TypeLiteral.get(VirtualMachineTemplateDto.class));
|
|
||||||
|
|
||||||
return wrap(context, VirtualMachineTemplate.class, parser.apply(response));
|
return wrap(context, VirtualMachineTemplate.class, parser.apply(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new BPM task to regenerate a failed conversion.
|
* Starts a new BPM task to regenerate a failed conversion.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-UpdateConversion"
|
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-UpdateConversion"
|
||||||
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-
|
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#
|
||||||
* UpdateConversion</a>
|
* ConversionResource- UpdateConversion</a>
|
||||||
* @return The task reference to track its progress
|
* @return The task reference to track its progress
|
||||||
*/
|
*/
|
||||||
public AsyncTask restartFailedConversion()
|
public AsyncTask restartFailedConversion() {
|
||||||
{
|
return getVirtualMachineTemplate().requestConversion(getTargetFormat());
|
||||||
return getVirtualMachineTemplate().requestConversion(getTargetFormat());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public String getSourcePath()
|
public String getSourcePath() {
|
||||||
{
|
return target.getSourcePath();
|
||||||
return target.getSourcePath();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public ConversionState getState()
|
public ConversionState getState() {
|
||||||
{
|
return target.getState();
|
||||||
return target.getState();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getTargetPath()
|
public String getTargetPath() {
|
||||||
{
|
return target.getTargetPath();
|
||||||
return target.getTargetPath();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTargetSizeInBytes()
|
public Long getTargetSizeInBytes() {
|
||||||
{
|
return target.getTargetSizeInBytes();
|
||||||
return target.getTargetSizeInBytes();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public DiskFormatType getSourceFormat()
|
public DiskFormatType getSourceFormat() {
|
||||||
{
|
return target.getSourceFormat();
|
||||||
return target.getSourceFormat();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public DiskFormatType getTargetFormat()
|
public DiskFormatType getTargetFormat() {
|
||||||
{
|
return target.getTargetFormat();
|
||||||
return target.getTargetFormat();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Date getStartTimestamp()
|
public Date getStartTimestamp() {
|
||||||
{
|
return target.getStartTimestamp();
|
||||||
return target.getStartTimestamp();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Conversion [sourcePath=" + getSourcePath() + ", sourceFormat=" + getSourceFormat() + ", targetPath="
|
||||||
return "Conversion [sourcePath=" + getSourcePath() + ", sourceFormat=" + getSourceFormat()
|
+ getTargetPath() + ", targetFormat=" + getTargetFormat() + ", targetSizeInBytes=" + getTargetSizeInBytes()
|
||||||
+ ", targetPath=" + getTargetPath() + ", targetFormat=" + getTargetFormat()
|
+ ", startTimestamp=" + getStartTimestamp() + ", state=" + getState() + "]";
|
||||||
+ ", targetSizeInBytes=" + getTargetSizeInBytes() + ", startTimestamp="
|
}
|
||||||
+ getStartTimestamp() + ", state=" + getState() + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,148 +34,131 @@ import com.abiquo.server.core.infrastructure.storage.DiskManagementDto;
|
||||||
/**
|
/**
|
||||||
* Represents a disk attached to a virtual machine.
|
* Represents a disk attached to a virtual machine.
|
||||||
* <p>
|
* <p>
|
||||||
* This disks will be created when a virtual machine is deployed, and will be destroyed when it is
|
* This disks will be created when a virtual machine is deployed, and will be
|
||||||
* undeployed. If there is a need to use persistent storage, a persistent {@link Volume} should be
|
* destroyed when it is undeployed. If there is a need to use persistent
|
||||||
* used instead.
|
* storage, a persistent {@link Volume} should be used instead.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Hard+Disks+Resource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/Hard+Disks+Resource">
|
||||||
* http://community.abiquo.com/display/ABI20/Hard+Disks+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Hard+Disks+Resource</a>
|
||||||
*/
|
*/
|
||||||
public class HardDisk extends DomainWrapper<DiskManagementDto>
|
public class HardDisk extends DomainWrapper<DiskManagementDto> {
|
||||||
{
|
/** The virtual datacenter where the hard disk belongs. */
|
||||||
/** The virtual datacenter where the hard disk belongs. */
|
private VirtualDatacenter virtualDatacenter;
|
||||||
private VirtualDatacenter virtualDatacenter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected HardDisk(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected HardDisk(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final DiskManagementDto target) {
|
||||||
final DiskManagementDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the hard disk in the selected virtual datacenter.
|
* Creates the hard disk in the selected virtual datacenter.
|
||||||
* <p>
|
* <p>
|
||||||
* Once the hard disk has been created it can be attached to a virtual machine of the virtual
|
* Once the hard disk has been created it can be attached to a virtual
|
||||||
* datacenter.
|
* machine of the virtual datacenter.
|
||||||
*/
|
*/
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
target = context.getApi().getCloudApi().createHardDisk(virtualDatacenter.unwrap(), target);
|
||||||
target = context.getApi().getCloudApi().createHardDisk(virtualDatacenter.unwrap(), target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the hard disk.
|
* Deletes the hard disk.
|
||||||
*/
|
*/
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getCloudApi().deleteHardDisk(target);
|
||||||
context.getApi().getCloudApi().deleteHardDisk(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the virtual datacenter where the hard disk belongs to.
|
* Gets the virtual datacenter where the hard disk belongs to.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @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"
|
||||||
* > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource#
|
* > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+
|
||||||
* VirtualDatacenterResource-RetrieveaVirtualDatacenter</a>
|
* Resource# VirtualDatacenterResource-RetrieveaVirtualDatacenter</a>
|
||||||
*/
|
*/
|
||||||
public VirtualDatacenter getVirtualDatacenter()
|
public VirtualDatacenter getVirtualDatacenter() {
|
||||||
{
|
Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
|
||||||
Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
|
VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
|
||||||
VirtualDatacenterDto dto =
|
virtualDatacenter = wrap(context, VirtualDatacenter.class, dto);
|
||||||
context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
|
return virtualDatacenter;
|
||||||
virtualDatacenter = wrap(context, VirtualDatacenter.class, dto);
|
}
|
||||||
return virtualDatacenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final VirtualDatacenter virtualDatacenter)
|
final VirtualDatacenter virtualDatacenter) {
|
||||||
{
|
return new Builder(context, virtualDatacenter);
|
||||||
return new Builder(context, virtualDatacenter);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private Long sizeInMb;
|
private Long sizeInMb;
|
||||||
|
|
||||||
private VirtualDatacenter virtualDatacenter;
|
private VirtualDatacenter virtualDatacenter;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final VirtualDatacenter virtualDatacenter) {
|
||||||
final VirtualDatacenter virtualDatacenter)
|
super();
|
||||||
{
|
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class);
|
||||||
super();
|
this.context = context;
|
||||||
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE
|
this.virtualDatacenter = virtualDatacenter;
|
||||||
+ VirtualDatacenter.class);
|
}
|
||||||
this.context = context;
|
|
||||||
this.virtualDatacenter = virtualDatacenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder sizeInMb(final long sizeInMb)
|
public Builder sizeInMb(final long sizeInMb) {
|
||||||
{
|
this.sizeInMb = sizeInMb;
|
||||||
this.sizeInMb = sizeInMb;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public HardDisk build()
|
public HardDisk build() {
|
||||||
{
|
DiskManagementDto dto = new DiskManagementDto();
|
||||||
DiskManagementDto dto = new DiskManagementDto();
|
dto.setSizeInMb(sizeInMb);
|
||||||
dto.setSizeInMb(sizeInMb);
|
|
||||||
|
|
||||||
HardDisk hardDisk = new HardDisk(context, dto);
|
HardDisk hardDisk = new HardDisk(context, dto);
|
||||||
hardDisk.virtualDatacenter = virtualDatacenter;
|
hardDisk.virtualDatacenter = virtualDatacenter;
|
||||||
|
|
||||||
return hardDisk;
|
return hardDisk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate methods. Since a hard disk cannot be edited, setters are not visible
|
// Delegate methods. Since a hard disk cannot be edited, setters are not
|
||||||
|
// visible
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the id of the hard disk.
|
* Returns the id of the hard disk.
|
||||||
*/
|
*/
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
// TODO: DiskManagementDto does not have an id field
|
||||||
// TODO: DiskManagementDto does not have an id field
|
return target.getEditLink() == null ? null : target.getIdFromLink("edit");
|
||||||
return target.getEditLink() == null ? null : target.getIdFromLink("edit");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of the hard disk in MB.
|
* Returns the size of the hard disk in MB.
|
||||||
*/
|
*/
|
||||||
public Long getSizeInMb()
|
public Long getSizeInMb() {
|
||||||
{
|
return target.getSizeInMb();
|
||||||
return target.getSizeInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sequence number of the hard disk.
|
* Returns the sequence number of the hard disk.
|
||||||
* <p>
|
* <p>
|
||||||
* It will be computed when attaching the hard disk to a virtual machine and will determine the
|
* It will be computed when attaching the hard disk to a virtual machine and
|
||||||
* attachment order of the disk in the virtual machine.
|
* will determine the attachment order of the disk in the virtual machine.
|
||||||
*/
|
*/
|
||||||
public Integer getSequence()
|
public Integer getSequence() {
|
||||||
{
|
return target.getSequence();
|
||||||
return target.getSequence();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "HardDisk [id=" + getId() + ", sizeInMb=" + getSizeInMb() + ", sequence=" + getSequence() + "]";
|
||||||
return "HardDisk [id=" + getId() + ", sizeInMb=" + getSizeInMb() + ", sequence="
|
}
|
||||||
+ getSequence() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,364 +50,333 @@ import com.google.common.collect.Lists;
|
||||||
/**
|
/**
|
||||||
* Represents a virtual appliance.
|
* Represents a virtual appliance.
|
||||||
* <p>
|
* <p>
|
||||||
* A virtual appliance is a logic container for virtual machines that together make an appliance.
|
* A virtual appliance is a logic container for virtual machines that together
|
||||||
|
* make an appliance.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource"
|
||||||
|
* >
|
||||||
* http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource</a>
|
||||||
*/
|
*/
|
||||||
public class VirtualAppliance extends DomainWrapper<VirtualApplianceDto>
|
public class VirtualAppliance extends DomainWrapper<VirtualApplianceDto> {
|
||||||
{
|
/** The virtual datacenter where the virtual appliance belongs. */
|
||||||
/** The virtual datacenter where the virtual appliance belongs. */
|
private VirtualDatacenter virtualDatacenter;
|
||||||
private VirtualDatacenter virtualDatacenter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected VirtualAppliance(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected VirtualAppliance(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final VirtualApplianceDto target) {
|
||||||
final VirtualApplianceDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the virtual appliance.
|
* Deletes the virtual appliance.
|
||||||
*/
|
*/
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getCloudApi().deleteVirtualAppliance(target);
|
||||||
context.getApi().getCloudApi().deleteVirtualAppliance(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the virtual appliance in the selected virtual datacenter.
|
* Creates the virtual appliance in the selected virtual datacenter.
|
||||||
*/
|
*/
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
target = context.getApi().getCloudApi().createVirtualAppliance(virtualDatacenter.unwrap(), target);
|
||||||
target =
|
}
|
||||||
context.getApi().getCloudApi()
|
|
||||||
.createVirtualAppliance(virtualDatacenter.unwrap(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the virtual appliance information when some of its properties have changed.
|
* Updates the virtual appliance information when some of its properties have
|
||||||
*/
|
* changed.
|
||||||
public void update()
|
*/
|
||||||
{
|
public void update() {
|
||||||
target = context.getApi().getCloudApi().updateVirtualAppliance(target);
|
target = context.getApi().getCloudApi().updateVirtualAppliance(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the virtual datacenter where the virtual appliance belongs to.
|
* Gets the virtual datacenter where the virtual appliance belongs to.
|
||||||
*
|
*
|
||||||
* @resturn The virtual datacenter where the virtual appliance belongs to.
|
* @resturn The virtual datacenter where the virtual appliance belongs to.
|
||||||
* @see API: <a href=
|
* @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"
|
||||||
* > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource#
|
* > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+
|
||||||
* VirtualDatacenterResource-RetrieveaVirtualDatacenter</a>
|
* Resource# VirtualDatacenterResource-RetrieveaVirtualDatacenter</a>
|
||||||
*/
|
*/
|
||||||
public VirtualDatacenter getVirtualDatacenter()
|
public VirtualDatacenter getVirtualDatacenter() {
|
||||||
{
|
Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
|
||||||
Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
|
VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
|
||||||
VirtualDatacenterDto dto =
|
virtualDatacenter = wrap(context, VirtualDatacenter.class, dto);
|
||||||
context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
|
return virtualDatacenter;
|
||||||
virtualDatacenter = wrap(context, VirtualDatacenter.class, dto);
|
}
|
||||||
return virtualDatacenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the enterprise where the virtual appliance belongs to.
|
* Gets the enterprise where the virtual appliance belongs to.
|
||||||
*
|
*
|
||||||
* @return The enterprise where the virtual appliance belongs to.
|
* @return The enterprise where the virtual appliance belongs to.
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise"
|
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise"
|
||||||
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-
|
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#
|
||||||
* RetrieveaEnterprise</a>
|
* EnterpriseResource- RetrieveaEnterprise</a>
|
||||||
*/
|
*/
|
||||||
public Enterprise getEnterprise()
|
public Enterprise getEnterprise() {
|
||||||
{
|
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
||||||
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
EnterpriseDto dto = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId);
|
||||||
EnterpriseDto dto = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId);
|
return wrap(context, Enterprise.class, dto);
|
||||||
return wrap(context, Enterprise.class, dto);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current state of the virtual appliance.
|
* Gets the current state of the virtual appliance.
|
||||||
*
|
*
|
||||||
* @return The current state of the virtual appliance.
|
* @return The current state of the virtual appliance.
|
||||||
*/
|
*/
|
||||||
public VirtualApplianceState getState()
|
public VirtualApplianceState getState() {
|
||||||
{
|
VirtualApplianceStateDto stateDto = context.getApi().getCloudApi().getVirtualApplianceState(target);
|
||||||
VirtualApplianceStateDto stateDto =
|
return stateDto.getPower();
|
||||||
context.getApi().getCloudApi().getVirtualApplianceState(target);
|
}
|
||||||
return stateDto.getPower();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Children access
|
// Children access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of virtual machines in the virtual appliance.
|
* Gets the list of virtual machines in the virtual appliance.
|
||||||
*
|
*
|
||||||
* @return The list of virtual machines in the virtual appliance.
|
* @return The list of virtual machines in the virtual appliance.
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource-RetrievethelistofVirtualMachines."
|
* "http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource-RetrievethelistofVirtualMachines."
|
||||||
* >
|
* > http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#
|
||||||
* http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource
|
* VirtualMachineResource -RetrievethelistofVirtualMachines.</a>
|
||||||
* -RetrievethelistofVirtualMachines.</a>
|
*/
|
||||||
*/
|
public List<VirtualMachine> listVirtualMachines() {
|
||||||
public List<VirtualMachine> listVirtualMachines()
|
return listVirtualMachines(VirtualMachineOptions.builder().disablePagination().build());
|
||||||
{
|
}
|
||||||
return listVirtualMachines(VirtualMachineOptions.builder().disablePagination().build());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of virtual machines in the virtual appliance.
|
* Gets the list of virtual machines in the virtual appliance.
|
||||||
*
|
*
|
||||||
* @return The list of virtual machines in the virtual appliance.
|
* @return The list of virtual machines in the virtual appliance.
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource-RetrievethelistofVirtualMachines."
|
* "http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource-RetrievethelistofVirtualMachines."
|
||||||
* >
|
* > http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#
|
||||||
* http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource
|
* VirtualMachineResource -RetrievethelistofVirtualMachines.</a>
|
||||||
* -RetrievethelistofVirtualMachines.</a>
|
*/
|
||||||
*/
|
public List<VirtualMachine> listVirtualMachines(final VirtualMachineOptions options) {
|
||||||
public List<VirtualMachine> listVirtualMachines(final VirtualMachineOptions options)
|
VirtualMachinesWithNodeExtendedDto vms = context.getApi().getCloudApi().listVirtualMachines(target, options);
|
||||||
{
|
return wrap(context, VirtualMachine.class, vms.getCollection());
|
||||||
VirtualMachinesWithNodeExtendedDto vms =
|
}
|
||||||
context.getApi().getCloudApi().listVirtualMachines(target, options);
|
|
||||||
return wrap(context, VirtualMachine.class, vms.getCollection());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of virtual machines in the virtual appliance matching the given filter.
|
* Gets the list of virtual machines in the virtual appliance matching the
|
||||||
*
|
* given filter.
|
||||||
* @param filter The filter to apply.
|
*
|
||||||
* @return The list of virtual machines in the virtual appliance matching the given filter.
|
* @param filter
|
||||||
*/
|
* The filter to apply.
|
||||||
public List<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter)
|
* @return The list of virtual machines in the virtual appliance matching the
|
||||||
{
|
* given filter.
|
||||||
return Lists.newLinkedList(filter(listVirtualMachines(), filter));
|
*/
|
||||||
}
|
public List<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter) {
|
||||||
|
return Lists.newLinkedList(filter(listVirtualMachines(), filter));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a single virtual machine in the virtual appliance matching the given filter.
|
* Gets a single virtual machine in the virtual appliance matching the given
|
||||||
*
|
* filter.
|
||||||
* @param filter The filter to apply.
|
*
|
||||||
* @return The virtual machine or <code>null</code> if none matched the given filter.
|
* @param filter
|
||||||
*/
|
* The filter to apply.
|
||||||
public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter)
|
* @return The virtual machine or <code>null</code> if none matched the given
|
||||||
{
|
* filter.
|
||||||
return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
|
*/
|
||||||
}
|
public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter) {
|
||||||
|
return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a concrete virtual machine in the virtual appliance.
|
* Gets a concrete virtual machine in the virtual appliance.
|
||||||
*
|
*
|
||||||
* @param id The id of the virtual machine.
|
* @param id
|
||||||
* @return The requested virtual machine.
|
* The id of the virtual machine.
|
||||||
*/
|
* @return The requested virtual machine.
|
||||||
public VirtualMachine getVirtualMachine(final Integer id)
|
*/
|
||||||
{
|
public VirtualMachine getVirtualMachine(final Integer id) {
|
||||||
VirtualMachineWithNodeExtendedDto vm =
|
VirtualMachineWithNodeExtendedDto vm = context.getApi().getCloudApi().getVirtualMachine(target, id);
|
||||||
context.getApi().getCloudApi().getVirtualMachine(target, id);
|
return wrap(context, VirtualMachine.class, vm);
|
||||||
return wrap(context, VirtualMachine.class, vm);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deploys the virtual appliance.
|
* Deploys the virtual appliance.
|
||||||
* <p>
|
* <p>
|
||||||
* This method will start the deployment of all the virtual machines in the virtual appliance,
|
* This method will start the deployment of all the virtual machines in the
|
||||||
* and will return an {@link AsyncTask} reference for each deployment operation. The deployment
|
* virtual appliance, and will return an {@link AsyncTask} reference for each
|
||||||
* will finish when all individual tasks finish.
|
* deployment operation. The deployment will finish when all individual tasks
|
||||||
*
|
* finish.
|
||||||
* @return The list of tasks corresponding to the deploy process of each virtual machine in the
|
*
|
||||||
* appliance.
|
* @return The list of tasks corresponding to the deploy process of each
|
||||||
*/
|
* virtual machine in the appliance.
|
||||||
public AsyncTask[] deploy()
|
*/
|
||||||
{
|
public AsyncTask[] deploy() {
|
||||||
return deploy(false);
|
return deploy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deploys the virtual appliance.
|
* Deploys the virtual appliance.
|
||||||
* <p>
|
* <p>
|
||||||
* This method will start the deployment of all the virtual machines in the virtual appliance,
|
* This method will start the deployment of all the virtual machines in the
|
||||||
* and will return an {@link AsyncTask} reference for each deploy operation. The deployment will
|
* virtual appliance, and will return an {@link AsyncTask} reference for each
|
||||||
* finish when all individual tasks finish.
|
* deploy operation. The deployment will finish when all individual tasks
|
||||||
*
|
* finish.
|
||||||
* @param forceEnterpriseSoftLimits Boolean indicating if the deployment must be executed even
|
*
|
||||||
* if the enterprise soft limits are reached.
|
* @param forceEnterpriseSoftLimits
|
||||||
* @return The list of tasks corresponding to the deploy process of each virtual machine in the
|
* Boolean indicating if the deployment must be executed even if
|
||||||
* appliance.
|
* the enterprise soft limits are reached.
|
||||||
*/
|
* @return The list of tasks corresponding to the deploy process of each
|
||||||
public AsyncTask[] deploy(final boolean forceEnterpriseSoftLimits)
|
* virtual machine in the appliance.
|
||||||
{
|
*/
|
||||||
VirtualMachineTaskDto force = new VirtualMachineTaskDto();
|
public AsyncTask[] deploy(final boolean forceEnterpriseSoftLimits) {
|
||||||
force.setForceEnterpriseSoftLimits(forceEnterpriseSoftLimits);
|
VirtualMachineTaskDto force = new VirtualMachineTaskDto();
|
||||||
|
force.setForceEnterpriseSoftLimits(forceEnterpriseSoftLimits);
|
||||||
|
|
||||||
AcceptedRequestDto<String> response =
|
AcceptedRequestDto<String> response = context.getApi().getCloudApi().deployVirtualAppliance(unwrap(), force);
|
||||||
context.getApi().getCloudApi().deployVirtualAppliance(unwrap(), force);
|
|
||||||
|
|
||||||
return getTasks(response);
|
return getTasks(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undeploys the virtual appliance.
|
* Undeploys the virtual appliance.
|
||||||
* <p>
|
* <p>
|
||||||
* This method will start the undeploy of all the virtual machines in the virtual appliance, and
|
* This method will start the undeploy of all the virtual machines in the
|
||||||
* will return an {@link AsyncTask} reference for each undeploy operation. The undeploy will
|
* virtual appliance, and will return an {@link AsyncTask} reference for each
|
||||||
* finish when all individual tasks finish.
|
* undeploy operation. The undeploy will finish when all individual tasks
|
||||||
*
|
* finish.
|
||||||
* @return The list of tasks corresponding to the undeploy process of each virtual machine in
|
*
|
||||||
* the appliance.
|
* @return The list of tasks corresponding to the undeploy process of each
|
||||||
*/
|
* virtual machine in the appliance.
|
||||||
public AsyncTask[] undeploy()
|
*/
|
||||||
{
|
public AsyncTask[] undeploy() {
|
||||||
return undeploy(false);
|
return undeploy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undeploys the virtual appliance.
|
* Undeploys the virtual appliance.
|
||||||
* <p>
|
* <p>
|
||||||
* This method will start the undeploy of all the virtual machines in the virtual appliance, and
|
* This method will start the undeploy of all the virtual machines in the
|
||||||
* will return an {@link AsyncTask} reference for each undeploy operation. The undeploy will
|
* virtual appliance, and will return an {@link AsyncTask} reference for each
|
||||||
* finish when all individual tasks finish.
|
* undeploy operation. The undeploy will finish when all individual tasks
|
||||||
*
|
* finish.
|
||||||
* @param forceUndeploy Boolean flag to force the undeploy even if the virtual appliance
|
*
|
||||||
* contains imported virtual machines.
|
* @param forceUndeploy
|
||||||
* @return The list of tasks corresponding to the undeploy process of each virtual machine in
|
* Boolean flag to force the undeploy even if the virtual appliance
|
||||||
* the appliance.
|
* contains imported virtual machines.
|
||||||
*/
|
* @return The list of tasks corresponding to the undeploy process of each
|
||||||
public AsyncTask[] undeploy(final boolean forceUndeploy)
|
* virtual machine in the appliance.
|
||||||
{
|
*/
|
||||||
VirtualMachineTaskDto force = new VirtualMachineTaskDto();
|
public AsyncTask[] undeploy(final boolean forceUndeploy) {
|
||||||
force.setForceUndeploy(forceUndeploy);
|
VirtualMachineTaskDto force = new VirtualMachineTaskDto();
|
||||||
|
force.setForceUndeploy(forceUndeploy);
|
||||||
|
|
||||||
AcceptedRequestDto<String> response =
|
AcceptedRequestDto<String> response = context.getApi().getCloudApi().undeployVirtualAppliance(unwrap(), force);
|
||||||
context.getApi().getCloudApi().undeployVirtualAppliance(unwrap(), force);
|
|
||||||
|
|
||||||
return getTasks(response);
|
return getTasks(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a String message with the price info of the virtual appliance.
|
* Returns a String message with the price info of the virtual appliance.
|
||||||
*
|
*
|
||||||
* @return The price of the virtual appliance
|
* @return The price of the virtual appliance
|
||||||
*/
|
*/
|
||||||
public String getPrice()
|
public String getPrice() {
|
||||||
{
|
return context.getApi().getCloudApi().getVirtualAppliancePrice(target);
|
||||||
return context.getApi().getCloudApi().getVirtualAppliancePrice(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final VirtualDatacenter virtualDatacenter)
|
final VirtualDatacenter virtualDatacenter) {
|
||||||
{
|
return new Builder(context, virtualDatacenter);
|
||||||
return new Builder(context, virtualDatacenter);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private VirtualDatacenter virtualDatacenter;
|
private VirtualDatacenter virtualDatacenter;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final VirtualDatacenter virtualDatacenter) {
|
||||||
final VirtualDatacenter virtualDatacenter)
|
super();
|
||||||
{
|
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class);
|
||||||
super();
|
this.virtualDatacenter = virtualDatacenter;
|
||||||
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE
|
this.context = context;
|
||||||
+ VirtualDatacenter.class);
|
}
|
||||||
this.virtualDatacenter = virtualDatacenter;
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder virtualDatacenter(final VirtualDatacenter virtualDatacenter)
|
public Builder virtualDatacenter(final VirtualDatacenter virtualDatacenter) {
|
||||||
{
|
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class);
|
||||||
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE
|
this.virtualDatacenter = virtualDatacenter;
|
||||||
+ VirtualDatacenter.class);
|
return this;
|
||||||
this.virtualDatacenter = virtualDatacenter;
|
}
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualAppliance build()
|
public VirtualAppliance build() {
|
||||||
{
|
VirtualApplianceDto dto = new VirtualApplianceDto();
|
||||||
VirtualApplianceDto dto = new VirtualApplianceDto();
|
dto.setName(name);
|
||||||
dto.setName(name);
|
|
||||||
|
|
||||||
VirtualAppliance virtualAppliance = new VirtualAppliance(context, dto);
|
VirtualAppliance virtualAppliance = new VirtualAppliance(context, dto);
|
||||||
virtualAppliance.virtualDatacenter = virtualDatacenter;
|
virtualAppliance.virtualDatacenter = virtualDatacenter;
|
||||||
|
|
||||||
return virtualAppliance;
|
return virtualAppliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromVirtualAppliance(final VirtualAppliance in)
|
public static Builder fromVirtualAppliance(final VirtualAppliance in) {
|
||||||
{
|
return VirtualAppliance.builder(in.context, in.virtualDatacenter).name(in.getName());
|
||||||
return VirtualAppliance.builder(in.context, in.virtualDatacenter).name(in.getName());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public int getError()
|
public int getError() {
|
||||||
{
|
return target.getError();
|
||||||
return target.getError();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getHighDisponibility()
|
public int getHighDisponibility() {
|
||||||
{
|
return target.getHighDisponibility();
|
||||||
return target.getHighDisponibility();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getPublicApp()
|
public int getPublicApp() {
|
||||||
{
|
return target.getPublicApp();
|
||||||
return target.getPublicApp();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setHighDisponibility(final int highDisponibility)
|
public void setHighDisponibility(final int highDisponibility) {
|
||||||
{
|
target.setHighDisponibility(highDisponibility);
|
||||||
target.setHighDisponibility(highDisponibility);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicApp(final int publicApp)
|
public void setPublicApp(final int publicApp) {
|
||||||
{
|
target.setPublicApp(publicApp);
|
||||||
target.setPublicApp(publicApp);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "VirtualAppliance [id=" + getId() + ", name=" + getName() + "]";
|
||||||
return "VirtualAppliance [id=" + getId() + ", name=" + getName() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -65,353 +65,316 @@ import com.google.inject.TypeLiteral;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource">
|
* @see API: <a href=
|
||||||
* http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource</a>
|
* "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>
|
public class VirtualMachineTemplate extends DomainWrapper<VirtualMachineTemplateDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected VirtualMachineTemplate(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
protected VirtualMachineTemplate(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
final VirtualMachineTemplateDto target) {
|
||||||
final VirtualMachineTemplateDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getVirtualMachineTemplateApi().deleteVirtualMachineTemplate(target);
|
||||||
context.getApi().getVirtualMachineTemplateApi().deleteVirtualMachineTemplate(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
target = context.getApi().getVirtualMachineTemplateApi().updateVirtualMachineTemplate(target);
|
||||||
target =
|
}
|
||||||
context.getApi().getVirtualMachineTemplateApi().updateVirtualMachineTemplate(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*
|
*
|
||||||
* @param vdc
|
* @param vdc
|
||||||
* @param volume
|
* @param volume
|
||||||
* @param persistentTemplateName
|
* @param persistentTemplateName
|
||||||
* @param persistentVolumeName
|
* @param persistentVolumeName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public AsyncTask makePersistent(final VirtualDatacenter vdc, final Volume volume,
|
public AsyncTask makePersistent(final VirtualDatacenter vdc, final Volume volume, final String persistentTemplateName) {
|
||||||
final String persistentTemplateName)
|
RESTLink storageLink = volume.unwrap().getEditLink();
|
||||||
{
|
storageLink.setRel("volume");
|
||||||
RESTLink storageLink = volume.unwrap().getEditLink();
|
return makePeristent(vdc, storageLink, persistentTemplateName, null);
|
||||||
storageLink.setRel("volume");
|
}
|
||||||
return makePeristent(vdc, storageLink, persistentTemplateName, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AsyncTask makePersistent(final VirtualDatacenter vdc, final Tier tier,
|
public AsyncTask makePersistent(final VirtualDatacenter vdc, final Tier tier, final String persistentTemplateName,
|
||||||
final String persistentTemplateName, final String persistentVolumeName)
|
final String persistentVolumeName) {
|
||||||
{
|
// infrastructure
|
||||||
// infrastructure
|
RESTLink storageLink = tier.unwrap().getEditLink();
|
||||||
RESTLink storageLink = tier.unwrap().getEditLink();
|
if (storageLink == null) {
|
||||||
if (storageLink == null)
|
// cloud
|
||||||
{
|
storageLink = tier.unwrap().searchLink("self");
|
||||||
// cloud
|
}
|
||||||
storageLink = tier.unwrap().searchLink("self");
|
storageLink.setRel(ParentLinkName.TIER);
|
||||||
}
|
return makePeristent(vdc, storageLink, persistentTemplateName, persistentVolumeName);
|
||||||
storageLink.setRel(ParentLinkName.TIER);
|
}
|
||||||
return makePeristent(vdc, storageLink, persistentTemplateName, persistentVolumeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AsyncTask makePeristent(final VirtualDatacenter vdc, final RESTLink storageLink,
|
private AsyncTask makePeristent(final VirtualDatacenter vdc, final RESTLink storageLink,
|
||||||
final String persistentTemplateName, final String persistentVolumeName)
|
final String persistentTemplateName, final String persistentVolumeName) {
|
||||||
{
|
VirtualMachineTemplatePersistentDto persistentData = new VirtualMachineTemplatePersistentDto();
|
||||||
VirtualMachineTemplatePersistentDto persistentData =
|
persistentData.setPersistentTemplateName(persistentTemplateName);
|
||||||
new VirtualMachineTemplatePersistentDto();
|
persistentData.setPersistentVolumeName(persistentVolumeName);
|
||||||
persistentData.setPersistentTemplateName(persistentTemplateName);
|
RESTLink vdcLink = new RESTLink(ParentLinkName.VIRTUAL_DATACENTER, vdc.unwrap().getEditLink().getHref());
|
||||||
persistentData.setPersistentVolumeName(persistentVolumeName);
|
RESTLink templateLink = new RESTLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE, target.getEditLink().getHref());
|
||||||
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(vdcLink);
|
||||||
persistentData.addLink(storageLink);
|
persistentData.addLink(storageLink);
|
||||||
persistentData.addLink(templateLink);
|
persistentData.addLink(templateLink);
|
||||||
|
|
||||||
// SCG:
|
// SCG:
|
||||||
// A simple user should not have permissions to obtain a datacenter repository, but at this
|
// A simple user should not have permissions to obtain a datacenter
|
||||||
// point we have the datacenter repository and enterprise ids in the own target uri. So we
|
// repository, but at this
|
||||||
// can obtain the path where do the POST
|
// point we have the datacenter repository and enterprise ids in the own
|
||||||
// Assumption that to create a new object a user needs to get the parent object cannot be
|
// target uri. So we
|
||||||
// applied in this case
|
// can obtain the path where do the POST
|
||||||
String editUri = getURI().getPath();
|
// Assumption that to create a new object a user needs to get the parent
|
||||||
Pattern p = Pattern.compile("\\d+");
|
// object cannot be
|
||||||
Matcher m = p.matcher(editUri);
|
// applied in this case
|
||||||
m.find();
|
String editUri = getURI().getPath();
|
||||||
Integer idEnt = new Integer(m.group());
|
Pattern p = Pattern.compile("\\d+");
|
||||||
m.find();
|
Matcher m = p.matcher(editUri);
|
||||||
Integer idDcRepo = new Integer(m.group());
|
m.find();
|
||||||
|
Integer idEnt = new Integer(m.group());
|
||||||
|
m.find();
|
||||||
|
Integer idDcRepo = new Integer(m.group());
|
||||||
|
|
||||||
AcceptedRequestDto<String> response =
|
AcceptedRequestDto<String> response = context.getApi().getVirtualMachineTemplateApi()
|
||||||
context.getApi().getVirtualMachineTemplateApi()
|
.createPersistentVirtualMachineTemplate(idEnt, idDcRepo, persistentData);
|
||||||
.createPersistentVirtualMachineTemplate(idEnt, idDcRepo, persistentData);
|
|
||||||
|
|
||||||
return getTask(response);
|
return getTask(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Children access
|
// Children access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Retrieveacategory"
|
* "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Retrieveacategory"
|
||||||
* > http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-
|
* > http://community.abiquo.com/display/ABI20/Category+Resource#
|
||||||
* Retrieveacategory</a>
|
* CategoryResource- Retrieveacategory</a>
|
||||||
*/
|
*/
|
||||||
public Category getCategory()
|
public Category getCategory() {
|
||||||
{
|
Integer categoryId = target.getIdFromLink(ParentLinkName.CATEGORY);
|
||||||
Integer categoryId = target.getIdFromLink(ParentLinkName.CATEGORY);
|
CategoryDto category = context.getApi().getConfigApi().getCategory(categoryId);
|
||||||
CategoryDto category = context.getApi().getConfigApi().getCategory(categoryId);
|
return wrap(context, Category.class, category);
|
||||||
return wrap(context, Category.class, category);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/Abiquo/Volume+Resource#VolumeResource-Retrieveavolume"
|
* "http://community.abiquo.com/display/Abiquo/Volume+Resource#VolumeResource-Retrieveavolume"
|
||||||
* > http://community.abiquo.com/display/Abiquo/Volume+Resource#VolumeResource-
|
* > http://community.abiquo.com/display/Abiquo/Volume+Resource#
|
||||||
* Retrieveavolume</a>
|
* VolumeResource- Retrieveavolume</a>
|
||||||
*/
|
*/
|
||||||
public Volume getVolume()
|
public Volume getVolume() {
|
||||||
{
|
if (this.isPersistent()) {
|
||||||
if (this.isPersistent())
|
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
||||||
{
|
HttpResponse rp = checkNotNull(utils.getAbiquoHttpClient().get(target.searchLink("volume")), "volume");
|
||||||
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
|
||||||
HttpResponse rp =
|
|
||||||
checkNotNull(utils.getAbiquoHttpClient().get(target.searchLink("volume")), "volume");
|
|
||||||
|
|
||||||
ParseXMLWithJAXB<VolumeManagementDto> parser =
|
ParseXMLWithJAXB<VolumeManagementDto> parser = new ParseXMLWithJAXB<VolumeManagementDto>(utils.getXml(),
|
||||||
new ParseXMLWithJAXB<VolumeManagementDto>(utils.getXml(),
|
TypeLiteral.get(VolumeManagementDto.class));
|
||||||
TypeLiteral.get(VolumeManagementDto.class));
|
|
||||||
|
|
||||||
VolumeManagementDto dto = parser.apply(rp);
|
VolumeManagementDto dto = parser.apply(rp);
|
||||||
return new Volume(context, dto);
|
return new Volume(context, dto);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPersistent()
|
public boolean isPersistent() {
|
||||||
{
|
return target.searchLink("volume") != null;
|
||||||
return target.searchLink("volume") != null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveanEnterprise"
|
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveanEnterprise"
|
||||||
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-
|
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#
|
||||||
* RetrieveanEnterprise</a>
|
* EnterpriseResource- RetrieveanEnterprise</a>
|
||||||
*/
|
*/
|
||||||
public Enterprise getEnterprise()
|
public Enterprise getEnterprise() {
|
||||||
{
|
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
||||||
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId));
|
||||||
return wrap(context, Enterprise.class,
|
}
|
||||||
context.getApi().getEnterpriseApi().getEnterprise(enterpriseId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Datacenter+Resource#DatacenterResource-RetrieveaDatacenter"
|
* "http://community.abiquo.com/display/ABI20/Datacenter+Resource#DatacenterResource-RetrieveaDatacenter"
|
||||||
* > http://community.abiquo.com/display/ABI20/Datacenter+Resource#DatacenterResource-
|
* > http://community.abiquo.com/display/ABI20/Datacenter+Resource#
|
||||||
* RetrieveaDatacenter</a>
|
* DatacenterResource- RetrieveaDatacenter</a>
|
||||||
*/
|
*/
|
||||||
public Datacenter getDatacenter()
|
public Datacenter getDatacenter() {
|
||||||
{
|
Integer repositoryId = target.getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY);
|
||||||
Integer repositoryId = target.getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY);
|
return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(repositoryId));
|
||||||
return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi()
|
}
|
||||||
.getDatacenter(repositoryId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all the conversions for the virtual machine template.
|
* List all the conversions for the virtual machine template.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-ListConversions"
|
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-ListConversions"
|
||||||
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-
|
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#
|
||||||
* ListConversions</a>
|
* ConversionResource- ListConversions</a>
|
||||||
* @return all the conversions of the virtual machine template
|
* @return all the conversions of the virtual machine template
|
||||||
*/
|
*/
|
||||||
public List<Conversion> listConversions()
|
public List<Conversion> listConversions() {
|
||||||
{
|
ConversionsDto convs = context.getApi().getVirtualMachineTemplateApi().listConversions(target);
|
||||||
ConversionsDto convs =
|
return wrap(context, Conversion.class, convs.getCollection());
|
||||||
context.getApi().getVirtualMachineTemplateApi().listConversions(target);
|
}
|
||||||
return wrap(context, Conversion.class, convs.getCollection());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all the conversions for the virtual machine template matching the given filter.
|
* List all the conversions for the virtual machine template matching the
|
||||||
*
|
* given filter.
|
||||||
* @param filter The filter to apply.
|
*
|
||||||
* @return The list all the conversions for the virtual machine template matching the given
|
* @param filter
|
||||||
* filter.
|
* The filter to apply.
|
||||||
*/
|
* @return The list all the conversions for the virtual machine template
|
||||||
public List<Conversion> listConversions(final Predicate<Conversion> filter)
|
* matching the given filter.
|
||||||
{
|
*/
|
||||||
return Lists.newLinkedList(filter(listConversions(), filter));
|
public List<Conversion> listConversions(final Predicate<Conversion> filter) {
|
||||||
}
|
return Lists.newLinkedList(filter(listConversions(), filter));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a single conversion in the virtual machine template matching the given filter.
|
* Gets a single conversion in the virtual machine template matching the
|
||||||
*
|
* given filter.
|
||||||
* @param filter The filter to apply.
|
*
|
||||||
* @return The conversion or <code>null</code> if none matched the given filter.
|
* @param filter
|
||||||
*/
|
* The filter to apply.
|
||||||
public Conversion findConversion(final Predicate<Conversion> filter)
|
* @return The conversion or <code>null</code> if none matched the given
|
||||||
{
|
* filter.
|
||||||
return Iterables.getFirst(filter(listConversions(), filter), null);
|
*/
|
||||||
}
|
public Conversion findConversion(final Predicate<Conversion> filter) {
|
||||||
|
return Iterables.getFirst(filter(listConversions(), filter), null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List conversions for a virtual machine template.
|
* List conversions for a virtual machine template.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-ListConversions"
|
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-ListConversions"
|
||||||
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-
|
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#
|
||||||
* ListConversions</a>
|
* ConversionResource- ListConversions</a>
|
||||||
* @param hypervisor, Optionally filter conversions compatible with the provided hypervisor
|
* @param hypervisor
|
||||||
* @param state, Optionally filter conversions with the desired state
|
* , Optionally filter conversions compatible with the provided
|
||||||
* @return all the conversions of the virtual machine template applying the constrains
|
* hypervisor
|
||||||
*/
|
* @param state
|
||||||
public List<Conversion> listConversions(final HypervisorType hypervisor,
|
* , Optionally filter conversions with the desired state
|
||||||
final ConversionState state)
|
* @return all the conversions of the virtual machine template applying the
|
||||||
{
|
* constrains
|
||||||
ConversionsDto convs =
|
*/
|
||||||
context
|
public List<Conversion> listConversions(final HypervisorType hypervisor, final ConversionState state) {
|
||||||
.getApi()
|
ConversionsDto convs = context
|
||||||
.getVirtualMachineTemplateApi()
|
.getApi()
|
||||||
.listConversions(
|
.getVirtualMachineTemplateApi()
|
||||||
target,
|
.listConversions(target,
|
||||||
ConversionOptions.builder().hypervisorType(hypervisor).conversionState(state)
|
ConversionOptions.builder().hypervisorType(hypervisor).conversionState(state).build());
|
||||||
.build());
|
return wrap(context, Conversion.class, convs.getCollection());
|
||||||
return wrap(context, Conversion.class, convs.getCollection());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new conversion for a virtual machine template.
|
* Starts a new conversion for a virtual machine template.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-RequestConversion"
|
* "http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-RequestConversion"
|
||||||
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource-
|
* > http://community.abiquo.com/display/ABI20/Conversion+Resource#
|
||||||
* RequestConversion</a>
|
* ConversionResource- RequestConversion</a>
|
||||||
* @param diskFormat, desired target format for the request template
|
* @param diskFormat
|
||||||
* @return The task reference to track its progress
|
* , desired target format for the request template
|
||||||
*/
|
* @return The task reference to track its progress
|
||||||
public AsyncTask requestConversion(final DiskFormatType diskFormat)
|
*/
|
||||||
{
|
public AsyncTask requestConversion(final DiskFormatType diskFormat) {
|
||||||
ConversionDto request = new ConversionDto();
|
ConversionDto request = new ConversionDto();
|
||||||
request.setTargetFormat(diskFormat);
|
request.setTargetFormat(diskFormat);
|
||||||
|
|
||||||
AcceptedRequestDto<String> taskRef =
|
AcceptedRequestDto<String> taskRef = context.getApi().getVirtualMachineTemplateApi()
|
||||||
context.getApi().getVirtualMachineTemplateApi()
|
.requestConversion(target, diskFormat, request);
|
||||||
.requestConversion(target, diskFormat, request);
|
|
||||||
|
|
||||||
return taskRef == null ? null : getTask(taskRef);
|
return taskRef == null ? null : getTask(taskRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CostCode getCostCode()
|
public CostCode getCostCode() {
|
||||||
{
|
Integer costcodeId = target.getIdFromLink(ParentLinkName.COST_CODE);
|
||||||
Integer costcodeId = target.getIdFromLink(ParentLinkName.COST_CODE);
|
CostCodeDto costcode = context.getApi().getPricingApi().getCostCode(costcodeId);
|
||||||
CostCodeDto costcode = context.getApi().getPricingApi().getCostCode(costcodeId);
|
return wrap(context, CostCode.class, costcode);
|
||||||
return wrap(context, CostCode.class, costcode);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public int getCpuRequired()
|
public int getCpuRequired() {
|
||||||
{
|
return target.getCpuRequired();
|
||||||
return target.getCpuRequired();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreationDate()
|
public Date getCreationDate() {
|
||||||
{
|
return target.getCreationDate();
|
||||||
return target.getCreationDate();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreationUser()
|
public String getCreationUser() {
|
||||||
{
|
return target.getCreationUser();
|
||||||
return target.getCreationUser();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getDiskFileSize()
|
public long getDiskFileSize() {
|
||||||
{
|
return target.getDiskFileSize();
|
||||||
return target.getDiskFileSize();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public DiskFormatType getDiskFormatType()
|
public DiskFormatType getDiskFormatType() {
|
||||||
{
|
return DiskFormatType.valueOf(target.getDiskFormatType());
|
||||||
return DiskFormatType.valueOf(target.getDiskFormatType());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getHdRequired()
|
public long getHdRequired() {
|
||||||
{
|
return target.getHdRequired();
|
||||||
return target.getHdRequired();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getPath()
|
public String getPath() {
|
||||||
{
|
return target.getPath();
|
||||||
return target.getPath();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getRamRequired()
|
public int getRamRequired() {
|
||||||
{
|
return target.getRamRequired();
|
||||||
return target.getRamRequired();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChefEnabled()
|
public boolean isChefEnabled() {
|
||||||
{
|
return target.isChefEnabled();
|
||||||
return target.isChefEnabled();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setChefEnabled(final boolean chefEnabled)
|
public void setChefEnabled(final boolean chefEnabled) {
|
||||||
{
|
target.setChefEnabled(chefEnabled);
|
||||||
target.setChefEnabled(chefEnabled);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getIconUrl()
|
public String getIconUrl() {
|
||||||
{
|
return target.getIconUrl();
|
||||||
return target.getIconUrl();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "VirtualMachineTemplate [id=" + getId() + ", cpuRequired=" + getCpuRequired() + ", creationDate="
|
||||||
return "VirtualMachineTemplate [id=" + getId() + ", cpuRequired=" + getCpuRequired()
|
+ getCreationDate() + ", creationUser=" + getCreationUser() + ", description=" + getDescription()
|
||||||
+ ", creationDate=" + getCreationDate() + ", creationUser=" + getCreationUser()
|
+ ", diskFileSize=" + getDiskFileSize() + ", diskFormatType=" + getDiskFormatType() + ", hdRequired="
|
||||||
+ ", description=" + getDescription() + ", diskFileSize=" + getDiskFileSize()
|
+ getHdRequired() + ", name=" + getName() + ", path=" + getPath() + ", ramRequired=" + getRamRequired()
|
||||||
+ ", diskFormatType=" + getDiskFormatType() + ", hdRequired=" + getHdRequired()
|
|
||||||
+ ", name=" + getName() + ", path=" + getPath() + ", ramRequired=" + getRamRequired()
|
|
||||||
+ ", chefEnabled=" + isChefEnabled() + "]";
|
+ ", chefEnabled=" + isChefEnabled() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,33 +21,28 @@ package org.jclouds.abiquo.domain.cloud;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper to hold the information of a virtual machine template scoped to a concrete hypervisor
|
* Wrapper to hold the information of a virtual machine template scoped to a
|
||||||
* type.
|
* concrete hypervisor type.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class VirtualMachineTemplateInVirtualDatacenter
|
public class VirtualMachineTemplateInVirtualDatacenter {
|
||||||
{
|
private VirtualMachineTemplate template;
|
||||||
private VirtualMachineTemplate template;
|
|
||||||
|
|
||||||
private VirtualDatacenter zone;
|
private VirtualDatacenter zone;
|
||||||
|
|
||||||
public VirtualMachineTemplateInVirtualDatacenter(final VirtualMachineTemplate template,
|
public VirtualMachineTemplateInVirtualDatacenter(final VirtualMachineTemplate template, final VirtualDatacenter zone) {
|
||||||
final VirtualDatacenter zone)
|
super();
|
||||||
{
|
this.template = checkNotNull(template, "template");
|
||||||
super();
|
this.zone = checkNotNull(zone, "zone");
|
||||||
this.template = checkNotNull(template, "template");
|
}
|
||||||
this.zone = checkNotNull(zone, "zone");
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualMachineTemplate getTemplate()
|
public VirtualMachineTemplate getTemplate() {
|
||||||
{
|
return template;
|
||||||
return template;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualDatacenter getZone()
|
public VirtualDatacenter getZone() {
|
||||||
{
|
return zone;
|
||||||
return zone;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,209 +42,183 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
||||||
* Adds high level functionality to {@link VolumeManagementDto}.
|
* Adds high level functionality to {@link VolumeManagementDto}.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Volume+Resource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/Volume+Resource">
|
||||||
* http://community.abiquo.com/display/ABI20/Volume+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Volume+Resource</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class Volume extends DomainWrapper<VolumeManagementDto>
|
public class Volume extends DomainWrapper<VolumeManagementDto> {
|
||||||
{
|
/** The default state for folumes. */
|
||||||
/** The default state for folumes. */
|
public static final VolumeState DEFAULT_STATE = VolumeState.DETACHED;
|
||||||
public static final VolumeState DEFAULT_STATE = VolumeState.DETACHED;
|
|
||||||
|
|
||||||
/** The virtual datacenter where the volume belongs. */
|
/** The virtual datacenter where the volume belongs. */
|
||||||
private VirtualDatacenter virtualDatacenter;
|
private VirtualDatacenter virtualDatacenter;
|
||||||
|
|
||||||
/** The tier where the volume belongs. */
|
/** The tier where the volume belongs. */
|
||||||
private Tier tier;
|
private Tier tier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected Volume(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final VolumeManagementDto target)
|
protected Volume(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final VolumeManagementDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getCloudApi().deleteVolume(target);
|
||||||
context.getApi().getCloudApi().deleteVolume(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
target = context.getApi().getCloudApi().createVolume(virtualDatacenter.unwrap(), target);
|
||||||
target = context.getApi().getCloudApi().createVolume(virtualDatacenter.unwrap(), target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public AsyncTask update()
|
public AsyncTask update() {
|
||||||
{
|
AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi().updateVolume(target);
|
||||||
AcceptedRequestDto<String> taskRef = context.getApi().getCloudApi().updateVolume(target);
|
return taskRef == null ? null : getTask(taskRef);
|
||||||
return taskRef == null ? null : getTask(taskRef);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @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"
|
||||||
* > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource#
|
* > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+
|
||||||
* VirtualDatacenterResource-RetrieveaVirtualDatacenter</a>
|
* Resource# VirtualDatacenterResource-RetrieveaVirtualDatacenter</a>
|
||||||
*/
|
*/
|
||||||
public VirtualDatacenter getVirtualDatacenter()
|
public VirtualDatacenter getVirtualDatacenter() {
|
||||||
{
|
Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
|
||||||
Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER);
|
VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
|
||||||
VirtualDatacenterDto dto =
|
virtualDatacenter = wrap(context, VirtualDatacenter.class, dto);
|
||||||
context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
|
return virtualDatacenter;
|
||||||
virtualDatacenter = wrap(context, VirtualDatacenter.class, dto);
|
}
|
||||||
return virtualDatacenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO javadoc link
|
* TODO javadoc link
|
||||||
*/
|
*/
|
||||||
public Tier getTier()
|
public Tier getTier() {
|
||||||
{
|
Integer tierId = target.getIdFromLink(ParentLinkName.TIER);
|
||||||
Integer tierId = target.getIdFromLink(ParentLinkName.TIER);
|
TierDto dto = context.getApi().getCloudApi().getStorageTier(virtualDatacenter.unwrap(), tierId);
|
||||||
TierDto dto =
|
tier = wrap(context, Tier.class, dto);
|
||||||
context.getApi().getCloudApi().getStorageTier(virtualDatacenter.unwrap(), tierId);
|
return tier;
|
||||||
tier = wrap(context, Tier.class, dto);
|
}
|
||||||
return tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the volume to the given virtual datacenter.
|
* Move the volume to the given virtual datacenter.
|
||||||
*
|
*
|
||||||
* @param newVirtualDatacenter The destination virtual datacenter.
|
* @param newVirtualDatacenter
|
||||||
*/
|
* The destination virtual datacenter.
|
||||||
public void moveTo(final VirtualDatacenter newVirtualDatacenter)
|
*/
|
||||||
{
|
public void moveTo(final VirtualDatacenter newVirtualDatacenter) {
|
||||||
target =
|
target = context.getApi().getCloudApi().moveVolume(unwrap(), newVirtualDatacenter.unwrap());
|
||||||
context.getApi().getCloudApi().moveVolume(unwrap(), newVirtualDatacenter.unwrap());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final VirtualDatacenter virtualDatacenter, final Tier tier)
|
final VirtualDatacenter virtualDatacenter, final Tier tier) {
|
||||||
{
|
return new Builder(context, virtualDatacenter, tier);
|
||||||
return new Builder(context, virtualDatacenter, tier);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private Long sizeInMb;
|
private Long sizeInMb;
|
||||||
|
|
||||||
private VirtualDatacenter virtualDatacenter;
|
private VirtualDatacenter virtualDatacenter;
|
||||||
|
|
||||||
private Tier tier;
|
private Tier tier;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final VirtualDatacenter virtualDatacenter,
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final VirtualDatacenter virtualDatacenter,
|
||||||
final Tier tier)
|
final Tier tier) {
|
||||||
{
|
super();
|
||||||
super();
|
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class);
|
||||||
checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE
|
checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class);
|
||||||
+ VirtualDatacenter.class);
|
this.context = context;
|
||||||
checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class);
|
this.virtualDatacenter = virtualDatacenter;
|
||||||
this.context = context;
|
this.tier = tier;
|
||||||
this.virtualDatacenter = virtualDatacenter;
|
}
|
||||||
this.tier = tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder description(final String description)
|
public Builder description(final String description) {
|
||||||
{
|
this.description = description;
|
||||||
this.description = description;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder sizeInMb(final long sizeInMb)
|
public Builder sizeInMb(final long sizeInMb) {
|
||||||
{
|
this.sizeInMb = sizeInMb;
|
||||||
this.sizeInMb = sizeInMb;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Volume build()
|
public Volume build() {
|
||||||
{
|
VolumeManagementDto dto = new VolumeManagementDto();
|
||||||
VolumeManagementDto dto = new VolumeManagementDto();
|
dto.setName(name);
|
||||||
dto.setName(name);
|
dto.setDescription(description);
|
||||||
dto.setDescription(description);
|
dto.setSizeInMB(sizeInMb);
|
||||||
dto.setSizeInMB(sizeInMb);
|
dto.setState(DEFAULT_STATE.name());
|
||||||
dto.setState(DEFAULT_STATE.name());
|
|
||||||
|
|
||||||
RESTLink link = tier.unwrap().searchLink("self");
|
RESTLink link = tier.unwrap().searchLink("self");
|
||||||
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
||||||
dto.addLink(new RESTLink("tier", link.getHref()));
|
dto.addLink(new RESTLink("tier", link.getHref()));
|
||||||
|
|
||||||
Volume volume = new Volume(context, dto);
|
Volume volume = new Volume(context, dto);
|
||||||
volume.virtualDatacenter = virtualDatacenter;
|
volume.virtualDatacenter = virtualDatacenter;
|
||||||
volume.tier = tier;
|
volume.tier = tier;
|
||||||
|
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getState()
|
public String getState() {
|
||||||
{
|
return target.getState();
|
||||||
return target.getState();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getSizeInMB()
|
public long getSizeInMB() {
|
||||||
{
|
return target.getSizeInMB();
|
||||||
return target.getSizeInMB();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setSizeInMB(final long sizeInMB)
|
public void setSizeInMB(final long sizeInMB) {
|
||||||
{
|
target.setSizeInMB(sizeInMB);
|
||||||
target.setSizeInMB(sizeInMB);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(final String description)
|
public void setDescription(final String description) {
|
||||||
{
|
target.setDescription(description);
|
||||||
target.setDescription(description);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Volume [id=" + getId() + ", state=" + getState() + ", name=" + getName() + ", sizeInMB=" + getSizeInMB()
|
||||||
return "Volume [id=" + getId() + ", state=" + getState() + ", name=" + getName()
|
+ ", description=" + getDescription() + "]";
|
||||||
+ ", sizeInMB=" + getSizeInMB() + ", description=" + getDescription() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,56 +27,47 @@ import com.abiquo.model.enumerator.HypervisorType;
|
||||||
/**
|
/**
|
||||||
* Available options to filter virtual machine template conversions
|
* Available options to filter virtual machine template conversions
|
||||||
*/
|
*/
|
||||||
public class ConversionOptions extends BaseHttpRequestOptions
|
public class ConversionOptions extends BaseHttpRequestOptions {
|
||||||
{
|
|
||||||
|
|
||||||
public static Builder builder()
|
public static Builder builder() {
|
||||||
{
|
return new Builder();
|
||||||
return new Builder();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
ConversionOptions options = new ConversionOptions();
|
||||||
ConversionOptions options = new ConversionOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private HypervisorType hypervisorType;
|
||||||
private HypervisorType hypervisorType;
|
|
||||||
|
|
||||||
private ConversionState conversionState;
|
private ConversionState conversionState;
|
||||||
|
|
||||||
/** Only conversions compatible with this hypervisor */
|
/** Only conversions compatible with this hypervisor */
|
||||||
public Builder hypervisorType(final HypervisorType hypervisorType)
|
public Builder hypervisorType(final HypervisorType hypervisorType) {
|
||||||
{
|
this.hypervisorType = hypervisorType;
|
||||||
this.hypervisorType = hypervisorType;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** Only conversions with the provided state */
|
/** Only conversions with the provided state */
|
||||||
public Builder conversionState(final ConversionState conversionState)
|
public Builder conversionState(final ConversionState conversionState) {
|
||||||
{
|
this.conversionState = conversionState;
|
||||||
this.conversionState = conversionState;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public ConversionOptions build()
|
public ConversionOptions build() {
|
||||||
{
|
ConversionOptions options = new ConversionOptions();
|
||||||
ConversionOptions options = new ConversionOptions();
|
|
||||||
|
|
||||||
if (hypervisorType != null)
|
if (hypervisorType != null) {
|
||||||
{
|
options.queryParameters.put("hypervisor", hypervisorType.name());
|
||||||
options.queryParameters.put("hypervisor", hypervisorType.name());
|
}
|
||||||
}
|
if (conversionState != null) {
|
||||||
if (conversionState != null)
|
options.queryParameters.put("state", conversionState.name());
|
||||||
{
|
}
|
||||||
options.queryParameters.put("state", conversionState.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,42 +27,35 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class VirtualApplianceOptions extends BaseHttpRequestOptions
|
public class VirtualApplianceOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
VirtualApplianceOptions options = new VirtualApplianceOptions();
|
||||||
VirtualApplianceOptions options = new VirtualApplianceOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
|
||||||
|
|
||||||
private Boolean available;
|
private Boolean available;
|
||||||
|
|
||||||
public Builder available(final boolean available)
|
public Builder available(final boolean available) {
|
||||||
{
|
this.available = available;
|
||||||
this.available = available;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualApplianceOptions build()
|
public VirtualApplianceOptions build() {
|
||||||
{
|
VirtualApplianceOptions options = new VirtualApplianceOptions();
|
||||||
VirtualApplianceOptions options = new VirtualApplianceOptions();
|
|
||||||
|
|
||||||
if (available != null)
|
if (available != null) {
|
||||||
{
|
options.queryParameters.put("available", String.valueOf(available));
|
||||||
options.queryParameters.put("available", String.valueOf(available));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,59 +26,50 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public class VirtualDatacenterOptions extends BaseHttpRequestOptions
|
public class VirtualDatacenterOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
VirtualDatacenterOptions options = new VirtualDatacenterOptions();
|
||||||
VirtualDatacenterOptions options = new VirtualDatacenterOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private Integer datacenterId;
|
||||||
private Integer datacenterId;
|
|
||||||
|
|
||||||
private Integer enterpriseId;
|
private Integer enterpriseId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the optional datacenter.
|
* Set the optional datacenter.
|
||||||
*/
|
*/
|
||||||
public Builder datacenterId(final int datacenterId)
|
public Builder datacenterId(final int datacenterId) {
|
||||||
{
|
this.datacenterId = datacenterId;
|
||||||
this.datacenterId = datacenterId;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the optional enterprise.
|
* Set the optional enterprise.
|
||||||
*/
|
*/
|
||||||
public Builder enterpriseId(final int enterpriseId)
|
public Builder enterpriseId(final int enterpriseId) {
|
||||||
{
|
this.enterpriseId = enterpriseId;
|
||||||
this.enterpriseId = enterpriseId;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualDatacenterOptions build()
|
public VirtualDatacenterOptions build() {
|
||||||
{
|
VirtualDatacenterOptions options = new VirtualDatacenterOptions();
|
||||||
VirtualDatacenterOptions options = new VirtualDatacenterOptions();
|
|
||||||
|
|
||||||
if (datacenterId != null)
|
if (datacenterId != null) {
|
||||||
{
|
options.queryParameters.put("datacenter", datacenterId.toString());
|
||||||
options.queryParameters.put("datacenter", datacenterId.toString());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (enterpriseId != null)
|
if (enterpriseId != null) {
|
||||||
{
|
options.queryParameters.put("enterprise", enterpriseId.toString());
|
||||||
options.queryParameters.put("enterprise", enterpriseId.toString());
|
}
|
||||||
}
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,41 +27,34 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
*
|
*
|
||||||
* @author Alessia Prete
|
* @author Alessia Prete
|
||||||
*/
|
*/
|
||||||
public class VirtualMachineOptions extends BaseHttpRequestOptions
|
public class VirtualMachineOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
VirtualMachineOptions options = new VirtualMachineOptions();
|
||||||
VirtualMachineOptions options = new VirtualMachineOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder extends BaseFilterOptionsBuilder<Builder>
|
public static class Builder extends BaseFilterOptionsBuilder<Builder> {
|
||||||
{
|
private Boolean force;
|
||||||
private Boolean force;
|
|
||||||
|
|
||||||
public Builder force(final Boolean force)
|
public Builder force(final Boolean force) {
|
||||||
{
|
this.force = force;
|
||||||
this.force = force;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualMachineOptions build()
|
public VirtualMachineOptions build() {
|
||||||
{
|
VirtualMachineOptions options = new VirtualMachineOptions();
|
||||||
VirtualMachineOptions options = new VirtualMachineOptions();
|
|
||||||
|
|
||||||
if (force != null)
|
if (force != null) {
|
||||||
{
|
options.queryParameters.put("force", String.valueOf(force));
|
||||||
options.queryParameters.put("force", String.valueOf(force));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return addFilterOptions(options);
|
return addFilterOptions(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,91 +30,76 @@ import com.abiquo.model.enumerator.StatefulInclusion;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class VirtualMachineTemplateOptions extends BaseHttpRequestOptions
|
public class VirtualMachineTemplateOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions();
|
||||||
VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private StatefulInclusion persistent;
|
||||||
private StatefulInclusion persistent;
|
|
||||||
|
|
||||||
private HypervisorType hypervisorType;
|
private HypervisorType hypervisorType;
|
||||||
|
|
||||||
private Category category;
|
private Category category;
|
||||||
|
|
||||||
private String categoryName;
|
private String categoryName;
|
||||||
|
|
||||||
private Integer idTemplate;
|
private Integer idTemplate;
|
||||||
|
|
||||||
public Builder persistent(final StatefulInclusion persistent)
|
public Builder persistent(final StatefulInclusion persistent) {
|
||||||
{
|
this.persistent = persistent;
|
||||||
this.persistent = persistent;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder hypervisorType(final HypervisorType hypervisorType)
|
public Builder hypervisorType(final HypervisorType hypervisorType) {
|
||||||
{
|
this.hypervisorType = hypervisorType;
|
||||||
this.hypervisorType = hypervisorType;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder category(final Category category)
|
public Builder category(final Category category) {
|
||||||
{
|
this.category = category;
|
||||||
this.category = category;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder categoryName(final String categoryName)
|
public Builder categoryName(final String categoryName) {
|
||||||
{
|
this.categoryName = categoryName;
|
||||||
this.categoryName = categoryName;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder idTemplate(final Integer idTemplate)
|
public Builder idTemplate(final Integer idTemplate) {
|
||||||
{
|
this.idTemplate = idTemplate;
|
||||||
this.idTemplate = idTemplate;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualMachineTemplateOptions build()
|
public VirtualMachineTemplateOptions build() {
|
||||||
{
|
VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions();
|
||||||
VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions();
|
|
||||||
|
|
||||||
if (persistent != null)
|
if (persistent != null) {
|
||||||
{
|
options.queryParameters.put("stateful", persistent.name());
|
||||||
options.queryParameters.put("stateful", persistent.name());
|
}
|
||||||
}
|
if (hypervisorType != null) {
|
||||||
if (hypervisorType != null)
|
options.queryParameters.put("hypervisorTypeName", hypervisorType.name());
|
||||||
{
|
}
|
||||||
options.queryParameters.put("hypervisorTypeName", hypervisorType.name());
|
if (category != null) {
|
||||||
}
|
options.queryParameters.put("categoryName", category.getName());
|
||||||
if (category != null)
|
}
|
||||||
{
|
|
||||||
options.queryParameters.put("categoryName", category.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (category == null && categoryName != null)
|
if (category == null && categoryName != null) {
|
||||||
{
|
options.queryParameters.put("categoryName", categoryName);
|
||||||
options.queryParameters.put("categoryName", categoryName);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (idTemplate != null)
|
if (idTemplate != null) {
|
||||||
{
|
options.queryParameters.put("idTemplate", String.valueOf(idTemplate));
|
||||||
options.queryParameters.put("idTemplate", String.valueOf(idTemplate));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,41 +29,34 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class VolumeOptions extends BaseHttpRequestOptions
|
public class VolumeOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
VolumeOptions options = new VolumeOptions();
|
||||||
VolumeOptions options = new VolumeOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder extends BaseFilterOptionsBuilder<Builder>
|
public static class Builder extends BaseFilterOptionsBuilder<Builder> {
|
||||||
{
|
private Boolean onlyAvailable;
|
||||||
private Boolean onlyAvailable;
|
|
||||||
|
|
||||||
public Builder onlyAvailable(final boolean onlyAvailable)
|
public Builder onlyAvailable(final boolean onlyAvailable) {
|
||||||
{
|
this.onlyAvailable = onlyAvailable;
|
||||||
this.onlyAvailable = onlyAvailable;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeOptions build()
|
public VolumeOptions build() {
|
||||||
{
|
VolumeOptions options = new VolumeOptions();
|
||||||
VolumeOptions options = new VolumeOptions();
|
|
||||||
|
|
||||||
if (onlyAvailable != null)
|
if (onlyAvailable != null) {
|
||||||
{
|
options.queryParameters.put("available", String.valueOf(onlyAvailable));
|
||||||
options.queryParameters.put("available", String.valueOf(onlyAvailable));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return addFilterOptions(options);
|
return addFilterOptions(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.config;
|
package org.jclouds.abiquo.domain.config;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -32,155 +31,139 @@ import com.abiquo.server.core.appslibrary.CategoryDto;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Category+Resource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/Category+Resource">
|
||||||
* http://community.abiquo.com/display/ABI20/Category+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Category+Resource</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Category extends DomainWrapper<CategoryDto>
|
public class Category extends DomainWrapper<CategoryDto> {
|
||||||
{
|
/** The default value for the default category flag. */
|
||||||
/** The default value for the default category flag. */
|
private static final boolean DEFAULT_DEFAULT_CATEGORY = false;
|
||||||
private static final boolean DEFAULT_DEFAULT_CATEGORY = false;
|
|
||||||
|
|
||||||
/** The default value for the erasable flag. */
|
/** The default value for the erasable flag. */
|
||||||
private static final boolean DEFAULT_ERASABLE = true;
|
private static final boolean DEFAULT_ERASABLE = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder. This resource cannot be created.
|
* Constructor to be used only by the builder. This resource cannot be
|
||||||
*/
|
* created.
|
||||||
private Category(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CategoryDto target)
|
*/
|
||||||
{
|
private Category(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CategoryDto target) {
|
||||||
super(context, target);
|
super(context, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Deleteacategory">
|
* "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Deleteacategory"
|
||||||
* http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Deleteacategory</a>
|
* > http://community.abiquo.com/display/ABI20/Category+Resource#
|
||||||
*/
|
* CategoryResource-Deleteacategory</a>
|
||||||
public void delete()
|
*/
|
||||||
{
|
public void delete() {
|
||||||
context.getApi().getConfigApi().deleteCategory(target);
|
context.getApi().getConfigApi().deleteCategory(target);
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Createacategory">
|
* "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Createacategory"
|
||||||
* http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Createacategory</a>
|
* > http://community.abiquo.com/display/ABI20/Category+Resource#
|
||||||
*/
|
* CategoryResource-Createacategory</a>
|
||||||
public void save()
|
*/
|
||||||
{
|
public void save() {
|
||||||
target = context.getApi().getConfigApi().createCategory(target);
|
target = context.getApi().getConfigApi().createCategory(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Updateanexistingcategory">
|
* "http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Updateanexistingcategory"
|
||||||
* http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Updateanexistingcategory</a>
|
* > http://community.abiquo.com/display/ABI20/Category+Resource#
|
||||||
*/
|
* CategoryResource-Updateanexistingcategory</a>
|
||||||
public void update()
|
*/
|
||||||
{
|
public void update() {
|
||||||
target = context.getApi().getConfigApi().updateCategory(target);
|
target = context.getApi().getConfigApi().updateCategory(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
return new Builder(context);
|
||||||
return new Builder(context);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Boolean erasable = DEFAULT_ERASABLE;
|
private Boolean erasable = DEFAULT_ERASABLE;
|
||||||
|
|
||||||
private Boolean defaultCategory = DEFAULT_DEFAULT_CATEGORY;
|
private Boolean defaultCategory = DEFAULT_DEFAULT_CATEGORY;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
super();
|
||||||
super();
|
this.context = context;
|
||||||
this.context = context;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder defaultCategory(final boolean defaultCategory)
|
public Builder defaultCategory(final boolean defaultCategory) {
|
||||||
{
|
this.defaultCategory = defaultCategory;
|
||||||
this.defaultCategory = defaultCategory;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder erasable(final boolean erasable)
|
public Builder erasable(final boolean erasable) {
|
||||||
{
|
this.erasable = erasable;
|
||||||
this.erasable = erasable;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Category build()
|
public Category build() {
|
||||||
{
|
CategoryDto dto = new CategoryDto();
|
||||||
CategoryDto dto = new CategoryDto();
|
dto.setErasable(erasable);
|
||||||
dto.setErasable(erasable);
|
dto.setDefaultCategory(defaultCategory);
|
||||||
dto.setDefaultCategory(defaultCategory);
|
dto.setName(name);
|
||||||
dto.setName(name);
|
Category category = new Category(context, dto);
|
||||||
Category category = new Category(context, dto);
|
|
||||||
|
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromCategory(final Category in)
|
public static Builder fromCategory(final Category in) {
|
||||||
{
|
Builder builder = Category.builder(in.context).name(in.getName()).erasable(in.isErasable())
|
||||||
Builder builder =
|
.defaultCategory(in.isDefaultCategory());
|
||||||
Category.builder(in.context).name(in.getName()).erasable(in.isErasable())
|
|
||||||
.defaultCategory(in.isDefaultCategory());
|
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDefaultCategory()
|
public boolean isDefaultCategory() {
|
||||||
{
|
return target.isDefaultCategory();
|
||||||
return target.isDefaultCategory();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isErasable()
|
public boolean isErasable() {
|
||||||
{
|
return target.isErasable();
|
||||||
return target.isErasable();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultCategory(final boolean defaultCategory)
|
public void setDefaultCategory(final boolean defaultCategory) {
|
||||||
{
|
target.setDefaultCategory(defaultCategory);
|
||||||
target.setDefaultCategory(defaultCategory);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setErasable(final boolean erasable)
|
public void setErasable(final boolean erasable) {
|
||||||
{
|
target.setErasable(erasable);
|
||||||
target.setErasable(erasable);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,164 +36,139 @@ import com.google.common.collect.Lists;
|
||||||
/**
|
/**
|
||||||
* A cost code is a kind of label where concrete prices can be assigned.
|
* A cost code is a kind of label where concrete prices can be assigned.
|
||||||
* <p>
|
* <p>
|
||||||
* Cloud administrators can create several cost codes and assign a price to each one, to have a
|
* Cloud administrators can create several cost codes and assign a price to each
|
||||||
* flexible way to configure custom billings for each resource.
|
* one, to have a flexible way to configure custom billings for each resource.
|
||||||
* <p>
|
* <p>
|
||||||
* Cost codes can be assigned to {@link VirtualMachineTemplate}s and other resources to provide
|
* Cost codes can be assigned to {@link VirtualMachineTemplate}s and other
|
||||||
* pricing information about them.
|
* resources to provide pricing information about them.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Susana Acedo
|
* @author Susana Acedo
|
||||||
*/
|
*/
|
||||||
public class CostCode extends DomainWrapper<CostCodeDto>
|
public class CostCode extends DomainWrapper<CostCodeDto> {
|
||||||
{
|
|
||||||
|
|
||||||
private List<CostCodePrice> defaultPrices;
|
private List<CostCodePrice> defaultPrices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder. This resource cannot be created.
|
* Constructor to be used only by the builder. This resource cannot be
|
||||||
*/
|
* created.
|
||||||
private CostCode(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CostCodeDto target)
|
*/
|
||||||
{
|
private CostCode(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CostCodeDto target) {
|
||||||
super(context, target);
|
super(context, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getPricingApi().deleteCostCode(target);
|
||||||
context.getApi().getPricingApi().deleteCostCode(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
target = context.getApi().getPricingApi().createCostCode(target);
|
||||||
target = context.getApi().getPricingApi().createCostCode(target);
|
|
||||||
|
|
||||||
if (defaultPrices != null && !defaultPrices.isEmpty())
|
if (defaultPrices != null && !defaultPrices.isEmpty()) {
|
||||||
{
|
CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto();
|
||||||
CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto();
|
for (CostCodePrice ccp : defaultPrices) {
|
||||||
for (CostCodePrice ccp : defaultPrices)
|
CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto();
|
||||||
{
|
Currency currency = ccp.getCurrency();
|
||||||
CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto();
|
|
||||||
Currency currency = ccp.getCurrency();
|
|
||||||
|
|
||||||
costcodecurrency.addLink(new RESTLink("currency", currency.unwrap().getEditLink()
|
costcodecurrency.addLink(new RESTLink("currency", currency.unwrap().getEditLink().getHref()));
|
||||||
.getHref()));
|
costcodecurrency.setPrice(ccp.getPrice());
|
||||||
costcodecurrency.setPrice(ccp.getPrice());
|
costcodecurrencies.add(costcodecurrency);
|
||||||
costcodecurrencies.add(costcodecurrency);
|
}
|
||||||
}
|
context.getApi().getPricingApi().updateCostCodeCurrencies(getId(), costcodecurrencies);
|
||||||
context.getApi().getPricingApi().updateCostCodeCurrencies(getId(), costcodecurrencies);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
target = context.getApi().getPricingApi().updateCostCode(target);
|
||||||
target = context.getApi().getPricingApi().updateCostCode(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
return new Builder(context);
|
||||||
return new Builder(context);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private List<CostCodePrice> defaultPrices = Lists.newArrayList();
|
private List<CostCodePrice> defaultPrices = Lists.newArrayList();
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
super();
|
||||||
super();
|
this.context = context;
|
||||||
this.context = context;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder description(final String description)
|
public Builder description(final String description) {
|
||||||
{
|
this.description = description;
|
||||||
this.description = description;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder defaultPrices(final List<CostCodePrice> prices)
|
public Builder defaultPrices(final List<CostCodePrice> prices) {
|
||||||
{
|
this.defaultPrices.addAll(prices);
|
||||||
this.defaultPrices.addAll(prices);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public CostCode build()
|
public CostCode build() {
|
||||||
{
|
CostCodeDto dto = new CostCodeDto();
|
||||||
CostCodeDto dto = new CostCodeDto();
|
dto.setName(name);
|
||||||
dto.setName(name);
|
dto.setDescription(description);
|
||||||
dto.setDescription(description);
|
CostCode costcode = new CostCode(context, dto);
|
||||||
CostCode costcode = new CostCode(context, dto);
|
costcode.setDefaultPrices(defaultPrices);
|
||||||
costcode.setDefaultPrices(defaultPrices);
|
return costcode;
|
||||||
return costcode;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder fromCostCode(final CostCode in)
|
public static Builder fromCostCode(final CostCode in) {
|
||||||
{
|
Builder builder = CostCode.builder(in.context).name(in.getName()).description(in.getDescription())
|
||||||
Builder builder =
|
.defaultPrices(in.getDefaultPrices());
|
||||||
CostCode.builder(in.context).name(in.getName()).description(in.getDescription())
|
return builder;
|
||||||
.defaultPrices(in.getDefaultPrices());
|
}
|
||||||
return builder;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(final String description)
|
public void setDescription(final String description) {
|
||||||
{
|
target.setDescription(description);
|
||||||
target.setDescription(description);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public List<CostCodePrice> getDefaultPrices()
|
public List<CostCodePrice> getDefaultPrices() {
|
||||||
{
|
return defaultPrices;
|
||||||
return defaultPrices;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultPrices(final List<CostCodePrice> defaultPrices)
|
public void setDefaultPrices(final List<CostCodePrice> defaultPrices) {
|
||||||
{
|
this.defaultPrices = defaultPrices;
|
||||||
this.defaultPrices = defaultPrices;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "CostCode [id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + "]";
|
||||||
return "CostCode [id=" + getId() + ", name=" + getName() + ", description="
|
}
|
||||||
+ getDescription() + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,30 +27,24 @@ import org.jclouds.rest.RestContext;
|
||||||
|
|
||||||
import com.abiquo.server.core.pricing.CostCodeCurrencyDto;
|
import com.abiquo.server.core.pricing.CostCodeCurrencyDto;
|
||||||
|
|
||||||
public class CostCodeCurrency extends DomainWrapper<CostCodeCurrencyDto>
|
public class CostCodeCurrency extends DomainWrapper<CostCodeCurrencyDto> {
|
||||||
{
|
|
||||||
|
|
||||||
protected CostCodeCurrency(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected CostCodeCurrency(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CostCodeCurrencyDto target) {
|
||||||
final CostCodeCurrencyDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPrice()
|
public BigDecimal getPrice() {
|
||||||
{
|
return target.getPrice();
|
||||||
return target.getPrice();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "CostCodeCurrency [id=" + getId() + ", price=" + getPrice() + "]";
|
||||||
return "CostCodeCurrency [id=" + getId() + ", price=" + getPrice() + "]";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,43 +25,36 @@ import java.math.BigDecimal;
|
||||||
*
|
*
|
||||||
* @author Susana Acedo
|
* @author Susana Acedo
|
||||||
*/
|
*/
|
||||||
public class CostCodePrice
|
public class CostCodePrice {
|
||||||
{
|
private Currency currency;
|
||||||
private Currency currency;
|
|
||||||
|
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
public CostCodePrice(final Currency currency, final BigDecimal price)
|
public CostCodePrice(final Currency currency, final BigDecimal price) {
|
||||||
{
|
super();
|
||||||
super();
|
this.currency = currency;
|
||||||
this.currency = currency;
|
this.price = price;
|
||||||
this.price = price;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Currency getCurrency()
|
public Currency getCurrency() {
|
||||||
{
|
return currency;
|
||||||
return currency;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrency(final Currency currency)
|
public void setCurrency(final Currency currency) {
|
||||||
{
|
this.currency = currency;
|
||||||
this.currency = currency;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPrice()
|
public BigDecimal getPrice() {
|
||||||
{
|
return price;
|
||||||
return price;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrice(final BigDecimal price)
|
public void setPrice(final BigDecimal price) {
|
||||||
{
|
this.price = price;
|
||||||
this.price = price;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "CostCodePrice [currency=" + currency + ", price=" + price + "]";
|
||||||
return "CostCodePrice [currency=" + currency + ", price=" + price + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,138 +32,117 @@ import com.abiquo.server.core.pricing.CurrencyDto;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Susana Acedo
|
* @author Susana Acedo
|
||||||
*/
|
*/
|
||||||
public class Currency extends DomainWrapper<CurrencyDto>
|
public class Currency extends DomainWrapper<CurrencyDto> {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder. This resource cannot be created.
|
* Constructor to be used only by the builder. This resource cannot be
|
||||||
*/
|
* created.
|
||||||
private Currency(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CurrencyDto target)
|
*/
|
||||||
{
|
private Currency(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final CurrencyDto target) {
|
||||||
super(context, target);
|
super(context, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getPricingApi().deleteCurrency(target);
|
||||||
context.getApi().getPricingApi().deleteCurrency(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
target = context.getApi().getPricingApi().createCurrency(target);
|
||||||
target = context.getApi().getPricingApi().createCurrency(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
target = context.getApi().getPricingApi().updateCurrency(target);
|
||||||
target = context.getApi().getPricingApi().updateCurrency(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
return new Builder(context);
|
||||||
return new Builder(context);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String symbol;
|
private String symbol;
|
||||||
|
|
||||||
private int digits;
|
private int digits;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
super();
|
||||||
super();
|
this.context = context;
|
||||||
this.context = context;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder symbol(final String symbol)
|
public Builder symbol(final String symbol) {
|
||||||
{
|
this.symbol = symbol;
|
||||||
this.symbol = symbol;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder digits(final int digits)
|
public Builder digits(final int digits) {
|
||||||
{
|
this.digits = digits;
|
||||||
this.digits = digits;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Currency build()
|
public Currency build() {
|
||||||
{
|
CurrencyDto dto = new CurrencyDto();
|
||||||
CurrencyDto dto = new CurrencyDto();
|
dto.setName(name);
|
||||||
dto.setName(name);
|
dto.setSymbol(symbol);
|
||||||
dto.setSymbol(symbol);
|
dto.setDigits(digits);
|
||||||
dto.setDigits(digits);
|
Currency currency = new Currency(context, dto);
|
||||||
Currency currency = new Currency(context, dto);
|
|
||||||
|
|
||||||
return currency;
|
return currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromCurrency(final Currency in)
|
public static Builder fromCurrency(final Currency in) {
|
||||||
{
|
Builder builder = Currency.builder(in.context).name(in.getName()).symbol(in.getSymbol())
|
||||||
Builder builder =
|
.digits(in.getDigits());
|
||||||
Currency.builder(in.context).name(in.getName()).symbol(in.getSymbol())
|
|
||||||
.digits(in.getDigits());
|
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getSymbol()
|
public String getSymbol() {
|
||||||
{
|
return target.getSymbol();
|
||||||
return target.getSymbol();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setSymbol(final String symbol)
|
public void setSymbol(final String symbol) {
|
||||||
{
|
target.setSymbol(symbol);
|
||||||
target.setSymbol(symbol);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getDigits()
|
public int getDigits() {
|
||||||
{
|
return target.getDigits();
|
||||||
return target.getDigits();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDigits(final int digits)
|
public void setDigits(final int digits) {
|
||||||
{
|
target.setDigits(digits);
|
||||||
target.setDigits(digits);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Currency [id=" + getId() + ", name=" + getName() + ", symbol=" + getSymbol() + ", digits=" + getDigits()
|
||||||
return "Currency [id=" + getId() + ", name=" + getName() + ", symbol=" + getSymbol()
|
+ "]";
|
||||||
+ ", digits=" + getDigits() + "]";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.config;
|
package org.jclouds.abiquo.domain.config;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -35,108 +34,90 @@ import com.abiquo.server.core.config.LicenseDto;
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class License extends DomainWrapper<LicenseDto>
|
public class License extends DomainWrapper<LicenseDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected License(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final LicenseDto target) {
|
||||||
protected License(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final LicenseDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
public void remove()
|
public void remove() {
|
||||||
{
|
context.getApi().getConfigApi().removeLicense(target);
|
||||||
context.getApi().getConfigApi().removeLicense(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void add()
|
public void add() {
|
||||||
{
|
target = context.getApi().getConfigApi().addLicense(target);
|
||||||
target = context.getApi().getConfigApi().addLicense(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final String code)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final String code) {
|
||||||
{
|
return new Builder(context, code);
|
||||||
return new Builder(context, code);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final String code)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final String code) {
|
||||||
{
|
super();
|
||||||
super();
|
this.context = context;
|
||||||
this.context = context;
|
this.code = code;
|
||||||
this.code = code;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder code(final String code)
|
public Builder code(final String code) {
|
||||||
{
|
this.code = code;
|
||||||
this.code = code;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public License build()
|
public License build() {
|
||||||
{
|
LicenseDto dto = new LicenseDto();
|
||||||
LicenseDto dto = new LicenseDto();
|
dto.setCode(code);
|
||||||
dto.setCode(code);
|
|
||||||
|
|
||||||
License license = new License(context, dto);
|
License license = new License(context, dto);
|
||||||
return license;
|
return license;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromLicense(final License in)
|
public static Builder fromLicense(final License in) {
|
||||||
{
|
return License.builder(in.context, in.getCode());
|
||||||
return License.builder(in.context, in.getCode());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public String getCode()
|
public String getCode() {
|
||||||
{
|
return target.getCode();
|
||||||
return target.getCode();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getCustomerId()
|
public String getCustomerId() {
|
||||||
{
|
return target.getCustomerid();
|
||||||
return target.getCustomerid();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getEnabledIp()
|
public String getEnabledIp() {
|
||||||
{
|
return target.getEnabledip();
|
||||||
return target.getEnabledip();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getExpiration()
|
public String getExpiration() {
|
||||||
{
|
return target.getExpiration();
|
||||||
return target.getExpiration();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getNumCores()
|
public Integer getNumCores() {
|
||||||
{
|
return target.getNumcores();
|
||||||
return target.getNumcores();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "License [id=" + getId() + ", code=" + getCode() + ", customerId=" + getCustomerId() + ", enabledIp="
|
||||||
return "License [id=" + getId() + ", code=" + getCode() + ", customerId=" + getCustomerId()
|
+ getEnabledIp() + ", expiration=" + getExpiration() + ", numCores=" + getNumCores() + "]";
|
||||||
+ ", enabledIp=" + getEnabledIp() + ", expiration=" + getExpiration() + ", numCores="
|
}
|
||||||
+ getNumCores() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,95 +36,80 @@ import com.abiquo.server.core.pricing.PricingCostCodeDto;
|
||||||
*
|
*
|
||||||
* @author Susana Acedo
|
* @author Susana Acedo
|
||||||
*/
|
*/
|
||||||
public class PricingCostCode extends DomainWrapper<PricingCostCodeDto>
|
public class PricingCostCode extends DomainWrapper<PricingCostCodeDto> {
|
||||||
{
|
private CostCode costcode;
|
||||||
private CostCode costcode;
|
|
||||||
|
|
||||||
private PricingTemplate pricingTemplate;
|
private PricingTemplate pricingTemplate;
|
||||||
|
|
||||||
protected PricingCostCode(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected PricingCostCode(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final PricingCostCodeDto target) {
|
||||||
final PricingCostCodeDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final PricingTemplate pricingtemplate, final CostCode costcode)
|
final PricingTemplate pricingtemplate, final CostCode costcode) {
|
||||||
{
|
return new Builder(context, pricingtemplate, costcode);
|
||||||
return new Builder(context, pricingtemplate, costcode);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private PricingTemplate pricingTemplate;
|
private PricingTemplate pricingTemplate;
|
||||||
|
|
||||||
private CostCode costcode;
|
private CostCode costcode;
|
||||||
|
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final PricingTemplate pricingTemplate,
|
||||||
final PricingTemplate pricingTemplate, final CostCode costcode)
|
final CostCode costcode) {
|
||||||
{
|
super();
|
||||||
super();
|
this.pricingTemplate = checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE + PricingTemplate.class);
|
||||||
this.pricingTemplate =
|
this.costcode = checkNotNull(costcode, ValidationErrors.NULL_RESOURCE + CostCode.class);
|
||||||
checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE
|
this.context = context;
|
||||||
+ PricingTemplate.class);
|
}
|
||||||
this.costcode = checkNotNull(costcode, ValidationErrors.NULL_RESOURCE + CostCode.class);
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder price(final BigDecimal price)
|
public Builder price(final BigDecimal price) {
|
||||||
{
|
this.price = price;
|
||||||
this.price = price;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public PricingCostCode build()
|
public PricingCostCode build() {
|
||||||
{
|
PricingCostCodeDto dto = new PricingCostCodeDto();
|
||||||
PricingCostCodeDto dto = new PricingCostCodeDto();
|
dto.setId(id);
|
||||||
dto.setId(id);
|
dto.setPrice(price);
|
||||||
dto.setPrice(price);
|
|
||||||
|
|
||||||
RESTLink link = costcode.unwrap().searchLink("edit");
|
RESTLink link = costcode.unwrap().searchLink("edit");
|
||||||
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
||||||
dto.addLink(new RESTLink("costcode", link.getHref()));
|
dto.addLink(new RESTLink("costcode", link.getHref()));
|
||||||
|
|
||||||
PricingCostCode pricingcostcode = new PricingCostCode(context, dto);
|
PricingCostCode pricingcostcode = new PricingCostCode(context, dto);
|
||||||
pricingcostcode.pricingTemplate = pricingTemplate;
|
pricingcostcode.pricingTemplate = pricingTemplate;
|
||||||
pricingcostcode.costcode = costcode;
|
pricingcostcode.costcode = costcode;
|
||||||
|
|
||||||
return pricingcostcode;
|
return pricingcostcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromPricingCostCode(final PricingCostCode in)
|
public static Builder fromPricingCostCode(final PricingCostCode in) {
|
||||||
{
|
return PricingCostCode.builder(in.context, in.pricingTemplate, in.costcode).price(in.getPrice());
|
||||||
return PricingCostCode.builder(in.context, in.pricingTemplate, in.costcode).price(
|
}
|
||||||
in.getPrice());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPrice()
|
public BigDecimal getPrice() {
|
||||||
{
|
return target.getPrice();
|
||||||
return target.getPrice();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "PricingCostCode [id=" + getId() + ", price=" + getPrice() + "]";
|
||||||
return "PricingCostCode [id=" + getId() + ", price=" + getPrice() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,408 +36,344 @@ import com.abiquo.model.rest.RESTLink;
|
||||||
import com.abiquo.server.core.pricing.PricingTemplateDto;
|
import com.abiquo.server.core.pricing.PricingTemplateDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pricing template is a complete pricing schema that can be assigned to an {@link Enterprise}.
|
* A pricing template is a complete pricing schema that can be assigned to an
|
||||||
|
* {@link Enterprise}.
|
||||||
* <p>
|
* <p>
|
||||||
* This pricing schema will provide detailed billing information for each resource consumed by the
|
* This pricing schema will provide detailed billing information for each
|
||||||
* users of the enterprise.
|
* resource consumed by the users of the enterprise.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Susana Acedo
|
* @author Susana Acedo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PricingTemplate extends DomainWrapper<PricingTemplateDto>
|
public class PricingTemplate extends DomainWrapper<PricingTemplateDto> {
|
||||||
{
|
|
||||||
|
|
||||||
/** The currency used by the pricing template. */
|
/** The currency used by the pricing template. */
|
||||||
protected Currency currency;
|
protected Currency currency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder. This resource cannot be created.
|
* Constructor to be used only by the builder. This resource cannot be
|
||||||
*/
|
* created.
|
||||||
private PricingTemplate(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
*/
|
||||||
final PricingTemplateDto target)
|
private PricingTemplate(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final PricingTemplateDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getPricingApi().deletePricingTemplate(target);
|
||||||
context.getApi().getPricingApi().deletePricingTemplate(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
target = context.getApi().getPricingApi().createPricingTemplate(target);
|
||||||
target = context.getApi().getPricingApi().createPricingTemplate(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
target = context.getApi().getPricingApi().updatePricingTemplate(target);
|
||||||
target = context.getApi().getPricingApi().updatePricingTemplate(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Currency currency) {
|
||||||
final Currency currency)
|
return new Builder(context, currency);
|
||||||
{
|
}
|
||||||
return new Builder(context, currency);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private Currency currency;
|
private Currency currency;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private BigDecimal hdGB;
|
private BigDecimal hdGB;
|
||||||
|
|
||||||
private BigDecimal standingChargePeriod;
|
private BigDecimal standingChargePeriod;
|
||||||
|
|
||||||
private BigDecimal vlan;
|
private BigDecimal vlan;
|
||||||
|
|
||||||
private PricingPeriod chargingPeriod;
|
private PricingPeriod chargingPeriod;
|
||||||
|
|
||||||
private BigDecimal minimumChargePeriod;
|
private BigDecimal minimumChargePeriod;
|
||||||
|
|
||||||
private boolean showChangesBefore;
|
|
||||||
|
|
||||||
private boolean showMinimumCharge;
|
private boolean showChangesBefore;
|
||||||
|
|
||||||
private PricingPeriod minimumCharge;
|
private boolean showMinimumCharge;
|
||||||
|
|
||||||
private BigDecimal publicIp;
|
private PricingPeriod minimumCharge;
|
||||||
|
|
||||||
private BigDecimal vcpu;
|
private BigDecimal publicIp;
|
||||||
|
|
||||||
private BigDecimal memoryGB;
|
private BigDecimal vcpu;
|
||||||
|
|
||||||
private boolean defaultTemplate;
|
private BigDecimal memoryGB;
|
||||||
|
|
||||||
private Date lastUpdate;
|
private boolean defaultTemplate;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Currency currency)
|
private Date lastUpdate;
|
||||||
{
|
|
||||||
super();
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Currency currency) {
|
||||||
this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class);
|
super();
|
||||||
this.context = context;
|
this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class);
|
||||||
}
|
this.context = context;
|
||||||
|
}
|
||||||
public Builder name(final String name)
|
|
||||||
{
|
public Builder name(final String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(final String description)
|
public Builder description(final String description) {
|
||||||
{
|
this.description = description;
|
||||||
this.description = description;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder hdGB(final BigDecimal hdGB) {
|
||||||
public Builder hdGB(final BigDecimal hdGB)
|
this.hdGB = hdGB;
|
||||||
{
|
return this;
|
||||||
this.hdGB = hdGB;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder standingChargePeriod(final BigDecimal standingChargePeriod) {
|
||||||
|
this.standingChargePeriod = standingChargePeriod;
|
||||||
public Builder standingChargePeriod(final BigDecimal standingChargePeriod)
|
return this;
|
||||||
{
|
}
|
||||||
this.standingChargePeriod = standingChargePeriod;
|
|
||||||
return this;
|
public Builder chargingPeriod(final PricingPeriod chargingPeriod) {
|
||||||
}
|
this.chargingPeriod = chargingPeriod;
|
||||||
|
return this;
|
||||||
public Builder chargingPeriod(final PricingPeriod chargingPeriod)
|
}
|
||||||
{
|
|
||||||
this.chargingPeriod = chargingPeriod;
|
public Builder vlan(final BigDecimal vlan) {
|
||||||
return this;
|
this.vlan = vlan;
|
||||||
}
|
return this;
|
||||||
|
}
|
||||||
public Builder vlan(final BigDecimal vlan)
|
|
||||||
{
|
public Builder minimumChargePeriod(final BigDecimal minimumChargePeriod) {
|
||||||
this.vlan = vlan;
|
this.minimumChargePeriod = minimumChargePeriod;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder minimumChargePeriod(final BigDecimal minimumChargePeriod)
|
public Builder minimumCharge(final PricingPeriod minimumCharge) {
|
||||||
{
|
this.minimumCharge = minimumCharge;
|
||||||
this.minimumChargePeriod = minimumChargePeriod;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder showChangesBefore(final boolean showChangesBefore) {
|
||||||
public Builder minimumCharge(final PricingPeriod minimumCharge)
|
this.showChangesBefore = showChangesBefore;
|
||||||
{
|
return this;
|
||||||
this.minimumCharge = minimumCharge;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder showMinimumCharge(final boolean showMinimumCharge) {
|
||||||
|
this.showMinimumCharge = showMinimumCharge;
|
||||||
public Builder showChangesBefore(final boolean showChangesBefore)
|
return this;
|
||||||
{
|
}
|
||||||
this.showChangesBefore = showChangesBefore;
|
|
||||||
return this;
|
public Builder publicIp(final BigDecimal publicIp) {
|
||||||
}
|
this.publicIp = publicIp;
|
||||||
|
return this;
|
||||||
public Builder showMinimumCharge(final boolean showMinimumCharge)
|
}
|
||||||
{
|
|
||||||
this.showMinimumCharge = showMinimumCharge;
|
public Builder vcpu(final BigDecimal vcpu) {
|
||||||
return this;
|
this.vcpu = vcpu;
|
||||||
}
|
return this;
|
||||||
|
}
|
||||||
public Builder publicIp(final BigDecimal publicIp)
|
|
||||||
{
|
public Builder memoryGB(final BigDecimal memoryGB) {
|
||||||
this.publicIp = publicIp;
|
this.memoryGB = memoryGB;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder vcpu(final BigDecimal vcpu)
|
public Builder defaultTemplate(final boolean defaultTemplate) {
|
||||||
{
|
this.defaultTemplate = defaultTemplate;
|
||||||
this.vcpu = vcpu;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder lastUpdate(final Date lastUpdate) {
|
||||||
public Builder memoryGB(final BigDecimal memoryGB)
|
this.lastUpdate = lastUpdate;
|
||||||
{
|
return this;
|
||||||
this.memoryGB = memoryGB;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder currency(final Currency currency) {
|
||||||
|
this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class);
|
||||||
public Builder defaultTemplate(final boolean defaultTemplate)
|
return this;
|
||||||
{
|
}
|
||||||
this.defaultTemplate = defaultTemplate;
|
|
||||||
return this;
|
public PricingTemplate build() {
|
||||||
}
|
PricingTemplateDto dto = new PricingTemplateDto();
|
||||||
|
dto.setName(name);
|
||||||
public Builder lastUpdate(final Date lastUpdate)
|
dto.setDescription(description);
|
||||||
{
|
dto.setHdGB(hdGB);
|
||||||
this.lastUpdate = lastUpdate;
|
dto.setStandingChargePeriod(standingChargePeriod);
|
||||||
return this;
|
dto.setVlan(vlan);
|
||||||
}
|
dto.setChargingPeriod(chargingPeriod.ordinal());
|
||||||
|
dto.setMinimumCharge(minimumCharge.ordinal());
|
||||||
public Builder currency(final Currency currency)
|
dto.setMinimumChargePeriod(minimumChargePeriod);
|
||||||
{
|
dto.setShowChangesBefore(showChangesBefore);
|
||||||
this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class);
|
dto.setShowMinimumCharge(showMinimumCharge);
|
||||||
return this;
|
dto.setPublicIp(publicIp);
|
||||||
}
|
dto.setVcpu(vcpu);
|
||||||
|
dto.setMemoryGB(memoryGB);
|
||||||
public PricingTemplate build()
|
dto.setDefaultTemplate(defaultTemplate);
|
||||||
{
|
dto.setLastUpdate(lastUpdate);
|
||||||
PricingTemplateDto dto = new PricingTemplateDto();
|
|
||||||
dto.setName(name);
|
RESTLink link = currency.unwrap().searchLink("edit");
|
||||||
dto.setDescription(description);
|
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
||||||
dto.setHdGB(hdGB);
|
dto.addLink(new RESTLink("currency", link.getHref()));
|
||||||
dto.setStandingChargePeriod(standingChargePeriod);
|
|
||||||
dto.setVlan(vlan);
|
PricingTemplate pricingTemplate = new PricingTemplate(context, dto);
|
||||||
dto.setChargingPeriod(chargingPeriod.ordinal());
|
pricingTemplate.currency = currency;
|
||||||
dto.setMinimumCharge(minimumCharge.ordinal());
|
|
||||||
dto.setMinimumChargePeriod(minimumChargePeriod);
|
return pricingTemplate;
|
||||||
dto.setShowChangesBefore(showChangesBefore);
|
}
|
||||||
dto.setShowMinimumCharge(showMinimumCharge);
|
|
||||||
dto.setPublicIp(publicIp);
|
public static Builder fromPricingTemplate(final PricingTemplate in) {
|
||||||
dto.setVcpu(vcpu);
|
Builder builder = PricingTemplate.builder(in.context, in.currency).name(in.getName())
|
||||||
dto.setMemoryGB(memoryGB);
|
.description(in.getDescription()).hdGB(in.getHdGB()).standingChargePeriod(in.getStandingChargePeriod())
|
||||||
dto.setDefaultTemplate(defaultTemplate);
|
.vcpu(in.getVlan()).chargingPeriod(in.getChargingPeriod()).minimumCharge(in.getMinimumCharge())
|
||||||
dto.setLastUpdate(lastUpdate);
|
.minimumChargePeriod(in.getMinimumChargePeriod()).showChangesBefore(in.isShowChangesBefore())
|
||||||
|
.showMinimumCharge(in.isShowMinimumCharge()).publicIp(in.getPublicIp()).vcpu(in.getVcpu())
|
||||||
RESTLink link = currency.unwrap().searchLink("edit");
|
.memoryGB(in.getMemoryGB()).defaultTemplate(in.isDefaultTemplate()).lastUpdate(in.getLastUpdate());
|
||||||
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
return builder;
|
||||||
dto.addLink(new RESTLink("currency", link.getHref()));
|
}
|
||||||
|
}
|
||||||
PricingTemplate pricingTemplate = new PricingTemplate(context, dto);
|
|
||||||
pricingTemplate.currency = currency;
|
// Delegate methods
|
||||||
|
|
||||||
return pricingTemplate;
|
public Integer getId() {
|
||||||
}
|
return target.getId();
|
||||||
|
}
|
||||||
public static Builder fromPricingTemplate(final PricingTemplate in)
|
|
||||||
{
|
public String getName() {
|
||||||
Builder builder =
|
return target.getName();
|
||||||
PricingTemplate.builder(in.context, in.currency).name(in.getName())
|
}
|
||||||
.description(in.getDescription()).hdGB(in.getHdGB())
|
|
||||||
.standingChargePeriod(in.getStandingChargePeriod()).vcpu(in.getVlan())
|
public void setName(final String name) {
|
||||||
.chargingPeriod(in.getChargingPeriod()).minimumCharge(in.getMinimumCharge())
|
target.setName(name);
|
||||||
.minimumChargePeriod(in.getMinimumChargePeriod())
|
}
|
||||||
.showChangesBefore(in.isShowChangesBefore())
|
|
||||||
.showMinimumCharge(in.isShowMinimumCharge()).publicIp(in.getPublicIp())
|
public String getDescription() {
|
||||||
.vcpu(in.getVcpu()).memoryGB(in.getMemoryGB())
|
return target.getDescription();
|
||||||
.defaultTemplate(in.isDefaultTemplate()).lastUpdate(in.getLastUpdate());
|
}
|
||||||
return builder;
|
|
||||||
}
|
public void setDescription(final String description) {
|
||||||
}
|
target.setDescription(description);
|
||||||
|
}
|
||||||
// Delegate methods
|
|
||||||
|
public BigDecimal getHdGB() {
|
||||||
public Integer getId()
|
return target.getHdGB();
|
||||||
{
|
}
|
||||||
return target.getId();
|
|
||||||
}
|
public void setHdGB(final BigDecimal hdGB) {
|
||||||
|
target.setHdGB(hdGB);
|
||||||
public String getName()
|
}
|
||||||
{
|
|
||||||
return target.getName();
|
public BigDecimal getStandingChargePeriod() {
|
||||||
}
|
return target.getStandingChargePeriod();
|
||||||
|
}
|
||||||
public void setName(final String name)
|
|
||||||
{
|
public void setStandingChargePeriod(final BigDecimal standingChargePeriod) {
|
||||||
target.setName(name);
|
target.setStandingChargePeriod(standingChargePeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public BigDecimal getVlan() {
|
||||||
{
|
return target.getVlan();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
public void setVlan(final BigDecimal vlan) {
|
||||||
public void setDescription(final String description)
|
target.getVlan();
|
||||||
{
|
}
|
||||||
target.setDescription(description);
|
|
||||||
}
|
public BigDecimal getMinimumChargePeriod() {
|
||||||
|
return target.getMinimumChargePeriod();
|
||||||
public BigDecimal getHdGB()
|
}
|
||||||
{
|
|
||||||
return target.getHdGB();
|
public void setMinimumChargePeriod(final BigDecimal minimumChargePeriod) {
|
||||||
}
|
target.setMinimumChargePeriod(minimumChargePeriod);
|
||||||
|
}
|
||||||
public void setHdGB(final BigDecimal hdGB)
|
|
||||||
{
|
public boolean isShowChangesBefore() {
|
||||||
target.setHdGB(hdGB);
|
return target.isShowChangesBefore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getStandingChargePeriod()
|
public void setShowChangesBefore(final boolean showChangesBefore) {
|
||||||
{
|
target.setShowChangesBefore(showChangesBefore);
|
||||||
return target.getStandingChargePeriod();
|
}
|
||||||
}
|
|
||||||
|
public boolean isShowMinimumCharge() {
|
||||||
public void setStandingChargePeriod(final BigDecimal standingChargePeriod)
|
return target.isShowMinimumCharge();
|
||||||
{
|
}
|
||||||
target.setStandingChargePeriod(standingChargePeriod);
|
|
||||||
}
|
public void setShowMinimumCharge(final boolean showMinimumCharge) {
|
||||||
|
target.setShowMinimumCharge(showMinimumCharge);
|
||||||
public BigDecimal getVlan()
|
}
|
||||||
{
|
|
||||||
return target.getVlan();
|
public PricingPeriod getMinimumCharge() {
|
||||||
}
|
return PricingPeriod.fromId(target.getMinimumCharge());
|
||||||
|
}
|
||||||
public void setVlan(final BigDecimal vlan)
|
|
||||||
{
|
public void setMinimumCharge(final PricingPeriod minimumCharge) {
|
||||||
target.getVlan();
|
target.setMinimumCharge(minimumCharge.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getMinimumChargePeriod()
|
public PricingPeriod getChargingPeriod() {
|
||||||
{
|
return PricingPeriod.fromId(target.getChargingPeriod());
|
||||||
return target.getMinimumChargePeriod();
|
}
|
||||||
}
|
|
||||||
|
public void setChargingPeriod(final PricingPeriod chargingPeriod) {
|
||||||
public void setMinimumChargePeriod(final BigDecimal minimumChargePeriod)
|
target.setChargingPeriod(chargingPeriod.ordinal());
|
||||||
{
|
}
|
||||||
target.setMinimumChargePeriod(minimumChargePeriod);
|
|
||||||
}
|
public BigDecimal getPublicIp() {
|
||||||
|
return target.getPublicIp();
|
||||||
public boolean isShowChangesBefore()
|
}
|
||||||
{
|
|
||||||
return target.isShowChangesBefore();
|
public void setPublicIp(final BigDecimal publicIp) {
|
||||||
}
|
target.setPublicIp(publicIp);
|
||||||
|
}
|
||||||
public void setShowChangesBefore(final boolean showChangesBefore)
|
|
||||||
{
|
public BigDecimal getVcpu() {
|
||||||
target.setShowChangesBefore(showChangesBefore);
|
return target.getVcpu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowMinimumCharge()
|
public void setVcpu(final BigDecimal vcpu) {
|
||||||
{
|
target.setVcpu(vcpu);
|
||||||
return target.isShowMinimumCharge();
|
}
|
||||||
}
|
|
||||||
|
public BigDecimal getMemoryGB() {
|
||||||
public void setShowMinimumCharge(final boolean showMinimumCharge)
|
return target.getMemoryGB();
|
||||||
{
|
}
|
||||||
target.setShowMinimumCharge(showMinimumCharge);
|
|
||||||
}
|
public void setMemoryGB(final BigDecimal memoryGB) {
|
||||||
|
target.setMemoryGB(memoryGB);
|
||||||
public PricingPeriod getMinimumCharge()
|
}
|
||||||
{
|
|
||||||
return PricingPeriod.fromId(target.getMinimumCharge());
|
public boolean isDefaultTemplate() {
|
||||||
}
|
return target.isDefaultTemplate();
|
||||||
|
}
|
||||||
public void setMinimumCharge(final PricingPeriod minimumCharge)
|
|
||||||
{
|
public void setDefaultTemplate(final boolean defaultTemplate) {
|
||||||
target.setMinimumCharge(minimumCharge.ordinal());
|
target.setDefaultTemplate(defaultTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PricingPeriod getChargingPeriod()
|
public Date getLastUpdate() {
|
||||||
{
|
return target.getLastUpdate();
|
||||||
return PricingPeriod.fromId(target.getChargingPeriod());
|
}
|
||||||
}
|
|
||||||
|
public void setLastUpdate(final Date lastUpdate) {
|
||||||
public void setChargingPeriod(final PricingPeriod chargingPeriod)
|
target.setLastUpdate(lastUpdate);
|
||||||
{
|
}
|
||||||
target.setChargingPeriod(chargingPeriod.ordinal());
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
public BigDecimal getPublicIp()
|
return "PricingTemplate [id=" + getId() + ", name=" + getName() + ", description=" + getDescription()
|
||||||
{
|
+ ", hdGB =" + getHdGB() + ", standingChargePeriod =" + getStandingChargePeriod() + ", vlan = " + getVlan()
|
||||||
return target.getPublicIp();
|
+ ", chargingPeriod =" + getChargingPeriod() + ", minimumChargePeriod=" + getMinimumChargePeriod()
|
||||||
}
|
+ ", showChangesBefore =" + isShowChangesBefore() + ", showMinimumCharge= " + isShowMinimumCharge()
|
||||||
|
+ ", minimumCharge = " + getMinimumCharge() + ", publicIp = " + getPublicIp() + ", vcpu =" + getVcpu()
|
||||||
public void setPublicIp(final BigDecimal publicIp)
|
+ ", memoryGB= " + getMemoryGB() + ", defaultTemplate= " + isDefaultTemplate() + ", lastUpdate = "
|
||||||
{
|
+ getLastUpdate() + "]";
|
||||||
target.setPublicIp(publicIp);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getVcpu()
|
|
||||||
{
|
|
||||||
return target.getVcpu();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVcpu(final BigDecimal vcpu)
|
|
||||||
{
|
|
||||||
target.setVcpu(vcpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getMemoryGB()
|
|
||||||
{
|
|
||||||
return target.getMemoryGB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMemoryGB(final BigDecimal memoryGB)
|
|
||||||
{
|
|
||||||
target.setMemoryGB(memoryGB);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDefaultTemplate()
|
|
||||||
{
|
|
||||||
return target.isDefaultTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultTemplate(final boolean defaultTemplate)
|
|
||||||
{
|
|
||||||
target.setDefaultTemplate(defaultTemplate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLastUpdate()
|
|
||||||
{
|
|
||||||
return target.getLastUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastUpdate(final Date lastUpdate)
|
|
||||||
{
|
|
||||||
target.setLastUpdate(lastUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "PricingTemplate [id=" + getId() + ", name=" + getName() + ", description="
|
|
||||||
+ getDescription() + ", hdGB =" + getHdGB() + ", standingChargePeriod ="
|
|
||||||
+ getStandingChargePeriod() + ", vlan = " + getVlan() + ", chargingPeriod ="
|
|
||||||
+ getChargingPeriod() + ", minimumChargePeriod=" + getMinimumChargePeriod()
|
|
||||||
+ ", showChangesBefore =" + isShowChangesBefore() + ", showMinimumCharge= "
|
|
||||||
+ isShowMinimumCharge() + ", minimumCharge = " + getMinimumCharge() + ", publicIp = "
|
|
||||||
+ getPublicIp() + ", vcpu =" + getVcpu() + ", memoryGB= " + getMemoryGB()
|
|
||||||
+ ", defaultTemplate= " + isDefaultTemplate() + ", lastUpdate = " + getLastUpdate()
|
|
||||||
+ "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,94 +37,79 @@ import com.abiquo.server.core.pricing.PricingTierDto;
|
||||||
*
|
*
|
||||||
* @author Susana Acedo
|
* @author Susana Acedo
|
||||||
*/
|
*/
|
||||||
public class PricingTier extends DomainWrapper<PricingTierDto>
|
public class PricingTier extends DomainWrapper<PricingTierDto> {
|
||||||
{
|
private Tier tier;
|
||||||
private Tier tier;
|
|
||||||
|
|
||||||
private PricingTemplate pricingTemplate;
|
private PricingTemplate pricingTemplate;
|
||||||
|
|
||||||
protected PricingTier(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected PricingTier(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final PricingTierDto target) {
|
||||||
final PricingTierDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final PricingTemplate pricingtemplate, final Tier tier)
|
final PricingTemplate pricingtemplate, final Tier tier) {
|
||||||
{
|
return new Builder(context, pricingtemplate, tier);
|
||||||
return new Builder(context, pricingtemplate, tier);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private PricingTemplate pricingTemplate;
|
private PricingTemplate pricingTemplate;
|
||||||
|
|
||||||
private Tier tier;
|
private Tier tier;
|
||||||
|
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final PricingTemplate pricingTemplate,
|
||||||
final PricingTemplate pricingTemplate, final Tier tier)
|
final Tier tier) {
|
||||||
{
|
super();
|
||||||
super();
|
this.pricingTemplate = checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE + PricingTemplate.class);
|
||||||
this.pricingTemplate =
|
this.tier = checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class);
|
||||||
checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE
|
this.context = context;
|
||||||
+ PricingTemplate.class);
|
}
|
||||||
this.tier = checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class);
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder price(final BigDecimal price)
|
public Builder price(final BigDecimal price) {
|
||||||
{
|
this.price = price;
|
||||||
this.price = price;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public PricingTier build()
|
public PricingTier build() {
|
||||||
{
|
PricingTierDto dto = new PricingTierDto();
|
||||||
PricingTierDto dto = new PricingTierDto();
|
dto.setId(id);
|
||||||
dto.setId(id);
|
dto.setPrice(price);
|
||||||
dto.setPrice(price);
|
|
||||||
|
|
||||||
RESTLink link = tier.unwrap().searchLink("edit");
|
RESTLink link = tier.unwrap().searchLink("edit");
|
||||||
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
||||||
dto.addLink(new RESTLink("tier", link.getHref()));
|
dto.addLink(new RESTLink("tier", link.getHref()));
|
||||||
|
|
||||||
PricingTier pricingTier = new PricingTier(context, dto);
|
PricingTier pricingTier = new PricingTier(context, dto);
|
||||||
pricingTier.pricingTemplate = pricingTemplate;
|
pricingTier.pricingTemplate = pricingTemplate;
|
||||||
pricingTier.tier = tier;
|
pricingTier.tier = tier;
|
||||||
|
|
||||||
return pricingTier;
|
return pricingTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromPricingTier(final PricingTier in)
|
public static Builder fromPricingTier(final PricingTier in) {
|
||||||
{
|
return PricingTier.builder(in.context, in.pricingTemplate, in.tier).price(in.getPrice());
|
||||||
return PricingTier.builder(in.context, in.pricingTemplate, in.tier)
|
}
|
||||||
.price(in.getPrice());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPrice()
|
public BigDecimal getPrice() {
|
||||||
{
|
return target.getPrice();
|
||||||
return target.getPrice();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "PricingTier [id=" + getId() + ", price=" + getPrice() + "]";
|
||||||
return "PricingTier [id=" + getId() + ", price=" + getPrice() + "]";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.config;
|
package org.jclouds.abiquo.domain.config;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -35,32 +34,28 @@ import com.abiquo.server.core.enterprise.PrivilegeDto;
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class Privilege extends DomainWrapper<PrivilegeDto>
|
public class Privilege extends DomainWrapper<PrivilegeDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder. This resource cannot be
|
||||||
* Constructor to be used only by the builder. This resource cannot be created.
|
* created.
|
||||||
*/
|
*/
|
||||||
private Privilege(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final PrivilegeDto target)
|
private Privilege(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final PrivilegeDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Privilege [id=" + getId() + ", name=" + getName() + "]";
|
||||||
return "Privilege [id=" + getId() + ", name=" + getName() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.config;
|
package org.jclouds.abiquo.domain.config;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -32,53 +31,49 @@ import com.abiquo.server.core.config.SystemPropertyDto;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/System+Property+resource">
|
* @see API: <a
|
||||||
* http://community.abiquo.com/display/ABI20/System+Property+resource</a>
|
* href="http://community.abiquo.com/display/ABI20/System+Property+resource"
|
||||||
|
* > http://community.abiquo.com/display/ABI20/System+Property+resource</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SystemProperty extends DomainWrapper<SystemPropertyDto>
|
public class SystemProperty extends DomainWrapper<SystemPropertyDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder. This resource cannot be
|
||||||
* Constructor to be used only by the builder. This resource cannot be created.
|
* created.
|
||||||
*/
|
*/
|
||||||
private SystemProperty(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final SystemPropertyDto target)
|
private SystemProperty(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final SystemPropertyDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/System+Property+resource#SystemPropertyresource-ModifyanexistingSystemProperty">
|
* "http://community.abiquo.com/display/ABI20/System+Property+resource#SystemPropertyresource-ModifyanexistingSystemProperty"
|
||||||
* http://community.abiquo.com/display/ABI20/System+Property+resource#SystemPropertyresource-ModifyanexistingSystemProperty</a>
|
* > http://community.abiquo.com/display/ABI20/System+Property+resource#
|
||||||
*/
|
* SystemPropertyresource-ModifyanexistingSystemProperty</a>
|
||||||
public void update()
|
*/
|
||||||
{
|
public void update() {
|
||||||
target = context.getApi().getConfigApi().updateSystemProperty(target);
|
target = context.getApi().getConfigApi().updateSystemProperty(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue()
|
public String getValue() {
|
||||||
{
|
return target.getValue();
|
||||||
return target.getValue();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(final String value)
|
public void setValue(final String value) {
|
||||||
{
|
target.setValue(value);
|
||||||
target.setValue(value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "SystemPorperty [getName()=" + getName() + ", getValue()=" + getValue() + "]";
|
||||||
return "SystemPorperty [getName()=" + getName() + ", getValue()=" + getValue() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,40 +26,33 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public class IconOptions extends BaseHttpRequestOptions
|
public class IconOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
IconOptions options = new IconOptions();
|
||||||
IconOptions options = new IconOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private String path;
|
||||||
private String path;
|
|
||||||
|
|
||||||
public Builder path(final String path)
|
public Builder path(final String path) {
|
||||||
{
|
this.path = path;
|
||||||
this.path = path;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public IconOptions build()
|
public IconOptions build() {
|
||||||
{
|
IconOptions options = new IconOptions();
|
||||||
IconOptions options = new IconOptions();
|
if (path != null) {
|
||||||
if (path != null)
|
options.queryParameters.put("path", path);
|
||||||
{
|
}
|
||||||
options.queryParameters.put("path", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,51 +28,43 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class LicenseOptions extends BaseHttpRequestOptions
|
public class LicenseOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
LicenseOptions options = new LicenseOptions();
|
||||||
LicenseOptions options = new LicenseOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private Boolean active;
|
||||||
private Boolean active;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search active licenses
|
* Search active licenses
|
||||||
*/
|
*/
|
||||||
public Builder active(final boolean active)
|
public Builder active(final boolean active) {
|
||||||
{
|
this.active = active;
|
||||||
this.active = active;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search inaactive licenses
|
* Search inaactive licenses
|
||||||
*/
|
*/
|
||||||
public Builder inactive(final boolean inactive)
|
public Builder inactive(final boolean inactive) {
|
||||||
{
|
this.active = !inactive;
|
||||||
this.active = !inactive;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public LicenseOptions build()
|
public LicenseOptions build() {
|
||||||
{
|
LicenseOptions options = new LicenseOptions();
|
||||||
LicenseOptions options = new LicenseOptions();
|
if (active != null) {
|
||||||
if (active != null)
|
options.queryParameters.put("active", active.toString());
|
||||||
{
|
}
|
||||||
options.queryParameters.put("active", active.toString());
|
return options;
|
||||||
}
|
}
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,52 +26,43 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public class PropertyOptions extends BaseHttpRequestOptions
|
public class PropertyOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
PropertyOptions options = new PropertyOptions();
|
||||||
PropertyOptions options = new PropertyOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private String component;
|
||||||
private String component;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public Builder component(final String component)
|
public Builder component(final String component) {
|
||||||
{
|
this.component = component;
|
||||||
this.component = component;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public PropertyOptions build()
|
public PropertyOptions build() {
|
||||||
{
|
PropertyOptions options = new PropertyOptions();
|
||||||
PropertyOptions options = new PropertyOptions();
|
if (component != null) {
|
||||||
if (component != null)
|
options.queryParameters.put("component", component.toString());
|
||||||
{
|
}
|
||||||
options.queryParameters.put("component", component.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name != null)
|
if (name != null) {
|
||||||
{
|
options.queryParameters.put("name", name.toString());
|
||||||
options.queryParameters.put("name", name.toString());
|
}
|
||||||
}
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,55 +34,52 @@ import com.abiquo.server.core.enterprise.EnterprisePropertiesDto;
|
||||||
* Adds high level functionality to {@link EnterprisePropertiesDto}.
|
* Adds high level functionality to {@link EnterprisePropertiesDto}.
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource">
|
* @see API: <a href=
|
||||||
* http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource</a>
|
* "http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource"
|
||||||
|
* >
|
||||||
|
* http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource
|
||||||
|
* </a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class EnterpriseProperties extends DomainWrapper<EnterprisePropertiesDto>
|
public class EnterpriseProperties extends DomainWrapper<EnterprisePropertiesDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected EnterpriseProperties(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
protected EnterpriseProperties(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
final EnterprisePropertiesDto target) {
|
||||||
final EnterprisePropertiesDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource#EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise"
|
* "http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource#EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise"
|
||||||
* > http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource#
|
* > http://community.abiquo.com/display/ABI20/Enterprise+Properties+
|
||||||
* EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise</a>
|
* Resource#
|
||||||
*/
|
* EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise</a>
|
||||||
public void update()
|
*/
|
||||||
{
|
public void update() {
|
||||||
target = context.getApi().getEnterpriseApi().updateEnterpriseProperties(target);
|
target = context.getApi().getEnterpriseApi().updateEnterpriseProperties(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise"
|
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise"
|
||||||
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-
|
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#
|
||||||
* RetrieveaEnterprise</a>
|
* EnterpriseResource- RetrieveaEnterprise</a>
|
||||||
*/
|
*/
|
||||||
public Enterprise getEnterprise()
|
public Enterprise getEnterprise() {
|
||||||
{
|
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
||||||
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId));
|
||||||
return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi()
|
}
|
||||||
.getEnterprise(enterpriseId));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
public Map<String, String> getProperties()
|
public Map<String, String> getProperties() {
|
||||||
{
|
return target.getProperties();
|
||||||
return target.getProperties();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setProperties(final Map<String, String> properties)
|
public void setProperties(final Map<String, String> properties) {
|
||||||
{
|
target.setProperties(properties);
|
||||||
target.setProperties(properties);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.enterprise;
|
package org.jclouds.abiquo.domain.enterprise;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWithLimitsWrapper;
|
import org.jclouds.abiquo.domain.DomainWithLimitsWrapper;
|
||||||
|
@ -33,133 +32,120 @@ import com.abiquo.server.core.enterprise.DatacenterLimitsDto;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource"
|
||||||
|
* >
|
||||||
* http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource</a>
|
||||||
*/
|
*/
|
||||||
public class Limits extends DomainWithLimitsWrapper<DatacenterLimitsDto>
|
public class Limits extends DomainWithLimitsWrapper<DatacenterLimitsDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected Limits(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final DatacenterLimitsDto target) {
|
||||||
protected Limits(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final DatacenterLimitsDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource#DatacenterLimitsResource-UpdatesanexistingLimitforanenterpriseinadatacenter">
|
* "http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource#DatacenterLimitsResource-UpdatesanexistingLimitforanenterpriseinadatacenter"
|
||||||
* http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource#DatacenterLimitsResource-UpdatesanexistingLimitforanenterpriseinadatacenter</a>
|
* >
|
||||||
*/
|
* http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource
|
||||||
public void update()
|
* #DatacenterLimitsResource
|
||||||
{
|
* -UpdatesanexistingLimitforanenterpriseinadatacenter</a>
|
||||||
target = context.getApi().getEnterpriseApi().updateLimits(target);
|
*/
|
||||||
}
|
public void update() {
|
||||||
|
target = context.getApi().getEnterpriseApi().updateLimits(target);
|
||||||
|
}
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
return new Builder(context);
|
||||||
return new Builder(context);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder extends LimitsBuilder<Builder>
|
public static class Builder extends LimitsBuilder<Builder> {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS);
|
protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS);
|
protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS);
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
super();
|
||||||
super();
|
this.context = context;
|
||||||
this.context = context;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder repositoryLimits(final long soft, final long hard)
|
public Builder repositoryLimits(final long soft, final long hard) {
|
||||||
{
|
this.repositorySoft = soft;
|
||||||
this.repositorySoft = soft;
|
this.repositoryHard = hard;
|
||||||
this.repositoryHard = hard;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Limits build()
|
public Limits build() {
|
||||||
{
|
DatacenterLimitsDto dto = new DatacenterLimitsDto();
|
||||||
DatacenterLimitsDto dto = new DatacenterLimitsDto();
|
dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb);
|
||||||
dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb);
|
dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit);
|
||||||
dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit);
|
dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb);
|
||||||
dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb);
|
dto.setStorageLimits(storageSoft, storageHard);
|
||||||
dto.setStorageLimits(storageSoft, storageHard);
|
dto.setVlansLimits(vlansSoft, vlansHard);
|
||||||
dto.setVlansLimits(vlansSoft, vlansHard);
|
dto.setPublicIPLimits(publicIpsSoft, publicIpsHard);
|
||||||
dto.setPublicIPLimits(publicIpsSoft, publicIpsHard);
|
dto.setRepositoryHardLimitsInMb(repositoryHard);
|
||||||
dto.setRepositoryHardLimitsInMb(repositoryHard);
|
dto.setRepositorySoftLimitsInMb(repositorySoft);
|
||||||
dto.setRepositorySoftLimitsInMb(repositorySoft);
|
|
||||||
|
|
||||||
Limits limits = new Limits(context, dto);
|
Limits limits = new Limits(context, dto);
|
||||||
|
|
||||||
return limits;
|
return limits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromEnterprise(final Limits in)
|
public static Builder fromEnterprise(final Limits in) {
|
||||||
{
|
return Limits.builder(in.context).ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb())
|
||||||
return Limits.builder(in.context)
|
.cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit())
|
||||||
.ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb())
|
.hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb())
|
||||||
.cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit())
|
.storageLimits(in.getStorageSoft(), in.getStorageHard())
|
||||||
.hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb())
|
.vlansLimits(in.getVlansSoft(), in.getVlansHard())
|
||||||
.storageLimits(in.getStorageSoft(), in.getStorageHard())
|
.publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard())
|
||||||
.vlansLimits(in.getVlansSoft(), in.getVlansHard())
|
.repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard());
|
||||||
.publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard())
|
}
|
||||||
.repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getRepositoryHard()
|
public long getRepositoryHard() {
|
||||||
{
|
return target.getRepositoryHardLimitsInMb();
|
||||||
return target.getRepositoryHardLimitsInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getRepositorySoft()
|
public long getRepositorySoft() {
|
||||||
{
|
return target.getRepositorySoftLimitsInMb();
|
||||||
return target.getRepositorySoftLimitsInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setRepositoryHard(final long repositoryHard)
|
public void setRepositoryHard(final long repositoryHard) {
|
||||||
{
|
target.setRepositoryHardLimitsInMb(repositoryHard);
|
||||||
target.setRepositoryHardLimitsInMb(repositoryHard);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setRepositoryLimits(final long soft, final long hard)
|
public void setRepositoryLimits(final long soft, final long hard) {
|
||||||
{
|
target.setRepositoryHardLimitsInMb(hard);
|
||||||
target.setRepositoryHardLimitsInMb(hard);
|
target.setRepositorySoftLimitsInMb(soft);
|
||||||
target.setRepositorySoftLimitsInMb(soft);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setRepositorySoft(final long repositorySoft)
|
public void setRepositorySoft(final long repositorySoft) {
|
||||||
{
|
target.setRepositorySoftLimitsInMb(repositorySoft);
|
||||||
target.setRepositorySoftLimitsInMb(repositorySoft);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Limits [id=" + getId() + ", repositoryHard=" + getRepositoryHard() + ", repositorySoft="
|
||||||
return "Limits [id=" + getId() + ", repositoryHard=" + getRepositoryHard()
|
+ getRepositorySoft() + ", cpuCounthard=" + getCpuCountHardLimit() + ", cpuCountSoft="
|
||||||
+ ", repositorySoft=" + getRepositorySoft() + ", cpuCounthard="
|
+ getCpuCountSoftLimit() + ", hdHardInMB=" + getHdHardLimitInMb() + ", hdSoftInMB=" + getHdSoftLimitInMb()
|
||||||
+ getCpuCountHardLimit() + ", cpuCountSoft=" + getCpuCountSoftLimit() + ", hdHardInMB="
|
+ ", publicIPsHard=" + getPublicIpsHard() + ", publicIpsSoft=" + getPublicIpsSoft() + ", ramHardInMB="
|
||||||
+ getHdHardLimitInMb() + ", hdSoftInMB=" + getHdSoftLimitInMb() + ", publicIPsHard="
|
+ getRamHardLimitInMb() + ", ramSoftInMB=" + getRamSoftLimitInMb() + ", storageHard=" + getStorageHard()
|
||||||
+ getPublicIpsHard() + ", publicIpsSoft=" + getPublicIpsSoft() + ", ramHardInMB="
|
+ ", storageSoft=" + getStorageSoft() + ", vlansHard=" + getVlansHard() + ", vlansSoft=" + getVlansSoft()
|
||||||
+ getRamHardLimitInMb() + ", ramSoftInMB=" + getRamSoftLimitInMb() + ", storageHard="
|
+ "]";
|
||||||
+ getStorageHard() + ", storageSoft=" + getStorageSoft() + ", vlansHard="
|
}
|
||||||
+ getVlansHard() + ", vlansSoft=" + getVlansSoft() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,204 +47,177 @@ import com.google.common.collect.Lists;
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Roles+Resource">
|
* @see API: <a href="http://community.abiquo.com/display/ABI20/Roles+Resource">
|
||||||
* http://community.abiquo.com/display/ABI20/Roles+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Roles+Resource</a>
|
||||||
*/
|
*/
|
||||||
public class Role extends DomainWrapper<RoleDto>
|
public class Role extends DomainWrapper<RoleDto> {
|
||||||
{
|
/** Default active value of the user */
|
||||||
/** Default active value of the user */
|
private static final boolean DEFAULT_BLOCKED = false;
|
||||||
private static final boolean DEFAULT_BLOCKED = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected Role(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final RoleDto target)
|
protected Role(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final RoleDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-DeleteanexistingRole"
|
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-DeleteanexistingRole"
|
||||||
* >
|
* >
|
||||||
* http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-DeleteanexistingRole
|
* http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource
|
||||||
* </a>
|
* -DeleteanexistingRole </a>
|
||||||
*/
|
*/
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getAdminApi().deleteRole(target);
|
||||||
context.getApi().getAdminApi().deleteRole(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-CreateanewRole">
|
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-CreateanewRole"
|
||||||
* http
|
* > http
|
||||||
* ://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-CreateanewRole</a>
|
* ://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource
|
||||||
*/
|
* -CreateanewRole</a>
|
||||||
public void save()
|
*/
|
||||||
{
|
public void save() {
|
||||||
target = context.getApi().getAdminApi().createRole(target);
|
target = context.getApi().getAdminApi().createRole(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-UpdateanexistingRole"
|
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-UpdateanexistingRole"
|
||||||
* >
|
* >
|
||||||
* http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-UpdateanexistingRole
|
* http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource
|
||||||
* </a>
|
* -UpdateanexistingRole </a>
|
||||||
*/
|
*/
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
target = context.getApi().getAdminApi().updateRole(target);
|
||||||
target = context.getApi().getAdminApi().updateRole(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnterprise(final Enterprise enterprise)
|
public void setEnterprise(final Enterprise enterprise) {
|
||||||
{
|
checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
|
||||||
checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
|
checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class);
|
||||||
checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in "
|
|
||||||
+ Enterprise.class);
|
|
||||||
|
|
||||||
RESTLink link = enterprise.unwrap().searchLink("edit");
|
RESTLink link = enterprise.unwrap().searchLink("edit");
|
||||||
|
|
||||||
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
||||||
|
|
||||||
target.addLink(new RESTLink("enterprise", link.getHref()));
|
target.addLink(new RESTLink("enterprise", link.getHref()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public void setPrivileges(final List<Privilege> privileges)
|
public void setPrivileges(final List<Privilege> privileges) {
|
||||||
{
|
for (Privilege privilege : privileges) {
|
||||||
for (Privilege privilege : privileges)
|
addPrivilege(privilege);
|
||||||
{
|
}
|
||||||
addPrivilege(privilege);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
private void addPrivilege(final Privilege privilege)
|
private void addPrivilege(final Privilege privilege) {
|
||||||
{
|
checkNotNull(privilege, ValidationErrors.NULL_RESOURCE + Privilege.class);
|
||||||
checkNotNull(privilege, ValidationErrors.NULL_RESOURCE + Privilege.class);
|
checkNotNull(privilege.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Privilege.class);
|
||||||
checkNotNull(privilege.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in "
|
|
||||||
+ Privilege.class);
|
|
||||||
|
|
||||||
RESTLink link = privilege.unwrap().searchLink("self");
|
RESTLink link = privilege.unwrap().searchLink("self");
|
||||||
|
|
||||||
// rel would be "privilege" if the object is coming from a privilege list.
|
// rel would be "privilege" if the object is coming from a privilege list.
|
||||||
if (link == null)
|
if (link == null) {
|
||||||
{
|
link = privilege.unwrap().searchLink("privilege");
|
||||||
link = privilege.unwrap().searchLink("privilege");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
|
||||||
|
|
||||||
target.addLink(new RESTLink("privilege" + privilege.getId(), link.getHref()));
|
target.addLink(new RESTLink("privilege" + privilege.getId(), link.getHref()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Children access
|
// Children access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-RetrievealistofprivilegesfromaRole"
|
* "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-RetrievealistofprivilegesfromaRole"
|
||||||
* > http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-
|
* > http://community.abiquo.com/display/ABI20/Roles+Resource#
|
||||||
* RetrievealistofprivilegesfromaRole</a>
|
* RolesResource- RetrievealistofprivilegesfromaRole</a>
|
||||||
*/
|
*/
|
||||||
public List<Privilege> listPrivileges()
|
public List<Privilege> listPrivileges() {
|
||||||
{
|
PrivilegesDto dto = context.getApi().getAdminApi().listPrivileges(target);
|
||||||
PrivilegesDto dto = context.getApi().getAdminApi().listPrivileges(target);
|
|
||||||
|
|
||||||
return wrap(context, Privilege.class, dto.getCollection());
|
return wrap(context, Privilege.class, dto.getCollection());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Privilege> listPrivileges(final Predicate<Privilege> filter)
|
public List<Privilege> listPrivileges(final Predicate<Privilege> filter) {
|
||||||
{
|
return Lists.newLinkedList(filter(listPrivileges(), filter));
|
||||||
return Lists.newLinkedList(filter(listPrivileges(), filter));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Privilege findPrivileges(final Predicate<Privilege> filter)
|
public Privilege findPrivileges(final Predicate<Privilege> filter) {
|
||||||
{
|
return Iterables.getFirst(filter(listPrivileges(), filter), null);
|
||||||
return Iterables.getFirst(filter(listPrivileges(), filter), null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
return new Builder(context);
|
||||||
return new Builder(context);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private boolean blocked = DEFAULT_BLOCKED;
|
private boolean blocked = DEFAULT_BLOCKED;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
|
||||||
{
|
super();
|
||||||
super();
|
this.context = context;
|
||||||
this.context = context;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder blocked(final boolean blocked)
|
public Builder blocked(final boolean blocked) {
|
||||||
{
|
this.blocked = blocked;
|
||||||
this.blocked = blocked;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Role build()
|
public Role build() {
|
||||||
{
|
RoleDto dto = new RoleDto();
|
||||||
RoleDto dto = new RoleDto();
|
dto.setName(name);
|
||||||
dto.setName(name);
|
dto.setBlocked(blocked);
|
||||||
dto.setBlocked(blocked);
|
Role role = new Role(context, dto);
|
||||||
Role role = new Role(context, dto);
|
|
||||||
|
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromRole(final Role in)
|
public static Builder fromRole(final Role in) {
|
||||||
{
|
return Role.builder(in.context).blocked(in.isBlocked()).name(in.getName());
|
||||||
return Role.builder(in.context).blocked(in.isBlocked()).name(in.getName());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBlocked()
|
public boolean isBlocked() {
|
||||||
{
|
return target.isBlocked();
|
||||||
return target.isBlocked();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlocked(final boolean blocked)
|
public void setBlocked(final boolean blocked) {
|
||||||
{
|
target.setBlocked(blocked);
|
||||||
target.setBlocked(blocked);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Role [id=" + getId() + ", name=" + getName() + ", blocked=" + isBlocked() + "]";
|
||||||
return "Role [id=" + getId() + ", name=" + getName() + ", blocked=" + isBlocked() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,202 +35,185 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link TemplateDefinitionListDto}. A Template Definition List
|
* Adds high level functionality to {@link TemplateDefinitionListDto}. A
|
||||||
* provides a way to organize multiple Template Definitions. A single Template Definition can be
|
* Template Definition List provides a way to organize multiple Template
|
||||||
* shared by many lists. Its compatible with ovfindex.xml format.
|
* Definitions. A single Template Definition can be shared by many lists. Its
|
||||||
|
* compatible with ovfindex.xml format.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public class TemplateDefinitionList extends DomainWrapper<TemplateDefinitionListDto>
|
public class TemplateDefinitionList extends DomainWrapper<TemplateDefinitionListDto> {
|
||||||
{
|
/** The enterprise where the list belongs. */
|
||||||
/** The enterprise where the list belongs. */
|
private Enterprise enterprise;
|
||||||
private Enterprise enterprise;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected TemplateDefinitionList(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected TemplateDefinitionList(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
final TemplateDefinitionListDto target)
|
final TemplateDefinitionListDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the template definition list. Deleting the list doesn't delete the containing Template
|
* Delete the template definition list. Deleting the list doesn't delete the
|
||||||
* Definitions.
|
* containing Template Definitions.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Deleteatemplatedefinitionlist"
|
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Deleteatemplatedefinitionlist"
|
||||||
* > http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#
|
* > http://community.abiquo.com/display/ABI20/
|
||||||
* TemplateDefinitionListResource-Deleteatemplatedefinitionlist</a>
|
* TemplateDefinitionListResource#
|
||||||
*/
|
* TemplateDefinitionListResource-Deleteatemplatedefinitionlist</a>
|
||||||
public void delete()
|
*/
|
||||||
{
|
public void delete() {
|
||||||
context.getApi().getEnterpriseApi().deleteTemplateDefinitionList(target);
|
context.getApi().getEnterpriseApi().deleteTemplateDefinitionList(target);
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a template definition list. All the contained Template Definitions will also be
|
* Create a template definition list. All the contained Template Definitions
|
||||||
* created.
|
* will also be created.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Createatemplatedefinitionlist"
|
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Createatemplatedefinitionlist"
|
||||||
* > http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#
|
* > http://community.abiquo.com/display/ABI20/
|
||||||
* TemplateDefinitionListResource-Createatemplatedefinitionlistr</a>
|
* TemplateDefinitionListResource#
|
||||||
*/
|
* TemplateDefinitionListResource-Createatemplatedefinitionlistr</a>
|
||||||
public void save()
|
*/
|
||||||
{
|
public void save() {
|
||||||
target =
|
target = context.getApi().getEnterpriseApi().createTemplateDefinitionList(enterprise.unwrap(), target);
|
||||||
context.getApi().getEnterpriseApi()
|
}
|
||||||
.createTemplateDefinitionList(enterprise.unwrap(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a template definition list with the data from this template definition list.
|
* Update a template definition list with the data from this template
|
||||||
*
|
* definition list.
|
||||||
* @see API: <a href=
|
*
|
||||||
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Modifyatemplatedefinitionlist"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#
|
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Modifyatemplatedefinitionlist"
|
||||||
* TemplateDefinitionListResource-Modifyatemplatedefinitionlist</a>
|
* > http://community.abiquo.com/display/ABI20/
|
||||||
*/
|
* TemplateDefinitionListResource#
|
||||||
public void update()
|
* TemplateDefinitionListResource-Modifyatemplatedefinitionlist</a>
|
||||||
{
|
*/
|
||||||
target = context.getApi().getEnterpriseApi().updateTemplateDefinitionList(target);
|
public void update() {
|
||||||
}
|
target = context.getApi().getEnterpriseApi().updateTemplateDefinitionList(target);
|
||||||
|
}
|
||||||
|
|
||||||
// Children access
|
// Children access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of states of the templates in the template definition list in the
|
* Retrieve the list of states of the templates in the template definition
|
||||||
* repository of the given datacenter. Template Definition are available sources, but in order
|
* list in the repository of the given datacenter. Template Definition are
|
||||||
* to create a Virtual Machine the Definition should be downloaded into the Datacenter
|
* available sources, but in order to create a Virtual Machine the Definition
|
||||||
* Repository (NFS filesystem).
|
* should be downloaded into the Datacenter Repository (NFS filesystem).
|
||||||
*
|
*
|
||||||
* @param The datacenter in which repository search.
|
* @param The
|
||||||
* @see API: <a href=
|
* datacenter in which repository search.
|
||||||
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#
|
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist"
|
||||||
* TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist</a>
|
* > http://community.abiquo.com/display/ABI20/
|
||||||
*/
|
* TemplateDefinitionListResource# TemplateDefinitionListResource-
|
||||||
public List<TemplateState> listStatus(final Datacenter datacenter)
|
* Retrievealistofthestatusofalltemplatestatuslist</a>
|
||||||
{
|
*/
|
||||||
TemplatesStateDto states =
|
public List<TemplateState> listStatus(final Datacenter datacenter) {
|
||||||
context.getApi().getEnterpriseApi()
|
TemplatesStateDto states = context.getApi().getEnterpriseApi()
|
||||||
.listTemplateListStatus(target, datacenter.unwrap());
|
.listTemplateListStatus(target, datacenter.unwrap());
|
||||||
return wrap(context, TemplateState.class, states.getCollection());
|
return wrap(context, TemplateState.class, states.getCollection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a filtered list of states of the templates in the template definition list in the
|
* Retrieve a filtered list of states of the templates in the template
|
||||||
* repository of the given datacenter. Template Definition are available sources, but in order
|
* definition list in the repository of the given datacenter. Template
|
||||||
* to create a Virtual Machine the Definition should be downloaded into the Datacenter
|
* Definition are available sources, but in order to create a Virtual Machine
|
||||||
* Repository (NFS filesystem).
|
* the Definition should be downloaded into the Datacenter Repository (NFS
|
||||||
*
|
* filesystem).
|
||||||
* @param filter Filter to be applied to the list.
|
*
|
||||||
* @param The datacenter in which repository search.
|
* @param filter
|
||||||
* @see API: <a href=
|
* Filter to be applied to the list.
|
||||||
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist"
|
* @param The
|
||||||
* > http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#
|
* datacenter in which repository search.
|
||||||
* TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist</a>
|
* @see API: <a href=
|
||||||
*/
|
* "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist"
|
||||||
public List<TemplateState> listStatus(final Predicate<TemplateState> filter,
|
* > http://community.abiquo.com/display/ABI20/
|
||||||
final Datacenter datacenter)
|
* TemplateDefinitionListResource# TemplateDefinitionListResource-
|
||||||
{
|
* Retrievealistofthestatusofalltemplatestatuslist</a>
|
||||||
return Lists.newLinkedList(filter(listStatus(datacenter), filter));
|
*/
|
||||||
}
|
public List<TemplateState> listStatus(final Predicate<TemplateState> filter, final Datacenter datacenter) {
|
||||||
|
return Lists.newLinkedList(filter(listStatus(datacenter), filter));
|
||||||
|
}
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Enterprise enterprise) {
|
||||||
final Enterprise enterprise)
|
return new Builder(context, enterprise);
|
||||||
{
|
}
|
||||||
return new Builder(context, enterprise);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private Enterprise enterprise;
|
private Enterprise enterprise;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Enterprise enterprise) {
|
||||||
final Enterprise enterprise)
|
super();
|
||||||
{
|
this.context = context;
|
||||||
super();
|
this.enterprise = enterprise;
|
||||||
this.context = context;
|
}
|
||||||
this.enterprise = enterprise;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder url(final String url)
|
public Builder url(final String url) {
|
||||||
{
|
this.url = url;
|
||||||
this.url = url;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TemplateDefinitionList build()
|
public TemplateDefinitionList build() {
|
||||||
{
|
TemplateDefinitionListDto dto = new TemplateDefinitionListDto();
|
||||||
TemplateDefinitionListDto dto = new TemplateDefinitionListDto();
|
dto.setName(name);
|
||||||
dto.setName(name);
|
dto.setUrl(url);
|
||||||
dto.setUrl(url);
|
|
||||||
|
|
||||||
TemplateDefinitionList templateList = new TemplateDefinitionList(context, dto);
|
TemplateDefinitionList templateList = new TemplateDefinitionList(context, dto);
|
||||||
templateList.enterprise = enterprise;
|
templateList.enterprise = enterprise;
|
||||||
return templateList;
|
return templateList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromTemplateDefinitionList(final TemplateDefinitionList in)
|
public static Builder fromTemplateDefinitionList(final TemplateDefinitionList in) {
|
||||||
{
|
return TemplateDefinitionList.builder(in.context, in.enterprise).name(in.getName()).url(in.getUrl());
|
||||||
return TemplateDefinitionList.builder(in.context, in.enterprise).name(in.getName())
|
}
|
||||||
.url(in.getUrl());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl()
|
public String getUrl() {
|
||||||
{
|
return target.getUrl();
|
||||||
return target.getUrl();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(final String url)
|
public void setUrl(final String url) {
|
||||||
{
|
target.setUrl(url);
|
||||||
target.setUrl(url);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "TemplateDefinitionList [getId()=" + getId() + ", getName()=" + getName() + ", getUrl()=" + getUrl() + "]";
|
||||||
return "TemplateDefinitionList [getId()=" + getId() + ", getName()=" + getName()
|
}
|
||||||
+ ", getUrl()=" + getUrl() + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,49 +33,40 @@ import com.abiquo.am.model.TemplateStatusEnumType;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public class TemplateState extends DomainWrapper<TemplateStateDto>
|
public class TemplateState extends DomainWrapper<TemplateStateDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected TemplateState(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final TemplateStateDto target) {
|
||||||
protected TemplateState(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
super(context, target);
|
||||||
final TemplateStateDto target)
|
}
|
||||||
{
|
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
public Double getDownloadingProgress()
|
public Double getDownloadingProgress() {
|
||||||
{
|
return target.getDownloadingProgress();
|
||||||
return target.getDownloadingProgress();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getErrorCause()
|
public String getErrorCause() {
|
||||||
{
|
return target.getErrorCause();
|
||||||
return target.getErrorCause();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getMasterOvf()
|
public String getMasterOvf() {
|
||||||
{
|
return target.getMasterOvf();
|
||||||
return target.getMasterOvf();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getOvfId()
|
public String getOvfId() {
|
||||||
{
|
return target.getOvfId();
|
||||||
return target.getOvfId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TemplateStatusEnumType getStatus()
|
public TemplateStatusEnumType getStatus() {
|
||||||
{
|
return target.getStatus();
|
||||||
return target.getStatus();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "TemplateState [getDownloadingProgress()=" + getDownloadingProgress() + ", getErrorCause()="
|
||||||
return "TemplateState [getDownloadingProgress()=" + getDownloadingProgress()
|
+ getErrorCause() + ", getMasterOvf()=" + getMasterOvf() + ", getOvfId()=" + getOvfId() + ", getStatus()="
|
||||||
+ ", getErrorCause()=" + getErrorCause() + ", getMasterOvf()=" + getMasterOvf()
|
+ getStatus() + "]";
|
||||||
+ ", getOvfId()=" + getOvfId() + ", getStatus()=" + getStatus() + "]";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,457 +53,392 @@ import com.google.common.collect.Lists;
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/Users+Resource">
|
* @see API: <a href="http://community.abiquo.com/display/ABI20/Users+Resource">
|
||||||
* http://community.abiquo.com/display/ABI20/Users+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Users+Resource</a>
|
||||||
*/
|
*/
|
||||||
public class User extends DomainWrapper<UserDto>
|
public class User extends DomainWrapper<UserDto> {
|
||||||
{
|
/** Default active value of the user */
|
||||||
/** Default active value of the user */
|
private static final boolean DEFAULT_ACTIVE = true;
|
||||||
private static final boolean DEFAULT_ACTIVE = true;
|
|
||||||
|
/** The default authentication type. */
|
||||||
/** The default authentication type. */
|
private static final String DEFAULT_AUTH_TYPE = "ABIQUO";
|
||||||
private static final String DEFAULT_AUTH_TYPE = "ABIQUO";
|
|
||||||
|
/** The default locale for the user. */
|
||||||
/** The default locale for the user. */
|
private static final String DEFAULT_LOCALE = "en_US";
|
||||||
private static final String DEFAULT_LOCALE = "en_US";
|
|
||||||
|
/** The enterprise where the user belongs. */
|
||||||
/** The enterprise where the user belongs. */
|
private Enterprise enterprise;
|
||||||
private Enterprise enterprise;
|
|
||||||
|
/** Role of the user. */
|
||||||
/** Role of the user. */
|
private Role role;
|
||||||
private Role role;
|
|
||||||
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected User(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final UserDto target) {
|
||||||
protected User(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final UserDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
// Domain operations
|
||||||
|
|
||||||
// Domain operations
|
/**
|
||||||
|
* @see API: <a href=
|
||||||
/**
|
* "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Deleteanexistinguser"
|
||||||
* @see API: <a href=
|
* >
|
||||||
* "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Deleteanexistinguser"
|
* http://community.abiquo.com/display/ABI20/User+resource#Userresource
|
||||||
* >
|
* -Deleteanexistinguser </a>
|
||||||
* http://community.abiquo.com/display/ABI20/User+resource#Userresource-Deleteanexistinguser
|
*/
|
||||||
* </a>
|
public void delete() {
|
||||||
*/
|
context.getApi().getEnterpriseApi().deleteUser(target);
|
||||||
public void delete()
|
target = null;
|
||||||
{
|
}
|
||||||
context.getApi().getEnterpriseApi().deleteUser(target);
|
|
||||||
target = null;
|
/**
|
||||||
}
|
* @see API: <a href=
|
||||||
|
* "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Createanewuser"
|
||||||
/**
|
* >
|
||||||
* @see API: <a
|
* http://community.abiquo.com/display/ABI20/User+resource#Userresource
|
||||||
* href="http://community.abiquo.com/display/ABI20/User+resource#Userresource-Createanewuser"
|
* -Createanewuser</a>
|
||||||
* >
|
*/
|
||||||
* http://community.abiquo.com/display/ABI20/User+resource#Userresource-Createanewuser</a>
|
public void save() {
|
||||||
*/
|
// set role link
|
||||||
public void save()
|
target.addLink(new RESTLink("role", role.unwrap().getEditLink().getHref()));
|
||||||
{
|
target = context.getApi().getEnterpriseApi().createUser(enterprise.unwrap(), target);
|
||||||
// set role link
|
}
|
||||||
target.addLink(new RESTLink("role", role.unwrap().getEditLink().getHref()));
|
|
||||||
target = context.getApi().getEnterpriseApi().createUser(enterprise.unwrap(), target);
|
/**
|
||||||
}
|
* @see API: <a href=
|
||||||
|
* "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Updatesanexistinguser"
|
||||||
/**
|
* >
|
||||||
* @see API: <a href=
|
* http://community.abiquo.com/display/ABI20/User+resource#Userresource
|
||||||
* "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Updatesanexistinguser"
|
* -Updatesanexistinguser </a>
|
||||||
* >
|
*/
|
||||||
* http://community.abiquo.com/display/ABI20/User+resource#Userresource-Updatesanexistinguser
|
public void update() {
|
||||||
* </a>
|
// update role link (if exists)
|
||||||
*/
|
if (role != null) {
|
||||||
public void update()
|
target.searchLink("role").setHref(role.unwrap().getEditLink().getHref());
|
||||||
{
|
}
|
||||||
// update role link (if exists)
|
|
||||||
if (role != null)
|
target = context.getApi().getEnterpriseApi().updateUser(target);
|
||||||
{
|
}
|
||||||
target.searchLink("role").setHref(role.unwrap().getEditLink().getHref());
|
|
||||||
}
|
public List<VirtualDatacenter> listPermitedVirtualDatacenters() {
|
||||||
|
List<Integer> ids = extractAvailableDatacenters();
|
||||||
target = context.getApi().getEnterpriseApi().updateUser(target);
|
|
||||||
}
|
// null value means all virtual datacenters all allowed
|
||||||
|
if (ids.size() == 0) {
|
||||||
public List<VirtualDatacenter> listPermitedVirtualDatacenters()
|
return this.getEnterprise().listVirtualDatacenters();
|
||||||
{
|
}
|
||||||
List<Integer> ids = extractAvailableDatacenters();
|
|
||||||
|
ListVirtualDatacenters listVirtualDatacenters = context.getUtils().getInjector()
|
||||||
// null value means all virtual datacenters all allowed
|
.getInstance(ListVirtualDatacenters.class);
|
||||||
if (ids.size() == 0)
|
return Lists.newArrayList(listVirtualDatacenters.execute(ids));
|
||||||
{
|
}
|
||||||
return this.getEnterprise().listVirtualDatacenters();
|
|
||||||
}
|
public List<VirtualDatacenter> listPermitedVirtualDatacenters(final Predicate<VirtualDatacenter> filter) {
|
||||||
|
return Lists.newLinkedList(filter(listPermitedVirtualDatacenters(), filter));
|
||||||
ListVirtualDatacenters listVirtualDatacenters =
|
}
|
||||||
context.getUtils().getInjector().getInstance(ListVirtualDatacenters.class);
|
|
||||||
return Lists.newArrayList(listVirtualDatacenters.execute(ids));
|
public VirtualDatacenter findPermitedVirtualDatacenter(final Predicate<VirtualDatacenter> filter) {
|
||||||
}
|
return Iterables.getFirst(filter(listPermitedVirtualDatacenters(), filter), null);
|
||||||
|
}
|
||||||
public List<VirtualDatacenter> listPermitedVirtualDatacenters(
|
|
||||||
final Predicate<VirtualDatacenter> filter)
|
/**
|
||||||
{
|
* Give access to all virtualdatacenters in the enterprise (requires update).
|
||||||
return Lists.newLinkedList(filter(listPermitedVirtualDatacenters(), filter));
|
*/
|
||||||
}
|
public void permitAllVirtualDatacenters() {
|
||||||
|
setAvailableVirtualDatacenters(null);
|
||||||
public VirtualDatacenter findPermitedVirtualDatacenter(final Predicate<VirtualDatacenter> filter)
|
}
|
||||||
{
|
|
||||||
return Iterables.getFirst(filter(listPermitedVirtualDatacenters(), filter), null);
|
/**
|
||||||
}
|
* Limits user access ONLY to the virtual datacenters in the list. If the
|
||||||
|
* list is empty, user will get access to all virtual datacenters.
|
||||||
/**
|
*
|
||||||
* Give access to all virtualdatacenters in the enterprise (requires update).
|
* @param vdc
|
||||||
*/
|
* List of virtual datancers from the user's enterprise.
|
||||||
public void permitAllVirtualDatacenters()
|
*/
|
||||||
{
|
public void setPermitedVirtualDatacenters(final List<VirtualDatacenter> vdcs) {
|
||||||
setAvailableVirtualDatacenters(null);
|
List<Integer> ids = new ArrayList<Integer>();
|
||||||
}
|
|
||||||
|
for (VirtualDatacenter vdc : vdcs) {
|
||||||
/**
|
checkNotNull(vdc.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + VirtualDatacenter.class);
|
||||||
* Limits user access ONLY to the virtual datacenters in the list. If the list is empty, user
|
ids.add(vdc.getId());
|
||||||
* will get access to all virtual datacenters.
|
}
|
||||||
*
|
|
||||||
* @param vdc List of virtual datancers from the user's enterprise.
|
setAvailableVirtualDatacenters(ids);
|
||||||
*/
|
}
|
||||||
public void setPermitedVirtualDatacenters(final List<VirtualDatacenter> vdcs)
|
|
||||||
{
|
// Parent access
|
||||||
List<Integer> ids = new ArrayList<Integer>();
|
/**
|
||||||
|
* @see API: <a href=
|
||||||
for (VirtualDatacenter vdc : vdcs)
|
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise"
|
||||||
{
|
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#
|
||||||
checkNotNull(vdc.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in "
|
* EnterpriseResource- RetrieveaEnterprise</a>
|
||||||
+ VirtualDatacenter.class);
|
*/
|
||||||
ids.add(vdc.getId());
|
public Enterprise getEnterprise() {
|
||||||
}
|
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
||||||
|
return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId));
|
||||||
setAvailableVirtualDatacenters(ids);
|
}
|
||||||
}
|
|
||||||
|
// Children access
|
||||||
// Parent access
|
|
||||||
/**
|
public Role getRole() {
|
||||||
* @see API: <a href=
|
RoleDto role = context.getApi().getAdminApi().getRole(target);
|
||||||
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise"
|
return wrap(context, Role.class, role);
|
||||||
* > http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-
|
}
|
||||||
* RetrieveaEnterprise</a>
|
|
||||||
*/
|
/**
|
||||||
public Enterprise getEnterprise()
|
* @see API: <a href=
|
||||||
{
|
* "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Retrievethelistofvirtualmachinesbyuser"
|
||||||
Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE);
|
* > http://community.abiquo.com/display/ABI20/User+resource#
|
||||||
return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi()
|
* Userresource- Retrievethelistofvirtualmachinesbyuser</a>
|
||||||
.getEnterprise(enterpriseId));
|
*/
|
||||||
}
|
public List<VirtualMachine> listMachines() {
|
||||||
|
VirtualMachinesWithNodeExtendedDto machines = context.getApi().getEnterpriseApi().listVirtualMachines(target);
|
||||||
// Children access
|
return wrap(context, VirtualMachine.class, machines.getCollection());
|
||||||
|
}
|
||||||
public Role getRole()
|
|
||||||
{
|
public List<VirtualMachine> listMachines(final Predicate<VirtualMachine> filter) {
|
||||||
RoleDto role = context.getApi().getAdminApi().getRole(target);
|
return Lists.newLinkedList(filter(listMachines(), filter));
|
||||||
return wrap(context, Role.class, role);
|
}
|
||||||
}
|
|
||||||
|
public VirtualMachine findMachine(final Predicate<VirtualMachine> filter) {
|
||||||
/**
|
return Iterables.getFirst(filter(listMachines(), filter), null);
|
||||||
* @see API: <a href=
|
}
|
||||||
* "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Retrievethelistofvirtualmachinesbyuser"
|
|
||||||
* > http://community.abiquo.com/display/ABI20/User+resource#Userresource-
|
// Builder
|
||||||
* Retrievethelistofvirtualmachinesbyuser</a>
|
|
||||||
*/
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Enterprise enterprise,
|
||||||
public List<VirtualMachine> listMachines()
|
final Role role) {
|
||||||
{
|
return new Builder(context, enterprise, role);
|
||||||
VirtualMachinesWithNodeExtendedDto machines =
|
}
|
||||||
context.getApi().getEnterpriseApi().listVirtualMachines(target);
|
|
||||||
return wrap(context, VirtualMachine.class, machines.getCollection());
|
public static class Builder {
|
||||||
}
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
|
|
||||||
public List<VirtualMachine> listMachines(final Predicate<VirtualMachine> filter)
|
private Enterprise enterprise;
|
||||||
{
|
|
||||||
return Lists.newLinkedList(filter(listMachines(), filter));
|
private Role role;
|
||||||
}
|
|
||||||
|
private String name;
|
||||||
public VirtualMachine findMachine(final Predicate<VirtualMachine> filter)
|
|
||||||
{
|
private String nick;
|
||||||
return Iterables.getFirst(filter(listMachines(), filter), null);
|
|
||||||
}
|
private String locale = DEFAULT_LOCALE;
|
||||||
|
|
||||||
// Builder
|
private String password;
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
private String surname;
|
||||||
final Enterprise enterprise, final Role role)
|
|
||||||
{
|
private boolean active = DEFAULT_ACTIVE;
|
||||||
return new Builder(context, enterprise, role);
|
|
||||||
}
|
private String email;
|
||||||
|
|
||||||
public static class Builder
|
private String description;
|
||||||
{
|
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
private String authType = DEFAULT_AUTH_TYPE;
|
||||||
|
|
||||||
private Enterprise enterprise;
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Enterprise enterprise, final Role role) {
|
||||||
|
super();
|
||||||
private Role role;
|
checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
|
||||||
|
checkNotNull(role, ValidationErrors.NULL_RESOURCE + Role.class);
|
||||||
private String name;
|
this.context = context;
|
||||||
|
this.enterprise = enterprise;
|
||||||
private String nick;
|
this.role = role;
|
||||||
|
}
|
||||||
private String locale = DEFAULT_LOCALE;
|
|
||||||
|
public Builder enterprise(final Enterprise enterprise) {
|
||||||
private String password;
|
checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
|
||||||
|
this.enterprise = enterprise;
|
||||||
private String surname;
|
return this;
|
||||||
|
}
|
||||||
private boolean active = DEFAULT_ACTIVE;
|
|
||||||
|
public Builder role(final Role role) {
|
||||||
private String email;
|
this.role = role;
|
||||||
|
return this;
|
||||||
private String description;
|
}
|
||||||
|
|
||||||
private String authType = DEFAULT_AUTH_TYPE;
|
public Builder name(final String name, final String surname) {
|
||||||
|
this.name = name;
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
this.surname = surname;
|
||||||
final Enterprise enterprise, final Role role)
|
return this;
|
||||||
{
|
}
|
||||||
super();
|
|
||||||
checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
|
public Builder nick(final String nick) {
|
||||||
checkNotNull(role, ValidationErrors.NULL_RESOURCE + Role.class);
|
this.nick = nick;
|
||||||
this.context = context;
|
return this;
|
||||||
this.enterprise = enterprise;
|
}
|
||||||
this.role = role;
|
|
||||||
}
|
public Builder locale(final String locale) {
|
||||||
|
this.locale = locale;
|
||||||
public Builder enterprise(final Enterprise enterprise)
|
return this;
|
||||||
{
|
}
|
||||||
checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
|
|
||||||
this.enterprise = enterprise;
|
public Builder password(final String password) {
|
||||||
return this;
|
this.password = password;
|
||||||
}
|
return this;
|
||||||
|
}
|
||||||
public Builder role(final Role role)
|
|
||||||
{
|
public Builder active(final boolean active) {
|
||||||
this.role = role;
|
this.active = active;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(final String name, final String surname)
|
public Builder email(final String email) {
|
||||||
{
|
this.email = email;
|
||||||
this.name = name;
|
return this;
|
||||||
this.surname = surname;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder description(final String description) {
|
||||||
|
this.description = description;
|
||||||
public Builder nick(final String nick)
|
return this;
|
||||||
{
|
}
|
||||||
this.nick = nick;
|
|
||||||
return this;
|
public Builder authType(final String authType) {
|
||||||
}
|
this.authType = authType;
|
||||||
|
return this;
|
||||||
public Builder locale(final String locale)
|
}
|
||||||
{
|
|
||||||
this.locale = locale;
|
public User build() {
|
||||||
return this;
|
UserDto dto = new UserDto();
|
||||||
}
|
dto.setActive(active);
|
||||||
|
dto.setAuthType(authType);
|
||||||
public Builder password(final String password)
|
dto.setDescription(description);
|
||||||
{
|
dto.setEmail(email);
|
||||||
this.password = password;
|
dto.setLocale(locale);
|
||||||
return this;
|
dto.setName(name);
|
||||||
}
|
dto.setNick(nick);
|
||||||
|
dto.setPassword(password);
|
||||||
public Builder active(final boolean active)
|
dto.setSurname(surname);
|
||||||
{
|
User user = new User(context, dto);
|
||||||
this.active = active;
|
user.enterprise = enterprise;
|
||||||
return this;
|
user.role = role;
|
||||||
}
|
|
||||||
|
return user;
|
||||||
public Builder email(final String email)
|
}
|
||||||
{
|
|
||||||
this.email = email;
|
public static Builder fromUser(final User in) {
|
||||||
return this;
|
return User.builder(in.context, in.enterprise, in.role).active(in.isActive()).authType(in.getAuthType())
|
||||||
}
|
.description(in.getDescription()).email(in.getEmail()).locale(in.getLocale())
|
||||||
|
.name(in.getName(), in.getSurname()).nick(in.getNick()).password(in.getPassword());
|
||||||
public Builder description(final String description)
|
}
|
||||||
{
|
}
|
||||||
this.description = description;
|
|
||||||
return this;
|
// Delegate methods
|
||||||
}
|
|
||||||
|
public String getAuthType() {
|
||||||
public Builder authType(final String authType)
|
return target.getAuthType();
|
||||||
{
|
}
|
||||||
this.authType = authType;
|
|
||||||
return this;
|
public String getDescription() {
|
||||||
}
|
return target.getDescription();
|
||||||
|
}
|
||||||
public User build()
|
|
||||||
{
|
public String getEmail() {
|
||||||
UserDto dto = new UserDto();
|
return target.getEmail();
|
||||||
dto.setActive(active);
|
}
|
||||||
dto.setAuthType(authType);
|
|
||||||
dto.setDescription(description);
|
public Integer getId() {
|
||||||
dto.setEmail(email);
|
return target.getId();
|
||||||
dto.setLocale(locale);
|
}
|
||||||
dto.setName(name);
|
|
||||||
dto.setNick(nick);
|
public String getLocale() {
|
||||||
dto.setPassword(password);
|
return target.getLocale();
|
||||||
dto.setSurname(surname);
|
}
|
||||||
User user = new User(context, dto);
|
|
||||||
user.enterprise = enterprise;
|
public String getName() {
|
||||||
user.role = role;
|
return target.getName();
|
||||||
|
}
|
||||||
return user;
|
|
||||||
}
|
public String getNick() {
|
||||||
|
return target.getNick();
|
||||||
public static Builder fromUser(final User in)
|
}
|
||||||
{
|
|
||||||
return User.builder(in.context, in.enterprise, in.role).active(in.isActive())
|
public String getPassword() {
|
||||||
.authType(in.getAuthType()).description(in.getDescription()).email(in.getEmail())
|
return target.getPassword();
|
||||||
.locale(in.getLocale()).name(in.getName(), in.getSurname()).nick(in.getNick())
|
}
|
||||||
.password(in.getPassword());
|
|
||||||
}
|
public String getSurname() {
|
||||||
}
|
return target.getSurname();
|
||||||
|
}
|
||||||
// Delegate methods
|
|
||||||
|
public boolean isActive() {
|
||||||
public String getAuthType()
|
return target.isActive();
|
||||||
{
|
}
|
||||||
return target.getAuthType();
|
|
||||||
}
|
public void setActive(final boolean active) {
|
||||||
|
target.setActive(active);
|
||||||
public String getDescription()
|
}
|
||||||
{
|
|
||||||
return target.getDescription();
|
public void setAuthType(final String authType) {
|
||||||
}
|
target.setAuthType(authType);
|
||||||
|
}
|
||||||
public String getEmail()
|
|
||||||
{
|
public void setDescription(final String description) {
|
||||||
return target.getEmail();
|
target.setDescription(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId()
|
public void setEmail(final String email) {
|
||||||
{
|
target.setEmail(email);
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
public void setLocale(final String locale) {
|
||||||
public String getLocale()
|
target.setLocale(locale);
|
||||||
{
|
}
|
||||||
return target.getLocale();
|
|
||||||
}
|
public void setName(final String name) {
|
||||||
|
target.setName(name);
|
||||||
public String getName()
|
}
|
||||||
{
|
|
||||||
return target.getName();
|
public void setNick(final String nick) {
|
||||||
}
|
target.setNick(nick);
|
||||||
|
}
|
||||||
public String getNick()
|
|
||||||
{
|
public void setPassword(final String password) {
|
||||||
return target.getNick();
|
target.setPassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword()
|
public void setSurname(final String surname) {
|
||||||
{
|
target.setSurname(surname);
|
||||||
return target.getPassword();
|
}
|
||||||
}
|
|
||||||
|
public void setRole(final Role role) {
|
||||||
public String getSurname()
|
this.role = role;
|
||||||
{
|
}
|
||||||
return target.getSurname();
|
|
||||||
}
|
// Aux operations
|
||||||
|
|
||||||
public boolean isActive()
|
/**
|
||||||
{
|
* Converts the tokenized String of available virtual datacenters provided in
|
||||||
return target.isActive();
|
* the userDto to a list of ids.
|
||||||
}
|
*/
|
||||||
|
private List<Integer> extractAvailableDatacenters() {
|
||||||
public void setActive(final boolean active)
|
List<Integer> ids = Lists.newArrayList();
|
||||||
{
|
|
||||||
target.setActive(active);
|
if (target.getAvailableVirtualDatacenters() != null) {
|
||||||
}
|
|
||||||
|
StringTokenizer st = new StringTokenizer(target.getAvailableVirtualDatacenters(), ",");
|
||||||
public void setAuthType(final String authType)
|
|
||||||
{
|
while (st.hasMoreTokens()) {
|
||||||
target.setAuthType(authType);
|
ids.add(Integer.parseInt(st.nextToken()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void setDescription(final String description)
|
|
||||||
{
|
return ids;
|
||||||
target.setDescription(description);
|
}
|
||||||
}
|
|
||||||
|
private void setAvailableVirtualDatacenters(final List<Integer> ids) {
|
||||||
public void setEmail(final String email)
|
if (ids == null || ids.size() == 0) {
|
||||||
{
|
target.setAvailableVirtualDatacenters("");
|
||||||
target.setEmail(email);
|
} else {
|
||||||
}
|
Joiner joiner = Joiner.on(",").skipNulls();
|
||||||
|
target.setAvailableVirtualDatacenters(joiner.join(ids));
|
||||||
public void setLocale(final String locale)
|
}
|
||||||
{
|
}
|
||||||
target.setLocale(locale);
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
public void setName(final String name)
|
return "User [id=" + getId() + ", role=" + getRole() + ", authType=" + getAuthType() + ", description="
|
||||||
{
|
+ getDescription() + ", email=" + getEmail() + ", locale=" + getLocale() + ", name=" + getName()
|
||||||
target.setName(name);
|
+ ", nick=" + getNick() + ", password=" + getPassword() + ", surname=" + getSurname() + ", active="
|
||||||
}
|
+ isActive() + "]";
|
||||||
|
}
|
||||||
public void setNick(final String nick)
|
|
||||||
{
|
|
||||||
target.setNick(nick);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(final String password)
|
|
||||||
{
|
|
||||||
target.setPassword(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSurname(final String surname)
|
|
||||||
{
|
|
||||||
target.setSurname(surname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRole(final Role role)
|
|
||||||
{
|
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aux operations
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the tokenized String of available virtual datacenters provided in the userDto to a
|
|
||||||
* list of ids.
|
|
||||||
*/
|
|
||||||
private List<Integer> extractAvailableDatacenters()
|
|
||||||
{
|
|
||||||
List<Integer> ids = Lists.newArrayList();
|
|
||||||
|
|
||||||
if (target.getAvailableVirtualDatacenters() != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
StringTokenizer st = new StringTokenizer(target.getAvailableVirtualDatacenters(), ",");
|
|
||||||
|
|
||||||
while (st.hasMoreTokens())
|
|
||||||
{
|
|
||||||
ids.add(Integer.parseInt(st.nextToken()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAvailableVirtualDatacenters(final List<Integer> ids)
|
|
||||||
{
|
|
||||||
if (ids == null || ids.size() == 0)
|
|
||||||
{
|
|
||||||
target.setAvailableVirtualDatacenters("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Joiner joiner = Joiner.on(",").skipNulls();
|
|
||||||
target.setAvailableVirtualDatacenters(joiner.join(ids));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "User [id=" + getId() + ", role=" + getRole() + ", authType=" + getAuthType()
|
|
||||||
+ ", description=" + getDescription() + ", email=" + getEmail() + ", locale="
|
|
||||||
+ getLocale() + ", name=" + getName() + ", nick=" + getNick() + ", password="
|
|
||||||
+ getPassword() + ", surname=" + getSurname() + ", active=" + isActive() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,106 +27,89 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
*
|
*
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public class EnterpriseOptions extends BaseHttpRequestOptions
|
public class EnterpriseOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
EnterpriseOptions options = new EnterpriseOptions();
|
||||||
EnterpriseOptions options = new EnterpriseOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder extends BaseFilterOptionsBuilder<Builder>
|
public static class Builder extends BaseFilterOptionsBuilder<Builder> {
|
||||||
{
|
private String idPricingTemplate;
|
||||||
private String idPricingTemplate;
|
|
||||||
|
|
||||||
private Boolean included;
|
private Boolean included;
|
||||||
|
|
||||||
private String filter;
|
private String filter;
|
||||||
|
|
||||||
private Integer page;
|
private Integer page;
|
||||||
|
|
||||||
private Integer results;
|
private Integer results;
|
||||||
|
|
||||||
private Boolean network;
|
private Boolean network;
|
||||||
|
|
||||||
public Builder pricingTemplate(final String idPricingTemplate)
|
public Builder pricingTemplate(final String idPricingTemplate) {
|
||||||
{
|
this.idPricingTemplate = idPricingTemplate;
|
||||||
this.idPricingTemplate = idPricingTemplate;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder included(final boolean included)
|
public Builder included(final boolean included) {
|
||||||
{
|
this.included = included;
|
||||||
this.included = included;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder filter(final String filter)
|
public Builder filter(final String filter) {
|
||||||
{
|
this.filter = filter;
|
||||||
this.filter = filter;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder network(final boolean network)
|
public Builder network(final boolean network) {
|
||||||
{
|
this.network = network;
|
||||||
this.network = network;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder page(final int page)
|
public Builder page(final int page) {
|
||||||
{
|
this.page = page;
|
||||||
this.page = page;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder results(final int results)
|
public Builder results(final int results) {
|
||||||
{
|
this.results = results;
|
||||||
this.results = results;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public EnterpriseOptions build()
|
public EnterpriseOptions build() {
|
||||||
{
|
EnterpriseOptions options = new EnterpriseOptions();
|
||||||
EnterpriseOptions options = new EnterpriseOptions();
|
|
||||||
|
|
||||||
if (idPricingTemplate != null)
|
if (idPricingTemplate != null) {
|
||||||
{
|
options.queryParameters.put("idPricingTemplate", String.valueOf(idPricingTemplate));
|
||||||
options.queryParameters.put("idPricingTemplate", String.valueOf(idPricingTemplate));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (included != null)
|
if (included != null) {
|
||||||
{
|
options.queryParameters.put("included", String.valueOf(included));
|
||||||
options.queryParameters.put("included", String.valueOf(included));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (filter != null)
|
if (filter != null) {
|
||||||
{
|
options.queryParameters.put("filter", String.valueOf(filter));
|
||||||
options.queryParameters.put("filter", String.valueOf(filter));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (page != null)
|
if (page != null) {
|
||||||
{
|
options.queryParameters.put("page", String.valueOf(page));
|
||||||
options.queryParameters.put("page", String.valueOf(page));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (results != null)
|
if (results != null) {
|
||||||
{
|
options.queryParameters.put("numResults", String.valueOf(results));
|
||||||
options.queryParameters.put("numResults", String.valueOf(results));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (network != null)
|
if (network != null) {
|
||||||
{
|
options.queryParameters.put("network", String.valueOf(network));
|
||||||
options.queryParameters.put("network", String.valueOf(network));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return addFilterOptions(options);
|
return addFilterOptions(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,362 +32,290 @@ import com.abiquo.server.core.event.EventDto;
|
||||||
/**
|
/**
|
||||||
* @author Vivien Mahé
|
* @author Vivien Mahé
|
||||||
*/
|
*/
|
||||||
public class Event extends DomainWrapper<EventDto>
|
public class Event extends DomainWrapper<EventDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected Event(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final EventDto target) {
|
||||||
protected Event(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
super(context, target);
|
||||||
final EventDto target)
|
}
|
||||||
{
|
|
||||||
super(context, target);
|
// Delegate methods
|
||||||
}
|
|
||||||
|
public Integer getId() {
|
||||||
// Delegate methods
|
return target.getId();
|
||||||
|
}
|
||||||
public Integer getId()
|
|
||||||
{
|
public String getUser() {
|
||||||
return target.getId();
|
return target.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUser()
|
public void setUser(final String user) {
|
||||||
{
|
target.setUser(user);
|
||||||
return target.getUser();
|
}
|
||||||
}
|
|
||||||
|
public String getStacktrace() {
|
||||||
public void setUser(final String user)
|
return target.getStacktrace();
|
||||||
{
|
}
|
||||||
target.setUser(user);
|
|
||||||
}
|
public void setStacktrace(final String stacktrace) {
|
||||||
|
target.setStacktrace(stacktrace);
|
||||||
public String getStacktrace()
|
}
|
||||||
{
|
|
||||||
return target.getStacktrace();
|
public String getComponent() {
|
||||||
}
|
return target.getComponent();
|
||||||
|
}
|
||||||
public void setStacktrace(final String stacktrace)
|
|
||||||
{
|
public void setComponent(final String component) {
|
||||||
target.setStacktrace(stacktrace);
|
target.setComponent(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getComponent()
|
public String getPerformedBy() {
|
||||||
{
|
return target.getPerformedBy();
|
||||||
return target.getComponent();
|
}
|
||||||
}
|
|
||||||
|
public void setPerformedBy(final String performedBy) {
|
||||||
public void setComponent(final String component)
|
target.setPerformedBy(performedBy);
|
||||||
{
|
}
|
||||||
target.setComponent(component);
|
|
||||||
}
|
public Integer getIdNetwork() {
|
||||||
|
return target.getIdNetwork();
|
||||||
public String getPerformedBy()
|
}
|
||||||
{
|
|
||||||
return target.getPerformedBy();
|
public void setIdNetwork(final Integer idNetwork) {
|
||||||
}
|
target.setIdNetwork(idNetwork);
|
||||||
|
}
|
||||||
public void setPerformedBy(final String performedBy)
|
|
||||||
{
|
public String getIdVolume() {
|
||||||
target.setPerformedBy(performedBy);
|
return target.getIdVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getIdNetwork()
|
public void setIdVolume(final String idVolume) {
|
||||||
{
|
target.setIdVolume(idVolume);
|
||||||
return target.getIdNetwork();
|
}
|
||||||
}
|
|
||||||
|
public String getStoragePool() {
|
||||||
public void setIdNetwork(final Integer idNetwork)
|
return target.getStoragePool();
|
||||||
{
|
}
|
||||||
target.setIdNetwork(idNetwork);
|
|
||||||
}
|
public void setStoragePool(final String storagePool) {
|
||||||
|
target.setStoragePool(storagePool);
|
||||||
public String getIdVolume()
|
}
|
||||||
{
|
|
||||||
return target.getIdVolume();
|
public Date getTimestamp() {
|
||||||
}
|
return target.getTimestamp();
|
||||||
|
}
|
||||||
public void setIdVolume(final String idVolume)
|
|
||||||
{
|
public void setTimestamp(final Date timestamp) {
|
||||||
target.setIdVolume(idVolume);
|
target.setTimestamp(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStoragePool()
|
public String getVirtualApp() {
|
||||||
{
|
return target.getVirtualApp();
|
||||||
return target.getStoragePool();
|
}
|
||||||
}
|
|
||||||
|
public void setVirtualApp(final String virtualApp) {
|
||||||
public void setStoragePool(final String storagePool)
|
target.setVirtualApp(virtualApp);
|
||||||
{
|
}
|
||||||
target.setStoragePool(storagePool);
|
|
||||||
}
|
public String getDatacenter() {
|
||||||
|
return target.getDatacenter();
|
||||||
public Date getTimestamp()
|
}
|
||||||
{
|
|
||||||
return target.getTimestamp();
|
public void setDatacenter(final String datacenter) {
|
||||||
}
|
target.setDatacenter(datacenter);
|
||||||
|
}
|
||||||
public void setTimestamp(final Date timestamp)
|
|
||||||
{
|
public String getActionPerformed() {
|
||||||
target.setTimestamp(timestamp);
|
return target.getActionPerformed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVirtualApp()
|
public void setActionPerformed(final String actionPerformed) {
|
||||||
{
|
target.setActionPerformed(actionPerformed);
|
||||||
return target.getVirtualApp();
|
}
|
||||||
}
|
|
||||||
|
public Integer getIdVirtualMachine() {
|
||||||
public void setVirtualApp(final String virtualApp)
|
return target.getIdVirtualMachine();
|
||||||
{
|
}
|
||||||
target.setVirtualApp(virtualApp);
|
|
||||||
}
|
public void setIdVirtualMachine(final Integer idVirtualMachine) {
|
||||||
|
target.setIdVirtualMachine(idVirtualMachine);
|
||||||
public String getDatacenter()
|
}
|
||||||
{
|
|
||||||
return target.getDatacenter();
|
public String getVirtualDatacenter() {
|
||||||
}
|
return target.getVirtualDatacenter();
|
||||||
|
}
|
||||||
public void setDatacenter(final String datacenter)
|
|
||||||
{
|
public void setVirtualDatacenter(final String virtualDatacenter) {
|
||||||
target.setDatacenter(datacenter);
|
target.setVirtualDatacenter(virtualDatacenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActionPerformed()
|
public String getEnterprise() {
|
||||||
{
|
return target.getEnterprise();
|
||||||
return target.getActionPerformed();
|
}
|
||||||
}
|
|
||||||
|
public void setEnterprise(final String enterprise) {
|
||||||
public void setActionPerformed(final String actionPerformed)
|
target.setEnterprise(enterprise);
|
||||||
{
|
}
|
||||||
target.setActionPerformed(actionPerformed);
|
|
||||||
}
|
public String getStorageSystem() {
|
||||||
|
return target.getStorageSystem();
|
||||||
public Integer getIdVirtualMachine()
|
}
|
||||||
{
|
|
||||||
return target.getIdVirtualMachine();
|
public void setStorageSystem(final String storageSystem) {
|
||||||
}
|
target.setStorageSystem(storageSystem);
|
||||||
|
}
|
||||||
public void setIdVirtualMachine(final Integer idVirtualMachine)
|
|
||||||
{
|
public Integer getIdPhysicalMachine() {
|
||||||
target.setIdVirtualMachine(idVirtualMachine);
|
return target.getIdPhysicalMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVirtualDatacenter()
|
public void setIdPhysicalMachine(final Integer idPhysicalMachine) {
|
||||||
{
|
target.setIdPhysicalMachine(idPhysicalMachine);
|
||||||
return target.getVirtualDatacenter();
|
}
|
||||||
}
|
|
||||||
|
public SeverityType getSeverity() {
|
||||||
public void setVirtualDatacenter(final String virtualDatacenter)
|
return target.getSeverity();
|
||||||
{
|
}
|
||||||
target.setVirtualDatacenter(virtualDatacenter);
|
|
||||||
}
|
public void setSeverity(final SeverityType severity) {
|
||||||
|
target.setSeverity(severity);
|
||||||
public String getEnterprise()
|
}
|
||||||
{
|
|
||||||
return target.getEnterprise();
|
public Integer getIdStorageSystem() {
|
||||||
}
|
return target.getIdStorageSystem();
|
||||||
|
}
|
||||||
public void setEnterprise(final String enterprise)
|
|
||||||
{
|
public void setIdStorageSystem(final Integer idStorageSystem) {
|
||||||
target.setEnterprise(enterprise);
|
target.setIdStorageSystem(idStorageSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStorageSystem()
|
public Integer getIdDatacenter() {
|
||||||
{
|
return target.getIdDatacenter();
|
||||||
return target.getStorageSystem();
|
}
|
||||||
}
|
|
||||||
|
public void setIdDatacenter(final Integer idDatacenter) {
|
||||||
public void setStorageSystem(final String storageSystem)
|
target.setIdDatacenter(idDatacenter);
|
||||||
{
|
}
|
||||||
target.setStorageSystem(storageSystem);
|
|
||||||
}
|
public String getNetwork() {
|
||||||
|
return target.getNetwork();
|
||||||
public Integer getIdPhysicalMachine()
|
}
|
||||||
{
|
|
||||||
return target.getIdPhysicalMachine();
|
public void setNetwork(final String network) {
|
||||||
}
|
target.setNetwork(network);
|
||||||
|
}
|
||||||
public void setIdPhysicalMachine(final Integer idPhysicalMachine)
|
|
||||||
{
|
public String getPhysicalMachine() {
|
||||||
target.setIdPhysicalMachine(idPhysicalMachine);
|
return target.getPhysicalMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeverityType getSeverity()
|
public void setPhysicalMachine(final String physicalMachine) {
|
||||||
{
|
target.setPhysicalMachine(physicalMachine);
|
||||||
return target.getSeverity();
|
}
|
||||||
}
|
|
||||||
|
public String getRack() {
|
||||||
public void setSeverity(final SeverityType severity)
|
return target.getRack();
|
||||||
{
|
}
|
||||||
target.setSeverity(severity);
|
|
||||||
}
|
public void setRack(final String rack) {
|
||||||
|
target.setRack(rack);
|
||||||
public Integer getIdStorageSystem()
|
}
|
||||||
{
|
|
||||||
return target.getIdStorageSystem();
|
public Integer getIdVirtualDatacenter() {
|
||||||
}
|
return target.getIdVirtualDatacenter();
|
||||||
|
}
|
||||||
public void setIdStorageSystem(final Integer idStorageSystem)
|
|
||||||
{
|
public void setIdVirtualDatacenter(final Integer idVirtualDatacenter) {
|
||||||
target.setIdStorageSystem(idStorageSystem);
|
target.setIdVirtualDatacenter(idVirtualDatacenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getIdDatacenter()
|
public Integer getIdSubnet() {
|
||||||
{
|
return target.getIdSubnet();
|
||||||
return target.getIdDatacenter();
|
}
|
||||||
}
|
|
||||||
|
public void setIdSubnet(final Integer idSubnet) {
|
||||||
public void setIdDatacenter(final Integer idDatacenter)
|
target.setIdSubnet(idSubnet);
|
||||||
{
|
}
|
||||||
target.setIdDatacenter(idDatacenter);
|
|
||||||
}
|
public String getVolume() {
|
||||||
|
return target.getVolume();
|
||||||
public String getNetwork()
|
}
|
||||||
{
|
|
||||||
return target.getNetwork();
|
public void setVolume(final String volume) {
|
||||||
}
|
target.setVolume(volume);
|
||||||
|
}
|
||||||
public void setNetwork(final String network)
|
|
||||||
{
|
public String getSubnet() {
|
||||||
target.setNetwork(network);
|
return target.getSubnet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhysicalMachine()
|
public void setSubnet(final String subnet) {
|
||||||
{
|
target.setSubnet(subnet);
|
||||||
return target.getPhysicalMachine();
|
}
|
||||||
}
|
|
||||||
|
public Integer getIdUser() {
|
||||||
public void setPhysicalMachine(final String physicalMachine)
|
return target.getIdUser();
|
||||||
{
|
}
|
||||||
target.setPhysicalMachine(physicalMachine);
|
|
||||||
}
|
public void setIdUser(final Integer idUser) {
|
||||||
|
target.setIdUser(idUser);
|
||||||
public String getRack()
|
}
|
||||||
{
|
|
||||||
return target.getRack();
|
public String getIdStoragePool() {
|
||||||
}
|
return target.getIdStoragePool();
|
||||||
|
}
|
||||||
public void setRack(final String rack)
|
|
||||||
{
|
public void setIdStoragePool(final String idStoragePool) {
|
||||||
target.setRack(rack);
|
target.setIdStoragePool(idStoragePool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getIdVirtualDatacenter()
|
public Integer getIdRack() {
|
||||||
{
|
return target.getIdRack();
|
||||||
return target.getIdVirtualDatacenter();
|
}
|
||||||
}
|
|
||||||
|
public void setIdRack(final Integer idRack) {
|
||||||
public void setIdVirtualDatacenter(final Integer idVirtualDatacenter)
|
target.setIdRack(idRack);
|
||||||
{
|
}
|
||||||
target.setIdVirtualDatacenter(idVirtualDatacenter);
|
|
||||||
}
|
public String getVirtualMachine() {
|
||||||
|
return target.getVirtualMachine();
|
||||||
public Integer getIdSubnet()
|
}
|
||||||
{
|
|
||||||
return target.getIdSubnet();
|
public void setVirtualMachine(final String virtualMachine) {
|
||||||
}
|
target.setVirtualMachine(virtualMachine);
|
||||||
|
}
|
||||||
public void setIdSubnet(final Integer idSubnet)
|
|
||||||
{
|
public Integer getIdVirtualApp() {
|
||||||
target.setIdSubnet(idSubnet);
|
return target.getIdVirtualApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVolume()
|
public void setIdVirtualApp(final Integer idVirtualApp) {
|
||||||
{
|
target.setIdVirtualApp(idVirtualApp);
|
||||||
return target.getVolume();
|
}
|
||||||
}
|
|
||||||
|
public Integer getIdEnterprise() {
|
||||||
public void setVolume(final String volume)
|
return target.getIdEnterprise();
|
||||||
{
|
}
|
||||||
target.setVolume(volume);
|
|
||||||
}
|
public void setIdEnterprise(final Integer idEnterprise) {
|
||||||
|
target.setIdEnterprise(idEnterprise);
|
||||||
public String getSubnet()
|
}
|
||||||
{
|
|
||||||
return target.getSubnet();
|
@Override
|
||||||
}
|
public String toString() {
|
||||||
|
return "Event [id=" + getId() + ", idUser=" + getIdUser() + ", user=" + getUser() + ", idEnterprise="
|
||||||
public void setSubnet(final String subnet)
|
+ getIdEnterprise() + ", enterprise=" + getEnterprise() + ", actionPerformed=" + getActionPerformed()
|
||||||
{
|
+ ", component=" + getComponent() + ", idDatacenter=" + getIdDatacenter() + ", datacenter="
|
||||||
target.setSubnet(subnet);
|
+ getDatacenter() + ", idStoragePool=" + getIdStoragePool() + ", storagePool=" + getStoragePool()
|
||||||
}
|
+ ", idVolume=" + getIdVolume() + ", volume=" + getVolume() + ", idNetwork=" + getIdNetwork()
|
||||||
|
+ ", network=" + getNetwork() + ", idPhysicalMachine=" + getIdPhysicalMachine() + ", physicalMachine="
|
||||||
public Integer getIdUser()
|
+ getPhysicalMachine() + ", idRack=" + getIdRack() + ", rack=" + getRack() + ", idStorageSystem="
|
||||||
{
|
+ getIdStorageSystem() + ", storageSystem=" + getStorageSystem() + ", idSubnet=" + getIdSubnet()
|
||||||
return target.getIdUser();
|
+ ", subnet=" + getSubnet() + ", idVirtualApp=" + getIdVirtualApp() + ", virtualApp=" + getVirtualApp()
|
||||||
}
|
+ ", idVirtualDatacenter=" + getIdVirtualDatacenter() + ", virtualDatacenter=" + getVirtualDatacenter()
|
||||||
|
+ ", idVirtualMachine=" + getIdVirtualMachine() + ", virtualMachine=" + getVirtualMachine()
|
||||||
public void setIdUser(final Integer idUser)
|
+ ", stackstrace=" + getStacktrace() + ", performedBy=" + getPerformedBy() + ", severity=" + getSeverity()
|
||||||
{
|
|
||||||
target.setIdUser(idUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIdStoragePool()
|
|
||||||
{
|
|
||||||
return target.getIdStoragePool();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdStoragePool(final String idStoragePool)
|
|
||||||
{
|
|
||||||
target.setIdStoragePool(idStoragePool);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIdRack()
|
|
||||||
{
|
|
||||||
return target.getIdRack();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdRack(final Integer idRack)
|
|
||||||
{
|
|
||||||
target.setIdRack(idRack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVirtualMachine()
|
|
||||||
{
|
|
||||||
return target.getVirtualMachine();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVirtualMachine(final String virtualMachine)
|
|
||||||
{
|
|
||||||
target.setVirtualMachine(virtualMachine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIdVirtualApp()
|
|
||||||
{
|
|
||||||
return target.getIdVirtualApp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdVirtualApp(final Integer idVirtualApp)
|
|
||||||
{
|
|
||||||
target.setIdVirtualApp(idVirtualApp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIdEnterprise()
|
|
||||||
{
|
|
||||||
return target.getIdEnterprise();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdEnterprise(final Integer idEnterprise)
|
|
||||||
{
|
|
||||||
target.setIdEnterprise(idEnterprise);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Event [id=" + getId() + ", idUser=" + getIdUser() + ", user=" + getUser()
|
|
||||||
+ ", idEnterprise=" + getIdEnterprise() + ", enterprise=" + getEnterprise()
|
|
||||||
+ ", actionPerformed=" + getActionPerformed() + ", component=" + getComponent()
|
|
||||||
+ ", idDatacenter=" + getIdDatacenter() + ", datacenter=" + getDatacenter()
|
|
||||||
+ ", idStoragePool=" + getIdStoragePool() + ", storagePool=" + getStoragePool()
|
|
||||||
+ ", idVolume=" + getIdVolume() + ", volume=" + getVolume() + ", idNetwork="
|
|
||||||
+ getIdNetwork() + ", network=" + getNetwork() + ", idPhysicalMachine="
|
|
||||||
+ getIdPhysicalMachine() + ", physicalMachine=" + getPhysicalMachine() + ", idRack="
|
|
||||||
+ getIdRack() + ", rack=" + getRack() + ", idStorageSystem=" + getIdStorageSystem()
|
|
||||||
+ ", storageSystem=" + getStorageSystem() + ", idSubnet=" + getIdSubnet() + ", subnet="
|
|
||||||
+ getSubnet() + ", idVirtualApp=" + getIdVirtualApp() + ", virtualApp="
|
|
||||||
+ getVirtualApp() + ", idVirtualDatacenter=" + getIdVirtualDatacenter()
|
|
||||||
+ ", virtualDatacenter=" + getVirtualDatacenter() + ", idVirtualMachine="
|
|
||||||
+ getIdVirtualMachine() + ", virtualMachine=" + getVirtualMachine() + ", stackstrace="
|
|
||||||
+ getStacktrace() + ", performedBy=" + getPerformedBy() + ", severity=" + getSeverity()
|
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,161 +36,134 @@ import com.google.common.collect.Maps;
|
||||||
*
|
*
|
||||||
* @author Vivien Mahé
|
* @author Vivien Mahé
|
||||||
*/
|
*/
|
||||||
public class EventOptions extends BaseHttpRequestOptions
|
public class EventOptions extends BaseHttpRequestOptions {
|
||||||
{
|
public static Builder builder() {
|
||||||
public static Builder builder()
|
return new Builder();
|
||||||
{
|
}
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object clone() throws CloneNotSupportedException
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
{
|
EventOptions options = new EventOptions();
|
||||||
EventOptions options = new EventOptions();
|
options.queryParameters.putAll(queryParameters);
|
||||||
options.queryParameters.putAll(queryParameters);
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder extends BaseFilterOptionsBuilder<Builder>
|
public static class Builder extends BaseFilterOptionsBuilder<Builder> {
|
||||||
{
|
private Map<String, String> filters = Maps.newHashMap();
|
||||||
private Map<String, String> filters = Maps.newHashMap();
|
|
||||||
|
|
||||||
public Builder filters(final Map<String, String> filters)
|
public Builder filters(final Map<String, String> filters) {
|
||||||
{
|
this.filters = filters;
|
||||||
this.filters = filters;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder severity(final SeverityType severity)
|
public Builder severity(final SeverityType severity) {
|
||||||
{
|
this.filters.put("severity", severity.name());
|
||||||
this.filters.put("severity", severity.name());
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder component(final ComponentType component)
|
public Builder component(final ComponentType component) {
|
||||||
{
|
this.filters.put("component", component.name());
|
||||||
this.filters.put("component", component.name());
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder actionPerformed(final EventType action)
|
public Builder actionPerformed(final EventType action) {
|
||||||
{
|
this.filters.put("actionperformed", action.name());
|
||||||
this.filters.put("actionperformed", action.name());
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder datacenterName(final String dc)
|
public Builder datacenterName(final String dc) {
|
||||||
{
|
this.filters.put("datacenter", dc);
|
||||||
this.filters.put("datacenter", dc);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder rackName(final String rack)
|
public Builder rackName(final String rack) {
|
||||||
{
|
this.filters.put("rack", rack);
|
||||||
this.filters.put("rack", rack);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder physicalMachineName(final String pm)
|
public Builder physicalMachineName(final String pm) {
|
||||||
{
|
this.filters.put("physicalmachine", pm);
|
||||||
this.filters.put("physicalmachine", pm);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder storageSystemName(final String ss)
|
public Builder storageSystemName(final String ss) {
|
||||||
{
|
this.filters.put("storagesystem", ss);
|
||||||
this.filters.put("storagesystem", ss);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder storagePoolName(final String sp)
|
public Builder storagePoolName(final String sp) {
|
||||||
{
|
this.filters.put("storagepool", sp);
|
||||||
this.filters.put("storagepool", sp);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder volumeName(final String volume)
|
public Builder volumeName(final String volume) {
|
||||||
{
|
this.filters.put("volume", volume);
|
||||||
this.filters.put("volume", volume);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder networkName(final String network)
|
public Builder networkName(final String network) {
|
||||||
{
|
this.filters.put("network", network);
|
||||||
this.filters.put("network", network);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder subnetName(final String subnet)
|
public Builder subnetName(final String subnet) {
|
||||||
{
|
this.filters.put("subnet", subnet);
|
||||||
this.filters.put("subnet", subnet);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder enterpriseName(final String ent)
|
public Builder enterpriseName(final String ent) {
|
||||||
{
|
this.filters.put("enterprise", ent);
|
||||||
this.filters.put("enterprise", ent);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder userName(final String user)
|
public Builder userName(final String user) {
|
||||||
{
|
this.filters.put("user", user);
|
||||||
this.filters.put("user", user);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder virtualDatacenterName(final String vdc)
|
public Builder virtualDatacenterName(final String vdc) {
|
||||||
{
|
this.filters.put("virtualdatacenter", vdc);
|
||||||
this.filters.put("virtualdatacenter", vdc);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder virtualAppName(final String vapp)
|
public Builder virtualAppName(final String vapp) {
|
||||||
{
|
this.filters.put("virtualapp", vapp);
|
||||||
this.filters.put("virtualapp", vapp);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder virtualMachineName(final String vm)
|
public Builder virtualMachineName(final String vm) {
|
||||||
{
|
this.filters.put("virtualMachine", vm);
|
||||||
this.filters.put("virtualMachine", vm);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder performedBy(final String pb)
|
public Builder performedBy(final String pb) {
|
||||||
{
|
this.filters.put("performedBy", pb);
|
||||||
this.filters.put("performedBy", pb);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder description(final String description)
|
public Builder description(final String description) {
|
||||||
{
|
this.filters.put("stacktrace", description);
|
||||||
this.filters.put("stacktrace", description);
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder dateFrom(final Date date)
|
public Builder dateFrom(final Date date) {
|
||||||
{
|
this.filters.put("datefrom", String.valueOf(date.getTime()));
|
||||||
this.filters.put("datefrom", String.valueOf(date.getTime()));
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder dateTo(final Date date)
|
public Builder dateTo(final Date date) {
|
||||||
{
|
this.filters.put("dateTo", String.valueOf(date.getTime()));
|
||||||
this.filters.put("dateTo", String.valueOf(date.getTime()));
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public EventOptions build()
|
public EventOptions build() {
|
||||||
{
|
EventOptions options = new EventOptions();
|
||||||
EventOptions options = new EventOptions();
|
|
||||||
|
|
||||||
for (Entry<String, String> filter : filters.entrySet())
|
for (Entry<String, String> filter : filters.entrySet()) {
|
||||||
{
|
options.queryParameters.put(filter.getKey(), filter.getValue());
|
||||||
options.queryParameters.put(filter.getKey(), filter.getValue());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return addFilterOptions(options);
|
return addFilterOptions(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,91 +38,80 @@ import com.google.common.collect.Lists;
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class AbiquoException extends RuntimeException
|
public class AbiquoException extends RuntimeException {
|
||||||
{
|
/** Serial UID. */
|
||||||
/** Serial UID. */
|
private static final long serialVersionUID = 1L;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** The HTTP statuc. */
|
/** The HTTP statuc. */
|
||||||
private Status httpStatus;
|
private Status httpStatus;
|
||||||
|
|
||||||
/** The errors. */
|
/** The errors. */
|
||||||
private ErrorsDto errors;
|
private ErrorsDto errors;
|
||||||
|
|
||||||
public AbiquoException(final Status httpStatus, final ErrorsDto errors)
|
public AbiquoException(final Status httpStatus, final ErrorsDto errors) {
|
||||||
{
|
super();
|
||||||
super();
|
this.httpStatus = httpStatus;
|
||||||
this.httpStatus = httpStatus;
|
this.errors = errors;
|
||||||
this.errors = errors;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if there is an error with the given code.
|
* Check if there is an error with the given code.
|
||||||
*/
|
*/
|
||||||
public boolean hasError(final String code)
|
public boolean hasError(final String code) {
|
||||||
{
|
return any(errors.getCollection(), code(code));
|
||||||
return any(errors.getCollection(), code(code));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the first error with the given code.
|
* Find the first error with the given code.
|
||||||
*/
|
*/
|
||||||
public ErrorDto findError(final String code)
|
public ErrorDto findError(final String code) {
|
||||||
{
|
return find(errors.getCollection(), code(code), null);
|
||||||
return find(errors.getCollection(), code(code), null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all errors with the given code.
|
* Find all errors with the given code.
|
||||||
*/
|
*/
|
||||||
public List<ErrorDto> findErrors(final String code)
|
public List<ErrorDto> findErrors(final String code) {
|
||||||
{
|
return Lists.newLinkedList(filter(errors.getCollection(), code(code)));
|
||||||
return Lists.newLinkedList(filter(errors.getCollection(), code(code)));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of errors.
|
* Get the number of errors.
|
||||||
*/
|
*/
|
||||||
public int numErrors()
|
public int numErrors() {
|
||||||
{
|
return errors.getCollection().size();
|
||||||
return errors.getCollection().size();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of all errors.
|
* Get the list of all errors.
|
||||||
*/
|
*/
|
||||||
public List<ErrorDto> getErrors()
|
public List<ErrorDto> getErrors() {
|
||||||
{
|
return errors.getCollection();
|
||||||
return errors.getCollection();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the HTTP status code.
|
* Get the HTTP status code.
|
||||||
*/
|
*/
|
||||||
public int getHttpStatusCode()
|
public int getHttpStatusCode() {
|
||||||
{
|
return httpStatus.getStatusCode();
|
||||||
return httpStatus.getStatusCode();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the HTTP status name.
|
* Get the HTTP status name.
|
||||||
*/
|
*/
|
||||||
public String getHttpStatusName()
|
public String getHttpStatusName() {
|
||||||
{
|
return httpStatus.getReasonPhrase();
|
||||||
return httpStatus.getReasonPhrase();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the HTTP status.
|
* Get the HTTP status.
|
||||||
*/
|
*/
|
||||||
public Status getHttpStatus()
|
public Status getHttpStatus() {
|
||||||
{
|
return httpStatus;
|
||||||
return httpStatus;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage()
|
public String getMessage() {
|
||||||
{
|
return errors.toString();
|
||||||
return errors.toString();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,38 +24,38 @@ package org.jclouds.abiquo.domain.exception;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class BuilderException extends RuntimeException
|
public class BuilderException extends RuntimeException {
|
||||||
{
|
private static final long serialVersionUID = 1L;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link BuilderException} with the given message.
|
* Creates a {@link BuilderException} with the given message.
|
||||||
*
|
*
|
||||||
* @param message The message.
|
* @param message
|
||||||
*/
|
* The message.
|
||||||
public BuilderException(String message)
|
*/
|
||||||
{
|
public BuilderException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link BuilderException} with the given cause.
|
* Creates a {@link BuilderException} with the given cause.
|
||||||
*
|
*
|
||||||
* @param cause The cause.
|
* @param cause
|
||||||
*/
|
* The cause.
|
||||||
public BuilderException(Throwable cause)
|
*/
|
||||||
{
|
public BuilderException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link BuilderException} with the given message and cause.
|
* Creates a {@link BuilderException} with the given message and cause.
|
||||||
*
|
*
|
||||||
* @param message The message.
|
* @param message
|
||||||
* @param cause The cause.
|
* The message.
|
||||||
*/
|
* @param cause
|
||||||
public BuilderException(String message, Throwable cause)
|
* The cause.
|
||||||
{
|
*/
|
||||||
super(message, cause);
|
public BuilderException(String message, Throwable cause) {
|
||||||
}
|
super(message, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,48 +28,40 @@ import com.abiquo.model.transport.SingleResourceTransportDto;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class WrapperException extends RuntimeException
|
public class WrapperException extends RuntimeException {
|
||||||
{
|
private static final long serialVersionUID = 1L;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private Class< ? extends DomainWrapper< ? >> wrapperClass;
|
private Class<? extends DomainWrapper<?>> wrapperClass;
|
||||||
|
|
||||||
private SingleResourceTransportDto target;
|
private SingleResourceTransportDto target;
|
||||||
|
|
||||||
public WrapperException(final Class< ? extends DomainWrapper< ? >> wrapperClass,
|
public WrapperException(final Class<? extends DomainWrapper<?>> wrapperClass,
|
||||||
final SingleResourceTransportDto target, Throwable cause)
|
final SingleResourceTransportDto target, Throwable cause) {
|
||||||
{
|
super(cause);
|
||||||
super(cause);
|
this.wrapperClass = wrapperClass;
|
||||||
this.wrapperClass = wrapperClass;
|
this.target = target;
|
||||||
this.target = target;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage()
|
public String getMessage() {
|
||||||
{
|
String msg = "Could not wrap object [" + target + "] in class " + wrapperClass.getName() + ": ";
|
||||||
String msg =
|
return msg + super.getMessage();
|
||||||
"Could not wrap object [" + target + "] in class " + wrapperClass.getName() + ": ";
|
}
|
||||||
return msg + super.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class< ? extends DomainWrapper< ? >> getWrapperClass()
|
public Class<? extends DomainWrapper<?>> getWrapperClass() {
|
||||||
{
|
return wrapperClass;
|
||||||
return wrapperClass;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setWrapperClass(Class< ? extends DomainWrapper< ? >> wrapperClass)
|
public void setWrapperClass(Class<? extends DomainWrapper<?>> wrapperClass) {
|
||||||
{
|
this.wrapperClass = wrapperClass;
|
||||||
this.wrapperClass = wrapperClass;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public SingleResourceTransportDto getTarget()
|
public SingleResourceTransportDto getTarget() {
|
||||||
{
|
return target;
|
||||||
return target;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setTarget(SingleResourceTransportDto target)
|
public void setTarget(SingleResourceTransportDto target) {
|
||||||
{
|
this.target = target;
|
||||||
this.target = target;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,316 +41,261 @@ import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link MachineDto}. This class defines common methods for
|
* Adds high level functionality to {@link MachineDto}. This class defines
|
||||||
* unmanaged {@link Machine} and managed {@link Blade} physical machines.
|
* common methods for unmanaged {@link Machine} and managed {@link Blade}
|
||||||
|
* physical machines.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/MachineResource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/MachineResource">
|
||||||
* http://community.abiquo.com/display/ABI20/MachineResource</a>
|
* http://community.abiquo.com/display/ABI20/MachineResource</a>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPhysicalMachine extends DomainWrapper<MachineDto>
|
public abstract class AbstractPhysicalMachine extends DomainWrapper<MachineDto> {
|
||||||
{
|
/** The default virtual ram used in MB. */
|
||||||
/** The default virtual ram used in MB. */
|
protected static final int DEFAULT_VRAM_USED = 1;
|
||||||
protected static final int DEFAULT_VRAM_USED = 1;
|
|
||||||
|
|
||||||
/** The default virtual cpu used in MB. */
|
/** The default virtual cpu used in MB. */
|
||||||
protected static final int DEFAULT_VCPU_USED = 1;
|
protected static final int DEFAULT_VCPU_USED = 1;
|
||||||
|
|
||||||
/** List of available virtual switches provided by discover operation **/
|
/** List of available virtual switches provided by discover operation **/
|
||||||
protected List<String> virtualSwitches;
|
protected List<String> virtualSwitches;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected AbstractPhysicalMachine(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
protected AbstractPhysicalMachine(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final MachineDto target) {
|
||||||
final MachineDto target)
|
super(context, target);
|
||||||
{
|
extractVirtualSwitches();
|
||||||
super(context, target);
|
}
|
||||||
extractVirtualSwitches();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getInfrastructureApi().deleteMachine(target);
|
||||||
context.getApi().getInfrastructureApi().deleteMachine(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
target = context.getApi().getInfrastructureApi().updateMachine(target);
|
||||||
target = context.getApi().getInfrastructureApi().updateMachine(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public MachineState check()
|
public MachineState check() {
|
||||||
{
|
MachineStateDto dto = context.getApi().getInfrastructureApi().checkMachineState(target, true);
|
||||||
MachineStateDto dto =
|
MachineState state = dto.getState();
|
||||||
context.getApi().getInfrastructureApi().checkMachineState(target, true);
|
target.setState(state);
|
||||||
MachineState state = dto.getState();
|
return state;
|
||||||
target.setState(state);
|
}
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MachineIpmiState checkIpmi()
|
public MachineIpmiState checkIpmi() {
|
||||||
{
|
MachineIpmiStateDto dto = context.getApi().getInfrastructureApi().checkMachineIpmiState(target);
|
||||||
MachineIpmiStateDto dto =
|
return dto.getState();
|
||||||
context.getApi().getInfrastructureApi().checkMachineIpmiState(target);
|
}
|
||||||
return dto.getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Children access
|
// Children access
|
||||||
|
|
||||||
public List<Datastore> getDatastores()
|
public List<Datastore> getDatastores() {
|
||||||
{
|
return wrap(context, Datastore.class, target.getDatastores().getCollection());
|
||||||
return wrap(context, Datastore.class, target.getDatastores().getCollection());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Datastore findDatastore(final String name)
|
public Datastore findDatastore(final String name) {
|
||||||
{
|
return find(getDatastores(), DatastorePredicates.name(name), null);
|
||||||
return find(getDatastores(), DatastorePredicates.name(name), null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getIp()
|
public String getIp() {
|
||||||
{
|
return target.getIp();
|
||||||
return target.getIp();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getIpmiIp()
|
public String getIpmiIp() {
|
||||||
{
|
return target.getIpmiIP();
|
||||||
return target.getIpmiIP();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getIpmiPassword()
|
public String getIpmiPassword() {
|
||||||
{
|
return target.getIpmiPassword();
|
||||||
return target.getIpmiPassword();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIpmiPort()
|
public Integer getIpmiPort() {
|
||||||
{
|
return target.getIpmiPort();
|
||||||
return target.getIpmiPort();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getIpmiUser()
|
public String getIpmiUser() {
|
||||||
{
|
return target.getIpmiUser();
|
||||||
return target.getIpmiUser();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getIpService()
|
public String getIpService() {
|
||||||
{
|
return target.getIpService();
|
||||||
return target.getIpService();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword()
|
public String getPassword() {
|
||||||
{
|
return target.getPassword();
|
||||||
return target.getPassword();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPort()
|
public Integer getPort() {
|
||||||
{
|
return target.getPort();
|
||||||
return target.getPort();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public MachineState getState()
|
public MachineState getState() {
|
||||||
{
|
return target.getState();
|
||||||
return target.getState();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public HypervisorType getType()
|
public HypervisorType getType() {
|
||||||
{
|
return target.getType();
|
||||||
return target.getType();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getUser()
|
public String getUser() {
|
||||||
{
|
return target.getUser();
|
||||||
return target.getUser();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVirtualCpuCores()
|
public Integer getVirtualCpuCores() {
|
||||||
{
|
return target.getVirtualCpuCores();
|
||||||
return target.getVirtualCpuCores();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVirtualCpusUsed()
|
public Integer getVirtualCpusUsed() {
|
||||||
{
|
return target.getVirtualCpusUsed();
|
||||||
return target.getVirtualCpusUsed();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVirtualRamInMb()
|
public Integer getVirtualRamInMb() {
|
||||||
{
|
return target.getVirtualRamInMb();
|
||||||
return target.getVirtualRamInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVirtualRamUsedInMb()
|
public Integer getVirtualRamUsedInMb() {
|
||||||
{
|
return target.getVirtualRamUsedInMb();
|
||||||
return target.getVirtualRamUsedInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getVirtualSwitch()
|
public String getVirtualSwitch() {
|
||||||
{
|
return target.getVirtualSwitch();
|
||||||
return target.getVirtualSwitch();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDatastores(final List<Datastore> datastores)
|
public void setDatastores(final List<Datastore> datastores) {
|
||||||
{
|
DatastoresDto datastoresDto = new DatastoresDto();
|
||||||
DatastoresDto datastoresDto = new DatastoresDto();
|
datastoresDto.getCollection().addAll(DomainWrapper.unwrap(datastores));
|
||||||
datastoresDto.getCollection().addAll(DomainWrapper.unwrap(datastores));
|
target.setDatastores(datastoresDto);
|
||||||
target.setDatastores(datastoresDto);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(final String description)
|
public void setDescription(final String description) {
|
||||||
{
|
target.setDescription(description);
|
||||||
target.setDescription(description);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setIp(final String ip)
|
public void setIp(final String ip) {
|
||||||
{
|
target.setIp(ip);
|
||||||
target.setIp(ip);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setIpmiIp(final String ipmiIp)
|
public void setIpmiIp(final String ipmiIp) {
|
||||||
{
|
target.setIpmiIP(ipmiIp);
|
||||||
target.setIpmiIP(ipmiIp);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setIpmiPassword(final String ipmiPassword)
|
public void setIpmiPassword(final String ipmiPassword) {
|
||||||
{
|
target.setIpmiPassword(ipmiPassword);
|
||||||
target.setIpmiPassword(ipmiPassword);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setIpmiPort(final Integer ipmiPort)
|
public void setIpmiPort(final Integer ipmiPort) {
|
||||||
{
|
target.setIpmiPort(ipmiPort);
|
||||||
target.setIpmiPort(ipmiPort);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setIpmiUser(final String ipmiUser)
|
public void setIpmiUser(final String ipmiUser) {
|
||||||
{
|
target.setIpmiUser(ipmiUser);
|
||||||
target.setIpmiUser(ipmiUser);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setIpService(final String ipService)
|
public void setIpService(final String ipService) {
|
||||||
{
|
target.setIpService(ipService);
|
||||||
target.setIpService(ipService);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(final String password)
|
public void setPassword(final String password) {
|
||||||
{
|
target.setPassword(password);
|
||||||
target.setPassword(password);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(final Integer port)
|
public void setPort(final Integer port) {
|
||||||
{
|
target.setPort(port);
|
||||||
target.setPort(port);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(final MachineState state)
|
public void setState(final MachineState state) {
|
||||||
{
|
target.setState(state);
|
||||||
target.setState(state);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(final HypervisorType type)
|
public void setType(final HypervisorType type) {
|
||||||
{
|
target.setType(type);
|
||||||
target.setType(type);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setUser(final String user)
|
public void setUser(final String user) {
|
||||||
{
|
target.setUser(user);
|
||||||
target.setUser(user);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVirtualCpuCores(final Integer virtualCpuCores)
|
public void setVirtualCpuCores(final Integer virtualCpuCores) {
|
||||||
{
|
target.setVirtualCpuCores(virtualCpuCores);
|
||||||
target.setVirtualCpuCores(virtualCpuCores);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVirtualCpusUsed(final Integer virtualCpusUsed)
|
public void setVirtualCpusUsed(final Integer virtualCpusUsed) {
|
||||||
{
|
target.setVirtualCpusUsed(virtualCpusUsed);
|
||||||
target.setVirtualCpusUsed(virtualCpusUsed);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVirtualRamInMb(final Integer virtualRamInMb)
|
public void setVirtualRamInMb(final Integer virtualRamInMb) {
|
||||||
{
|
target.setVirtualRamInMb(virtualRamInMb);
|
||||||
target.setVirtualRamInMb(virtualRamInMb);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb)
|
public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb) {
|
||||||
{
|
target.setVirtualRamUsedInMb(virtualRamUsedInMb);
|
||||||
target.setVirtualRamUsedInMb(virtualRamUsedInMb);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVirtualSwitch(final String virtualSwitch)
|
public void setVirtualSwitch(final String virtualSwitch) {
|
||||||
{
|
target.setVirtualSwitch(virtualSwitch);
|
||||||
target.setVirtualSwitch(virtualSwitch);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Aux operations
|
// Aux operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the tokenized String provided by the node collector API to a list of Strings and
|
* Converts the tokenized String provided by the node collector API to a list
|
||||||
* stores it at the attribute switches.
|
* of Strings and stores it at the attribute switches.
|
||||||
*/
|
*/
|
||||||
protected void extractVirtualSwitches()
|
protected void extractVirtualSwitches() {
|
||||||
{
|
StringTokenizer st = new StringTokenizer(getVirtualSwitch(), "/");
|
||||||
StringTokenizer st = new StringTokenizer(getVirtualSwitch(), "/");
|
this.virtualSwitches = Lists.newArrayList();
|
||||||
this.virtualSwitches = Lists.newArrayList();
|
|
||||||
|
|
||||||
while (st.hasMoreTokens())
|
while (st.hasMoreTokens()) {
|
||||||
{
|
this.virtualSwitches.add(st.nextToken());
|
||||||
this.virtualSwitches.add(st.nextToken());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (virtualSwitches.size() > 0)
|
if (virtualSwitches.size() > 0) {
|
||||||
{
|
this.setVirtualSwitch(virtualSwitches.get(0));
|
||||||
this.setVirtualSwitch(virtualSwitches.get(0));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the virtual switches available. One of them needs to be selected.
|
* Returns the virtual switches available. One of them needs to be selected.
|
||||||
*/
|
*/
|
||||||
public List<String> getAvailableVirtualSwitches()
|
public List<String> getAvailableVirtualSwitches() {
|
||||||
{
|
return virtualSwitches;
|
||||||
return virtualSwitches;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String findAvailableVirtualSwitch(final String vswitch)
|
public String findAvailableVirtualSwitch(final String vswitch) {
|
||||||
{
|
return find(virtualSwitches, Predicates.equalTo(vswitch));
|
||||||
return find(virtualSwitches, Predicates.equalTo(vswitch));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Machine [id=" + getId() + ", ip=" + getIp() + ", ipmiIp=" + getIpmiIp() + ", ipmiPassword="
|
||||||
return "Machine [id=" + getId() + ", ip=" + getIp() + ", ipmiIp=" + getIpmiIp()
|
+ getIpmiPassword() + ", ipmiPort=" + getIpmiPort() + ", ipmiUser=" + getIpmiUser() + ", ipService="
|
||||||
+ ", ipmiPassword=" + getIpmiPassword() + ", ipmiPort=" + getIpmiPort() + ", ipmiUser="
|
+ getIpService() + ", name=" + getName() + ", password=" + getPassword() + ", port=" + getPort()
|
||||||
+ getIpmiUser() + ", ipService=" + getIpService() + ", name=" + getName()
|
+ ", state=" + getState() + ", type=" + getType() + ", user=" + getUser() + ", virtualCpuCores="
|
||||||
+ ", password=" + getPassword() + ", port=" + getPort() + ", state=" + getState()
|
+ getVirtualCpuCores() + ", virtualCpusUsed=" + getVirtualCpusUsed() + ", getVirtualRamInMb()="
|
||||||
+ ", type=" + getType() + ", user=" + getUser() + ", virtualCpuCores="
|
+ getVirtualRamInMb() + ", virtualRamUsedInMb=" + getVirtualRamUsedInMb() + ", virtualSwitch="
|
||||||
+ getVirtualCpuCores() + ", virtualCpusUsed=" + getVirtualCpusUsed()
|
+ getVirtualSwitch() + ", description=" + getDescription() + ", availableVirtualSwitches="
|
||||||
+ ", getVirtualRamInMb()=" + getVirtualRamInMb() + ", virtualRamUsedInMb="
|
+ getAvailableVirtualSwitches() + "]";
|
||||||
+ getVirtualRamUsedInMb() + ", virtualSwitch=" + getVirtualSwitch() + ", description="
|
}
|
||||||
+ getDescription() + ", availableVirtualSwitches=" + getAvailableVirtualSwitches()
|
|
||||||
+ "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,139 +38,136 @@ import com.abiquo.server.core.infrastructure.UcsRackDto;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to a {@link MachineDto} managed in a UCS rack. This resource allows
|
* Adds high level functionality to a {@link MachineDto} managed in a UCS rack.
|
||||||
* you to access blades in managed racks in the cloud infrastructure.
|
* This resource allows you to access blades in managed racks in the cloud
|
||||||
|
* infrastructure.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/MachineResource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/MachineResource">
|
||||||
* http://community.abiquo.com/display/ABI20/MachineResource</a>
|
* http://community.abiquo.com/display/ABI20/MachineResource</a>
|
||||||
*/
|
*/
|
||||||
public class Blade extends AbstractPhysicalMachine
|
public class Blade extends AbstractPhysicalMachine {
|
||||||
{
|
/** The rack where the machine belongs. */
|
||||||
/** The rack where the machine belongs. */
|
protected UcsRackDto rack;
|
||||||
protected UcsRackDto rack;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected Blade(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final MachineDto target)
|
protected Blade(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final MachineDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the UCS rack where the blade is.
|
* Retrieve the UCS rack where the blade is.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaUCSRack" >
|
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaUCSRack"
|
||||||
* http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaUCSRack</a>
|
* >
|
||||||
*/
|
* http://community.abiquo.com/display/ABI20/RackResource#RackResource-
|
||||||
public ManagedRack getRack()
|
* RetrieveaUCSRack</a>
|
||||||
{
|
*/
|
||||||
RESTLink link =
|
public ManagedRack getRack() {
|
||||||
checkNotNull(target.searchLink(ParentLinkName.RACK),
|
RESTLink link = checkNotNull(target.searchLink(ParentLinkName.RACK), ValidationErrors.MISSING_REQUIRED_LINK + " "
|
||||||
ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.RACK);
|
+ ParentLinkName.RACK);
|
||||||
|
|
||||||
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
||||||
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
||||||
|
|
||||||
ParseXMLWithJAXB<UcsRackDto> parser =
|
ParseXMLWithJAXB<UcsRackDto> parser = new ParseXMLWithJAXB<UcsRackDto>(utils.getXml(),
|
||||||
new ParseXMLWithJAXB<UcsRackDto>(utils.getXml(), TypeLiteral.get(UcsRackDto.class));
|
TypeLiteral.get(UcsRackDto.class));
|
||||||
|
|
||||||
return wrap(context, ManagedRack.class, parser.apply(response));
|
return wrap(context, ManagedRack.class, parser.apply(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the logic server associated with this machine in the Cisco UCS rack.
|
* Retrieve the logic server associated with this machine in the Cisco UCS
|
||||||
*
|
* rack.
|
||||||
* @see API: <a href=
|
*
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveslogicserverassociatedwithamachineinaCiscoUCS"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveslogicserverassociatedwithamachineinaCiscoUCS"
|
||||||
* RetrieveslogicserverassociatedwithamachineinaCiscoUCS</a>
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
*/
|
* MachineResource-
|
||||||
public LogicServer getLogicServer()
|
* RetrieveslogicserverassociatedwithamachineinaCiscoUCS</a>
|
||||||
{
|
*/
|
||||||
LogicServerDto server = context.getApi().getInfrastructureApi().getLogicServer(target);
|
public LogicServer getLogicServer() {
|
||||||
|
LogicServerDto server = context.getApi().getInfrastructureApi().getLogicServer(target);
|
||||||
|
|
||||||
return wrap(context, LogicServer.class, server);
|
return wrap(context, LogicServer.class, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn the blade associated to the provided logic server off. The blade must belong to a Logic
|
* Turn the blade associated to the provided logic server off. The blade must
|
||||||
* Server. This action sets the state of a given machine to STOPPED. Also sends a stop request
|
* belong to a Logic Server. This action sets the state of a given machine to
|
||||||
* to Cisco UCS to shut down the machine. The given machine must be a Physical Machine inside a
|
* STOPPED. Also sends a stop request to Cisco UCS to shut down the machine.
|
||||||
* Cisco UCS.
|
* The given machine must be a Physical Machine inside a Cisco UCS.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-PoweroffanexistingmachineinCiscoUCS"
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-PoweroffanexistingmachineinCiscoUCS"
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* PoweroffanexistingmachineinCiscoUCS</a>
|
* MachineResource- PoweroffanexistingmachineinCiscoUCS</a>
|
||||||
*/
|
*/
|
||||||
public void powerOff()
|
public void powerOff() {
|
||||||
{
|
context.getApi().getInfrastructureApi().powerOff(target);
|
||||||
context.getApi().getInfrastructureApi().powerOff(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn the blade associated to the provided logic server on. The machine must belong to an UCS
|
* Turn the blade associated to the provided logic server on. The machine
|
||||||
* Rack. The blade must belong to a Logic Server.
|
* must belong to an UCS Rack. The blade must belong to a Logic Server.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-PoweronanexistingmachineinCiscoUCS"
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-PoweronanexistingmachineinCiscoUCS"
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* PoweronanexistingmachineinCiscoUCS</a>
|
* MachineResource- PoweronanexistingmachineinCiscoUCS</a>
|
||||||
*/
|
*/
|
||||||
public void powerOn()
|
public void powerOn() {
|
||||||
{
|
context.getApi().getInfrastructureApi().powerOn(target);
|
||||||
context.getApi().getInfrastructureApi().powerOn(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn blade led on. The machine must belong to an UCS Rack. The blade must belong to a Logic
|
* Turn blade led on. The machine must belong to an UCS Rack. The blade must
|
||||||
* Server.
|
* belong to a Logic Server.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-LightoffthelocatorledofanexistingmachineinaCiscoUCS"
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-LightoffthelocatorledofanexistingmachineinaCiscoUCS"
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* LightoffthelocatorledofanexistingmachineinaCiscoUCS</a>
|
* MachineResource-
|
||||||
*/
|
* LightoffthelocatorledofanexistingmachineinaCiscoUCS</a>
|
||||||
public void ledOn()
|
*/
|
||||||
{
|
public void ledOn() {
|
||||||
context.getApi().getInfrastructureApi().ledOn(target);
|
context.getApi().getInfrastructureApi().ledOn(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn blade led off. The machine must belong to an UCS Rack. The blade must belong to a Logic
|
* Turn blade led off. The machine must belong to an UCS Rack. The blade must
|
||||||
* Server.
|
* belong to a Logic Server.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource-LightoffthelocatorledofanexistingmachineinaCiscoUCS"
|
* "http://community.abiquo.com/display/ABI20/MachineResource-LightoffthelocatorledofanexistingmachineinaCiscoUCS"
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource-
|
* > http://community.abiquo.com/display/ABI20/MachineResource-
|
||||||
* LightoffthelocatorledofanexistingmachineinaCiscoUCS</a>
|
* LightoffthelocatorledofanexistingmachineinaCiscoUCS</a>
|
||||||
*/
|
*/
|
||||||
public void ledOff()
|
public void ledOff() {
|
||||||
{
|
context.getApi().getInfrastructureApi().ledOff(target);
|
||||||
context.getApi().getInfrastructureApi().ledOff(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the led locator information as a {@link BladeLocatorLed}.
|
* Retrieve the led locator information as a {@link BladeLocatorLed}.
|
||||||
*
|
*
|
||||||
* @return Blade locator led representation.
|
* @return Blade locator led representation.
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Retrievethelocatorledoftheblade"
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Retrievethelocatorledoftheblade"
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* Retrievethelocatorledoftheblade</a>
|
* MachineResource- Retrievethelocatorledoftheblade</a>
|
||||||
*/
|
*/
|
||||||
public BladeLocatorLed getLocatorLed()
|
public BladeLocatorLed getLocatorLed() {
|
||||||
{
|
BladeLocatorLedDto led = context.getApi().getInfrastructureApi().getLocatorLed(target);
|
||||||
BladeLocatorLedDto led = context.getApi().getInfrastructureApi().getLocatorLed(target);
|
|
||||||
|
|
||||||
return wrap(context, BladeLocatorLed.class, led);
|
return wrap(context, BladeLocatorLed.class, led);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.infrastructure;
|
package org.jclouds.abiquo.domain.infrastructure;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -35,47 +34,40 @@ import com.abiquo.server.core.infrastructure.BladeLocatorLedDto;
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Retrievethelocatorledoftheblade"
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Retrievethelocatorledoftheblade"
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* Retrievethelocatorledoftheblade</a>
|
* MachineResource- Retrievethelocatorledoftheblade</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class BladeLocatorLed extends DomainWrapper<BladeLocatorLedDto>
|
public class BladeLocatorLed extends DomainWrapper<BladeLocatorLedDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected BladeLocatorLed(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final BladeLocatorLedDto target) {
|
||||||
protected BladeLocatorLed(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final BladeLocatorLedDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate Methods
|
// Delegate Methods
|
||||||
|
|
||||||
public String getAdminStatus()
|
public String getAdminStatus() {
|
||||||
{
|
return target.getAdminStatus();
|
||||||
return target.getAdminStatus();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getBladeDn()
|
public String getBladeDn() {
|
||||||
{
|
return target.getBladeDn();
|
||||||
return target.getBladeDn();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getColor()
|
public String getColor() {
|
||||||
{
|
return target.getColor();
|
||||||
return target.getColor();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDn()
|
public String getDn() {
|
||||||
{
|
return target.getDn();
|
||||||
return target.getDn();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "BladeLocatorLed [Dn=" + getDn() + ", BladeDn=" + getBladeDn() + ", Color=" + getColor()
|
||||||
return "BladeLocatorLed [Dn=" + getDn() + ", BladeDn=" + getBladeDn() + ", Color="
|
+ ", AdminStatus=" + getAdminStatus() + "]";
|
||||||
+ getColor() + ", AdminStatus=" + getAdminStatus() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.infrastructure;
|
package org.jclouds.abiquo.domain.infrastructure;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -33,69 +32,58 @@ import com.abiquo.server.core.infrastructure.DatastoreDto;
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
*/
|
*/
|
||||||
public class Datastore extends DomainWrapper<DatastoreDto>
|
public class Datastore extends DomainWrapper<DatastoreDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder. This resource cannot be
|
||||||
* Constructor to be used only by the builder. This resource cannot be created.
|
* created.
|
||||||
*/
|
*/
|
||||||
private Datastore(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final DatastoreDto target)
|
private Datastore(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final DatastoreDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public String getDatastoreUUID()
|
public String getDatastoreUUID() {
|
||||||
{
|
return target.getDatastoreUUID();
|
||||||
return target.getDatastoreUUID();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDirectory()
|
public String getDirectory() {
|
||||||
{
|
return target.getDirectory();
|
||||||
return target.getDirectory();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getRootPath()
|
public String getRootPath() {
|
||||||
{
|
return target.getRootPath();
|
||||||
return target.getRootPath();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getSize()
|
public long getSize() {
|
||||||
{
|
return target.getSize();
|
||||||
return target.getSize();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getUsedSize()
|
public long getUsedSize() {
|
||||||
{
|
return target.getUsedSize();
|
||||||
return target.getUsedSize();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled() {
|
||||||
{
|
return target.isEnabled();
|
||||||
return target.isEnabled();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(final boolean enabled)
|
public void setEnabled(final boolean enabled) {
|
||||||
{
|
target.setEnabled(enabled);
|
||||||
target.setEnabled(enabled);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Datastore [id=" + getId() + ", uuid=" + getDatastoreUUID() + ", directory=" + getDirectory() + ", name="
|
||||||
return "Datastore [id=" + getId() + ", uuid=" + getDatastoreUUID() + ", directory="
|
+ getName() + ", rootPath=" + getRootPath() + ", size=" + getSize() + ", usedSize=" + getUsedSize()
|
||||||
+ getDirectory() + ", name=" + getName() + ", rootPath=" + getRootPath() + ", size="
|
+ ", enabled=" + isEnabled() + "]";
|
||||||
+ getSize() + ", usedSize=" + getUsedSize() + ", enabled=" + isEnabled() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.infrastructure;
|
package org.jclouds.abiquo.domain.infrastructure;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -37,48 +36,40 @@ import com.abiquo.server.core.infrastructure.FsmDto;
|
||||||
* http://community.abiquo.com/display/ABI20/Rack+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Rack+Resource</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class Fsm extends DomainWrapper<FsmDto>
|
public class Fsm extends DomainWrapper<FsmDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected Fsm(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final FsmDto target) {
|
||||||
protected Fsm(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final FsmDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate Methods
|
// Delegate Methods
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDn()
|
public String getDn() {
|
||||||
{
|
return target.getDn();
|
||||||
return target.getDn();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getError()
|
public String getError() {
|
||||||
{
|
return target.getError();
|
||||||
return target.getError();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getProgress()
|
public String getProgress() {
|
||||||
{
|
return target.getProgress();
|
||||||
return target.getProgress();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus() {
|
||||||
{
|
return target.getStatus();
|
||||||
return target.getStatus();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Fsm [Dn=" + getDn() + ", Description=" + getDescription() + ", Error=" + getError() + ", Progress="
|
||||||
return "Fsm [Dn=" + getDn() + ", Description=" + getDescription() + ", Error=" + getError()
|
+ getProgress() + ", Status=" + getStatus() + "]";
|
||||||
+ ", Progress=" + getProgress() + ", Status=" + getStatus() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,64 +39,52 @@ import com.abiquo.server.core.infrastructure.LogicServerPolicyDto;
|
||||||
* http://community.abiquo.com/display/ABI20/Rack+Resource</a>
|
* http://community.abiquo.com/display/ABI20/Rack+Resource</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class LogicServer extends DomainWrapper<LogicServerDto>
|
public class LogicServer extends DomainWrapper<LogicServerDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected LogicServer(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final LogicServerDto target) {
|
||||||
protected LogicServer(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final LogicServerDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate Methods
|
// Delegate Methods
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(final String value)
|
public void setType(final String value) {
|
||||||
{
|
target.setType(value);
|
||||||
target.setType(value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getAssociated()
|
public String getAssociated() {
|
||||||
{
|
return target.getAssociated();
|
||||||
return target.getAssociated();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getType()
|
public String getType() {
|
||||||
{
|
return target.getType();
|
||||||
return target.getType();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getAssociatedTo()
|
public String getAssociatedTo() {
|
||||||
{
|
return target.getAssociatedTo();
|
||||||
return target.getAssociatedTo();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(final String value)
|
public void setDescription(final String value) {
|
||||||
{
|
target.setDescription(value);
|
||||||
target.setDescription(value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public List<LogicServerPolicyDto> getCollection()
|
public List<LogicServerPolicyDto> getCollection() {
|
||||||
{
|
return target.getCollection();
|
||||||
return target.getCollection();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "LogicServer [name=" + getName() + ", associated=" + getAssociated() + ", type=" + getType()
|
||||||
return "LogicServer [name=" + getName() + ", associated=" + getAssociated() + ", type="
|
+ ", associatedTo=" + getAssociatedTo() + ", description=" + getDescription() + "]";
|
||||||
+ getType() + ", associatedTo=" + getAssociatedTo() + ", description="
|
}
|
||||||
+ getDescription() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,496 +54,456 @@ import com.google.common.collect.Lists;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link MachineDto}. This resource allows you to manage physical
|
* Adds high level functionality to {@link MachineDto}. This resource allows you
|
||||||
* machines in the cloud infrastructure.
|
* to manage physical machines in the cloud infrastructure.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/MachineResource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/MachineResource">
|
||||||
* http://community.abiquo.com/display/ABI20/MachineResource</a>
|
* http://community.abiquo.com/display/ABI20/MachineResource</a>
|
||||||
*/
|
*/
|
||||||
public class Machine extends AbstractPhysicalMachine
|
public class Machine extends AbstractPhysicalMachine {
|
||||||
{
|
/** The rack where the machine belongs. */
|
||||||
/** The rack where the machine belongs. */
|
protected Rack rack;
|
||||||
protected Rack rack;
|
|
||||||
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected Machine(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final MachineDto target) {
|
||||||
protected Machine(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final MachineDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
/**
|
||||||
|
* Create a new physical machine in Abiquo. The best way to create a machine
|
||||||
/**
|
* if first calling {@link Datacenter#discoverSingleMachine} or
|
||||||
* Create a new physical machine in Abiquo. The best way to create a machine if first calling
|
* {@link Datacenter#discoverMultipleMachines}. This will return a new
|
||||||
* {@link Datacenter#discoverSingleMachine} or {@link Datacenter#discoverMultipleMachines}. This
|
* {@link Machine}. The following steps are: enabling a datastore, selecting
|
||||||
* will return a new {@link Machine}. The following steps are: enabling a datastore, selecting a
|
* a virtual switch and choosing a rack. Refer link for more information.
|
||||||
* virtual switch and choosing a rack. Refer link for more information.
|
*
|
||||||
*
|
* @see API: <a href=
|
||||||
* @see API: <a href=
|
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveremotemachineinformation"
|
||||||
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveremotemachineinformation"
|
* > http://community.abiquo.com/display/ABI20/DatacenterResource#
|
||||||
* > http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-
|
* DatacenterResource- Retrieveremotemachineinformation</a>
|
||||||
* Retrieveremotemachineinformation</a>
|
* @see API: <a href=
|
||||||
* @see API: <a href=
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Createamachine"
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Createamachine"
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* MachineResource- Createamachine</a>
|
||||||
* Createamachine</a>
|
*/
|
||||||
*/
|
public void save() {
|
||||||
public void save()
|
target = context.getApi().getInfrastructureApi().createMachine(rack.unwrap(), target);
|
||||||
{
|
}
|
||||||
target = context.getApi().getInfrastructureApi().createMachine(rack.unwrap(), target);
|
|
||||||
}
|
@Override
|
||||||
|
public MachineState check() {
|
||||||
@Override
|
MachineStateDto dto = context.getApi().getInfrastructureApi().checkMachineState(target, true);
|
||||||
public MachineState check()
|
MachineState state = dto.getState();
|
||||||
{
|
target.setState(state);
|
||||||
MachineStateDto dto =
|
return state;
|
||||||
context.getApi().getInfrastructureApi().checkMachineState(target, true);
|
}
|
||||||
MachineState state = dto.getState();
|
|
||||||
target.setState(state);
|
// Parent access
|
||||||
return state;
|
/**
|
||||||
}
|
* Retrieve the unmanaged rack where the machine is.
|
||||||
|
*
|
||||||
// Parent access
|
* @see API: <a href=
|
||||||
/**
|
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaRack"
|
||||||
* Retrieve the unmanaged rack where the machine is.
|
* >
|
||||||
*
|
* http://community.abiquo.com/display/ABI20/RackResource#RackResource-
|
||||||
* @see API: <a href=
|
* RetrieveaRack</a>
|
||||||
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaRack" >
|
*/
|
||||||
* http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaRack</a>
|
public Rack getRack() {
|
||||||
*/
|
RESTLink link = checkNotNull(target.searchLink(ParentLinkName.RACK), ValidationErrors.MISSING_REQUIRED_LINK + " "
|
||||||
public Rack getRack()
|
+ ParentLinkName.RACK);
|
||||||
{
|
|
||||||
RESTLink link =
|
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
||||||
checkNotNull(target.searchLink(ParentLinkName.RACK),
|
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
||||||
ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.RACK);
|
|
||||||
|
ParseXMLWithJAXB<RackDto> parser = new ParseXMLWithJAXB<RackDto>(utils.getXml(), TypeLiteral.get(RackDto.class));
|
||||||
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
|
||||||
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
return wrap(context, Rack.class, parser.apply(response));
|
||||||
|
}
|
||||||
ParseXMLWithJAXB<RackDto> parser =
|
|
||||||
new ParseXMLWithJAXB<RackDto>(utils.getXml(), TypeLiteral.get(RackDto.class));
|
// Children access
|
||||||
|
|
||||||
return wrap(context, Rack.class, parser.apply(response));
|
@Override
|
||||||
}
|
public List<Datastore> getDatastores() {
|
||||||
|
return wrap(context, Datastore.class, target.getDatastores().getCollection());
|
||||||
// Children access
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Datastore> getDatastores()
|
public Datastore findDatastore(final String name) {
|
||||||
{
|
return find(getDatastores(), DatastorePredicates.name(name), null);
|
||||||
return wrap(context, Datastore.class, target.getDatastores().getCollection());
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
@Override
|
* Gets the list of virtual machines in the physical machine.
|
||||||
public Datastore findDatastore(final String name)
|
*
|
||||||
{
|
* @return The list of virtual machines in the physical machine.
|
||||||
return find(getDatastores(), DatastorePredicates.name(name), null);
|
* @see API: <a href=
|
||||||
}
|
* "http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource-Retrievethelistofvirtualmachinesbymachine'shypervisor"
|
||||||
|
* > http://community.abiquo.com/display/ABI20/Machine+Resource#
|
||||||
/**
|
* MachineResource-
|
||||||
* Gets the list of virtual machines in the physical machine.
|
* Retrievethelistofvirtualmachinesbymachine'shypervisor</a>
|
||||||
*
|
*/
|
||||||
* @return The list of virtual machines in the physical machine.
|
public List<VirtualMachine> listVirtualMachines() {
|
||||||
* @see API: <a href=
|
MachineOptions options = MachineOptions.builder().sync(false).build();
|
||||||
* "http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource-Retrievethelistofvirtualmachinesbymachine'shypervisor"
|
VirtualMachinesWithNodeExtendedDto vms = context.getApi().getInfrastructureApi()
|
||||||
* > http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource-
|
.listVirtualMachinesByMachine(target, options);
|
||||||
* Retrievethelistofvirtualmachinesbymachine'shypervisor</a>
|
return wrap(context, VirtualMachine.class, vms.getCollection());
|
||||||
*/
|
}
|
||||||
public List<VirtualMachine> listVirtualMachines()
|
|
||||||
{
|
/**
|
||||||
MachineOptions options = MachineOptions.builder().sync(false).build();
|
* Gets the list of virtual machines in the physical machine matching the
|
||||||
VirtualMachinesWithNodeExtendedDto vms =
|
* given filter.
|
||||||
context.getApi().getInfrastructureApi().listVirtualMachinesByMachine(target, options);
|
*
|
||||||
return wrap(context, VirtualMachine.class, vms.getCollection());
|
* @param filter
|
||||||
}
|
* The filter to apply.
|
||||||
|
* @return The list of virtual machines in the physical machine matching the
|
||||||
/**
|
* given filter.
|
||||||
* Gets the list of virtual machines in the physical machine matching the given filter.
|
*/
|
||||||
*
|
public List<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter) {
|
||||||
* @param filter The filter to apply.
|
return Lists.newLinkedList(filter(listVirtualMachines(), filter));
|
||||||
* @return The list of virtual machines in the physical machine matching the given filter.
|
}
|
||||||
*/
|
|
||||||
public List<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter)
|
/**
|
||||||
{
|
* Gets a single virtual machine in the physical machine matching the given
|
||||||
return Lists.newLinkedList(filter(listVirtualMachines(), filter));
|
* filter.
|
||||||
}
|
*
|
||||||
|
* @param filter
|
||||||
/**
|
* The filter to apply.
|
||||||
* Gets a single virtual machine in the physical machine matching the given filter.
|
* @return The virtual machine or <code>null</code> if none matched the given
|
||||||
*
|
* filter.
|
||||||
* @param filter The filter to apply.
|
*/
|
||||||
* @return The virtual machine or <code>null</code> if none matched the given filter.
|
public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter) {
|
||||||
*/
|
return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
|
||||||
public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter)
|
}
|
||||||
{
|
|
||||||
return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
|
/**
|
||||||
}
|
* Gets the list of virtual machines in the physical machine sinchronizing
|
||||||
|
* virtual machines from remote hypervisor with abiquo's database.
|
||||||
/**
|
*
|
||||||
* Gets the list of virtual machines in the physical machine sinchronizing virtual machines from
|
* @return The list of virtual machines in the physical machine.
|
||||||
* remote hypervisor with abiquo's database.
|
* @see API: <a href=
|
||||||
*
|
* "http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource-Retrievethelistofvirtualmachinesbymachine'shypervisor"
|
||||||
* @return The list of virtual machines in the physical machine.
|
* > http://community.abiquo.com/display/ABI20/Machine+Resource#
|
||||||
* @see API: <a href=
|
* MachineResource-
|
||||||
* "http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource-Retrievethelistofvirtualmachinesbymachine'shypervisor"
|
* Retrievethelistofvirtualmachinesbymachine'shypervisor</a>
|
||||||
* > http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource-
|
*/
|
||||||
* Retrievethelistofvirtualmachinesbymachine'shypervisor</a>
|
public List<VirtualMachine> listRemoteVirtualMachines() {
|
||||||
*/
|
MachineOptions options = MachineOptions.builder().sync(true).build();
|
||||||
public List<VirtualMachine> listRemoteVirtualMachines()
|
VirtualMachinesWithNodeExtendedDto vms = context.getApi().getInfrastructureApi()
|
||||||
{
|
.listVirtualMachinesByMachine(target, options);
|
||||||
MachineOptions options = MachineOptions.builder().sync(true).build();
|
return wrap(context, VirtualMachine.class, vms.getCollection());
|
||||||
VirtualMachinesWithNodeExtendedDto vms =
|
}
|
||||||
context.getApi().getInfrastructureApi().listVirtualMachinesByMachine(target, options);
|
|
||||||
return wrap(context, VirtualMachine.class, vms.getCollection());
|
/**
|
||||||
}
|
* Gets the list of virtual machines in the physical machine matching the
|
||||||
|
* given filter sinchronizing virtual machines from remote hypervisor with
|
||||||
/**
|
* abiquo's database.
|
||||||
* Gets the list of virtual machines in the physical machine matching the given filter
|
*
|
||||||
* sinchronizing virtual machines from remote hypervisor with abiquo's database.
|
* @param filter
|
||||||
*
|
* The filter to apply.
|
||||||
* @param filter The filter to apply.
|
* @return The list of remote virtual machines in the physical machine
|
||||||
* @return The list of remote virtual machines in the physical machine matching the given
|
* matching the given filter.
|
||||||
* filter.
|
*/
|
||||||
*/
|
public List<VirtualMachine> listRemoteVirtualMachines(final Predicate<VirtualMachine> filter) {
|
||||||
public List<VirtualMachine> listRemoteVirtualMachines(final Predicate<VirtualMachine> filter)
|
return Lists.newLinkedList(filter(listVirtualMachines(), filter));
|
||||||
{
|
}
|
||||||
return Lists.newLinkedList(filter(listVirtualMachines(), filter));
|
|
||||||
}
|
/**
|
||||||
|
* Gets a single virtual machine in the physical machine matching the given
|
||||||
/**
|
* filter sinchronizing virtual machines from remote hypervisor with abiquo's
|
||||||
* Gets a single virtual machine in the physical machine matching the given filter sinchronizing
|
* database.
|
||||||
* virtual machines from remote hypervisor with abiquo's database.
|
*
|
||||||
*
|
* @param filter
|
||||||
* @param filter The filter to apply.
|
* The filter to apply.
|
||||||
* @return The virtual machine or <code>null</code> if none matched the given filter.
|
* @return The virtual machine or <code>null</code> if none matched the given
|
||||||
*/
|
* filter.
|
||||||
public VirtualMachine findRemoteVirtualMachine(final Predicate<VirtualMachine> filter)
|
*/
|
||||||
{
|
public VirtualMachine findRemoteVirtualMachine(final Predicate<VirtualMachine> filter) {
|
||||||
return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
|
return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reserve the machine for the given enterprise.
|
* Reserve the machine for the given enterprise.
|
||||||
* <p>
|
* <p>
|
||||||
* When a {@link Machine} is reserved for an {@link Enterprise}, only the users of that
|
* When a {@link Machine} is reserved for an {@link Enterprise}, only the
|
||||||
* enterprise will be able to deploy {@link VirtualMachine}s in it.
|
* users of that enterprise will be able to deploy {@link VirtualMachine}s in
|
||||||
*
|
* it.
|
||||||
* @param enterprise The enterprise reserving the machine.
|
*
|
||||||
*/
|
* @param enterprise
|
||||||
public void reserveFor(final Enterprise enterprise)
|
* The enterprise reserving the machine.
|
||||||
{
|
*/
|
||||||
target =
|
public void reserveFor(final Enterprise enterprise) {
|
||||||
context.getApi().getInfrastructureApi().reserveMachine(enterprise.unwrap(), target);
|
target = context.getApi().getInfrastructureApi().reserveMachine(enterprise.unwrap(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the machine reservation for the given enterprise.
|
* Cancels the machine reservation for the given enterprise.
|
||||||
*
|
*
|
||||||
* @param enterprise The enterprise to cancel reservation for.
|
* @param enterprise
|
||||||
*/
|
* The enterprise to cancel reservation for.
|
||||||
public void cancelReservationFor(final Enterprise enterprise)
|
*/
|
||||||
{
|
public void cancelReservationFor(final Enterprise enterprise) {
|
||||||
context.getApi().getInfrastructureApi().cancelReservation(enterprise.unwrap(), target);
|
context.getApi().getInfrastructureApi().cancelReservation(enterprise.unwrap(), target);
|
||||||
target.getLinks().remove(target.searchLink(ParentLinkName.ENTERPRISE));
|
target.getLinks().remove(target.searchLink(ParentLinkName.ENTERPRISE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the machine is reserved.
|
* Check if the machine is reserved.
|
||||||
*
|
*
|
||||||
* @return Boolean indicating if the machine is reserved for an enterprise.
|
* @return Boolean indicating if the machine is reserved for an enterprise.
|
||||||
*/
|
*/
|
||||||
public boolean isReserved()
|
public boolean isReserved() {
|
||||||
{
|
return target.searchLink(ParentLinkName.ENTERPRISE) != null;
|
||||||
return target.searchLink(ParentLinkName.ENTERPRISE) != null;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Get the enterprise that has reserved the machine or <code>null</code> if
|
||||||
* Get the enterprise that has reserved the machine or <code>null</code> if the machine is not
|
* the machine is not reserved.
|
||||||
* reserved.
|
*
|
||||||
*
|
* @return The enterprise that has reserved the machine or <code>null</code>
|
||||||
* @return The enterprise that has reserved the machine or <code>null</code> if the machine is
|
* if the machine is not reserved.
|
||||||
* not reserved.
|
*/
|
||||||
*/
|
public Enterprise getOwnerEnterprise() {
|
||||||
public Enterprise getOwnerEnterprise()
|
if (!isReserved()) {
|
||||||
{
|
return null;
|
||||||
if (!isReserved())
|
}
|
||||||
{
|
|
||||||
return null;
|
EnterpriseDto enterprise = context.getApi().getEnterpriseApi()
|
||||||
}
|
.getEnterprise(target.getIdFromLink(ParentLinkName.ENTERPRISE));
|
||||||
|
|
||||||
EnterpriseDto enterprise =
|
return wrap(context, Enterprise.class, enterprise);
|
||||||
context.getApi().getEnterpriseApi()
|
}
|
||||||
.getEnterprise(target.getIdFromLink(ParentLinkName.ENTERPRISE));
|
|
||||||
|
// Builder
|
||||||
return wrap(context, Enterprise.class, enterprise);
|
|
||||||
}
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Rack rack) {
|
||||||
|
return new Builder(context, rack);
|
||||||
// Builder
|
}
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static class Builder {
|
||||||
final Rack rack)
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
{
|
|
||||||
return new Builder(context, rack);
|
private String name, description;
|
||||||
}
|
|
||||||
|
private Integer virtualRamInMb;
|
||||||
public static class Builder
|
|
||||||
{
|
private Integer virtualRamUsedInMb = DEFAULT_VRAM_USED;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
private Integer virtualCpuCores;
|
||||||
private String name, description;
|
|
||||||
|
private Integer virtualCpusUsed = DEFAULT_VCPU_USED;
|
||||||
private Integer virtualRamInMb;
|
|
||||||
|
private String virtualSwitch;
|
||||||
private Integer virtualRamUsedInMb = DEFAULT_VRAM_USED;
|
|
||||||
|
private Integer port;
|
||||||
private Integer virtualCpuCores;
|
|
||||||
|
private String ip;
|
||||||
private Integer virtualCpusUsed = DEFAULT_VCPU_USED;
|
|
||||||
|
private MachineState state = MachineState.STOPPED;
|
||||||
private String virtualSwitch;
|
|
||||||
|
private String ipService;
|
||||||
private Integer port;
|
|
||||||
|
private HypervisorType type;
|
||||||
private String ip;
|
|
||||||
|
private String user;
|
||||||
private MachineState state = MachineState.STOPPED;
|
|
||||||
|
private String password;
|
||||||
private String ipService;
|
|
||||||
|
private Iterable<Datastore> datastores;
|
||||||
private HypervisorType type;
|
|
||||||
|
private String ipmiIp;
|
||||||
private String user;
|
|
||||||
|
private Integer ipmiPort;
|
||||||
private String password;
|
|
||||||
|
private String ipmiUser;
|
||||||
private Iterable<Datastore> datastores;
|
|
||||||
|
private String ipmiPassword;
|
||||||
private String ipmiIp;
|
|
||||||
|
private Rack rack;
|
||||||
private Integer ipmiPort;
|
|
||||||
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Rack rack) {
|
||||||
private String ipmiUser;
|
super();
|
||||||
|
checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Rack.class);
|
||||||
private String ipmiPassword;
|
this.rack = rack;
|
||||||
|
this.context = context;
|
||||||
private Rack rack;
|
}
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Rack rack)
|
public Builder state(final MachineState state) {
|
||||||
{
|
this.state = state;
|
||||||
super();
|
return this;
|
||||||
checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Rack.class);
|
}
|
||||||
this.rack = rack;
|
|
||||||
this.context = context;
|
public Builder ipmiPassword(final String ipmiPassword) {
|
||||||
}
|
this.ipmiPassword = ipmiPassword;
|
||||||
|
return this;
|
||||||
public Builder state(final MachineState state)
|
}
|
||||||
{
|
|
||||||
this.state = state;
|
public Builder ipmiUser(final String ipmiUser) {
|
||||||
return this;
|
this.ipmiUser = ipmiUser;
|
||||||
}
|
return this;
|
||||||
|
}
|
||||||
public Builder ipmiPassword(final String ipmiPassword)
|
|
||||||
{
|
public Builder ipmiPort(final int ipmiPort) {
|
||||||
this.ipmiPassword = ipmiPassword;
|
this.ipmiPort = ipmiPort;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder ipmiUser(final String ipmiUser)
|
public Builder ipmiIp(final String ipmiIp) {
|
||||||
{
|
this.ipmiIp = ipmiIp;
|
||||||
this.ipmiUser = ipmiUser;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder user(final String user) {
|
||||||
public Builder ipmiPort(final int ipmiPort)
|
this.user = user;
|
||||||
{
|
return this;
|
||||||
this.ipmiPort = ipmiPort;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder ip(final String ip) {
|
||||||
|
this.ip = ip;
|
||||||
public Builder ipmiIp(final String ipmiIp)
|
if (ipService == null) {
|
||||||
{
|
ipService = ip;
|
||||||
this.ipmiIp = ipmiIp;
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder user(final String user)
|
public Builder ipService(final String ipService) {
|
||||||
{
|
this.ipService = ipService;
|
||||||
this.user = user;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder password(final String password) {
|
||||||
public Builder ip(final String ip)
|
this.password = password;
|
||||||
{
|
return this;
|
||||||
this.ip = ip;
|
}
|
||||||
if (ipService == null)
|
|
||||||
{
|
public Builder virtualSwitch(final String virtualSwitch) {
|
||||||
ipService = ip;
|
this.virtualSwitch = virtualSwitch;
|
||||||
}
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder name(final String name) {
|
||||||
public Builder ipService(final String ipService)
|
this.name = name;
|
||||||
{
|
return this;
|
||||||
this.ipService = ipService;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder description(final String description) {
|
||||||
|
this.description = description;
|
||||||
public Builder password(final String password)
|
return this;
|
||||||
{
|
}
|
||||||
this.password = password;
|
|
||||||
return this;
|
public Builder port(final int port) {
|
||||||
}
|
this.port = port;
|
||||||
|
return this;
|
||||||
public Builder virtualSwitch(final String virtualSwitch)
|
}
|
||||||
{
|
|
||||||
this.virtualSwitch = virtualSwitch;
|
public Builder datastores(final Iterable<Datastore> datastores) {
|
||||||
return this;
|
this.datastores = datastores;
|
||||||
}
|
return this;
|
||||||
|
}
|
||||||
public Builder name(final String name)
|
|
||||||
{
|
public Builder virtualRamInMb(final int virtualRamInMb) {
|
||||||
this.name = name;
|
this.virtualRamInMb = virtualRamInMb;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(final String description)
|
public Builder virtualRamUsedInMb(final int virtualRamUsedInMb) {
|
||||||
{
|
this.virtualRamUsedInMb = virtualRamUsedInMb;
|
||||||
this.description = description;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder virtualCpuCores(final int virtualCpuCores) {
|
||||||
public Builder port(final int port)
|
this.virtualCpuCores = virtualCpuCores;
|
||||||
{
|
return this;
|
||||||
this.port = port;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder virtualCpusUsed(final int virtualCpusUsed) {
|
||||||
|
this.virtualCpusUsed = virtualCpusUsed;
|
||||||
public Builder datastores(final Iterable<Datastore> datastores)
|
return this;
|
||||||
{
|
}
|
||||||
this.datastores = datastores;
|
|
||||||
return this;
|
public Builder hypervisorType(final HypervisorType hypervisorType) {
|
||||||
}
|
this.type = hypervisorType;
|
||||||
|
|
||||||
public Builder virtualRamInMb(final int virtualRamInMb)
|
// Sets default hypervisor port
|
||||||
{
|
if (this.port == null) {
|
||||||
this.virtualRamInMb = virtualRamInMb;
|
this.port = hypervisorType.defaultPort;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
return this;
|
||||||
public Builder virtualRamUsedInMb(final int virtualRamUsedInMb)
|
}
|
||||||
{
|
|
||||||
this.virtualRamUsedInMb = virtualRamUsedInMb;
|
public Builder rack(final Rack rack) {
|
||||||
return this;
|
checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
||||||
}
|
this.rack = rack;
|
||||||
|
return this;
|
||||||
public Builder virtualCpuCores(final int virtualCpuCores)
|
}
|
||||||
{
|
|
||||||
this.virtualCpuCores = virtualCpuCores;
|
public Machine build() {
|
||||||
return this;
|
MachineDto dto = new MachineDto();
|
||||||
}
|
dto.setName(name);
|
||||||
|
dto.setDescription(description);
|
||||||
public Builder virtualCpusUsed(final int virtualCpusUsed)
|
dto.setVirtualRamInMb(virtualRamInMb);
|
||||||
{
|
dto.setVirtualRamUsedInMb(virtualRamUsedInMb);
|
||||||
this.virtualCpusUsed = virtualCpusUsed;
|
dto.setVirtualCpuCores(virtualCpuCores);
|
||||||
return this;
|
dto.setVirtualCpusUsed(virtualCpusUsed);
|
||||||
}
|
dto.setVirtualSwitch(virtualSwitch);
|
||||||
|
if (port != null) {
|
||||||
public Builder hypervisorType(final HypervisorType hypervisorType)
|
dto.setPort(port);
|
||||||
{
|
}
|
||||||
this.type = hypervisorType;
|
dto.setIp(ip);
|
||||||
|
dto.setIpService(ipService);
|
||||||
// Sets default hypervisor port
|
dto.setType(type);
|
||||||
if (this.port == null)
|
dto.setUser(user);
|
||||||
{
|
dto.setPassword(password);
|
||||||
this.port = hypervisorType.defaultPort;
|
dto.setIpmiIP(ipmiIp);
|
||||||
}
|
dto.setIpmiPassword(ipmiPassword);
|
||||||
|
if (ipmiPort != null) {
|
||||||
return this;
|
dto.setIpmiPort(ipmiPort);
|
||||||
}
|
}
|
||||||
|
dto.setIpmiUser(ipmiUser);
|
||||||
public Builder rack(final Rack rack)
|
dto.setState(state);
|
||||||
{
|
|
||||||
checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
DatastoresDto datastoresDto = new DatastoresDto();
|
||||||
this.rack = rack;
|
datastoresDto.getCollection().addAll(unwrap(datastores));
|
||||||
return this;
|
dto.setDatastores(datastoresDto);
|
||||||
}
|
|
||||||
|
Machine machine = new Machine(context, dto);
|
||||||
public Machine build()
|
machine.rack = rack;
|
||||||
{
|
|
||||||
MachineDto dto = new MachineDto();
|
return machine;
|
||||||
dto.setName(name);
|
}
|
||||||
dto.setDescription(description);
|
|
||||||
dto.setVirtualRamInMb(virtualRamInMb);
|
public static Builder fromMachine(final Machine in) {
|
||||||
dto.setVirtualRamUsedInMb(virtualRamUsedInMb);
|
Builder builder = Machine.builder(in.context, in.rack).name(in.getName()).description(in.getDescription())
|
||||||
dto.setVirtualCpuCores(virtualCpuCores);
|
.virtualCpuCores(in.getVirtualCpuCores()).virtualCpusUsed(in.getVirtualCpusUsed())
|
||||||
dto.setVirtualCpusUsed(virtualCpusUsed);
|
.virtualRamInMb(in.getVirtualRamInMb()).virtualRamUsedInMb(in.getVirtualRamUsedInMb())
|
||||||
dto.setVirtualSwitch(virtualSwitch);
|
.virtualSwitch(in.getVirtualSwitch()).port(in.getPort()).ip(in.getIp()).ipService(in.getIpService())
|
||||||
if (port != null)
|
.hypervisorType(in.getType()).user(in.getUser()).password(in.getPassword()).ipmiIp(in.getIpmiIp())
|
||||||
{
|
.ipmiPassword(in.getIpmiPassword()).ipmiUser(in.getIpmiUser()).state(in.getState())
|
||||||
dto.setPort(port);
|
.datastores(in.getDatastores());
|
||||||
}
|
|
||||||
dto.setIp(ip);
|
// Parameters that can be null
|
||||||
dto.setIpService(ipService);
|
if (in.getIpmiPort() != null) {
|
||||||
dto.setType(type);
|
builder.ipmiPort(in.getIpmiPort());
|
||||||
dto.setUser(user);
|
}
|
||||||
dto.setPassword(password);
|
|
||||||
dto.setIpmiIP(ipmiIp);
|
return builder;
|
||||||
dto.setIpmiPassword(ipmiPassword);
|
}
|
||||||
if (ipmiPort != null)
|
}
|
||||||
{
|
|
||||||
dto.setIpmiPort(ipmiPort);
|
// Delegate methods
|
||||||
}
|
|
||||||
dto.setIpmiUser(ipmiUser);
|
public void setRack(final Rack rack) {
|
||||||
dto.setState(state);
|
this.rack = rack;
|
||||||
|
}
|
||||||
DatastoresDto datastoresDto = new DatastoresDto();
|
|
||||||
datastoresDto.getCollection().addAll(unwrap(datastores));
|
public VirtualMachine getVirtualMachine(final Integer virtualMachineId) {
|
||||||
dto.setDatastores(datastoresDto);
|
VirtualMachineWithNodeExtendedDto vm = context.getApi().getInfrastructureApi()
|
||||||
|
.getVirtualMachine(target, virtualMachineId);
|
||||||
Machine machine = new Machine(context, dto);
|
return wrap(context, VirtualMachine.class, vm);
|
||||||
machine.rack = rack;
|
}
|
||||||
|
|
||||||
return machine;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder fromMachine(final Machine in)
|
|
||||||
{
|
|
||||||
Builder builder =
|
|
||||||
Machine.builder(in.context, in.rack).name(in.getName())
|
|
||||||
.description(in.getDescription()).virtualCpuCores(in.getVirtualCpuCores())
|
|
||||||
.virtualCpusUsed(in.getVirtualCpusUsed())
|
|
||||||
.virtualRamInMb(in.getVirtualRamInMb())
|
|
||||||
.virtualRamUsedInMb(in.getVirtualRamUsedInMb())
|
|
||||||
.virtualSwitch(in.getVirtualSwitch()).port(in.getPort()).ip(in.getIp())
|
|
||||||
.ipService(in.getIpService()).hypervisorType(in.getType()).user(in.getUser())
|
|
||||||
.password(in.getPassword()).ipmiIp(in.getIpmiIp())
|
|
||||||
.ipmiPassword(in.getIpmiPassword()).ipmiUser(in.getIpmiUser())
|
|
||||||
.state(in.getState()).datastores(in.getDatastores());
|
|
||||||
|
|
||||||
// Parameters that can be null
|
|
||||||
if (in.getIpmiPort() != null)
|
|
||||||
{
|
|
||||||
builder.ipmiPort(in.getIpmiPort());
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
|
||||||
|
|
||||||
public void setRack(final Rack rack)
|
|
||||||
{
|
|
||||||
this.rack = rack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualMachine getVirtualMachine(final Integer virtualMachineId)
|
|
||||||
{
|
|
||||||
VirtualMachineWithNodeExtendedDto vm =
|
|
||||||
context.getApi().getInfrastructureApi().getVirtualMachine(target, virtualMachineId);
|
|
||||||
return wrap(context, VirtualMachine.class, vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.abiquo.domain.infrastructure;
|
package org.jclouds.abiquo.domain.infrastructure;
|
||||||
|
|
||||||
|
|
||||||
import org.jclouds.abiquo.AbiquoAsyncApi;
|
import org.jclouds.abiquo.AbiquoAsyncApi;
|
||||||
import org.jclouds.abiquo.AbiquoApi;
|
import org.jclouds.abiquo.AbiquoApi;
|
||||||
import org.jclouds.abiquo.domain.DomainWrapper;
|
import org.jclouds.abiquo.domain.DomainWrapper;
|
||||||
|
@ -37,72 +36,59 @@ import com.abiquo.server.core.infrastructure.OrganizationDto;
|
||||||
* http://community.abiquo.com/display/ABI20/RackResource</a>
|
* http://community.abiquo.com/display/ABI20/RackResource</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class Organization extends DomainWrapper<OrganizationDto>
|
public class Organization extends DomainWrapper<OrganizationDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected Organization(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final OrganizationDto target) {
|
||||||
protected Organization(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final OrganizationDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate Methods
|
// Delegate Methods
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDn()
|
public String getDn() {
|
||||||
{
|
return target.getDn();
|
||||||
return target.getDn();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getLevel()
|
public String getLevel() {
|
||||||
{
|
return target.getLevel();
|
||||||
return target.getLevel();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus() {
|
||||||
{
|
return target.getStatus();
|
||||||
return target.getStatus();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(final String value)
|
public void setDescription(final String value) {
|
||||||
{
|
target.setDescription(value);
|
||||||
target.setDescription(value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDn(final String dn)
|
public void setDn(final String dn) {
|
||||||
{
|
target.setDn(dn);
|
||||||
target.setDn(dn);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setLevel(final String value)
|
public void setLevel(final String value) {
|
||||||
{
|
target.setLevel(value);
|
||||||
target.setLevel(value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String value)
|
public void setName(final String value) {
|
||||||
{
|
target.setName(value);
|
||||||
target.setName(value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(final String value)
|
public void setStatus(final String value) {
|
||||||
{
|
target.setStatus(value);
|
||||||
target.setStatus(value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Organization [name=" + getName() + ", description=" + getDescription() + ", dn=" + getDn() + ", level="
|
||||||
return "Organization [name=" + getName() + ", description=" + getDescription() + ", dn="
|
+ getLevel() + ", status=" + getStatus() + "]";
|
||||||
+ getDn() + ", level=" + getLevel() + ", status=" + getStatus() + "]";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,383 +39,339 @@ import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link RackDto}. Represents unmanaged racks in the Abiquo
|
* Adds high level functionality to {@link RackDto}. Represents unmanaged racks
|
||||||
* platform.
|
* in the Abiquo platform.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/RackResource">
|
* @see API: <a href="http://community.abiquo.com/display/ABI20/RackResource">
|
||||||
* http://community.abiquo.com/display/ABI20/RackResource</a>
|
* http://community.abiquo.com/display/ABI20/RackResource</a>
|
||||||
*/
|
*/
|
||||||
public class Rack extends DomainWrapper<RackDto>
|
public class Rack extends DomainWrapper<RackDto> {
|
||||||
{
|
/** The default minimum VLAN id. */
|
||||||
/** The default minimum VLAN id. */
|
private static final int DEFAULT_VLAN_ID_MIN = 2;
|
||||||
private static final int DEFAULT_VLAN_ID_MIN = 2;
|
|
||||||
|
|
||||||
/** The default maximum VLAN id. */
|
/** The default maximum VLAN id. */
|
||||||
private static final int DEFAULT_VLAN_ID_MAX = 4094;
|
private static final int DEFAULT_VLAN_ID_MAX = 4094;
|
||||||
|
|
||||||
/** The default maximum VLAN per virtual datacenter. */
|
/** The default maximum VLAN per virtual datacenter. */
|
||||||
private static final int DEFAULT_VLAN_PER_VDC = 1;
|
private static final int DEFAULT_VLAN_PER_VDC = 1;
|
||||||
|
|
||||||
/** The default nrsq factor. */
|
/** The default nrsq factor. */
|
||||||
private static final int DEFAULT_NRSQ = 10;
|
private static final int DEFAULT_NRSQ = 10;
|
||||||
|
|
||||||
/** The datacenter where the rack belongs. */
|
/** The datacenter where the rack belongs. */
|
||||||
private Datacenter datacenter;
|
private Datacenter datacenter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected Rack(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final RackDto target)
|
protected Rack(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final RackDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the unmanaged rack.
|
* Delete the unmanaged rack.
|
||||||
*
|
*
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/RackResource#RackResource-DeleteaRack" >
|
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-DeleteaRack"
|
||||||
* http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource#RackResource-
|
* >
|
||||||
* DeleteaRack</a>
|
* http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource
|
||||||
*/
|
* #RackResource- DeleteaRack</a>
|
||||||
public void delete()
|
*/
|
||||||
{
|
public void delete() {
|
||||||
context.getApi().getInfrastructureApi().deleteRack(target);
|
context.getApi().getInfrastructureApi().deleteRack(target);
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new unmanaged rack in Abiquo.
|
* Create a new unmanaged rack in Abiquo.
|
||||||
*
|
*
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/RackResource#RackResource-CreateanewRack"
|
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-CreateanewRack"
|
||||||
* > http://community.abiquo.com/display/ABI20/RackResource#RackResource-CreateanewRack</a>
|
* > http://community.abiquo.com/display/ABI20/RackResource#RackResource
|
||||||
*/
|
* -CreateanewRack</a>
|
||||||
public void save()
|
*/
|
||||||
{
|
public void save() {
|
||||||
target = context.getApi().getInfrastructureApi().createRack(datacenter.unwrap(), target);
|
target = context.getApi().getInfrastructureApi().createRack(datacenter.unwrap(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update rack information in the server with the data from this rack.
|
* Update rack information in the server with the data from this rack.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-UpdateanexistingRack"
|
* "http://community.abiquo.com/display/ABI20/RackResource#RackResource-UpdateanexistingRack"
|
||||||
* >
|
* >
|
||||||
* http://community.abiquo.com/display/ABI20/RackResource#RackResource-UpdateanexistingRack
|
* http://community.abiquo.com/display/ABI20/RackResource#RackResource-
|
||||||
* </a>
|
* UpdateanexistingRack </a>
|
||||||
*/
|
*/
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
target = context.getApi().getInfrastructureApi().updateRack(target);
|
||||||
target = context.getApi().getInfrastructureApi().updateRack(target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
/**
|
/**
|
||||||
* Retrieve the datacenter where this rack is.
|
* Retrieve the datacenter where this rack is.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
||||||
* > http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-
|
* > http://community.abiquo.com/display/ABI20/DatacenterResource#
|
||||||
* Retrieveadatacenter</a>
|
* DatacenterResource- Retrieveadatacenter</a>
|
||||||
*/
|
*/
|
||||||
public Datacenter getDatacenter()
|
public Datacenter getDatacenter() {
|
||||||
{
|
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
||||||
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(datacenterId));
|
||||||
return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi()
|
}
|
||||||
.getDatacenter(datacenterId));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Children access
|
// Children access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of physical machines in this rack.
|
* Retrieve the list of physical machines in this rack.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* RetrievealistofMachines</a>
|
* MachineResource- RetrievealistofMachines</a>
|
||||||
*/
|
*/
|
||||||
public List<Machine> listMachines()
|
public List<Machine> listMachines() {
|
||||||
{
|
MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target);
|
||||||
MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target);
|
return wrap(context, Machine.class, machines.getCollection());
|
||||||
return wrap(context, Machine.class, machines.getCollection());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a filtered list of physical machines in this rack.
|
* Retrieve a filtered list of physical machines in this rack.
|
||||||
*
|
*
|
||||||
* @param filter Filter to be applied to the list.
|
* @param filter
|
||||||
* @see API: <a href=
|
* Filter to be applied to the list.
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
|
||||||
* RetrievealistofMachines</a>
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
*/
|
* MachineResource- RetrievealistofMachines</a>
|
||||||
public List<Machine> listMachines(final Predicate<Machine> filter)
|
*/
|
||||||
{
|
public List<Machine> listMachines(final Predicate<Machine> filter) {
|
||||||
return Lists.newLinkedList(filter(listMachines(), filter));
|
return Lists.newLinkedList(filter(listMachines(), filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the first physical machine matching the filter within the list of machines in this
|
* Retrieve the first physical machine matching the filter within the list of
|
||||||
* rack.
|
* machines in this rack.
|
||||||
*
|
*
|
||||||
* @param filter Filter to be applied to the list.
|
* @param filter
|
||||||
* @see API: <a href=
|
* Filter to be applied to the list.
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
|
||||||
* RetrievealistofMachines</a>
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
*/
|
* MachineResource- RetrievealistofMachines</a>
|
||||||
public Machine findMachine(final Predicate<Machine> filter)
|
*/
|
||||||
{
|
public Machine findMachine(final Predicate<Machine> filter) {
|
||||||
return Iterables.getFirst(filter(listMachines(), filter), null);
|
return Iterables.getFirst(filter(listMachines(), filter), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a single physical machine.
|
* Retrieve a single physical machine.
|
||||||
*
|
*
|
||||||
* @param id Unique ID of the physical machine in this rack.
|
* @param id
|
||||||
* @see API: <a href=
|
* Unique ID of the physical machine in this rack.
|
||||||
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveaMachine"
|
* @see API: <a href=
|
||||||
* >
|
* "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveaMachine"
|
||||||
* http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveaMachine
|
* > http://community.abiquo.com/display/ABI20/MachineResource#
|
||||||
* </a>
|
* MachineResource-RetrieveaMachine </a>
|
||||||
* @return Unmanaged rack with the given id or <code>null</code> if it does not exist.
|
* @return Unmanaged rack with the given id or <code>null</code> if it does
|
||||||
*/
|
* not exist.
|
||||||
public Machine getMachine(final Integer id)
|
*/
|
||||||
{
|
public Machine getMachine(final Integer id) {
|
||||||
MachineDto machine = context.getApi().getInfrastructureApi().getMachine(target, id);
|
MachineDto machine = context.getApi().getInfrastructureApi().getMachine(target, id);
|
||||||
return wrap(context, Machine.class, machine);
|
return wrap(context, Machine.class, machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter) {
|
||||||
final Datacenter datacenter)
|
return new Builder(context, datacenter);
|
||||||
{
|
}
|
||||||
return new Builder(context, datacenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String shortDescription;
|
private String shortDescription;
|
||||||
|
|
||||||
private boolean haEnabled = false;
|
private boolean haEnabled = false;
|
||||||
|
|
||||||
private Integer nrsq = DEFAULT_NRSQ;
|
private Integer nrsq = DEFAULT_NRSQ;
|
||||||
|
|
||||||
private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX;
|
private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX;
|
||||||
|
|
||||||
private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN;
|
private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN;
|
||||||
|
|
||||||
private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC;
|
private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC;
|
||||||
|
|
||||||
private String vlansIdAvoided;
|
private String vlansIdAvoided;
|
||||||
|
|
||||||
private Datacenter datacenter;
|
private Datacenter datacenter;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter) {
|
||||||
final Datacenter datacenter)
|
super();
|
||||||
{
|
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
||||||
super();
|
this.datacenter = datacenter;
|
||||||
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
this.context = context;
|
||||||
this.datacenter = datacenter;
|
}
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder id(final Integer id)
|
public Builder id(final Integer id) {
|
||||||
{
|
this.id = id;
|
||||||
this.id = id;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder shortDescription(final String shortDescription)
|
public Builder shortDescription(final String shortDescription) {
|
||||||
{
|
this.shortDescription = shortDescription;
|
||||||
this.shortDescription = shortDescription;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder haEnabled(final boolean haEnabled)
|
public Builder haEnabled(final boolean haEnabled) {
|
||||||
{
|
this.haEnabled = haEnabled;
|
||||||
this.haEnabled = haEnabled;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder nrsq(final int nrsq)
|
public Builder nrsq(final int nrsq) {
|
||||||
{
|
this.nrsq = nrsq;
|
||||||
this.nrsq = nrsq;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder vlanIdMax(final int vlanIdMax)
|
public Builder vlanIdMax(final int vlanIdMax) {
|
||||||
{
|
this.vlanIdMax = vlanIdMax;
|
||||||
this.vlanIdMax = vlanIdMax;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder vlanIdMin(final int vlanIdMin)
|
public Builder vlanIdMin(final int vlanIdMin) {
|
||||||
{
|
this.vlanIdMin = vlanIdMin;
|
||||||
this.vlanIdMin = vlanIdMin;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder vlanPerVdcReserved(final int vlanPerVdcExpected)
|
public Builder vlanPerVdcReserved(final int vlanPerVdcExpected) {
|
||||||
{
|
this.vlanPerVdcReserved = vlanPerVdcExpected;
|
||||||
this.vlanPerVdcReserved = vlanPerVdcExpected;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder VlansIdAvoided(final String vlansIdAvoided)
|
public Builder VlansIdAvoided(final String vlansIdAvoided) {
|
||||||
{
|
this.vlansIdAvoided = vlansIdAvoided;
|
||||||
this.vlansIdAvoided = vlansIdAvoided;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder datacenter(final Datacenter datacenter)
|
public Builder datacenter(final Datacenter datacenter) {
|
||||||
{
|
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
||||||
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
this.datacenter = datacenter;
|
||||||
this.datacenter = datacenter;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Rack build()
|
public Rack build() {
|
||||||
{
|
RackDto dto = new RackDto();
|
||||||
RackDto dto = new RackDto();
|
dto.setId(id);
|
||||||
dto.setId(id);
|
dto.setName(name);
|
||||||
dto.setName(name);
|
dto.setShortDescription(shortDescription);
|
||||||
dto.setShortDescription(shortDescription);
|
dto.setHaEnabled(haEnabled);
|
||||||
dto.setHaEnabled(haEnabled);
|
dto.setNrsq(nrsq);
|
||||||
dto.setNrsq(nrsq);
|
dto.setVlanIdMax(vlanIdMax);
|
||||||
dto.setVlanIdMax(vlanIdMax);
|
dto.setVlanIdMin(vlanIdMin);
|
||||||
dto.setVlanIdMin(vlanIdMin);
|
dto.setVlanPerVdcReserved(vlanPerVdcReserved);
|
||||||
dto.setVlanPerVdcReserved(vlanPerVdcReserved);
|
dto.setVlansIdAvoided(vlansIdAvoided);
|
||||||
dto.setVlansIdAvoided(vlansIdAvoided);
|
Rack rack = new Rack(context, dto);
|
||||||
Rack rack = new Rack(context, dto);
|
rack.datacenter = datacenter;
|
||||||
rack.datacenter = datacenter;
|
return rack;
|
||||||
return rack;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder fromRack(final Rack in)
|
public static Builder fromRack(final Rack in) {
|
||||||
{
|
return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName())
|
||||||
return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName())
|
.shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq())
|
||||||
.shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled())
|
.vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin())
|
||||||
.nrsq(in.getNrsq()).vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin())
|
.vlanPerVdcReserved(in.getVlanPerVdcReserved()).VlansIdAvoided(in.getVlansIdAvoided());
|
||||||
.vlanPerVdcReserved(in.getVlanPerVdcReserved())
|
}
|
||||||
.VlansIdAvoided(in.getVlansIdAvoided());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getShortDescription()
|
public String getShortDescription() {
|
||||||
{
|
return target.getShortDescription();
|
||||||
return target.getShortDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setShortDescription(final String description)
|
public void setShortDescription(final String description) {
|
||||||
{
|
target.setShortDescription(description);
|
||||||
target.setShortDescription(description);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setHaEnabled(final boolean haEnabled)
|
public void setHaEnabled(final boolean haEnabled) {
|
||||||
{
|
target.setHaEnabled(haEnabled);
|
||||||
target.setHaEnabled(haEnabled);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHaEnabled()
|
public boolean isHaEnabled() {
|
||||||
{
|
return target.isHaEnabled();
|
||||||
return target.isHaEnabled();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getNrsq()
|
public Integer getNrsq() {
|
||||||
{
|
return target.getNrsq();
|
||||||
return target.getNrsq();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVlanIdMax()
|
public Integer getVlanIdMax() {
|
||||||
{
|
return target.getVlanIdMax();
|
||||||
return target.getVlanIdMax();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVlanIdMin()
|
public Integer getVlanIdMin() {
|
||||||
{
|
return target.getVlanIdMin();
|
||||||
return target.getVlanIdMin();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVlanPerVdcReserved()
|
public Integer getVlanPerVdcReserved() {
|
||||||
{
|
return target.getVlanPerVdcReserved();
|
||||||
return target.getVlanPerVdcReserved();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getVlansIdAvoided()
|
public String getVlansIdAvoided() {
|
||||||
{
|
return target.getVlansIdAvoided();
|
||||||
return target.getVlansIdAvoided();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setNrsq(final Integer nrsq)
|
public void setNrsq(final Integer nrsq) {
|
||||||
{
|
target.setNrsq(nrsq);
|
||||||
target.setNrsq(nrsq);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVlanIdMax(final Integer vlanIdMax)
|
public void setVlanIdMax(final Integer vlanIdMax) {
|
||||||
{
|
target.setVlanIdMax(vlanIdMax);
|
||||||
target.setVlanIdMax(vlanIdMax);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVlanIdMin(final Integer vlanIdMin)
|
public void setVlanIdMin(final Integer vlanIdMin) {
|
||||||
{
|
target.setVlanIdMin(vlanIdMin);
|
||||||
target.setVlanIdMin(vlanIdMin);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved)
|
public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved) {
|
||||||
{
|
target.setVlanPerVdcReserved(vlanPerVdcReserved);
|
||||||
target.setVlanPerVdcReserved(vlanPerVdcReserved);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setVlansIdAvoided(final String vlansIdAvoided)
|
public void setVlansIdAvoided(final String vlansIdAvoided) {
|
||||||
{
|
target.setVlansIdAvoided(vlansIdAvoided);
|
||||||
target.setVlansIdAvoided(vlansIdAvoided);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Rack [id=" + getId() + ", name=" + getName() + ", description=" + getShortDescription() + ", haEnabled="
|
||||||
return "Rack [id=" + getId() + ", name=" + getName() + ", description="
|
+ isHaEnabled() + ", nrsq=" + getNrsq() + ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin=" + getVlanIdMin()
|
||||||
+ getShortDescription() + ", haEnabled=" + isHaEnabled() + ", nrsq=" + getNrsq()
|
+ ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided=" + getVlansIdAvoided() + "]";
|
||||||
+ ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin=" + getVlanIdMin()
|
}
|
||||||
+ ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided="
|
|
||||||
+ getVlansIdAvoided() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,245 +33,217 @@ import com.abiquo.server.core.infrastructure.DatacenterDto;
|
||||||
import com.abiquo.server.core.infrastructure.RemoteServiceDto;
|
import com.abiquo.server.core.infrastructure.RemoteServiceDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link RemoteServiceDto}. The Remote Service resource offers the
|
* Adds high level functionality to {@link RemoteServiceDto}. The Remote Service
|
||||||
* functionality of managing the remote services of a datacenter in a logical way.
|
* resource offers the functionality of managing the remote services of a
|
||||||
|
* datacenter in a logical way.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/RemoteServiceResource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/RemoteServiceResource">
|
||||||
* http://community.abiquo.com/display/ABI20/RemoteServiceResource</a>
|
* http://community.abiquo.com/display/ABI20/RemoteServiceResource</a>
|
||||||
*/
|
*/
|
||||||
public class RemoteService extends DomainWrapper<RemoteServiceDto>
|
public class RemoteService extends DomainWrapper<RemoteServiceDto> {
|
||||||
{
|
/** The default status. */
|
||||||
/** The default status. */
|
private static final int DEFAULT_STATUS = 0;
|
||||||
private static final int DEFAULT_STATUS = 0;
|
|
||||||
|
|
||||||
/** The datacenter using the remote service. */
|
/** The datacenter using the remote service. */
|
||||||
private Datacenter datacenter;
|
private Datacenter datacenter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected RemoteService(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final RemoteServiceDto target)
|
protected RemoteService(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final RemoteServiceDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the remote service.
|
* Delete the remote service.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-DeleteaRemoteService"
|
* "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-DeleteaRemoteService"
|
||||||
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-
|
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
|
||||||
* DeleteaRemoteService</a>
|
* RemoteServiceResource- DeleteaRemoteService</a>
|
||||||
*/
|
*/
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getInfrastructureApi().deleteRemoteService(target);
|
||||||
context.getApi().getInfrastructureApi().deleteRemoteService(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the remote service.
|
* Create the remote service.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-CreateaRemoteService"
|
* "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-CreateaRemoteService"
|
||||||
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-
|
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
|
||||||
* CreateaRemoteService</a>
|
* RemoteServiceResource- CreateaRemoteService</a>
|
||||||
*/
|
*/
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
target = context.getApi().getInfrastructureApi().createRemoteService(datacenter.unwrap(), target);
|
||||||
target =
|
}
|
||||||
context.getApi().getInfrastructureApi()
|
|
||||||
.createRemoteService(datacenter.unwrap(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update remote service information in the server with the data from this remote service.
|
* 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"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-
|
* "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-UpdateanexistingRemoteService"
|
||||||
* UpdateanexistingRemoteService</a>
|
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
|
||||||
*/
|
* RemoteServiceResource- UpdateanexistingRemoteService</a>
|
||||||
public void update()
|
*/
|
||||||
{
|
public void update() {
|
||||||
target = context.getApi().getInfrastructureApi().updateRemoteService(target);
|
target = context.getApi().getInfrastructureApi().updateRemoteService(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check remote service availability.
|
* Check remote service availability.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-CheckthestatusofaRemoteService"
|
* "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-CheckthestatusofaRemoteService"
|
||||||
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-
|
* > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
|
||||||
* CheckthestatusofaRemoteService</a>
|
* RemoteServiceResource- CheckthestatusofaRemoteService</a>
|
||||||
*/
|
*/
|
||||||
public boolean isAvailable()
|
public boolean isAvailable() {
|
||||||
{
|
// If the remote service can not be checked, assume it is available
|
||||||
// If the remote service can not be checked, assume it is available
|
return !getType().canBeChecked() ? true : context.getApi().getInfrastructureApi().isAvailable(target);
|
||||||
return !getType().canBeChecked() ? true : context.getApi().getInfrastructureApi()
|
}
|
||||||
.isAvailable(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the datacenter using this remotes service.
|
* Retrieve the datacenter using this remotes service.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
||||||
* > http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-
|
* > http://community.abiquo.com/display/ABI20/DatacenterResource#
|
||||||
* Retrieveadatacenter</a>
|
* DatacenterResource- Retrieveadatacenter</a>
|
||||||
*/
|
*/
|
||||||
public Datacenter getDatacenter()
|
public Datacenter getDatacenter() {
|
||||||
{
|
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
||||||
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
|
||||||
DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
|
datacenter = wrap(context, Datacenter.class, dto);
|
||||||
datacenter = wrap(context, Datacenter.class, dto);
|
return datacenter;
|
||||||
return datacenter;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter) {
|
||||||
{
|
return new Builder(context, datacenter);
|
||||||
return new Builder(context, datacenter);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private Datacenter datacenter;
|
private Datacenter datacenter;
|
||||||
|
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
private RemoteServiceType type;
|
private RemoteServiceType type;
|
||||||
|
|
||||||
private Integer status = DEFAULT_STATUS;
|
private Integer status = DEFAULT_STATUS;
|
||||||
|
|
||||||
// To be used only internally by the builder
|
// To be used only internally by the builder
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter) {
|
||||||
{
|
super();
|
||||||
super();
|
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
||||||
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
this.datacenter = datacenter;
|
||||||
this.datacenter = datacenter;
|
this.context = context;
|
||||||
this.context = context;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder datacenter(final Datacenter datacenter)
|
public Builder datacenter(final Datacenter datacenter) {
|
||||||
{
|
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
||||||
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
this.datacenter = datacenter;
|
||||||
this.datacenter = datacenter;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder status(final int status)
|
public Builder status(final int status) {
|
||||||
{
|
this.status = status;
|
||||||
this.status = status;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder type(final RemoteServiceType type)
|
public Builder type(final RemoteServiceType type) {
|
||||||
{
|
this.type = type;
|
||||||
this.type = type;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder ip(final String ip)
|
public Builder ip(final String ip) {
|
||||||
{
|
this.ip = ip;
|
||||||
this.ip = ip;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder port(final int port)
|
public Builder port(final int port) {
|
||||||
{
|
this.port = port;
|
||||||
this.port = port;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private String generateUri(final String ip, final Integer port, final RemoteServiceType type)
|
private String generateUri(final String ip, final Integer port, final RemoteServiceType type) {
|
||||||
{
|
return type.getDefaultProtocol() + ip + ":" + port + "/" + type.getServiceMapping();
|
||||||
return type.getDefaultProtocol() + ip + ":" + port + "/" + type.getServiceMapping();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public RemoteService build()
|
public RemoteService build() {
|
||||||
{
|
if (uri == null) {
|
||||||
if (uri == null)
|
checkNotNull(ip, ValidationErrors.MISSING_REQUIRED_FIELD + "ip");
|
||||||
{
|
checkNotNull(type, ValidationErrors.MISSING_REQUIRED_FIELD + "type");
|
||||||
checkNotNull(ip, ValidationErrors.MISSING_REQUIRED_FIELD + "ip");
|
|
||||||
checkNotNull(type, ValidationErrors.MISSING_REQUIRED_FIELD + "type");
|
|
||||||
|
|
||||||
uri = generateUri(ip, port == null ? type.getDefaultPort() : port, type);
|
uri = generateUri(ip, port == null ? type.getDefaultPort() : port, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteServiceDto dto = new RemoteServiceDto();
|
RemoteServiceDto dto = new RemoteServiceDto();
|
||||||
dto.setId(id);
|
dto.setId(id);
|
||||||
dto.setType(type);
|
dto.setType(type);
|
||||||
dto.setUri(uri);
|
dto.setUri(uri);
|
||||||
dto.setStatus(status);
|
dto.setStatus(status);
|
||||||
RemoteService remoteservice = new RemoteService(context, dto);
|
RemoteService remoteservice = new RemoteService(context, dto);
|
||||||
remoteservice.datacenter = datacenter;
|
remoteservice.datacenter = datacenter;
|
||||||
return remoteservice;
|
return remoteservice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromRemoteService(final RemoteService in)
|
public static Builder fromRemoteService(final RemoteService in) {
|
||||||
{
|
Builder builder = RemoteService.builder(in.context, in.getDatacenter()).status(in.getStatus())
|
||||||
Builder builder =
|
.type(in.getType());
|
||||||
RemoteService.builder(in.context, in.getDatacenter()).status(in.getStatus())
|
builder.uri = in.getUri();
|
||||||
.type(in.getType());
|
return builder;
|
||||||
builder.uri = in.getUri();
|
}
|
||||||
return builder;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public RemoteServiceType getType()
|
public RemoteServiceType getType() {
|
||||||
{
|
return target.getType();
|
||||||
return target.getType();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getStatus()
|
public int getStatus() {
|
||||||
{
|
return target.getStatus();
|
||||||
return target.getStatus();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri()
|
public String getUri() {
|
||||||
{
|
return target.getUri();
|
||||||
return target.getUri();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(final int status)
|
public void setStatus(final int status) {
|
||||||
{
|
target.setStatus(status);
|
||||||
target.setStatus(status);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(final RemoteServiceType type)
|
public void setType(final RemoteServiceType type) {
|
||||||
{
|
target.setType(type);
|
||||||
target.setType(type);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setUri(final String uri)
|
public void setUri(final String uri) {
|
||||||
{
|
target.setUri(uri);
|
||||||
target.setUri(uri);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "RemoteService [id=" + getId() + ", available=" + isAvailable() + ", type=" + getType() + ", status="
|
||||||
return "RemoteService [id=" + getId() + ", available=" + isAvailable() + ", type="
|
+ getStatus() + ", uri" + getUri() + "]";
|
||||||
+ getType() + ", status=" + getStatus() + ", uri" + getUri() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,490 +43,440 @@ import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link StorageDeviceDto}. The Storage Device Resource offers the
|
* Adds high level functionality to {@link StorageDeviceDto}. The Storage Device
|
||||||
* functionality of managing the external storage.
|
* Resource offers the functionality of managing the external storage.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/StorageDeviceResource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/StorageDeviceResource">
|
||||||
* http://community.abiquo.com/display/ABI20/StorageDeviceResource</a>
|
* http://community.abiquo.com/display/ABI20/StorageDeviceResource</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class StorageDevice extends DomainWrapper<StorageDeviceDto>
|
public class StorageDevice extends DomainWrapper<StorageDeviceDto> {
|
||||||
{
|
/** The datacenter where the storage device is. */
|
||||||
/** The datacenter where the storage device is. */
|
private Datacenter datacenter;
|
||||||
private Datacenter datacenter;
|
|
||||||
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected StorageDevice(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StorageDeviceDto target) {
|
||||||
protected StorageDevice(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
super(context, target);
|
||||||
final StorageDeviceDto target)
|
}
|
||||||
{
|
|
||||||
super(context, target);
|
/**
|
||||||
}
|
* Delete the storage device.
|
||||||
|
*
|
||||||
/**
|
* @see API: <a href=
|
||||||
* Delete the storage device.
|
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Deleteastoragedevice"
|
||||||
*
|
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
|
||||||
* @see API: <a href=
|
* StorageDeviceResource- Deleteastoragedevice</a>
|
||||||
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Deleteastoragedevice"
|
*/
|
||||||
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-
|
public void delete() {
|
||||||
* Deleteastoragedevice</a>
|
context.getApi().getInfrastructureApi().deleteStorageDevice(target);
|
||||||
*/
|
target = null;
|
||||||
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"
|
||||||
* Create a new storage device.
|
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
|
||||||
*
|
* StorageDeviceResource- Createastoragedevice</a>
|
||||||
* @see API: <a href=
|
*/
|
||||||
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Createastoragedevice"
|
public void save() {
|
||||||
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-
|
target = context.getApi().getInfrastructureApi().createStorageDevice(datacenter.unwrap(), target);
|
||||||
* Createastoragedevice</a>
|
}
|
||||||
*/
|
|
||||||
public void save()
|
/**
|
||||||
{
|
* Update storage device information in the server with the data from this
|
||||||
target =
|
* device.
|
||||||
context.getApi().getInfrastructureApi()
|
*
|
||||||
.createStorageDevice(datacenter.unwrap(), target);
|
* @see API: <a href=
|
||||||
}
|
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Updateastoragedevice"
|
||||||
|
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
|
||||||
/**
|
* StorageDeviceResource- Updateastoragedevice</a>
|
||||||
* Update storage device information in the server with the data from this device.
|
*/
|
||||||
*
|
public void update() {
|
||||||
* @see API: <a href=
|
target = context.getApi().getInfrastructureApi().updateStorageDevice(target);
|
||||||
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Updateastoragedevice"
|
}
|
||||||
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-
|
|
||||||
* Updateastoragedevice</a>
|
// Parent access
|
||||||
*/
|
|
||||||
public void update()
|
/**
|
||||||
{
|
* Retrieve the datacenter where this storage device is.
|
||||||
target = context.getApi().getInfrastructureApi().updateStorageDevice(target);
|
*
|
||||||
}
|
* @see API: <a href=
|
||||||
|
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
||||||
// Parent access
|
* > http://community.abiquo.com/display/ABI20/DatacenterResource#
|
||||||
|
* DatacenterResource- Retrieveadatacenter</a>
|
||||||
/**
|
*/
|
||||||
* Retrieve the datacenter where this storage device is.
|
public Datacenter getDatacenter() {
|
||||||
*
|
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
||||||
* @see API: <a href=
|
DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
|
||||||
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
datacenter = wrap(context, Datacenter.class, dto);
|
||||||
* > http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-
|
return datacenter;
|
||||||
* Retrieveadatacenter</a>
|
}
|
||||||
*/
|
|
||||||
public Datacenter getDatacenter()
|
// Children access
|
||||||
{
|
|
||||||
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
/**
|
||||||
DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
|
* Retrieve the list of storage pools in this device (synchronized with the
|
||||||
datacenter = wrap(context, Datacenter.class, dto);
|
* device).
|
||||||
return datacenter;
|
*
|
||||||
}
|
* @see API: <a href=
|
||||||
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
// Children access
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
/**
|
* @return Synchronized list of storage pools in this device.
|
||||||
* Retrieve the list of storage pools in this device (synchronized with the device).
|
*/
|
||||||
*
|
public List<StoragePool> listRemoteStoragePools() {
|
||||||
* @see API: <a href=
|
StoragePoolsDto storagePools = context.getApi().getInfrastructureApi()
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
.listStoragePools(target, StoragePoolOptions.builder().sync(true).build());
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
|
||||||
* Retrievestoragepools</a>
|
List<StoragePool> storagePoolList = wrap(context, StoragePool.class, storagePools.getCollection());
|
||||||
* @return Synchronized list of storage pools in this device.
|
|
||||||
*/
|
for (StoragePool storagePool : storagePoolList) {
|
||||||
public List<StoragePool> listRemoteStoragePools()
|
storagePool.storageDevice = this;
|
||||||
{
|
}
|
||||||
StoragePoolsDto storagePools =
|
|
||||||
context.getApi().getInfrastructureApi()
|
return storagePoolList;
|
||||||
.listStoragePools(target, StoragePoolOptions.builder().sync(true).build());
|
}
|
||||||
|
|
||||||
List<StoragePool> storagePoolList =
|
/**
|
||||||
wrap(context, StoragePool.class, storagePools.getCollection());
|
* Retrieve a filtered list of storage pools in this device (synchronized
|
||||||
|
* with the device).
|
||||||
for (StoragePool storagePool : storagePoolList)
|
*
|
||||||
{
|
* @param filter
|
||||||
storagePool.storageDevice = this;
|
* Filter to be applied to the list.
|
||||||
}
|
* @see API: <a href=
|
||||||
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
return storagePoolList;
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
}
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
|
* @return Filtered synchronized list of storage pools in this device.
|
||||||
/**
|
*/
|
||||||
* Retrieve a filtered list of storage pools in this device (synchronized with the device).
|
public List<StoragePool> listRemoteStoragePools(final Predicate<StoragePool> filter) {
|
||||||
*
|
return Lists.newLinkedList(filter(listRemoteStoragePools(), filter));
|
||||||
* @param filter Filter to be applied to the list.
|
}
|
||||||
* @see API: <a href=
|
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
/**
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
* Retrieve the first storage pool matching the filter within the list of
|
||||||
* Retrievestoragepools</a>
|
* storage pools in this device (synchronized with the device).
|
||||||
* @return Filtered synchronized list of storage pools in this device.
|
*
|
||||||
*/
|
* @param filter
|
||||||
public List<StoragePool> listRemoteStoragePools(final Predicate<StoragePool> filter)
|
* Filter to be applied to the list.
|
||||||
{
|
* @see API: <a href=
|
||||||
return Lists.newLinkedList(filter(listRemoteStoragePools(), filter));
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
}
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
/**
|
* @return First storage pool (synchronized) matching the filter or
|
||||||
* Retrieve the first storage pool matching the filter within the list of storage pools in this
|
* <code>null</code> if there is none.
|
||||||
* device (synchronized with the device).
|
*/
|
||||||
*
|
public StoragePool findRemoteStoragePool(final Predicate<StoragePool> filter) {
|
||||||
* @param filter Filter to be applied to the list.
|
return Iterables.getFirst(filter(listRemoteStoragePools(), filter), null);
|
||||||
* @see API: <a href=
|
}
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
/**
|
||||||
* Retrievestoragepools</a>
|
* Retrieve the list of storage pools in this device from Abiquo database
|
||||||
* @return First storage pool (synchronized) matching the filter or <code>null</code> if there
|
* (may not be synchronized with the device).
|
||||||
* is none.
|
*
|
||||||
*/
|
* @see API: <a href=
|
||||||
public StoragePool findRemoteStoragePool(final Predicate<StoragePool> filter)
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
{
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
return Iterables.getFirst(filter(listRemoteStoragePools(), filter), null);
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
}
|
* @return Unsynchronized list of storage pools in this device.
|
||||||
|
*/
|
||||||
/**
|
public List<StoragePool> listStoragePools() {
|
||||||
* Retrieve the list of storage pools in this device from Abiquo database (may not be
|
StoragePoolsDto storagePools = context.getApi().getInfrastructureApi()
|
||||||
* synchronized with the device).
|
.listStoragePools(target, StoragePoolOptions.builder().sync(false).build());
|
||||||
*
|
return wrap(context, StoragePool.class, storagePools.getCollection());
|
||||||
* @see API: <a href=
|
}
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
/**
|
||||||
* Retrievestoragepools</a>
|
* Retrieve a filtered list of storage pools in this device from Abiquo
|
||||||
* @return Unsynchronized list of storage pools in this device.
|
* database (may not be synchronized with the device).
|
||||||
*/
|
*
|
||||||
public List<StoragePool> listStoragePools()
|
* @param filter
|
||||||
{
|
* Filter to be applied to the list.
|
||||||
StoragePoolsDto storagePools =
|
* @see API: <a href=
|
||||||
context.getApi().getInfrastructureApi()
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
.listStoragePools(target, StoragePoolOptions.builder().sync(false).build());
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
return wrap(context, StoragePool.class, storagePools.getCollection());
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
}
|
* @return Filtered unsynchronized list of storage pools in this device.
|
||||||
|
*/
|
||||||
/**
|
public List<StoragePool> listStoragePools(final Predicate<StoragePool> filter) {
|
||||||
* Retrieve a filtered list of storage pools in this device from Abiquo database (may not be
|
return Lists.newLinkedList(filter(listStoragePools(), filter));
|
||||||
* synchronized with the device).
|
}
|
||||||
*
|
|
||||||
* @param filter Filter to be applied to the list.
|
/**
|
||||||
* @see API: <a href=
|
* Retrieve the first storage pool matching the filter within the list of
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
* storage pools in this device (unsynchronized with the device).
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
*
|
||||||
* Retrievestoragepools</a>
|
* @param filter
|
||||||
* @return Filtered unsynchronized list of storage pools in this device.
|
* Filter to be applied to the list.
|
||||||
*/
|
* @see API: <a href=
|
||||||
public List<StoragePool> listStoragePools(final Predicate<StoragePool> filter)
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
{
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
return Lists.newLinkedList(filter(listStoragePools(), filter));
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
}
|
* @return First storage pool (unsynchronized) matching the filter or
|
||||||
|
* <code>null</code> if there is none.
|
||||||
/**
|
*/
|
||||||
* Retrieve the first storage pool matching the filter within the list of storage pools in this
|
public StoragePool findStoragePool(final Predicate<StoragePool> filter) {
|
||||||
* device (unsynchronized with the device).
|
return Iterables.getFirst(filter(listStoragePools(), filter), null);
|
||||||
*
|
}
|
||||||
* @param filter Filter to be applied to the list.
|
|
||||||
* @see API: <a href=
|
/**
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
* Retrieve a single storage pool in this device from Abiquo database.
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
*
|
||||||
* Retrievestoragepools</a>
|
* @param id
|
||||||
* @return First storage pool (unsynchronized) matching the filter or <code>null</code> if there
|
* Unique ID of the storage device in this datacenter.
|
||||||
* is none.
|
* @see API: <a href=
|
||||||
*/
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievearegisteredpool"
|
||||||
public StoragePool findStoragePool(final Predicate<StoragePool> filter)
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
{
|
* StoragePoolResource- Retrievearegisteredpool</a>
|
||||||
return Iterables.getFirst(filter(listStoragePools(), filter), null);
|
* @return Storage pool with the given id or <code>null</code> if it does not
|
||||||
}
|
* exist.
|
||||||
|
*/
|
||||||
/**
|
public StoragePool getStoragePool(final String id) {
|
||||||
* Retrieve a single storage pool in this device from Abiquo database.
|
StoragePoolDto storagePool = context.getApi().getInfrastructureApi().getStoragePool(target, id);
|
||||||
*
|
return wrap(context, StoragePool.class, storagePool);
|
||||||
* @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-
|
* Retrieve the list of tiers in the datacenter using this device.
|
||||||
* Retrievearegisteredpool</a>
|
*
|
||||||
* @return Storage pool with the given id or <code>null</code> if it does not exist.
|
* @see API: <a href=
|
||||||
*/
|
* "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers"
|
||||||
public StoragePool getStoragePool(final String id)
|
* >
|
||||||
{
|
* http://community.abiquo.com/display/ABI20/TierResource#TierResource-
|
||||||
StoragePoolDto storagePool =
|
* Retrievethelistoftiers </a>
|
||||||
context.getApi().getInfrastructureApi().getStoragePool(target, id);
|
* @return List of tiers in the datacenter using this device.
|
||||||
return wrap(context, StoragePool.class, storagePool);
|
*/
|
||||||
}
|
public List<Tier> listTiersFromDatacenter() {
|
||||||
|
DatacenterDto datacenter;
|
||||||
/**
|
|
||||||
* Retrieve the list of tiers in the datacenter using this device.
|
if (this.datacenter == null) {
|
||||||
*
|
datacenter = new DatacenterDto();
|
||||||
* @see API: <a href=
|
datacenter.setId(target.getIdFromLink(ParentLinkName.DATACENTER));
|
||||||
* "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers"
|
} else {
|
||||||
* >
|
datacenter = this.getDatacenter().unwrap();
|
||||||
* http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers
|
}
|
||||||
* </a>
|
|
||||||
* @return List of tiers in the datacenter using this device.
|
TiersDto dto = context.getApi().getInfrastructureApi().listTiers(datacenter);
|
||||||
*/
|
return DomainWrapper.wrap(context, Tier.class, dto.getCollection());
|
||||||
public List<Tier> listTiersFromDatacenter()
|
}
|
||||||
{
|
|
||||||
DatacenterDto datacenter;
|
/**
|
||||||
|
* Retrieve a filtered list of tiers in the datacenter using this device.
|
||||||
if (this.datacenter == null)
|
*
|
||||||
{
|
* @param filter
|
||||||
datacenter = new DatacenterDto();
|
* Filter to be applied to the list.
|
||||||
datacenter.setId(target.getIdFromLink(ParentLinkName.DATACENTER));
|
* @see API: <a href=
|
||||||
}
|
* "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers"
|
||||||
else
|
* >
|
||||||
{
|
* http://community.abiquo.com/display/ABI20/TierResource#TierResource-
|
||||||
datacenter = this.getDatacenter().unwrap();
|
* Retrievethelistoftiers </a>
|
||||||
}
|
* @return Filtered list of tiers in the datacenter using this device.
|
||||||
|
*/
|
||||||
TiersDto dto = context.getApi().getInfrastructureApi().listTiers(datacenter);
|
public List<Tier> listTiersFromDatacenter(final Predicate<Tier> filter) {
|
||||||
return DomainWrapper.wrap(context, Tier.class, dto.getCollection());
|
return Lists.newLinkedList(filter(listTiersFromDatacenter(), filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a filtered list of tiers in the datacenter using this device.
|
* Retrieve the first tier matching the filter within the list of tiers in
|
||||||
*
|
* the datacenter.
|
||||||
* @param filter Filter to be applied to the list.
|
*
|
||||||
* @see API: <a href=
|
* @param filter
|
||||||
* "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers"
|
* Filter to be applied to the list.
|
||||||
* >
|
* @see API: <a href=
|
||||||
* http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers
|
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrievethelistofstoragedevices"
|
||||||
* </a>
|
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
|
||||||
* @return Filtered list of tiers in the datacenter using this device.
|
* StorageDeviceResource- Retrievethelistofstoragedevices</a>
|
||||||
*/
|
* @return First tier matching the filter or <code>null</code> if there is
|
||||||
public List<Tier> listTiersFromDatacenter(final Predicate<Tier> filter)
|
* none.
|
||||||
{
|
*/
|
||||||
return Lists.newLinkedList(filter(listTiersFromDatacenter(), filter));
|
public Tier findTierInDatacenter(final Predicate<Tier> filter) {
|
||||||
}
|
return Iterables.getFirst(filter(listTiersFromDatacenter(), filter), null);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Retrieve the first tier matching the filter within the list of tiers in the datacenter.
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter) {
|
||||||
*
|
return new Builder(context, datacenter);
|
||||||
* @param filter Filter to be applied to the list.
|
}
|
||||||
* @see API: <a href=
|
|
||||||
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrievethelistofstoragedevices"
|
public static class Builder {
|
||||||
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
* Retrievethelistofstoragedevices</a>
|
|
||||||
* @return First tier matching the filter or <code>null</code> if there is none.
|
private Datacenter datacenter;
|
||||||
*/
|
|
||||||
public Tier findTierInDatacenter(final Predicate<Tier> filter)
|
private String iscsiIp;
|
||||||
{
|
|
||||||
return Iterables.getFirst(filter(listTiersFromDatacenter(), filter), null);
|
private Integer iscsiPort;
|
||||||
}
|
|
||||||
|
private String managementIp;
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
|
||||||
final Datacenter datacenter)
|
private Integer managementPort;
|
||||||
{
|
|
||||||
return new Builder(context, datacenter);
|
private String name;
|
||||||
}
|
|
||||||
|
private String password;
|
||||||
public static class Builder
|
|
||||||
{
|
private String type;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
private String username;
|
||||||
private Datacenter datacenter;
|
|
||||||
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final Datacenter datacenter) {
|
||||||
private String iscsiIp;
|
super();
|
||||||
|
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
||||||
private Integer iscsiPort;
|
this.datacenter = datacenter;
|
||||||
|
this.context = context;
|
||||||
private String managementIp;
|
}
|
||||||
|
|
||||||
private Integer managementPort;
|
public Builder datacenter(final Datacenter datacenter) {
|
||||||
|
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
||||||
private String name;
|
this.datacenter = datacenter;
|
||||||
|
return this;
|
||||||
private String password;
|
}
|
||||||
|
|
||||||
private String type;
|
public Builder iscsiIp(final String iscsiIp) {
|
||||||
|
this.iscsiIp = iscsiIp;
|
||||||
private String username;
|
return this;
|
||||||
|
}
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
|
||||||
final Datacenter datacenter)
|
public Builder iscsiPort(final int iscsiPort) {
|
||||||
{
|
this.iscsiPort = iscsiPort;
|
||||||
super();
|
return this;
|
||||||
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
}
|
||||||
this.datacenter = datacenter;
|
|
||||||
this.context = context;
|
public Builder password(final String password) {
|
||||||
}
|
this.password = password;
|
||||||
|
return this;
|
||||||
public Builder datacenter(final Datacenter datacenter)
|
}
|
||||||
{
|
|
||||||
checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
|
public Builder name(final String name) {
|
||||||
this.datacenter = datacenter;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder iscsiIp(final String iscsiIp)
|
public Builder managementPort(final int managementPort) {
|
||||||
{
|
this.managementPort = managementPort;
|
||||||
this.iscsiIp = iscsiIp;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public Builder managementIp(final String managementIp) {
|
||||||
public Builder iscsiPort(final int iscsiPort)
|
this.managementIp = managementIp;
|
||||||
{
|
return this;
|
||||||
this.iscsiPort = iscsiPort;
|
}
|
||||||
return this;
|
|
||||||
}
|
public Builder type(final String type) {
|
||||||
|
this.type = type;
|
||||||
public Builder password(final String password)
|
return this;
|
||||||
{
|
}
|
||||||
this.password = password;
|
|
||||||
return this;
|
public Builder username(final String username) {
|
||||||
}
|
this.username = username;
|
||||||
|
return this;
|
||||||
public Builder name(final String name)
|
}
|
||||||
{
|
|
||||||
this.name = name;
|
public StorageDevice build() {
|
||||||
return this;
|
StorageDeviceDto dto = new StorageDeviceDto();
|
||||||
}
|
dto.setIscsiIp(iscsiIp);
|
||||||
|
dto.setIscsiPort(iscsiPort);
|
||||||
public Builder managementPort(final int managementPort)
|
dto.setManagementIp(managementIp);
|
||||||
{
|
dto.setManagementPort(managementPort);
|
||||||
this.managementPort = managementPort;
|
dto.setName(name);
|
||||||
return this;
|
dto.setPassword(password);
|
||||||
}
|
dto.setStorageTechnology(type);
|
||||||
|
dto.setUsername(username);
|
||||||
public Builder managementIp(final String managementIp)
|
StorageDevice storageDevice = new StorageDevice(context, dto);
|
||||||
{
|
storageDevice.datacenter = datacenter;
|
||||||
this.managementIp = managementIp;
|
return storageDevice;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
public static Builder fromStorageDevice(final StorageDevice in) {
|
||||||
public Builder type(final String type)
|
Builder builder = StorageDevice.builder(in.context, in.getDatacenter()).iscsiIp(in.getIscsiIp())
|
||||||
{
|
.iscsiPort(in.getIscsiPort()).managementIp(in.getManagementIp()).managementPort(in.getManagementPort())
|
||||||
this.type = type;
|
.name(in.getName()).password(in.getPassword()).type(in.getType()).username(in.getUsername());
|
||||||
return this;
|
|
||||||
}
|
return builder;
|
||||||
|
}
|
||||||
public Builder username(final String username)
|
}
|
||||||
{
|
|
||||||
this.username = username;
|
// Delegate methods
|
||||||
return this;
|
|
||||||
}
|
public Integer getId() {
|
||||||
|
return target.getId();
|
||||||
public StorageDevice build()
|
}
|
||||||
{
|
|
||||||
StorageDeviceDto dto = new StorageDeviceDto();
|
public String getIscsiIp() {
|
||||||
dto.setIscsiIp(iscsiIp);
|
return target.getIscsiIp();
|
||||||
dto.setIscsiPort(iscsiPort);
|
}
|
||||||
dto.setManagementIp(managementIp);
|
|
||||||
dto.setManagementPort(managementPort);
|
public int getIscsiPort() {
|
||||||
dto.setName(name);
|
return target.getIscsiPort();
|
||||||
dto.setPassword(password);
|
}
|
||||||
dto.setStorageTechnology(type);
|
|
||||||
dto.setUsername(username);
|
public String getManagementIp() {
|
||||||
StorageDevice storageDevice = new StorageDevice(context, dto);
|
return target.getManagementIp();
|
||||||
storageDevice.datacenter = datacenter;
|
}
|
||||||
return storageDevice;
|
|
||||||
}
|
public int getManagementPort() {
|
||||||
|
return target.getManagementPort();
|
||||||
public static Builder fromStorageDevice(final StorageDevice in)
|
}
|
||||||
{
|
|
||||||
Builder builder =
|
public String getName() {
|
||||||
StorageDevice.builder(in.context, in.getDatacenter()).iscsiIp(in.getIscsiIp())
|
return target.getName();
|
||||||
.iscsiPort(in.getIscsiPort()).managementIp(in.getManagementIp())
|
}
|
||||||
.managementPort(in.getManagementPort()).name(in.getName())
|
|
||||||
.password(in.getPassword()).type(in.getType()).username(in.getUsername());
|
public String getPassword() {
|
||||||
|
return target.getPassword();
|
||||||
return builder;
|
}
|
||||||
}
|
|
||||||
}
|
public String getType() {
|
||||||
|
return target.getStorageTechnology();
|
||||||
// Delegate methods
|
}
|
||||||
|
|
||||||
public Integer getId()
|
public String getUsername() {
|
||||||
{
|
return target.getUsername();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
public void setIscsiIp(final String iscsiIp) {
|
||||||
public String getIscsiIp()
|
target.setIscsiIp(iscsiIp);
|
||||||
{
|
}
|
||||||
return target.getIscsiIp();
|
|
||||||
}
|
public void setIscsiPort(final int iscsiPort) {
|
||||||
|
target.setIscsiPort(iscsiPort);
|
||||||
public int getIscsiPort()
|
}
|
||||||
{
|
|
||||||
return target.getIscsiPort();
|
public void setManagementIp(final String managementIp) {
|
||||||
}
|
target.setManagementIp(managementIp);
|
||||||
|
}
|
||||||
public String getManagementIp()
|
|
||||||
{
|
public void setManagementPort(final int managementPort) {
|
||||||
return target.getManagementIp();
|
target.setManagementPort(managementPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getManagementPort()
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
return target.getManagementPort();
|
}
|
||||||
}
|
|
||||||
|
public void setPassword(final String password) {
|
||||||
public String getName()
|
target.setPassword(password);
|
||||||
{
|
}
|
||||||
return target.getName();
|
|
||||||
}
|
public void setType(final String type) {
|
||||||
|
target.setStorageTechnology(type);
|
||||||
public String getPassword()
|
}
|
||||||
{
|
|
||||||
return target.getPassword();
|
public void setUsername(final String username) {
|
||||||
}
|
target.setUsername(username);
|
||||||
|
}
|
||||||
public String getType()
|
|
||||||
{
|
@Override
|
||||||
return target.getStorageTechnology();
|
public String toString() {
|
||||||
}
|
return "StorageDevice [id=" + getId() + ", iscsiIp=" + getIscsiIp() + ", iscsiPort=" + getIscsiPort()
|
||||||
|
+ ", managementIp=" + getManagementIp() + ", managementPort=" + getManagementPort() + ", name=" + getName()
|
||||||
public String getUsername()
|
+ ", password=" + getPassword() + ", type=" + getType() + ", user=" + 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() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,37 +31,31 @@ import com.abiquo.server.core.infrastructure.storage.StorageDeviceMetadataDto;
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
*/
|
*/
|
||||||
public class StorageDeviceMetadata extends DomainWrapper<StorageDeviceMetadataDto>
|
public class StorageDeviceMetadata extends DomainWrapper<StorageDeviceMetadataDto> {
|
||||||
{
|
/**
|
||||||
/**
|
* Constructor to be used only by the builder.
|
||||||
* Constructor to be used only by the builder.
|
*/
|
||||||
*/
|
protected StorageDeviceMetadata(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
||||||
protected StorageDeviceMetadata(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
|
final StorageDeviceMetadataDto target) {
|
||||||
final StorageDeviceMetadataDto target)
|
super(context, target);
|
||||||
{
|
}
|
||||||
super(context, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public String getType()
|
public String getType() {
|
||||||
{
|
return target.getType();
|
||||||
return target.getType();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getDefaultManagementPort()
|
public int getDefaultManagementPort() {
|
||||||
{
|
return target.getDefaultManagementPort();
|
||||||
return target.getDefaultManagementPort();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getDefaultIscsiPort()
|
public int getDefaultIscsiPort() {
|
||||||
{
|
return target.getDefaultIscsiPort();
|
||||||
return target.getDefaultIscsiPort();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean requiresAuthentication()
|
public boolean requiresAuthentication() {
|
||||||
{
|
return target.isRequiresAuthentication();
|
||||||
return target.isRequiresAuthentication();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,336 +41,314 @@ import com.abiquo.server.core.infrastructure.storage.TierDto;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link StoragePoolDto}. The Storage Pool Resource allows you to
|
* Adds high level functionality to {@link StoragePoolDto}. The Storage Pool
|
||||||
* perform any administrative task for remote pools.
|
* Resource allows you to perform any administrative task for remote pools.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
* @see API: <a href="http://community.abiquo.com/display/ABI20/StoragePoolResource">
|
* @see API: <a
|
||||||
|
* href="http://community.abiquo.com/display/ABI20/StoragePoolResource">
|
||||||
* http://community.abiquo.com/display/ABI20/StoragePoolResource</a>
|
* http://community.abiquo.com/display/ABI20/StoragePoolResource</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class StoragePool extends DomainWrapper<StoragePoolDto>
|
public class StoragePool extends DomainWrapper<StoragePoolDto> {
|
||||||
{
|
/** The default value for the used space. */
|
||||||
/** The default value for the used space. */
|
private static final long DEFAULT_USED_SIZE = 0;
|
||||||
private static final long DEFAULT_USED_SIZE = 0;
|
|
||||||
|
|
||||||
/** The datacenter where the storage device is. */
|
/** The datacenter where the storage device is. */
|
||||||
// Package protected to allow the storage device to be set automatically when discovering the
|
// Package protected to allow the storage device to be set automatically when
|
||||||
// pools in a device.
|
// discovering the
|
||||||
StorageDevice storageDevice;
|
// pools in a device.
|
||||||
|
StorageDevice storageDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected StoragePool(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StoragePoolDto target)
|
protected StoragePool(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StoragePoolDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the storage pool.
|
* Delete the storage pool.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Deleteastoragepool"
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Deleteastoragepool"
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
* Deleteastoragepool</a>
|
* StoragePoolResource- Deleteastoragepool</a>
|
||||||
*/
|
*/
|
||||||
public void delete()
|
public void delete() {
|
||||||
{
|
context.getApi().getInfrastructureApi().deleteStoragePool(target);
|
||||||
context.getApi().getInfrastructureApi().deleteStoragePool(target);
|
target = null;
|
||||||
target = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a storage pool. Create a storage pool means registering an existing storage pool
|
* Create a storage pool. Create a storage pool means registering an existing
|
||||||
* obtained from {@link StorageDevice#listRemoteStoragePools} method and saving it. The Storage
|
* storage pool obtained from {@link StorageDevice#listRemoteStoragePools}
|
||||||
* Pools must be associated with a Tier using {@link #setTier}.
|
* 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"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Createastoragepoolwithatierlink"
|
||||||
* Createastoragepoolwithatierlink</a>
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
*/
|
* StoragePoolResource- Createastoragepoolwithatierlink</a>
|
||||||
public void save()
|
*/
|
||||||
{
|
public void save() {
|
||||||
target =
|
target = context.getApi().getInfrastructureApi().createStoragePool(storageDevice.unwrap(), target);
|
||||||
context.getApi().getInfrastructureApi()
|
}
|
||||||
.createStoragePool(storageDevice.unwrap(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update pool information in the server with the data from this pool. Storage pool parameters
|
* Update pool information in the server with the data from this pool.
|
||||||
* cannot be updated by a user, so the parameters are only a representation of the remote pool.
|
* Storage pool parameters cannot be updated by a user, so the parameters are
|
||||||
* Although the whole storage pool entity is sent to the API in the update call, the only thing
|
* only a representation of the remote pool. Although the whole storage pool
|
||||||
* a user can change is the tier that the pool belongs to by calling {@link #setTier}.
|
* 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"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/Storage+Pool+Resource#StoragePoolResource-
|
* "http://community.abiquo.com/display/ABI20/Storage+Pool+Resource#StoragePoolResource-UpdateaStoragePool"
|
||||||
* UpdateaStoragePool</a>
|
* > http://community.abiquo.com/display/ABI20/Storage+Pool+Resource#
|
||||||
*/
|
* StoragePoolResource- UpdateaStoragePool</a>
|
||||||
public void update()
|
*/
|
||||||
{
|
public void update() {
|
||||||
target = context.getApi().getInfrastructureApi().updateStoragePool(target);
|
target = context.getApi().getInfrastructureApi().updateStoragePool(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh()
|
public void refresh() {
|
||||||
{
|
target = context.getApi().getInfrastructureApi()
|
||||||
target =
|
.refreshStoragePool(target, StoragePoolOptions.builder().sync(true).build());
|
||||||
context.getApi().getInfrastructureApi()
|
}
|
||||||
.refreshStoragePool(target, StoragePoolOptions.builder().sync(true).build());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the tier in which the pool will be added.
|
* Define the tier in which the pool will be added.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Createastoragepoolwithatierlink"
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Createastoragepoolwithatierlink"
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
* Createastoragepoolwithatierlink</a>
|
* StoragePoolResource- Createastoragepoolwithatierlink</a>
|
||||||
*/
|
*/
|
||||||
public void setTier(final Tier tier)
|
public void setTier(final Tier tier) {
|
||||||
{
|
checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Privilege.class);
|
||||||
checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Privilege.class);
|
checkNotNull(tier.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Tier.class);
|
||||||
checkNotNull(tier.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Tier.class);
|
|
||||||
|
|
||||||
this.updateLink(target, ParentLinkName.TIER, tier.unwrap(), "edit");
|
this.updateLink(target, ParentLinkName.TIER, tier.unwrap(), "edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the device where the pool belongs.
|
* Get the device where the pool belongs.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrieveastoragedevice"
|
* "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrieveastoragedevice"
|
||||||
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-
|
* > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
|
||||||
* Retrieveastoragedevice</a>
|
* StorageDeviceResource- Retrieveastoragedevice</a>
|
||||||
*/
|
*/
|
||||||
public StorageDevice getStorageDevice()
|
public StorageDevice getStorageDevice() {
|
||||||
{
|
RESTLink link = checkNotNull(target.searchLink(ParentLinkName.STORAGE_DEVICE),
|
||||||
RESTLink link =
|
ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.STORAGE_DEVICE);
|
||||||
checkNotNull(target.searchLink(ParentLinkName.STORAGE_DEVICE),
|
|
||||||
ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.STORAGE_DEVICE);
|
|
||||||
|
|
||||||
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
||||||
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
||||||
|
|
||||||
ParseXMLWithJAXB<StorageDeviceDto> parser =
|
ParseXMLWithJAXB<StorageDeviceDto> parser = new ParseXMLWithJAXB<StorageDeviceDto>(utils.getXml(),
|
||||||
new ParseXMLWithJAXB<StorageDeviceDto>(utils.getXml(),
|
TypeLiteral.get(StorageDeviceDto.class));
|
||||||
TypeLiteral.get(StorageDeviceDto.class));
|
|
||||||
|
|
||||||
return wrap(context, StorageDevice.class, parser.apply(response));
|
return wrap(context, StorageDevice.class, parser.apply(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Children access
|
// Children access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the tier assigned to the pool. The storage pool needs to be persisted in Abiquo first.
|
* Get the tier assigned to the pool. The storage pool needs to be persisted
|
||||||
*
|
* in Abiquo first.
|
||||||
* @return The tier assinged to this storage pool.
|
*
|
||||||
*/
|
* @return The tier assinged to this storage pool.
|
||||||
public Tier getTier()
|
*/
|
||||||
{
|
public Tier getTier() {
|
||||||
RESTLink link =
|
RESTLink link = checkNotNull(target.searchLink(ParentLinkName.TIER), ValidationErrors.MISSING_REQUIRED_LINK + " "
|
||||||
checkNotNull(target.searchLink(ParentLinkName.TIER),
|
+ ParentLinkName.TIER);
|
||||||
ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.TIER);
|
|
||||||
|
|
||||||
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
ExtendedUtils utils = (ExtendedUtils) context.getUtils();
|
||||||
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
HttpResponse response = utils.getAbiquoHttpClient().get(link);
|
||||||
|
|
||||||
ParseXMLWithJAXB<TierDto> parser =
|
ParseXMLWithJAXB<TierDto> parser = new ParseXMLWithJAXB<TierDto>(utils.getXml(), TypeLiteral.get(TierDto.class));
|
||||||
new ParseXMLWithJAXB<TierDto>(utils.getXml(), TypeLiteral.get(TierDto.class));
|
|
||||||
|
|
||||||
return wrap(context, Tier.class, parser.apply(response));
|
return wrap(context, Tier.class, parser.apply(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
|
|
||||||
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StorageDevice storageDevice)
|
public static Builder builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StorageDevice storageDevice) {
|
||||||
{
|
return new Builder(context, storageDevice);
|
||||||
return new Builder(context, storageDevice);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder
|
public static class Builder {
|
||||||
{
|
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
|
||||||
|
|
||||||
private StorageDevice storageDevice;
|
private StorageDevice storageDevice;
|
||||||
|
|
||||||
private Long availableSizeInMb;
|
private Long availableSizeInMb;
|
||||||
|
|
||||||
// The enabled flag is still not used. It will be added when Abiquo includes anstorage
|
// The enabled flag is still not used. It will be added when Abiquo
|
||||||
// allocator
|
// includes anstorage
|
||||||
|
// allocator
|
||||||
|
|
||||||
// private Boolean enabled;
|
// private Boolean enabled;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Long totalSizeInMb;
|
private Long totalSizeInMb;
|
||||||
|
|
||||||
private Long usedSizeInMb = DEFAULT_USED_SIZE;
|
private Long usedSizeInMb = DEFAULT_USED_SIZE;
|
||||||
|
|
||||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StorageDevice storageDevice)
|
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StorageDevice storageDevice) {
|
||||||
{
|
super();
|
||||||
super();
|
checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class);
|
||||||
checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class);
|
this.storageDevice = storageDevice;
|
||||||
this.storageDevice = storageDevice;
|
this.context = context;
|
||||||
this.context = context;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder storageDevice(final StorageDevice storageDevice)
|
public Builder storageDevice(final StorageDevice storageDevice) {
|
||||||
{
|
checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class);
|
||||||
checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class);
|
this.storageDevice = storageDevice;
|
||||||
this.storageDevice = storageDevice;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This value is no longer used in Abiquo and will be removed in future
|
* @deprecated This value is no longer used in Abiquo and will be removed
|
||||||
* versions.
|
* in future versions.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Builder availableSizeInMb(final long availableSizeInMb)
|
public Builder availableSizeInMb(final long availableSizeInMb) {
|
||||||
{
|
this.availableSizeInMb = availableSizeInMb;
|
||||||
this.availableSizeInMb = availableSizeInMb;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder name(final String name)
|
public Builder name(final String name) {
|
||||||
{
|
this.name = name;
|
||||||
this.name = name;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// The enabled flag is still not used. It will be added when Abiquo includes anstorage
|
// The enabled flag is still not used. It will be added when Abiquo
|
||||||
// allocator
|
// includes anstorage
|
||||||
|
// allocator
|
||||||
|
|
||||||
// public Builder enabled(final boolean enabled)
|
// public Builder enabled(final boolean enabled)
|
||||||
// {
|
// {
|
||||||
// this.enabled = enabled;
|
// this.enabled = enabled;
|
||||||
// return this;
|
// return this;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public Builder totalSizeInMb(final long totalSizeInMb)
|
public Builder totalSizeInMb(final long totalSizeInMb) {
|
||||||
{
|
this.totalSizeInMb = totalSizeInMb;
|
||||||
this.totalSizeInMb = totalSizeInMb;
|
if (availableSizeInMb == null) {
|
||||||
if (availableSizeInMb == null)
|
availableSizeInMb = totalSizeInMb;
|
||||||
{
|
}
|
||||||
availableSizeInMb = totalSizeInMb;
|
return this;
|
||||||
}
|
}
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This value is no longer used in Abiquo and will be removed in future
|
* @deprecated This value is no longer used in Abiquo and will be removed
|
||||||
* versions.
|
* in future versions.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Builder usedSizeInMb(final long usedSizeInMb)
|
public Builder usedSizeInMb(final long usedSizeInMb) {
|
||||||
{
|
this.usedSizeInMb = usedSizeInMb;
|
||||||
this.usedSizeInMb = usedSizeInMb;
|
return this;
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public StoragePool build()
|
public StoragePool build() {
|
||||||
{
|
StoragePoolDto dto = new StoragePoolDto();
|
||||||
StoragePoolDto dto = new StoragePoolDto();
|
dto.setAvailableSizeInMb(availableSizeInMb);
|
||||||
dto.setAvailableSizeInMb(availableSizeInMb);
|
|
||||||
|
|
||||||
// The enabled flag is still not used. It will be added when Abiquo includes anstorage
|
// The enabled flag is still not used. It will be added when Abiquo
|
||||||
// allocator
|
// includes anstorage
|
||||||
// dto.setEnabled(enabled);
|
// allocator
|
||||||
|
// dto.setEnabled(enabled);
|
||||||
|
|
||||||
dto.setName(name);
|
dto.setName(name);
|
||||||
dto.setTotalSizeInMb(totalSizeInMb);
|
dto.setTotalSizeInMb(totalSizeInMb);
|
||||||
dto.setUsedSizeInMb(usedSizeInMb);
|
dto.setUsedSizeInMb(usedSizeInMb);
|
||||||
StoragePool storagePool = new StoragePool(context, dto);
|
StoragePool storagePool = new StoragePool(context, dto);
|
||||||
storagePool.storageDevice = storageDevice;
|
storagePool.storageDevice = storageDevice;
|
||||||
return storagePool;
|
return storagePool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromStoragePool(final StoragePool in)
|
public static Builder fromStoragePool(final StoragePool in) {
|
||||||
{
|
Builder builder = StoragePool.builder(in.context, in.getStorageDevice())
|
||||||
Builder builder =
|
.availableSizeInMb(in.getAvailableSizeInMb())/*
|
||||||
StoragePool.builder(in.context, in.getStorageDevice())
|
* .enabled(in.
|
||||||
.availableSizeInMb(in.getAvailableSizeInMb())/* .enabled(in.getEnabled()) */
|
* getEnabled())
|
||||||
.totalSizeInMb(in.getTotalSizeInMb()).usedSizeInMb(in.getUsedSizeInMb());
|
*/
|
||||||
|
.totalSizeInMb(in.getTotalSizeInMb()).usedSizeInMb(in.getUsedSizeInMb());
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This value is no longer used in Abiquo and will be removed in future versions.
|
* @deprecated This value is no longer used in Abiquo and will be removed in
|
||||||
*/
|
* future versions.
|
||||||
@Deprecated
|
*/
|
||||||
public long getAvailableSizeInMb()
|
@Deprecated
|
||||||
{
|
public long getAvailableSizeInMb() {
|
||||||
return target.getAvailableSizeInMb();
|
return target.getAvailableSizeInMb();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The enabled flag is still not used. It will be added when Abiquo includes anstorage
|
// The enabled flag is still not used. It will be added when Abiquo includes
|
||||||
// allocator
|
// anstorage
|
||||||
|
// allocator
|
||||||
|
|
||||||
// public boolean getEnabled()
|
// public boolean getEnabled()
|
||||||
// {
|
// {
|
||||||
// return target.getEnabled();
|
// return target.getEnabled();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalSizeInMb()
|
public long getTotalSizeInMb() {
|
||||||
{
|
return target.getTotalSizeInMb();
|
||||||
return target.getTotalSizeInMb();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This value is no longer used in Abiquo and will be removed in future versions.
|
* @deprecated This value is no longer used in Abiquo and will be removed in
|
||||||
*/
|
* future versions.
|
||||||
@Deprecated
|
*/
|
||||||
public long getUsedSizeInMb()
|
@Deprecated
|
||||||
{
|
public long getUsedSizeInMb() {
|
||||||
return target.getUsedSizeInMb();
|
return target.getUsedSizeInMb();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The enabled flag is still not used. It will be added when Abiquo includes anstorage
|
// The enabled flag is still not used. It will be added when Abiquo includes
|
||||||
// allocator
|
// anstorage
|
||||||
|
// allocator
|
||||||
|
|
||||||
// public void setEnabled(final boolean enabled)
|
// public void setEnabled(final boolean enabled)
|
||||||
// {
|
// {
|
||||||
// target.setEnabled(enabled);
|
// target.setEnabled(enabled);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalSizeInMb(final long totalSizeInMb)
|
public void setTotalSizeInMb(final long totalSizeInMb) {
|
||||||
{
|
target.setTotalSizeInMb(totalSizeInMb);
|
||||||
target.setTotalSizeInMb(totalSizeInMb);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Readonly property
|
// Readonly property
|
||||||
public String getUUID()
|
public String getUUID() {
|
||||||
{
|
return target.getIdStorage();
|
||||||
return target.getIdStorage();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "StoragePool [name=" + getName() + ", totalSizeInMb=" + getTotalSizeInMb() + ", uuid=" + getUUID() + "]";
|
||||||
return "StoragePool [name=" + getName() + ", totalSizeInMb=" + getTotalSizeInMb()
|
}
|
||||||
+ ", uuid=" + getUUID() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds high level functionality to {@link TierDto}. The Tier Resource offers the functionality of
|
* Adds high level functionality to {@link TierDto}. The Tier Resource offers
|
||||||
* managing the logic of QoS volume management. These are only logical levels of QoS and the real
|
* the functionality of managing the logic of QoS volume management. These are
|
||||||
* QoS (networking speed, volume replication, availability) must be configured manually in the
|
* only logical levels of QoS and the real QoS (networking speed, volume
|
||||||
* infrastructure.
|
* replication, availability) must be configured manually in the infrastructure.
|
||||||
*
|
*
|
||||||
* @author Ignasi Barrera
|
* @author Ignasi Barrera
|
||||||
* @author Francesc Montserrat
|
* @author Francesc Montserrat
|
||||||
|
@ -49,139 +49,129 @@ import com.google.common.collect.Lists;
|
||||||
* http://community.abiquo.com/display/ABI20/TierResource</a>
|
* http://community.abiquo.com/display/ABI20/TierResource</a>
|
||||||
*/
|
*/
|
||||||
@EnterpriseEdition
|
@EnterpriseEdition
|
||||||
public class Tier extends DomainWrapper<TierDto>
|
public class Tier extends DomainWrapper<TierDto> {
|
||||||
{
|
/** The datacenter where the tier belongs. */
|
||||||
/** The datacenter where the tier belongs. */
|
private Datacenter datacenter;
|
||||||
private Datacenter datacenter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to be used only by the builder.
|
* Constructor to be used only by the builder.
|
||||||
*/
|
*/
|
||||||
protected Tier(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final TierDto target)
|
protected Tier(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final TierDto target) {
|
||||||
{
|
super(context, target);
|
||||||
super(context, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Domain operations
|
// Domain operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update tier information in the server with the data from this tier.
|
* Update tier information in the server with the data from this tier.
|
||||||
*
|
*
|
||||||
* @see API: <a
|
* @see API: <a href=
|
||||||
* href="http://community.abiquo.com/display/ABI20/TierResource#TierResource-Updateatier">
|
* "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Updateatier"
|
||||||
* http://community.abiquo.com/display/ABI20/TierResource#TierResource-Updateatier</a>
|
* >
|
||||||
*/
|
* http://community.abiquo.com/display/ABI20/TierResource#TierResource-
|
||||||
public void update()
|
* Updateatier</a>
|
||||||
{
|
*/
|
||||||
target = context.getApi().getInfrastructureApi().updateTier(target);
|
public void update() {
|
||||||
}
|
target = context.getApi().getInfrastructureApi().updateTier(target);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of storage pools in this tier.
|
* Retrieve the list of storage pools in this tier.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
* Retrievestoragepools</a>
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
* @return List of storage pools in this tier.
|
* @return List of storage pools in this tier.
|
||||||
*/
|
*/
|
||||||
public List<StoragePool> listStoragePools()
|
public List<StoragePool> listStoragePools() {
|
||||||
{
|
StoragePoolsDto storagePools = context.getApi().getInfrastructureApi().listStoragePools(target);
|
||||||
StoragePoolsDto storagePools =
|
return wrap(context, StoragePool.class, storagePools.getCollection());
|
||||||
context.getApi().getInfrastructureApi().listStoragePools(target);
|
}
|
||||||
return wrap(context, StoragePool.class, storagePools.getCollection());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a filtered list of storage pools in this tier.
|
* Retrieve a filtered list of storage pools in this tier.
|
||||||
*
|
*
|
||||||
* @param filter Filter to be applied to the list.
|
* @param filter
|
||||||
* @see API: <a href=
|
* Filter to be applied to the list.
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
* @see API: <a href=
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
* Retrievestoragepools</a>
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
* @return Filtered list of storage pools in this tier.
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
*/
|
* @return Filtered list of storage pools in this tier.
|
||||||
public List<StoragePool> listStoragePools(final Predicate<StoragePool> filter)
|
*/
|
||||||
{
|
public List<StoragePool> listStoragePools(final Predicate<StoragePool> filter) {
|
||||||
return Lists.newLinkedList(filter(listStoragePools(), filter));
|
return Lists.newLinkedList(filter(listStoragePools(), filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the first storage pool matching the filter within the list of pools in this tier.
|
* Retrieve the first storage pool matching the filter within the list of
|
||||||
*
|
* pools in this tier.
|
||||||
* @param filter Filter to be applied to the list.
|
*
|
||||||
* @see API: <a href=
|
* @param filter
|
||||||
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
* Filter to be applied to the list.
|
||||||
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-
|
* @see API: <a href=
|
||||||
* Retrievestoragepools</a>
|
* "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
|
||||||
* @return First storage pool matching the filter or <code>null</code> if there is none.
|
* > http://community.abiquo.com/display/ABI20/StoragePoolResource#
|
||||||
*/
|
* StoragePoolResource- Retrievestoragepools</a>
|
||||||
public StoragePool findStoragePool(final Predicate<StoragePool> filter)
|
* @return First storage pool matching the filter or <code>null</code> if
|
||||||
{
|
* there is none.
|
||||||
return Iterables.getFirst(filter(listStoragePools(), filter), null);
|
*/
|
||||||
}
|
public StoragePool findStoragePool(final Predicate<StoragePool> filter) {
|
||||||
|
return Iterables.getFirst(filter(listStoragePools(), filter), null);
|
||||||
|
}
|
||||||
|
|
||||||
// Parent access
|
// Parent access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the datacenter where this tier is.
|
* Retrieve the datacenter where this tier is.
|
||||||
*
|
*
|
||||||
* @see API: <a href=
|
* @see API: <a href=
|
||||||
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
* "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
|
||||||
* > http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-
|
* > http://community.abiquo.com/display/ABI20/DatacenterResource#
|
||||||
* Retrieveadatacenter</a>
|
* DatacenterResource- Retrieveadatacenter</a>
|
||||||
*/
|
*/
|
||||||
public Datacenter getDatacenter()
|
public Datacenter getDatacenter() {
|
||||||
{
|
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
||||||
Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
|
DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
|
||||||
DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
|
datacenter = wrap(context, Datacenter.class, dto);
|
||||||
datacenter = wrap(context, Datacenter.class, dto);
|
return datacenter;
|
||||||
return datacenter;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate methods
|
// Delegate methods
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
return target.getDescription();
|
||||||
return target.getDescription();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getEnabled()
|
public boolean getEnabled() {
|
||||||
{
|
return target.getEnabled();
|
||||||
return target.getEnabled();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId()
|
public Integer getId() {
|
||||||
{
|
return target.getId();
|
||||||
return target.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
return target.getName();
|
||||||
return target.getName();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(final String description)
|
public void setDescription(final String description) {
|
||||||
{
|
target.setDescription(description);
|
||||||
target.setDescription(description);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(final boolean enabled)
|
public void setEnabled(final boolean enabled) {
|
||||||
{
|
target.setEnabled(enabled);
|
||||||
target.setEnabled(enabled);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name)
|
public void setName(final String name) {
|
||||||
{
|
target.setName(name);
|
||||||
target.setName(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "Tier [id=" + getId() + ", description=" + getDescription() + ", enabled=" + getEnabled() + ", name="
|
||||||
return "Tier [id=" + getId() + ", description=" + getDescription() + ", enabled="
|
+ getName() + "]";
|
||||||
+ getEnabled() + ", name=" + getName() + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue