From 5ba08d8448d22adf72eb0b3cf465ab806ae3fcf2 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Wed, 31 Oct 2012 18:46:16 +0100 Subject: [PATCH 1/2] Cleanup unnecessary strategies Removed all over engineering introduced by strategies that did not perform anything else than a simple api call. --- .../services/AdministrationService.java | 25 ++- .../features/services/PricingService.java | 37 ++++- .../internal/BaseAdministrationService.java | 153 ++++++++---------- .../abiquo/internal/BaseEventService.java | 17 +- .../abiquo/internal/BasePricingService.java | 66 ++++---- .../abiquo/strategy/admin/ListRoles.java | 36 ----- .../admin/internal/ListRolesImpl.java | 67 -------- .../strategy/config/ListCategories.java | 35 ---- .../abiquo/strategy/config/ListCostCodes.java | 36 ----- .../strategy/config/ListCurrencies.java | 36 ----- .../abiquo/strategy/config/ListLicenses.java | 37 ----- .../strategy/config/ListPricingTemplates.java | 36 ----- .../strategy/config/ListPrivileges.java | 35 ---- .../strategy/config/ListProperties.java | 37 ----- .../config/internal/ListCategoriesImpl.java | 67 -------- .../config/internal/ListCostCodesImpl.java | 67 -------- .../config/internal/ListCurrenciesImpl.java | 67 -------- .../config/internal/ListLicensesImpl.java | 74 --------- .../internal/ListPricingTemplatesImpl.java | 67 -------- .../config/internal/ListPrivilegesImpl.java | 67 -------- .../config/internal/ListPropertiesImpl.java | 73 --------- .../strategy/enterprise/ListEnterprises.java | 36 ----- .../internal/ListEnterprisesImpl.java | 67 -------- .../abiquo/strategy/event/ListEvents.java | 37 ----- .../event/internal/ListEventsImpl.java | 65 -------- .../infrastructure/ListDatacenters.java | 38 ----- .../internal/ListDatacentersImpl.java | 106 ------------ .../internal/ListMachinesImpl.java | 13 +- .../BaseAdministrationServiceTest.java | 5 - .../abiquo/internal/BaseEventServiceTest.java | 1 - .../internal/ListRolesImplLiveApiTest.java | 65 -------- .../ListCategoriesImplLiveApiTest.java | 78 --------- .../internal/ListLicensesImplLiveApiTest.java | 82 ---------- .../ListPrivilegesImplLiveApiTest.java | 77 --------- .../ListPropertiesImplLiveApiTest.java | 89 ---------- .../ListEnterprisesImplLiveApiTest.java | 65 -------- .../ListDatacentersImplLiveApiTest.java | 65 -------- 37 files changed, 173 insertions(+), 1851 deletions(-) delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java delete mode 100644 labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java delete mode 100644 labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java delete mode 100644 labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java delete mode 100644 labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java delete mode 100644 labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java delete mode 100644 labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java delete mode 100644 labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java index a6648d171e..b73e35e9f2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java @@ -19,8 +19,6 @@ package org.jclouds.abiquo.features.services; -import java.util.List; - import org.jclouds.abiquo.domain.config.Category; import org.jclouds.abiquo.domain.config.License; import org.jclouds.abiquo.domain.config.Privilege; @@ -67,11 +65,6 @@ public interface AdministrationService { */ Datacenter getDatacenter(final Integer datacenterId); - /** - * Get the list of datacenters with the given ids. - */ - Iterable getDatacenters(final List datacenterIds); - /*********************** Machine ***********************/ /** @@ -160,6 +153,15 @@ public interface AdministrationService { */ Privilege findPrivilege(final Predicate filter); + /** + * Get a privilege given its id. + * + * @param privilegeId + * The id of the privilege. + * @return The privilege. + */ + Privilege getPrivilege(Integer privilegeId); + /*********************** User ***********************/ /** @@ -245,4 +247,13 @@ public interface AdministrationService { * null if none is found. */ Category findCategory(final Predicate filter); + + /** + * Get the category identified by the given id. + * + * @param categoryId + * The id of the category. + * @return The requested category. + */ + Category getCategory(Integer categoryId); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java index dd26afdb3e..dc55123306 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java @@ -59,6 +59,15 @@ public interface PricingService { */ Currency findCurrency(final Predicate filter); + /** + * Get the currency with the given id. + * + * @param currencyId + * The id of the currency to get. + * @return The currency with the gicen id. + */ + Currency getCurrency(final Integer currencyId); + /*********************** CostCode ***********************/ /** @@ -77,37 +86,55 @@ public interface PricingService { */ CostCode findCostCode(final Predicate filter); + /** + * Get a cost code given its id. + * + * @param costCodeId + * The id of the cost code. + * @return The cost code. + */ + CostCode getCostCode(Integer costCodeId); + /*********************** PricingTemplate ***********************/ /** * Get the list of pricingtemplates. */ - public Iterable listPricingTemplates(); + Iterable listPricingTemplates(); /** * Get the list of pricingtemplates matching the given filter. */ - public Iterable listPricingTemplates(final Predicate filter); + Iterable listPricingTemplates(final Predicate filter); /** * Get the first pricingtemplates that matches the given filter or * null if none is found. */ - public PricingTemplate findPricingTemplate(final Predicate filter); + PricingTemplate findPricingTemplate(final Predicate filter); + + /** + * Get a pricing template given its id. + * + * @param pricingTemplateId + * The id of the pricing template. + * @return The pricing template. + */ + PricingTemplate getPricingTemplate(Integer pricingTemplateId); /*********************** CostCodeCurrency ***********************/ /** * Get a cost code currency */ - public Iterable getCostCodeCurrencies(Integer costcodeid, Integer currencyid); + Iterable getCostCodeCurrencies(Integer costcodeid, Integer currencyid); /*********************** PricingCostCode ***********************/ /** * Get pricing cost codes */ - public Collection getPricingCostCodes(Integer pricingTemplateId); + Collection getPricingCostCodes(Integer pricingTemplateId); /** * Get a pricing cost code diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java index 25aacb8f2a..458a091fe2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java @@ -20,15 +20,15 @@ package org.jclouds.abiquo.internal; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.getFirst; import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import java.util.List; - import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.domain.config.Category; import org.jclouds.abiquo.domain.config.License; import org.jclouds.abiquo.domain.config.Privilege; @@ -43,21 +43,23 @@ import org.jclouds.abiquo.domain.infrastructure.Datacenter; import org.jclouds.abiquo.domain.infrastructure.Machine; import org.jclouds.abiquo.features.services.AdministrationService; import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.strategy.admin.ListRoles; -import org.jclouds.abiquo.strategy.config.ListCategories; -import org.jclouds.abiquo.strategy.config.ListLicenses; -import org.jclouds.abiquo.strategy.config.ListPrivileges; -import org.jclouds.abiquo.strategy.config.ListProperties; -import org.jclouds.abiquo.strategy.enterprise.ListEnterprises; -import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters; import org.jclouds.abiquo.strategy.infrastructure.ListMachines; import org.jclouds.collect.Memoized; import org.jclouds.rest.RestContext; +import com.abiquo.server.core.appslibrary.CategoriesDto; +import com.abiquo.server.core.appslibrary.CategoryDto; +import com.abiquo.server.core.config.LicensesDto; +import com.abiquo.server.core.config.SystemPropertiesDto; import com.abiquo.server.core.enterprise.EnterpriseDto; import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; +import com.abiquo.server.core.enterprise.EnterprisesDto; +import com.abiquo.server.core.enterprise.PrivilegeDto; +import com.abiquo.server.core.enterprise.PrivilegesDto; import com.abiquo.server.core.enterprise.RoleDto; +import com.abiquo.server.core.enterprise.RolesDto; import com.abiquo.server.core.infrastructure.DatacenterDto; +import com.abiquo.server.core.infrastructure.DatacentersDto; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Predicate; import com.google.common.base.Supplier; @@ -74,30 +76,9 @@ public class BaseAdministrationService implements AdministrationService { @VisibleForTesting protected RestContext context; - @VisibleForTesting - protected final ListDatacenters listDatacenters; - @VisibleForTesting protected final ListMachines listMachines; - @VisibleForTesting - protected final ListEnterprises listEnterprises; - - @VisibleForTesting - protected final ListRoles listRoles; - - @VisibleForTesting - protected final ListLicenses listLicenses; - - @VisibleForTesting - protected final ListPrivileges listPrivileges; - - @VisibleForTesting - protected final ListProperties listProperties; - - @VisibleForTesting - protected final ListCategories listCategories; - @VisibleForTesting protected final Supplier currentUser; @@ -106,19 +87,10 @@ public class BaseAdministrationService implements AdministrationService { @Inject protected BaseAdministrationService(final RestContext context, - final ListDatacenters listDatacenters, final ListMachines listMachines, final ListEnterprises listEnterprises, - final ListRoles listRoles, final ListLicenses listLicenses, final ListPrivileges listPrivileges, - final ListProperties listProperties, final ListCategories listCategories, - @Memoized final Supplier currentUser, @Memoized final Supplier currentEnterprise) { + final ListMachines listMachines, @Memoized final Supplier currentUser, + @Memoized final Supplier currentEnterprise) { this.context = checkNotNull(context, "context"); - this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); this.listMachines = checkNotNull(listMachines, "listMachines"); - this.listEnterprises = checkNotNull(listEnterprises, "listEnterprises"); - this.listRoles = checkNotNull(listRoles, "listRoles"); - this.listLicenses = checkNotNull(listLicenses, "listLicenses"); - this.listPrivileges = checkNotNull(listPrivileges, "listPrivileges"); - this.listProperties = checkNotNull(listProperties, "listProperties"); - this.listCategories = checkNotNull(listCategories, "listCategories"); this.currentUser = checkNotNull(currentUser, "currentUser"); this.currentEnterprise = checkNotNull(currentEnterprise, "currentEnterprise"); } @@ -127,12 +99,18 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listDatacenters() { - return listDatacenters.execute(); + DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); + return wrap(context, Datacenter.class, result.getCollection()); } @Override public Iterable listDatacenters(final Predicate filter) { - return listDatacenters.execute(filter); + return filter(listDatacenters(), filter); + } + + @Override + public Datacenter findDatacenter(final Predicate filter) { + return getFirst(listDatacenters(filter), null); } @Override @@ -141,16 +119,6 @@ public class BaseAdministrationService implements AdministrationService { return wrap(context, Datacenter.class, datacenter); } - @Override - public Datacenter findDatacenter(final Predicate filter) { - return Iterables.getFirst(listDatacenters(filter), null); - } - - @Override - public Iterable getDatacenters(final List datacenterIds) { - return listDatacenters.execute(datacenterIds); - } - /*********************** Machine ***********************/ @Override @@ -172,12 +140,13 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listEnterprises() { - return listEnterprises.execute(); + EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises(); + return wrap(context, Enterprise.class, result.getCollection()); } @Override public Iterable listEnterprises(final Predicate filter) { - return listEnterprises.execute(filter); + return filter(listEnterprises(), filter); } @Override @@ -206,17 +175,18 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listRoles() { - return listRoles.execute(); + RolesDto result = context.getApi().getAdminApi().listRoles(); + return wrap(context, Role.class, result.getCollection()); } @Override public Iterable listRoles(final Predicate filter) { - return listRoles.execute(filter); + return filter(listRoles(), filter); } @Override public Role findRole(final Predicate filter) { - return Iterables.getFirst(listRoles(filter), null); + return getFirst(listRoles(filter), null); } @Override @@ -227,19 +197,26 @@ public class BaseAdministrationService implements AdministrationService { /*********************** Privilege ***********************/ - @Override - public Privilege findPrivilege(final Predicate filter) { - return Iterables.getFirst(listPrivileges(filter), null); - } - @Override public Iterable listPrivileges() { - return listPrivileges.execute(); + PrivilegesDto result = context.getApi().getConfigApi().listPrivileges(); + return wrap(context, Privilege.class, result.getCollection()); } @Override public Iterable listPrivileges(final Predicate filter) { - return listPrivileges.execute(filter); + return filter(listPrivileges(), filter); + } + + @Override + public Privilege findPrivilege(final Predicate filter) { + return getFirst(listPrivileges(filter), null); + } + + @Override + public Privilege getPrivilege(Integer privilegeId) { + PrivilegeDto result = context.getApi().getConfigApi().getPrivilege(privilegeId); + return wrap(context, Privilege.class, result); } /*********************** User ***********************/ @@ -258,52 +235,68 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listLicenses() { - return listLicenses.execute(); + LicensesDto result = context.getApi().getConfigApi().listLicenses(); + return wrap(context, License.class, result.getCollection()); } @Override public Iterable listLicenses(final boolean active) { LicenseOptions options = LicenseOptions.builder().active(active).build(); - return listLicenses.execute(options); + LicensesDto result = context.getApi().getConfigApi().listLicenses(options); + return wrap(context, License.class, result.getCollection()); } @Override public Iterable listLicenses(final Predicate filter) { - return listLicenses.execute(filter); + return filter(listLicenses(), filter); } @Override public License findLicense(final Predicate filter) { - return Iterables.getFirst(listLicenses(filter), null); + return getFirst(listLicenses(filter), null); } /*********************** System Properties ***********************/ @Override public Iterable listSystemProperties() { - return listProperties.execute(); + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(); + return wrap(context, SystemProperty.class, result.getCollection()); } @Override public Iterable listSystemProperties(final Predicate filter) { - return listProperties.execute(filter); + return filter(listSystemProperties(), filter); } @Override public SystemProperty findSystemProperty(final Predicate filter) { - return Iterables.getFirst(listSystemProperties(filter), null); + return getFirst(listSystemProperties(filter), null); } @Override public SystemProperty getSystemProperty(final String name) { PropertyOptions options = PropertyOptions.builder().name(name).build(); - return Iterables.getFirst(listProperties.execute(options), null); + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); + return getFirst(wrap(context, SystemProperty.class, result.getCollection()), null); } @Override public Iterable listSystemProperties(final String component) { PropertyOptions options = PropertyOptions.builder().component(component).build(); - return listProperties.execute(options); + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); + return wrap(context, SystemProperty.class, result.getCollection()); + } + + @Override + public Iterable listCategories() { + CategoriesDto result = context.getApi().getConfigApi().listCategories(); + return wrap(context, Category.class, result.getCollection()); + } + + @Override + public Iterable listCategories(final Predicate filter) { + return filter(listCategories(), filter); } @Override @@ -312,12 +305,8 @@ public class BaseAdministrationService implements AdministrationService { } @Override - public Iterable listCategories() { - return listCategories.execute(); - } - - @Override - public Iterable listCategories(final Predicate filter) { - return listCategories.execute(filter); + public Category getCategory(Integer categoryId) { + CategoryDto result = context.getApi().getConfigApi().getCategory(categoryId); + return wrap(context, Category.class, result); } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java index 960065d16a..e3c5c994bc 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java @@ -20,18 +20,19 @@ package org.jclouds.abiquo.internal; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.abiquo.domain.DomainWrapper.wrap; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.domain.event.Event; import org.jclouds.abiquo.domain.event.options.EventOptions; import org.jclouds.abiquo.features.services.EventService; -import org.jclouds.abiquo.strategy.event.ListEvents; import org.jclouds.rest.RestContext; +import com.abiquo.server.core.event.EventsDto; import com.google.common.annotations.VisibleForTesting; /** @@ -45,22 +46,20 @@ public class BaseEventService implements EventService { @VisibleForTesting protected RestContext context; - @VisibleForTesting - protected final ListEvents listEvents; - @Inject - protected BaseEventService(final RestContext context, final ListEvents listEvents) { + protected BaseEventService(final RestContext context) { this.context = checkNotNull(context, "context"); - this.listEvents = checkNotNull(listEvents, "listEvents"); } @Override public Iterable listEvents() { - return listEvents.execute(); + EventsDto result = context.getApi().getEventApi().listEvents(); + return wrap(context, Event.class, result.getCollection()); } @Override public Iterable listEvents(final EventOptions options) { - return listEvents.execute(options); + EventsDto result = context.getApi().getEventApi().listEvents(options); + return wrap(context, Event.class, result.getCollection()); } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java index 1fc2c9aebc..27083cfefa 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java @@ -20,6 +20,8 @@ package org.jclouds.abiquo.internal; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.getFirst; import static org.jclouds.abiquo.domain.DomainWrapper.wrap; import java.util.Collection; @@ -36,14 +38,17 @@ import org.jclouds.abiquo.domain.config.PricingCostCode; import org.jclouds.abiquo.domain.config.PricingTemplate; import org.jclouds.abiquo.domain.config.PricingTier; import org.jclouds.abiquo.features.services.PricingService; -import org.jclouds.abiquo.strategy.config.ListCostCodes; -import org.jclouds.abiquo.strategy.config.ListCurrencies; -import org.jclouds.abiquo.strategy.config.ListPricingTemplates; import org.jclouds.rest.RestContext; import com.abiquo.server.core.pricing.CostCodeCurrenciesDto; +import com.abiquo.server.core.pricing.CostCodeDto; +import com.abiquo.server.core.pricing.CostCodesDto; +import com.abiquo.server.core.pricing.CurrenciesDto; +import com.abiquo.server.core.pricing.CurrencyDto; import com.abiquo.server.core.pricing.PricingCostCodeDto; import com.abiquo.server.core.pricing.PricingCostCodesDto; +import com.abiquo.server.core.pricing.PricingTemplateDto; +import com.abiquo.server.core.pricing.PricingTemplatesDto; import com.abiquo.server.core.pricing.PricingTierDto; import com.abiquo.server.core.pricing.PricingTiersDto; import com.google.common.annotations.VisibleForTesting; @@ -51,7 +56,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; /** - * Provides high level Abiquo administration operations. + * Provides access to Abiquo pricing features. * * @author Ignasi Barrera * @author Susana Acedo @@ -61,52 +66,46 @@ public class BasePricingService implements PricingService { @VisibleForTesting protected RestContext context; - @VisibleForTesting - protected final ListCurrencies listCurrencies; - - @VisibleForTesting - protected final ListCostCodes listCostCodes; - - @VisibleForTesting - protected final ListPricingTemplates listPricingTemplates; - @Inject - protected BasePricingService(final RestContext context, - final ListCurrencies listCurrencies, final ListCostCodes listCostCodes, - final ListPricingTemplates listPricingTemplates) { + protected BasePricingService(final RestContext context) { this.context = checkNotNull(context, "context"); - this.listCurrencies = checkNotNull(listCurrencies, "listCurrencies"); - this.listCostCodes = checkNotNull(listCostCodes, "listCostCodes"); - this.listPricingTemplates = checkNotNull(listPricingTemplates, "listPricingTemplates"); } /*********************** Currency ********************** */ @Override public Iterable listCurrencies() { - return listCurrencies.execute(); + CurrenciesDto result = context.getApi().getPricingApi().listCurrencies(); + return wrap(context, Currency.class, result.getCollection()); } @Override public Iterable listCurrencies(final Predicate filter) { - return listCurrencies.execute(filter); + return filter(listCurrencies(), filter); } @Override public Currency findCurrency(final Predicate filter) { - return Iterables.getFirst(listCurrencies(filter), null); + return getFirst(listCurrencies(filter), null); + } + + @Override + public Currency getCurrency(final Integer currencyId) { + CurrencyDto result = context.getApi().getPricingApi().getCurrency(currencyId); + return wrap(context, Currency.class, result); } /*********************** CostCode ********************** */ @Override public Iterable listCostCodes() { - return listCostCodes.execute(); + CostCodesDto result = context.getApi().getPricingApi().listCostCodes(); + return wrap(context, CostCode.class, result.getCollection()); } @Override public Iterable listCostCodes(final Predicate filter) { - return listCostCodes.execute(filter); + return filter(listCostCodes(), filter); } @Override @@ -114,21 +113,34 @@ public class BasePricingService implements PricingService { return Iterables.getFirst(listCostCodes(filter), null); } + @Override + public CostCode getCostCode(Integer costCodeId) { + CostCodeDto result = context.getApi().getPricingApi().getCostCode(costCodeId); + return wrap(context, CostCode.class, result); + } + /*********************** PricingTemplate ********************** */ @Override public Iterable listPricingTemplates() { - return listPricingTemplates.execute(); + PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates(); + return wrap(context, PricingTemplate.class, result.getCollection()); } @Override public Iterable listPricingTemplates(final Predicate filter) { - return listPricingTemplates.execute(filter); + return filter(listPricingTemplates(), filter); } @Override public PricingTemplate findPricingTemplate(final Predicate filter) { - return Iterables.getFirst(listPricingTemplates(filter), null); + return getFirst(listPricingTemplates(filter), null); + } + + @Override + public PricingTemplate getPricingTemplate(Integer pricingTemplateId) { + PricingTemplateDto result = context.getApi().getPricingApi().getPricingTemplate(pricingTemplateId); + return wrap(context, PricingTemplate.class, result); } /*********************** CostCodeCurrency ********************** */ diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java deleted file mode 100644 index 3ff98c1c7a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.admin; - -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.admin.internal.ListRolesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List roles. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListRolesImpl.class) -public interface ListRoles extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java deleted file mode 100644 index 0e6d5f0bf4..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.admin.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.strategy.admin.ListRoles; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.RolesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List enterprises. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListRolesImpl implements ListRoles { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListRolesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - RolesDto result = context.getApi().getAdminApi().listRoles(); - return wrap(context, Role.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java deleted file mode 100644 index 61314cdbba..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListCategoriesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List privileges. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListCategoriesImpl.class) -public interface ListCategories extends ListRootEntities { -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java deleted file mode 100644 index 8a4ff4aa8a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config; - -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListCostCodesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List cost codes - * - * @author Susana Acedo - */ -@ImplementedBy(ListCostCodesImpl.class) -public interface ListCostCodes extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java deleted file mode 100644 index 2b4ce779ab..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config; - -import org.jclouds.abiquo.domain.config.Currency; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListCurrenciesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List currencies - * - * @author Susana Acedo - */ -@ImplementedBy(ListCurrenciesImpl.class) -public interface ListCurrencies extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java deleted file mode 100644 index 027e2e788c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config; - -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListLicensesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List licenses. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListLicensesImpl.class) -public interface ListLicenses extends ListRootEntities { - public Iterable execute(LicenseOptions options); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java deleted file mode 100644 index 87c0eb4f36..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config; - -import org.jclouds.abiquo.domain.config.PricingTemplate; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListPricingTemplatesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List pricing templates - * - * @author Susana Acedo - */ -@ImplementedBy(ListPricingTemplatesImpl.class) -public interface ListPricingTemplates extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java deleted file mode 100644 index 874d860c98..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config; - -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListPrivilegesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List privileges. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListPrivilegesImpl.class) -public interface ListPrivileges extends ListRootEntities { -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java deleted file mode 100644 index fa54a9deb9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config; - -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListPropertiesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List system properties. - * - * @author Francesc Montserrat - */ -@ImplementedBy(ListPropertiesImpl.class) -public interface ListProperties extends ListRootEntities { - public Iterable execute(PropertyOptions options); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java deleted file mode 100644 index 8fc5ed3bed..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.strategy.config.ListCategories; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.appslibrary.CategoriesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List categories. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListCategoriesImpl implements ListCategories { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListCategoriesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - CategoriesDto result = context.getApi().getConfigApi().listCategories(); - return wrap(context, Category.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java deleted file mode 100644 index 2187ce1838..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.strategy.config.ListCostCodes; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.CostCodesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List cost codes - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Singleton -public class ListCostCodesImpl implements ListCostCodes { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListCostCodesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - CostCodesDto result = context.getApi().getPricingApi().listCostCodes(); - return wrap(context, CostCode.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java deleted file mode 100644 index 9ac1380f57..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.Currency; -import org.jclouds.abiquo.strategy.config.ListCurrencies; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.CurrenciesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List currencies - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Singleton -public class ListCurrenciesImpl implements ListCurrencies { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListCurrenciesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - CurrenciesDto result = context.getApi().getPricingApi().listCurrencies(); - return wrap(context, Currency.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java deleted file mode 100644 index ab28472b06..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.strategy.config.ListLicenses; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.config.LicensesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List licenses. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListLicensesImpl implements ListLicenses { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListLicensesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - LicensesDto result = context.getApi().getConfigApi().listLicenses(); - return wrap(context, License.class, result.getCollection()); - } - - @Override - public Iterable execute(final LicenseOptions options) { - LicensesDto result = context.getApi().getConfigApi().listLicenses(options); - return wrap(context, License.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java deleted file mode 100644 index 8d9ac4045e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.PricingTemplate; -import org.jclouds.abiquo.strategy.config.ListPricingTemplates; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.PricingTemplatesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List pricing templates - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Singleton -public class ListPricingTemplatesImpl implements ListPricingTemplates { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListPricingTemplatesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates(); - return wrap(context, PricingTemplate.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java deleted file mode 100644 index 6a16511abf..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.strategy.config.ListPrivileges; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List licenses. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListPrivilegesImpl implements ListPrivileges { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListPrivilegesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - PrivilegesDto result = context.getApi().getConfigApi().listPrivileges(); - return wrap(context, Privilege.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java deleted file mode 100644 index 07eaab416b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.strategy.config.ListProperties; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.config.SystemPropertiesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List properties. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListPropertiesImpl implements ListProperties { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListPropertiesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(); - return wrap(context, SystemProperty.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - @Override - public Iterable execute(final PropertyOptions options) { - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); - return wrap(context, SystemProperty.class, result.getCollection()); - } -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java deleted file mode 100644 index 1e0ba94eb6..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.enterprise; - -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.enterprise.internal.ListEnterprisesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List enterprises. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListEnterprisesImpl.class) -public interface ListEnterprises extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java deleted file mode 100644 index ee401b4e0e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.enterprise.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.strategy.enterprise.ListEnterprises; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.EnterprisesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List enterprises. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListEnterprisesImpl implements ListEnterprises { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListEnterprisesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises(); - return wrap(context, Enterprise.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java deleted file mode 100644 index 083991599d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.event; - -import org.jclouds.abiquo.domain.event.Event; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.event.internal.ListEventsImpl; - -import com.google.inject.ImplementedBy; - -/** - * List events. - * - * @author Vivien Mahé - */ -@ImplementedBy(ListEventsImpl.class) -public interface ListEvents extends ListRootEntities { - Iterable execute(EventOptions options); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java deleted file mode 100644 index ed1da35236..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.event.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.event.Event; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.strategy.event.ListEvents; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.event.EventsDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -public class ListEventsImpl implements ListEvents { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListEventsImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - EventsDto result = context.getApi().getEventApi().listEvents(); - return wrap(context, Event.class, result.getCollection()); - } - - @Override - public Iterable execute(final EventOptions options) { - EventsDto result = context.getApi().getEventApi().listEvents(options); - return wrap(context, Event.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java deleted file mode 100644 index 99a67bfaaa..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.infrastructure; - -import java.util.List; - -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.infrastructure.internal.ListDatacentersImpl; - -import com.google.inject.ImplementedBy; - -/** - * List datacenters. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListDatacentersImpl.class) -public interface ListDatacenters extends ListRootEntities { - Iterable execute(List datacenterIds); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java deleted file mode 100644 index fad587620f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.infrastructure.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Lists; -import com.google.inject.Inject; - -/** - * List datacenters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListDatacentersImpl implements ListDatacenters { - - protected final RestContext context; - - protected final ExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListDatacentersImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { - this.context = context; - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); - return wrap(context, Datacenter.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - @Override - public Iterable execute(final List datacenterIds) { - // Find virtual datacenters in concurrent requests - return listConcurrentDatacenters(datacenterIds); - } - - private Iterable listConcurrentDatacenters(final List ids) { - Iterable dcs = transformParallel(ids, new Function>() { - @Override - public Future apply(final Integer input) { - return context.getAsyncApi().getInfrastructureApi().getDatacenter(input); - } - }, userExecutor, maxTime, logger, "getting datacenters"); - - return DomainWrapper.wrap(context, Datacenter.class, Lists.newArrayList(dcs)); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java index 326d5febb4..c14f79f5f9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java @@ -32,16 +32,16 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.domain.DomainWrapper; import org.jclouds.abiquo.domain.infrastructure.Datacenter; import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters; import org.jclouds.abiquo.strategy.infrastructure.ListMachines; import org.jclouds.logging.Logger; import org.jclouds.rest.RestContext; +import com.abiquo.server.core.infrastructure.DatacentersDto; import com.abiquo.server.core.infrastructure.MachineDto; import com.abiquo.server.core.infrastructure.MachinesDto; import com.abiquo.server.core.infrastructure.RackDto; @@ -59,8 +59,6 @@ import com.google.inject.Inject; public class ListMachinesImpl implements ListMachines { protected RestContext context; - protected ListDatacenters listDatacenters; - protected final ExecutorService userExecutor; @Resource @@ -72,18 +70,17 @@ public class ListMachinesImpl implements ListMachines { @Inject ListMachinesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, - final ListDatacenters listDatacenters) { + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { super(); this.context = checkNotNull(context, "context"); - this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); this.userExecutor = checkNotNull(userExecutor, "userExecutor"); } @Override public Iterable execute() { // Find machines in concurrent requests - Iterable datacenters = listDatacenters.execute(); + DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); + Iterable datacenters = wrap(context, Datacenter.class, result.getCollection()); Iterable racks = listConcurrentRacks(datacenters); Iterable machines = listConcurrentMachines(racks); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java index 4a2b2122bc..05e5f47744 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java @@ -36,12 +36,7 @@ public class BaseAdministrationServiceTest extends BaseInjectionTest { BaseAdministrationService service = (BaseAdministrationService) injector.getInstance(AdministrationService.class); assertNotNull(service.context); - assertNotNull(service.listDatacenters); assertNotNull(service.listMachines); - assertNotNull(service.listEnterprises); - assertNotNull(service.listLicenses); - assertNotNull(service.listPrivileges); - assertNotNull(service.listRoles); assertNotNull(service.currentUser); assertNotNull(service.currentEnterprise); } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java index 137c88194b..ea3cb9489c 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java @@ -35,6 +35,5 @@ public class BaseEventServiceTest extends BaseInjectionTest { BaseEventService service = (BaseEventService) injector.getInstance(EventService.class); assertNotNull(service.context); - assertNotNull(service.listEvents); } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java deleted file mode 100644 index 5e6aabbb1e..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.admin.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.predicates.enterprise.RolePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListRolesImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListRolesImplLiveApiTest") -public class ListRolesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListRolesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListRolesImpl.class); - } - - public void testExecute() { - Iterable roles = strategy.execute(); - assertNotNull(roles); - assertTrue(size(roles) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable roles = strategy.execute(RolePredicates.name("UNEXISTING")); - assertNotNull(roles); - assertEquals(size(roles), 0); - } - - public void testExecutePredicateWithResults() { - Iterable roles = strategy.execute(RolePredicates.name(env.role.getName())); - assertNotNull(roles); - assertEquals(size(roles), 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java deleted file mode 100644 index de62bb849f..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.predicates.config.CategoryPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; - -/** - * Live tests for the {@link ListPropertiesImpl} strategy. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "ListCategoriesImplLiveApiTest") -public class ListCategoriesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListCategoriesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListCategoriesImpl.class); - } - - public void testExecute() { - Iterable categories = strategy.execute(); - assertNotNull(categories); - assertTrue(size(categories) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable categories = strategy.execute(CategoryPredicates.name("Unexisting category")); - assertNotNull(categories); - assertEquals(size(categories), 0); - } - - public void testExecutePredicateWithResults() { - Iterable categories = strategy.execute(CategoryPredicates.name("Applications servers")); - assertNotNull(categories); - assertEquals(size(categories), 1); - } - - public void testExecuteNotPredicateWithResults() { - Iterable categories = strategy.execute(Predicates.not(CategoryPredicates.name("Applications servers"))); - - Iterable allProperties = strategy.execute(); - - assertNotNull(categories); - assertNotNull(allProperties); - assertEquals(size(categories), size(allProperties) - 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java deleted file mode 100644 index d9776c52f8..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.predicates.config.LicensePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListLicenseImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListLicensesImplLiveApiTest") -public class ListLicensesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListLicensesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListLicensesImpl.class); - } - - public void testExecute() { - Iterable licenses = strategy.execute(); - assertNotNull(licenses); - assertTrue(size(licenses) > 0); - } - - public void testExecuteInactive() { - LicenseOptions options = LicenseOptions.builder().inactive(true).build(); - - Iterable licenses = strategy.execute(options); - assertNotNull(licenses); - assertTrue(size(licenses) == 1); - } - - public void testExecuteActive() { - LicenseOptions options = LicenseOptions.builder().active(true).build(); - - Iterable licenses = strategy.execute(options); - assertNotNull(licenses); - assertTrue(size(licenses) >= 1); - } - - public void testExecutePredicateWithoutResults() { - Iterable licenses = strategy.execute(LicensePredicates.customer("FAIL")); - assertNotNull(licenses); - assertEquals(size(licenses), 0); - } - - public void testExecutePredicateWithResults() { - Iterable licenses = strategy.execute(LicensePredicates.code(env.license.getCode())); - assertNotNull(licenses); - assertEquals(size(licenses), 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java deleted file mode 100644 index eea2ebc953..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.predicates.config.PrivilegePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; - -/** - * Live tests for the {@link ListPrivilegesImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListPrivilegesImplLiveApiTest") -public class ListPrivilegesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListPrivilegesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListPrivilegesImpl.class); - } - - public void testExecute() { - Iterable privileges = strategy.execute(); - assertNotNull(privileges); - assertTrue(size(privileges) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable privileges = strategy.execute(PrivilegePredicates.name("Destroy the universe")); - assertNotNull(privileges); - assertEquals(size(privileges), 0); - } - - public void testExecutePredicateWithResults() { - Iterable privileges = strategy.execute(PrivilegePredicates.name("USERS_MANAGE_USERS")); - assertNotNull(privileges); - assertEquals(size(privileges), 1); - } - - public void testExecuteNotPredicateWithResults() { - Iterable privileges = strategy.execute(Predicates.not(PrivilegePredicates.name("USERS_MANAGE_USERS"))); - - Iterable allPrivileges = strategy.execute(); - - assertNotNull(privileges); - assertNotNull(allPrivileges); - assertEquals(size(privileges), size(allPrivileges) - 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java deleted file mode 100644 index 28e747e5e3..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.predicates.config.SystemPropertyPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; - -/** - * Live tests for the {@link ListPropertiesImpl} strategy. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "ListPropertiesImplLiveApiTest") -public class ListPropertiesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListPropertiesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListPropertiesImpl.class); - } - - public void testExecute() { - Iterable properties = strategy.execute(); - assertNotNull(properties); - assertTrue(size(properties) > 0); - } - - public void testExecuteWithOptions() { - PropertyOptions options = PropertyOptions.builder().component("client").build(); - - Iterable properties = strategy.execute(options); - assertNotNull(properties); - assertTrue(size(properties) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable properties = strategy.execute(SystemPropertyPredicates.name("Cloud color")); - assertNotNull(properties); - assertEquals(size(properties), 0); - } - - public void testExecutePredicateWithResults() { - Iterable properties = strategy.execute(SystemPropertyPredicates - .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval")); - assertNotNull(properties); - assertEquals(size(properties), 1); - } - - public void testExecuteNotPredicateWithResults() { - Iterable properties = strategy.execute(Predicates.not(SystemPropertyPredicates - .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval"))); - - Iterable allProperties = strategy.execute(); - - assertNotNull(properties); - assertNotNull(allProperties); - assertEquals(size(properties), size(allProperties) - 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java deleted file mode 100644 index 13f1167e2d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.enterprise.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.predicates.enterprise.EnterprisePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListEnterprisesImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListEnterprisesImplLiveApiTest") -public class ListEnterprisesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListEnterprisesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListEnterprisesImpl.class); - } - - public void testExecute() { - Iterable enterprises = strategy.execute(); - assertNotNull(enterprises); - assertTrue(size(enterprises) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable enterprises = strategy.execute(EnterprisePredicates.name("UNEXISTING")); - assertNotNull(enterprises); - assertEquals(size(enterprises), 0); - } - - public void testExecutePredicateWithResults() { - Iterable enterprises = strategy.execute(EnterprisePredicates.name(env.enterprise.getName())); - assertNotNull(enterprises); - assertEquals(size(enterprises), 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java deleted file mode 100644 index 391c46c857..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.infrastructure.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.predicates.infrastructure.DatacenterPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListDatacentersImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListDatacentersImplLiveApiTest") -public class ListDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListDatacentersImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListDatacentersImpl.class); - } - - public void testExecute() { - Iterable datacenters = strategy.execute(); - assertNotNull(datacenters); - assertTrue(size(datacenters) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable datacenters = strategy.execute(DatacenterPredicates.name("UNEXISTING")); - assertNotNull(datacenters); - assertEquals(size(datacenters), 0); - } - - public void testExecutePredicateWithResults() { - Iterable datacenters = strategy.execute(DatacenterPredicates.name(env.datacenter.getName())); - assertNotNull(datacenters); - assertEquals(size(datacenters), 1); - } -} From f39c1add8981a81e0e9766a77707ba23323ab13a Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Wed, 31 Oct 2012 19:00:32 +0100 Subject: [PATCH 2/2] Removed all unnecessary interfaces from strategies Removed all interfaces from the strategy classes that only have one implementation. --- .../strategy/cloud/ListAttachedNics.java | 91 ++++++++++++-- .../strategy/cloud/ListVirtualAppliances.java | 80 +++++++++++- .../cloud/ListVirtualDatacenters.java | 88 +++++++++++-- .../strategy/cloud/ListVirtualMachines.java | 84 ++++++++++++- .../cloud/internal/ListAttachedNicsImpl.java | 116 ----------------- .../internal/ListVirtualAppliancesImpl.java | 106 ---------------- .../internal/ListVirtualDatacentersImpl.java | 119 ------------------ .../internal/ListVirtualMachinesImpl.java | 114 ----------------- .../ListVirtualMachineTemplates.java | 76 ++++++++++- .../ListVirtualMachineTemplatesImpl.java | 106 ---------------- .../strategy/infrastructure/ListMachines.java | 88 ++++++++++++- .../internal/ListMachinesImpl.java | 117 ----------------- ....java => ListAttachedNicsLiveApiTest.java} | 13 +- ... => ListVirtualAppliancesLiveApiTest.java} | 13 +- ...=> ListVirtualDatacentersLiveApiTest.java} | 13 +- ...va => ListVirtualMachinesLiveApiTest.java} | 13 +- ...stVirtualMachineTemplatesLiveApiTest.java} | 15 +-- ...Test.java => ListMachinesLiveApiTest.java} | 13 +- 18 files changed, 515 insertions(+), 750 deletions(-) delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java delete mode 100644 labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java rename labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/{internal/ListAttachedNicsImplLiveApiTest.java => ListAttachedNicsLiveApiTest.java} (90%) rename labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/{internal/ListVirtualAppliancesImplLiveApiTest.java => ListVirtualAppliancesLiveApiTest.java} (83%) rename labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/{internal/ListVirtualDatacentersImplLiveApiTest.java => ListVirtualDatacentersLiveApiTest.java} (87%) rename labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/{internal/ListVirtualMachinesImplLiveApiTest.java => ListVirtualMachinesLiveApiTest.java} (88%) rename labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/{internal/ListVirtualMachineTemplatesImplLiveApiTest.java => ListVirtualMachineTemplatesLiveApiTest.java} (82%) rename labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/{internal/ListMachinesImplLiveApiTest.java => ListMachinesLiveApiTest.java} (84%) diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java index 81e7aa4d95..51abbb10d1 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java @@ -19,19 +19,96 @@ package org.jclouds.abiquo.strategy.cloud; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.strategy.ListEntities; -import org.jclouds.abiquo.strategy.cloud.internal.ListAttachedNicsImpl; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.transform; +import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import com.google.inject.ImplementedBy; +import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; +import org.jclouds.abiquo.domain.cloud.VirtualMachine; +import org.jclouds.abiquo.domain.network.ExternalIp; +import org.jclouds.abiquo.domain.network.Ip; +import org.jclouds.abiquo.domain.network.PrivateIp; +import org.jclouds.abiquo.domain.network.PublicIp; +import org.jclouds.abiquo.domain.network.UnmanagedIp; +import org.jclouds.abiquo.domain.util.LinkUtils; +import org.jclouds.abiquo.rest.internal.ExtendedUtils; +import org.jclouds.abiquo.strategy.ListEntities; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.functions.ParseXMLWithJAXB; +import org.jclouds.rest.RestContext; + +import com.abiquo.model.rest.RESTLink; +import com.abiquo.server.core.infrastructure.network.ExternalIpDto; +import com.abiquo.server.core.infrastructure.network.PrivateIpDto; +import com.abiquo.server.core.infrastructure.network.PublicIpDto; +import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.TypeLiteral; /** * List all NICs attached to a given virtual machine. * * @author Ignasi Barrera */ -@ImplementedBy(ListAttachedNicsImpl.class) -public interface ListAttachedNics extends ListEntities, VirtualMachine> { +@Singleton +public class ListAttachedNics implements ListEntities, VirtualMachine> { + protected final RestContext context; + protected final ExtendedUtils extendedUtils; + + @Inject + public ListAttachedNics(final RestContext context, final ExtendedUtils extendedUtils) { + this.context = checkNotNull(context, "context"); + this.extendedUtils = checkNotNull(extendedUtils, "extendedUtils"); + } + + @Override + public Iterable> execute(final VirtualMachine parent) { + parent.refresh(); + Iterable nicLinks = LinkUtils.filterNicLinks(parent.unwrap().getLinks()); + return listIps(nicLinks); + } + + @Override + public Iterable> execute(final VirtualMachine parent, final Predicate> selector) { + return filter(execute(parent), selector); + } + + private Iterable> listIps(final Iterable nicLinks) { + return transform(nicLinks, new Function>() { + @Override + public Ip apply(final RESTLink input) { + HttpResponse response = extendedUtils.getAbiquoHttpClient().get(input); + + if (input.getType().equals(PrivateIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(PrivateIpDto.class)); + + return wrap(context, PrivateIp.class, parser.apply(response)); + } else if (input.getType().equals(PublicIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(PublicIpDto.class)); + + return wrap(context, PublicIp.class, parser.apply(response)); + } else if (input.getType().equals(ExternalIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(ExternalIpDto.class)); + + return wrap(context, ExternalIp.class, parser.apply(response)); + } else if (input.getType().equals(UnmanagedIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(UnmanagedIpDto.class)); + + return wrap(context, UnmanagedIp.class, parser.apply(response)); + } else { + throw new IllegalArgumentException("Unsupported media type: " + input.getType()); + } + } + }); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java index 7d286175df..b571060311 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java @@ -19,18 +19,86 @@ package org.jclouds.abiquo.strategy.cloud; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualAppliancesImpl; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static org.jclouds.abiquo.domain.DomainWrapper.wrap; +import static org.jclouds.concurrent.FutureIterables.transformParallel; -import com.google.inject.ImplementedBy; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import javax.annotation.Resource; +import javax.inject.Named; + +import org.jclouds.Constants; +import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; +import org.jclouds.abiquo.domain.DomainWrapper; +import org.jclouds.abiquo.domain.cloud.VirtualAppliance; +import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; +import org.jclouds.abiquo.strategy.ListRootEntities; +import org.jclouds.logging.Logger; +import org.jclouds.rest.RestContext; + +import com.abiquo.server.core.cloud.VirtualApplianceDto; +import com.abiquo.server.core.cloud.VirtualAppliancesDto; +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * List virtual appliances in each virtual datacenter. * * @author Ignasi Barrera */ -@ImplementedBy(ListVirtualAppliancesImpl.class) -public interface ListVirtualAppliances extends ListRootEntities { +@Singleton +public class ListVirtualAppliances implements ListRootEntities { + protected final RestContext context; + protected final ListVirtualDatacenters listVirtualDatacenters; + + protected final ExecutorService userExecutor; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; + + @Inject + ListVirtualAppliances(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, + final ListVirtualDatacenters listVirtualDatacenters) { + this.context = checkNotNull(context, "context"); + this.listVirtualDatacenters = checkNotNull(listVirtualDatacenters, "listVirtualDatacenters"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } + + @Override + public Iterable execute() { + // Find virtual appliances in concurrent requests + Iterable vdcs = listVirtualDatacenters.execute(); + Iterable vapps = listConcurrentVirtualAppliances(vdcs); + + return wrap(context, VirtualAppliance.class, vapps); + } + + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } + + private Iterable listConcurrentVirtualAppliances(final Iterable vdcs) { + Iterable vapps = transformParallel(vdcs, + new Function>() { + @Override + public Future apply(final VirtualDatacenter input) { + return context.getAsyncApi().getCloudApi().listVirtualAppliances(input.unwrap()); + } + }, userExecutor, maxTime, logger, "getting virtual appliances"); + + return DomainWrapper.join(vapps); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java index 88596af86b..da280ae70c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java @@ -19,28 +19,98 @@ package org.jclouds.abiquo.strategy.cloud; -import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static org.jclouds.abiquo.domain.DomainWrapper.wrap; +import static org.jclouds.concurrent.FutureIterables.transformParallel; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import javax.annotation.Resource; +import javax.inject.Named; + +import org.jclouds.Constants; +import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; +import org.jclouds.abiquo.domain.DomainWrapper; import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualDatacentersImpl; +import org.jclouds.logging.Logger; +import org.jclouds.rest.RestContext; +import com.abiquo.server.core.cloud.VirtualDatacenterDto; +import com.abiquo.server.core.cloud.VirtualDatacentersDto; +import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.inject.ImplementedBy; +import com.google.common.collect.Lists; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * List virtual datacenters. * * @author Ignasi Barrera */ -@ImplementedBy(ListVirtualDatacentersImpl.class) -public interface ListVirtualDatacenters extends ListRootEntities { - Iterable execute(VirtualDatacenterOptions virtualDatacenterOptions); +@Singleton +public class ListVirtualDatacenters implements ListRootEntities { + protected final RestContext context; - Iterable execute(List virtualDatacenterIds); + protected final ExecutorService userExecutor; - Iterable execute(Predicate selector, - VirtualDatacenterOptions virtualDatacenterOptions); + @Resource + protected Logger logger = Logger.NULL; + + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; + + @Inject + ListVirtualDatacenters(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { + this.context = checkNotNull(context, "context"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } + + @Override + public Iterable execute() { + VirtualDatacenterOptions virtualDatacenterOptions = VirtualDatacenterOptions.builder().build(); + + return execute(virtualDatacenterOptions); + } + + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } + + public Iterable execute(final VirtualDatacenterOptions virtualDatacenterOptions) { + VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions); + return wrap(context, VirtualDatacenter.class, result.getCollection()); + } + + public Iterable execute(final Predicate selector, + final VirtualDatacenterOptions virtualDatacenterOptions) { + return filter(execute(virtualDatacenterOptions), selector); + } + + public Iterable execute(final List virtualDatacenterIds) { + // Find virtual datacenters in concurrent requests + return listConcurrentVirtualDatacenters(virtualDatacenterIds); + } + + private Iterable listConcurrentVirtualDatacenters(final List ids) { + Iterable vdcs = transformParallel(ids, + new Function>() { + @Override + public Future apply(final Integer input) { + return context.getAsyncApi().getCloudApi().getVirtualDatacenter(input); + } + }, userExecutor, maxTime, logger, "getting virtual datacenters"); + + return DomainWrapper.wrap(context, VirtualDatacenter.class, Lists.newArrayList(vdcs)); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java index 9cdea47224..245560252d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java @@ -19,19 +19,93 @@ package org.jclouds.abiquo.strategy.cloud; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static org.jclouds.abiquo.domain.DomainWrapper.wrap; +import static org.jclouds.concurrent.FutureIterables.transformParallel; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import javax.annotation.Resource; +import javax.inject.Named; + +import org.jclouds.Constants; +import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; +import org.jclouds.abiquo.domain.DomainWrapper; +import org.jclouds.abiquo.domain.cloud.VirtualAppliance; import org.jclouds.abiquo.domain.cloud.VirtualMachine; import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualMachinesImpl; +import org.jclouds.logging.Logger; +import org.jclouds.rest.RestContext; -import com.google.inject.ImplementedBy; +import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; +import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * List virtual machines in each virtual datacenter and each virtual appliance. * * @author Ignasi Barrera */ -@ImplementedBy(ListVirtualMachinesImpl.class) -public interface ListVirtualMachines extends ListRootEntities { - Iterable execute(VirtualMachineOptions options); +@Singleton +public class ListVirtualMachines implements ListRootEntities { + protected final RestContext context; + + protected final ExecutorService userExecutor; + + protected final ListVirtualAppliances listVirtualAppliances; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; + + @Inject + ListVirtualMachines(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, + final ListVirtualAppliances listVirtualAppliances) { + super(); + this.context = checkNotNull(context, "context"); + this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } + + @Override + public Iterable execute() { + return execute(VirtualMachineOptions.builder().disablePagination().build()); + } + + public Iterable execute(final VirtualMachineOptions options) { + // Find virtual machines in concurrent requests + Iterable vapps = listVirtualAppliances.execute(); + Iterable vms = listConcurrentVirtualMachines(vapps, options); + + return wrap(context, VirtualMachine.class, vms); + } + + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } + + private Iterable listConcurrentVirtualMachines( + final Iterable vapps, final VirtualMachineOptions options) { + Iterable vms = transformParallel(vapps, + new Function>() { + @Override + public Future apply(final VirtualAppliance input) { + return context.getAsyncApi().getCloudApi().listVirtualMachines(input.unwrap(), options); + } + }, userExecutor, maxTime, logger, "getting virtual machines"); + + return DomainWrapper.join(vms); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java deleted file mode 100644 index b577339fd8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.network.ExternalIp; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.domain.network.UnmanagedIp; -import org.jclouds.abiquo.domain.util.LinkUtils; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.abiquo.strategy.cloud.ListAttachedNics; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.inject.Inject; -import com.google.inject.TypeLiteral; - -/** - * List all NICs attached to a given virtual machine. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListAttachedNicsImpl implements ListAttachedNics { - protected final RestContext context; - - protected final ExtendedUtils extendedUtils; - - @Inject - public ListAttachedNicsImpl(final RestContext context, final ExtendedUtils extendedUtils) { - this.context = checkNotNull(context, "context"); - this.extendedUtils = checkNotNull(extendedUtils, "extendedUtils"); - } - - @Override - public Iterable> execute(final VirtualMachine parent) { - parent.refresh(); - Iterable nicLinks = LinkUtils.filterNicLinks(parent.unwrap().getLinks()); - return listIps(nicLinks); - } - - @Override - public Iterable> execute(final VirtualMachine parent, final Predicate> selector) { - return filter(execute(parent), selector); - } - - private Iterable> listIps(final Iterable nicLinks) { - return transform(nicLinks, new Function>() { - @Override - public Ip apply(final RESTLink input) { - HttpResponse response = extendedUtils.getAbiquoHttpClient().get(input); - - if (input.getType().equals(PrivateIpDto.BASE_MEDIA_TYPE)) { - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), - TypeLiteral.get(PrivateIpDto.class)); - - return wrap(context, PrivateIp.class, parser.apply(response)); - } else if (input.getType().equals(PublicIpDto.BASE_MEDIA_TYPE)) { - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), - TypeLiteral.get(PublicIpDto.class)); - - return wrap(context, PublicIp.class, parser.apply(response)); - } else if (input.getType().equals(ExternalIpDto.BASE_MEDIA_TYPE)) { - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), - TypeLiteral.get(ExternalIpDto.class)); - - return wrap(context, ExternalIp.class, parser.apply(response)); - } else if (input.getType().equals(UnmanagedIpDto.BASE_MEDIA_TYPE)) { - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), - TypeLiteral.get(UnmanagedIpDto.class)); - - return wrap(context, UnmanagedIp.class, parser.apply(response)); - } else { - throw new IllegalArgumentException("Unsupported media type: " + input.getType()); - } - } - }); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java deleted file mode 100644 index 1d6025ed7f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances; -import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List virtual appliance in each virtual datacenter. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListVirtualAppliancesImpl implements ListVirtualAppliances { - protected final RestContext context; - - protected final ListVirtualDatacenters listVirtualDatacenters; - - protected final ExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualAppliancesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, - final ListVirtualDatacenters listVirtualDatacenters) { - this.context = checkNotNull(context, "context"); - this.listVirtualDatacenters = checkNotNull(listVirtualDatacenters, "listVirtualDatacenters"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - // Find virtual appliances in concurrent requests - Iterable vdcs = listVirtualDatacenters.execute(); - Iterable vapps = listConcurrentVirtualAppliances(vdcs); - - return wrap(context, VirtualAppliance.class, vapps); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - private Iterable listConcurrentVirtualAppliances(final Iterable vdcs) { - Iterable vapps = transformParallel(vdcs, - new Function>() { - @Override - public Future apply(final VirtualDatacenter input) { - return context.getAsyncApi().getCloudApi().listVirtualAppliances(input.unwrap()); - } - }, userExecutor, maxTime, logger, "getting virtual appliances"); - - return DomainWrapper.join(vapps); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java deleted file mode 100644 index 50f775c337..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Lists; -import com.google.inject.Inject; - -/** - * List virtual datacenters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListVirtualDatacentersImpl implements ListVirtualDatacenters { - protected final RestContext context; - - protected final ExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualDatacentersImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { - this.context = checkNotNull(context, "context"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - VirtualDatacenterOptions virtualDatacenterOptions = VirtualDatacenterOptions.builder().build(); - - return execute(virtualDatacenterOptions); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - @Override - public Iterable execute(final VirtualDatacenterOptions virtualDatacenterOptions) { - VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions); - return wrap(context, VirtualDatacenter.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector, - final VirtualDatacenterOptions virtualDatacenterOptions) { - return filter(execute(virtualDatacenterOptions), selector); - } - - @Override - public Iterable execute(final List virtualDatacenterIds) { - // Find virtual datacenters in concurrent requests - return listConcurrentVirtualDatacenters(virtualDatacenterIds); - } - - private Iterable listConcurrentVirtualDatacenters(final List ids) { - Iterable vdcs = transformParallel(ids, - new Function>() { - @Override - public Future apply(final Integer input) { - return context.getAsyncApi().getCloudApi().getVirtualDatacenter(input); - } - }, userExecutor, maxTime, logger, "getting virtual datacenters"); - - return DomainWrapper.wrap(context, VirtualDatacenter.class, Lists.newArrayList(vdcs)); - } -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java deleted file mode 100644 index d094fb9545..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances; -import org.jclouds.abiquo.strategy.cloud.ListVirtualMachines; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List virtual machines in each virtual datacenter and each virtual appliance. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListVirtualMachinesImpl implements ListVirtualMachines { - protected final RestContext context; - - protected final ExecutorService userExecutor; - - protected final ListVirtualAppliances listVirtualAppliances; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualMachinesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, - final ListVirtualAppliances listVirtualAppliances) { - super(); - this.context = checkNotNull(context, "context"); - this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - return execute(VirtualMachineOptions.builder().disablePagination().build()); - } - - @Override - public Iterable execute(final VirtualMachineOptions options) { - // Find virtual machines in concurrent requests - Iterable vapps = listVirtualAppliances.execute(); - Iterable vms = listConcurrentVirtualMachines(vapps, options); - - return wrap(context, VirtualMachine.class, vms); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - private Iterable listConcurrentVirtualMachines( - final Iterable vapps, final VirtualMachineOptions options) { - Iterable vms = transformParallel(vapps, - new Function>() { - @Override - public Future apply(final VirtualAppliance input) { - return context.getAsyncApi().getCloudApi().listVirtualMachines(input.unwrap(), options); - } - }, userExecutor, maxTime, logger, "getting virtual machines"); - - return DomainWrapper.join(vms); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java index 29136bf778..0d646f6d79 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java @@ -19,19 +19,87 @@ package org.jclouds.abiquo.strategy.enterprise; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static org.jclouds.abiquo.domain.DomainWrapper.wrap; +import static org.jclouds.concurrent.FutureIterables.transformParallel; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import javax.annotation.Resource; +import javax.inject.Named; + +import org.jclouds.Constants; +import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; +import org.jclouds.abiquo.domain.DomainWrapper; import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; import org.jclouds.abiquo.domain.enterprise.Enterprise; +import org.jclouds.abiquo.domain.infrastructure.Datacenter; import org.jclouds.abiquo.strategy.ListEntities; -import org.jclouds.abiquo.strategy.enterprise.internal.ListVirtualMachineTemplatesImpl; +import org.jclouds.logging.Logger; +import org.jclouds.rest.RestContext; -import com.google.inject.ImplementedBy; +import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; +import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * List all virtual machine templates available to an enterprise. * * @author Ignasi Barrera */ -@ImplementedBy(ListVirtualMachineTemplatesImpl.class) -public interface ListVirtualMachineTemplates extends ListEntities { +@Singleton +public class ListVirtualMachineTemplates implements ListEntities { + protected final RestContext context; + protected final ExecutorService userExecutor; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; + + @Inject + ListVirtualMachineTemplates(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { + super(); + this.context = checkNotNull(context, "context"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } + + @Override + public Iterable execute(final Enterprise parent) { + // Find virtual machine templates in concurrent requests + Iterable dcs = parent.listAllowedDatacenters(); + Iterable templates = listConcurrentTemplates(parent, dcs); + + return wrap(context, VirtualMachineTemplate.class, templates); + } + + @Override + public Iterable execute(final Enterprise parent, + final Predicate selector) { + return filter(execute(parent), selector); + } + + private Iterable listConcurrentTemplates(final Enterprise parent, + final Iterable dcs) { + Iterable templates = transformParallel(dcs, + new Function>() { + @Override + public Future apply(final Datacenter input) { + return context.getAsyncApi().getVirtualMachineTemplateApi() + .listVirtualMachineTemplates(parent.getId(), input.getId()); + } + }, userExecutor, maxTime, logger, "getting virtual machine templates"); + + return DomainWrapper.join(templates); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java deleted file mode 100644 index 29209ad5c5..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.enterprise.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List all virtual machine templates available to an enterprise. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListVirtualMachineTemplatesImpl implements ListVirtualMachineTemplates { - protected final RestContext context; - - protected final ExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualMachineTemplatesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { - super(); - this.context = checkNotNull(context, "context"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute(final Enterprise parent) { - // Find virtual machine templates in concurrent requests - Iterable dcs = parent.listAllowedDatacenters(); - Iterable templates = listConcurrentTemplates(parent, dcs); - - return wrap(context, VirtualMachineTemplate.class, templates); - } - - @Override - public Iterable execute(final Enterprise parent, - final Predicate selector) { - return filter(execute(parent), selector); - } - - private Iterable listConcurrentTemplates(final Enterprise parent, - final Iterable dcs) { - Iterable templates = transformParallel(dcs, - new Function>() { - @Override - public Future apply(final Datacenter input) { - return context.getAsyncApi().getVirtualMachineTemplateApi() - .listVirtualMachineTemplates(parent.getId(), input.getId()); - } - }, userExecutor, maxTime, logger, "getting virtual machine templates"); - - return DomainWrapper.join(templates); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java index d14d3c613e..0b7a887d30 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java @@ -19,18 +19,98 @@ package org.jclouds.abiquo.strategy.infrastructure; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.filter; +import static org.jclouds.abiquo.domain.DomainWrapper.wrap; +import static org.jclouds.concurrent.FutureIterables.transformParallel; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import javax.annotation.Resource; +import javax.inject.Named; + +import org.jclouds.Constants; +import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; +import org.jclouds.abiquo.domain.DomainWrapper; +import org.jclouds.abiquo.domain.infrastructure.Datacenter; import org.jclouds.abiquo.domain.infrastructure.Machine; import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.infrastructure.internal.ListMachinesImpl; +import org.jclouds.logging.Logger; +import org.jclouds.rest.RestContext; -import com.google.inject.ImplementedBy; +import com.abiquo.server.core.infrastructure.DatacentersDto; +import com.abiquo.server.core.infrastructure.MachineDto; +import com.abiquo.server.core.infrastructure.MachinesDto; +import com.abiquo.server.core.infrastructure.RackDto; +import com.abiquo.server.core.infrastructure.RacksDto; +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * List machines in each datacenter and rack. * * @author Ignasi Barrera */ -@ImplementedBy(ListMachinesImpl.class) -public interface ListMachines extends ListRootEntities { +@Singleton +public class ListMachines implements ListRootEntities { + protected RestContext context; + protected final ExecutorService userExecutor; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; + + @Inject + ListMachines(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { + super(); + this.context = checkNotNull(context, "context"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } + + @Override + public Iterable execute() { + // Find machines in concurrent requests + DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); + Iterable datacenters = wrap(context, Datacenter.class, result.getCollection()); + Iterable racks = listConcurrentRacks(datacenters); + Iterable machines = listConcurrentMachines(racks); + + return wrap(context, Machine.class, machines); + } + + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } + + private Iterable listConcurrentRacks(final Iterable datacenters) { + Iterable racks = transformParallel(datacenters, new Function>() { + @Override + public Future apply(final Datacenter input) { + return context.getAsyncApi().getInfrastructureApi().listRacks(input.unwrap()); + } + }, userExecutor, maxTime, logger, "getting racks"); + + return DomainWrapper.join(racks); + } + + private Iterable listConcurrentMachines(final Iterable racks) { + Iterable machines = transformParallel(racks, new Function>() { + @Override + public Future apply(final RackDto input) { + return context.getAsyncApi().getInfrastructureApi().listMachines(input); + } + }, userExecutor, maxTime, logger, "getting machines"); + + return DomainWrapper.join(machines); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java deleted file mode 100644 index c14f79f5f9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.infrastructure.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.strategy.infrastructure.ListMachines; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RacksDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List machines in each datacenter and rack. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListMachinesImpl implements ListMachines { - protected RestContext context; - - protected final ExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListMachinesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { - super(); - this.context = checkNotNull(context, "context"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - // Find machines in concurrent requests - DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); - Iterable datacenters = wrap(context, Datacenter.class, result.getCollection()); - Iterable racks = listConcurrentRacks(datacenters); - Iterable machines = listConcurrentMachines(racks); - - return wrap(context, Machine.class, machines); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - private Iterable listConcurrentRacks(final Iterable datacenters) { - Iterable racks = transformParallel(datacenters, new Function>() { - @Override - public Future apply(final Datacenter input) { - return context.getAsyncApi().getInfrastructureApi().listRacks(input.unwrap()); - } - }, userExecutor, maxTime, logger, "getting racks"); - - return DomainWrapper.join(racks); - } - - private Iterable listConcurrentMachines(final Iterable racks) { - Iterable machines = transformParallel(racks, new Function>() { - @Override - public Future apply(final RackDto input) { - return context.getAsyncApi().getInfrastructureApi().listMachines(input); - } - }, userExecutor, maxTime, logger, "getting machines"); - - return DomainWrapper.join(machines); - } - -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java similarity index 90% rename from labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImplLiveApiTest.java rename to labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java index 70d1cc9637..3ccf9cdc9b 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.abiquo.strategy.cloud.internal; +package org.jclouds.abiquo.strategy.cloud; import static com.google.common.collect.Iterables.size; import static org.testng.Assert.assertEquals; @@ -32,6 +32,7 @@ import org.jclouds.abiquo.domain.network.PublicIp; import org.jclouds.abiquo.domain.network.UnmanagedNetwork; import org.jclouds.abiquo.predicates.network.IpPredicates; import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; +import org.jclouds.abiquo.strategy.cloud.ListAttachedNics; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -39,13 +40,13 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; /** - * Live tests for the {@link ListAttachedNicsImpl} strategy. + * Live tests for the {@link ListAttachedNics} strategy. * * @author Ignasi Barrera */ -@Test(groups = "api", testName = "ListAttachedNicsImplLiveApiTest") -public class ListAttachedNicsImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListAttachedNicsImpl strategy; +@Test(groups = "api", testName = "ListAttachedNicsLiveApiTest") +public class ListAttachedNicsLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListAttachedNics strategy; private PrivateIp privateIp; @@ -56,7 +57,7 @@ public class ListAttachedNicsImplLiveApiTest extends BaseAbiquoStrategyLiveApiTe @Override @BeforeClass(groups = "api") protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListAttachedNicsImpl.class); + this.strategy = env.context.getUtils().getInjector().getInstance(ListAttachedNics.class); privateIp = env.privateNetwork.listUnusedIps().get(0); assertNotNull(privateIp); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java similarity index 83% rename from labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImplLiveApiTest.java rename to labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java index c577de9b41..981d4c29ac 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.abiquo.strategy.cloud.internal; +package org.jclouds.abiquo.strategy.cloud; import static com.google.common.collect.Iterables.size; import static org.testng.Assert.assertEquals; @@ -27,22 +27,23 @@ import static org.testng.Assert.assertTrue; import org.jclouds.abiquo.domain.cloud.VirtualAppliance; import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates; import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; +import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Live tests for the {@link ListVirtualAppliancesImpl} strategy. + * Live tests for the {@link ListVirtualAppliances} strategy. * * @author Ignasi Barrera */ -@Test(groups = "api", testName = "ListVirtualAppliancesImplLiveApiTest") -public class ListVirtualAppliancesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualAppliancesImpl strategy; +@Test(groups = "api", testName = "ListVirtualAppliancesLiveApiTest") +public class ListVirtualAppliancesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualAppliances strategy; @Override @BeforeClass(groups = "api") protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualAppliancesImpl.class); + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualAppliances.class); } public void testExecute() { diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java similarity index 87% rename from labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImplLiveApiTest.java rename to labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java index 1a155baf17..f8b1666a4a 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.abiquo.strategy.cloud.internal; +package org.jclouds.abiquo.strategy.cloud; import static com.google.common.collect.Iterables.size; import static org.testng.Assert.assertEquals; @@ -28,22 +28,23 @@ import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; import org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates; import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; +import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Live tests for the {@link ListVirtualDatacentersImpl} strategy. + * Live tests for the {@link ListVirtualDatacenters} strategy. * * @author Ignasi Barrera */ -@Test(groups = "api", testName = "ListVirtualDatacentersImplLiveApiTest") -public class ListVirtualDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualDatacentersImpl strategy; +@Test(groups = "api", testName = "ListVirtualDatacentersLiveApiTest") +public class ListVirtualDatacentersLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualDatacenters strategy; @Override @BeforeClass(groups = "api") protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualDatacentersImpl.class); + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualDatacenters.class); } public void testExecute() { diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java similarity index 88% rename from labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImplLiveApiTest.java rename to labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java index 4c87e244e9..1d80fc5e97 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.abiquo.strategy.cloud.internal; +package org.jclouds.abiquo.strategy.cloud; import static com.google.common.collect.Iterables.size; import static org.testng.Assert.assertEquals; @@ -30,22 +30,23 @@ import java.util.List; import org.jclouds.abiquo.domain.cloud.VirtualMachine; import org.jclouds.abiquo.predicates.cloud.VirtualMachinePredicates; import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; +import org.jclouds.abiquo.strategy.cloud.ListVirtualMachines; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Live tests for the {@link ListVirtualMachinesImpl} strategy. + * Live tests for the {@link ListVirtualMachines} strategy. * * @author Ignasi Barrera */ -@Test(groups = "api", testName = "ListVirtualMachinesImplLiveApiTest") -public class ListVirtualMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualMachinesImpl strategy; +@Test(groups = "api", testName = "ListVirtualMachinesLiveApiTest") +public class ListVirtualMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualMachines strategy; @Override @BeforeClass(groups = "api") protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachinesImpl.class); + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachines.class); } public void testExecute() { diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java similarity index 82% rename from labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImplLiveApiTest.java rename to labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java index 20b739608a..04d830297d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.abiquo.strategy.enterprise.internal; +package org.jclouds.abiquo.strategy.enterprise; import static com.google.common.collect.Iterables.size; import static org.testng.Assert.assertEquals; @@ -27,23 +27,24 @@ import static org.testng.Assert.assertTrue; import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates; import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.jclouds.abiquo.strategy.cloud.internal.ListVirtualAppliancesImpl; +import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances; +import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Live tests for the {@link ListVirtualAppliancesImpl} strategy. + * Live tests for the {@link ListVirtualAppliances} strategy. * * @author Ignasi Barrera */ -@Test(groups = "api", testName = "ListVirtualMachineTemplatesImplLiveApiTest") -public class ListVirtualMachineTemplatesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualMachineTemplatesImpl strategy; +@Test(groups = "api", testName = "ListVirtualMachineTemplatesLiveApiTest") +public class ListVirtualMachineTemplatesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualMachineTemplates strategy; @Override @BeforeClass(groups = "api") protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachineTemplatesImpl.class); + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachineTemplates.class); } public void testExecute() { diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java similarity index 84% rename from labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImplLiveApiTest.java rename to labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java index b739f42623..011ed71784 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.abiquo.strategy.infrastructure.internal; +package org.jclouds.abiquo.strategy.infrastructure; import static com.google.common.collect.Iterables.size; import static org.testng.Assert.assertEquals; @@ -27,22 +27,23 @@ import static org.testng.Assert.assertTrue; import org.jclouds.abiquo.domain.infrastructure.Machine; import org.jclouds.abiquo.predicates.infrastructure.MachinePredicates; import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; +import org.jclouds.abiquo.strategy.infrastructure.ListMachines; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Live tests for the {@link ListMachinesImpl} strategy. + * Live tests for the {@link ListMachines} strategy. * * @author Ignasi Barrera */ -@Test(groups = "api", testName = "ListMachinesImplLiveApiTest") -public class ListMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListMachinesImpl strategy; +@Test(groups = "api", testName = "ListMachinesLiveApiTest") +public class ListMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListMachines strategy; @Override @BeforeClass(groups = "api") protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListMachinesImpl.class); + this.strategy = env.context.getUtils().getInjector().getInstance(ListMachines.class); } public void testExecute() {