You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2013/07/02 18:28:48 UTC
[1/8] JCLOUDS-156: Cleanup Abiquo provider
Updated Branches:
refs/heads/master 91960ff11 -> c5e108a83
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/features/PricingApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/features/PricingApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/features/PricingApiTest.java
deleted file mode 100644
index 94ef8ed..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/features/PricingApiTest.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.features;
-
-import static org.jclouds.abiquo.domain.DomainUtils.withHeader;
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.abiquo.domain.PricingResources;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.reflect.Invocation;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-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.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-
-/**
- * Tests annotation parsing of {@code PricingApi}.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-@Test(groups = "unit", singleThreaded = true, testName = "PricingApiTest")
-public class PricingApiTest extends BaseAbiquoApiTest<PricingApi> {
- /*********************** Currency ***********************/
-
- public void testListCurrencies() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "listCurrencies");
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of()));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/currencies HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CurrenciesDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetCurrency() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getCurrency", Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/currencies/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testCreateCurrency() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "createCurrency", CurrencyDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.currencyPost())));
-
- assertRequestLineEquals(request, "POST http://localhost/api/config/currencies HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.currencyPostPayload()), CurrencyDto.class,
- CurrencyDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUpdateCurrency() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "updateCurrency", CurrencyDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.currencyPut())));
-
- assertRequestLineEquals(request, "PUT http://localhost/api/config/currencies/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.currencyPutPayload()), CurrencyDto.class,
- CurrencyDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteCurrency() throws SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(PricingApi.class, "deleteCurrency", CurrencyDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.currencyPut())));
-
- assertRequestLineEquals(request, "DELETE http://localhost/api/config/currencies/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- /*********************** Cost Code ***********************/
-
- public void testListCostCodes() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "listCostCodes");
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of()));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CostCodesDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetCostCode() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getCostCode", Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testCreateCostCode() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "createCostCode", CostCodeDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.costcodePost())));
-
- assertRequestLineEquals(request, "POST http://localhost/api/config/costcodes HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.costcodePostPayload()), CostCodeDto.class,
- CostCodeDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUpdateCostCode() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "updateCostCode", CostCodeDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.costcodePut())));
-
- assertRequestLineEquals(request, "PUT http://localhost/api/config/costcodes/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.costcodePutPayload()), CostCodeDto.class,
- CostCodeDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteCostCode() throws SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(PricingApi.class, "deleteCostCode", CostCodeDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.costcodePut())));
-
- assertRequestLineEquals(request, "DELETE http://localhost/api/config/costcodes/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- /*********************** Pricing Template ***********************/
-
- public void testListPricingTemplates() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "listPricingTemplates");
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of()));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplatesDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetPricingTemplate() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getPricingTemplate", Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testCreatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "createPricingTemplate", PricingTemplateDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.pricingtemplatePost())));
-
- assertRequestLineEquals(request, "POST http://localhost/api/config/pricingtemplates HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.pricingtemplatePostPayload()), PricingTemplateDto.class,
- PricingTemplateDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUpdatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "updatePricingTemplate", PricingTemplateDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.pricingtemplatePut())));
-
- assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.pricingtemplatePutPayload()), PricingTemplateDto.class,
- PricingTemplateDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeletePricingTemplate() throws SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(PricingApi.class, "deletePricingTemplate", PricingTemplateDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.pricingtemplatePut())));
-
- assertRequestLineEquals(request, "DELETE http://localhost/api/config/pricingtemplates/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- /*********************** Cost Code Currency ***********************/
-
- public void testGetCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getCostCodeCurrencies", Integer.class, Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1, 1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes/1/currencies?idCurrency=1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeCurrenciesDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testUpdateCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "updateCostCodeCurrencies", Integer.class,
- CostCodeCurrenciesDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(1, PricingResources.costcodecurrencyPut())));
-
- assertRequestLineEquals(request, "PUT http://localhost/api/config/costcodes/1/currencies HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeCurrenciesDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.costcodecurrencyPutPayload()),
- CostCodeCurrenciesDto.class, CostCodeCurrenciesDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- /*********************** Pricing Cost Code ***********************/
-
- public void testGetPricingCostCodes() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getPricingCostCodes", Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/costcodes HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodesDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetPricingCostCode() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getPricingCostCode", Integer.class, Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1, 1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodeDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testUpdatePricingCostCode() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "updatePricingCostCode", PricingCostCodeDto.class,
- Integer.class, Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.pricingCostcodePut(), 1, 1)));
-
- assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodeDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.pricingCostCodePutPayload()), PricingCostCodeDto.class,
- PricingCostCodeDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- /*********************** Pricing Tier ***************************/
-
- public void testGetPricingTiers() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getPricingTiers", Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/tiers HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingTiersDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetPricingTier() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "getPricingTier", Integer.class, Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(1, 1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/tiers/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingTierDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testUpdatePricingTier() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(PricingApi.class, "updatePricingTier", PricingTierDto.class, Integer.class,
- Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(PricingResources.pricingTierPut(), 1, 2)));
-
- assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1/tiers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + PricingTierDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(PricingResources.pricingTierPutPayload()), PricingTierDto.class,
- PricingTierDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java b/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java
index 8dc00a2..e11e43a 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java
@@ -32,9 +32,9 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.easymock.EasyMock;
-import org.jclouds.abiquo.events.monitor.MonitorEvent;
import org.jclouds.abiquo.internal.BaseMonitoringService.AsyncMonitor;
import org.jclouds.abiquo.monitor.MonitorStatus;
+import org.jclouds.abiquo.monitor.events.MonitorEvent;
import org.jclouds.rest.ApiContext;
import org.testng.annotations.Test;
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java
index 534f072..b230525 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java
@@ -38,13 +38,6 @@ public abstract class BaseAbiquoApiLiveApiTest extends BaseAbiquoLiveApiTest {
setupEnvironment();
}
- // @BeforeSuite(groups = "ucs", dependsOnMethods = "setupContext")
- protected void setupUcsEnvironment() throws Exception {
- if (env != null) {
- env.createUcsRack();
- }
- }
-
@Override
@AfterSuite(groups = "api")
protected void tearDownContext() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandlerTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandlerTest.java b/abiquo/src/test/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandlerTest.java
new file mode 100644
index 0000000..a438abb
--- /dev/null
+++ b/abiquo/src/test/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandlerTest.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.monitor.handlers;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.abiquo.monitor.events.MonitorEvent;
+import org.jclouds.abiquo.monitor.events.MonitorEvent.Type;
+import org.jclouds.abiquo.monitor.handlers.BlockingEventHandler;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for the {@link BlockingEventHandler} handler.
+ *
+ * @author Ignasi Barrera
+ */
+@Test(groups = "unit", testName = "BlockingEventHandlerTest")
+public class BlockingEventHandlerTest {
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testConstructorWithoutObjects() {
+ new BlockingEventHandler<Object>();
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testConstructorWithNullObjects() {
+ new BlockingEventHandler<Object>((Object[]) null);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testConstructorWithtEmptyObjects() {
+ new BlockingEventHandler<Object>(new Object[] {});
+ }
+
+ public void testHandles() {
+ Object object = new Object();
+ BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
+
+ assertTrue(handler.handles(new MonitorEvent<Object>(Type.COMPLETED, object)));
+ assertFalse(handler.handles(new MonitorEvent<Object>(Type.COMPLETED, new Object())));
+ }
+
+ public void testReleaseDoesNothingIfNotLocked() {
+ Object object = new Object();
+ BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
+ handler.release(object);
+ }
+
+ public void testRelease() {
+ final Object object = new Object();
+ final BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
+
+ // Unlock the handler (in a separate thread) after a certain delay
+ Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() {
+ @Override
+ public void run() {
+ handler.release(object);
+ assertTrue(handler.lockedObjects.isEmpty());
+ }
+
+ }, 500L, TimeUnit.MILLISECONDS);
+
+ handler.lock();
+ }
+
+ public void testHandle() {
+ final Object object = new Object();
+ final BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
+
+ // Unlock the handler (in a separate thread) after a certain delay
+ Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() {
+ @Override
+ public void run() {
+ handler.handle(new MonitorEvent<Object>(Type.COMPLETED, object));
+ assertTrue(handler.lockedObjects.isEmpty());
+ }
+
+ }, 500L, TimeUnit.MILLISECONDS);
+
+ handler.lock();
+ }
+
+ public void testLockDoesNothingIfNoObjects() {
+ Object object = new Object();
+ BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
+ handler.lockedObjects.clear();
+
+ handler.lock(); // Lock should do nothing
+
+ assertNull(handler.completeSignal);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java
index d8d7981..7bb9a7b 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.strategy.cloud;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.size;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -26,12 +27,12 @@ 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.UnmanagedNetwork;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
/**
@@ -62,8 +63,12 @@ public class ListAttachedNicsLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0);
env.virtualDatacenter.purchasePublicIp(publicIp);
- publicIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(publicIp.getIp()));
- assertNotNull(publicIp);
+ publicIp = find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(publicIp.getIp());
+ }
+ });
env.virtualMachine.setNics(Lists.<Ip<?, ?>> newArrayList(privateIp, externalIp, publicIp),
Lists.<UnmanagedNetwork> newArrayList(env.unmanagedNetwork));
@@ -72,9 +77,14 @@ public class ListAttachedNicsLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
@AfterClass(groups = "api")
protected void tearDownStrategy() {
env.virtualMachine.setNics(Lists.<Ip<?, ?>> newArrayList(privateIp));
- String address = publicIp.getIp();
+ final String address = publicIp.getIp();
env.virtualDatacenter.releasePublicIp(publicIp);
- assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(address)));
+ assertNull(find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(address);
+ }
+ }, null));
}
public void testExecute() {
@@ -82,16 +92,4 @@ public class ListAttachedNicsLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
assertNotNull(vapps);
assertEquals(4, size(vapps));
}
-
- public void testExecutePredicateWithoutResults() {
- Iterable<Ip<?, ?>> vapps = strategy.execute(env.virtualMachine, IpPredicates.address("UNEXISTING"));
- assertNotNull(vapps);
- assertEquals(size(vapps), 0);
- }
-
- public void testExecutePredicateWithResults() {
- Iterable<Ip<?, ?>> vapps = strategy.execute(env.virtualMachine, IpPredicates.address(publicIp.getIp()));
- assertNotNull(vapps);
- assertEquals(size(vapps), 1);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java
index 1db2e04..4817913 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java
@@ -17,12 +17,10 @@
package org.jclouds.abiquo.strategy.cloud;
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.cloud.VirtualAppliance;
-import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -47,17 +45,4 @@ public class ListVirtualAppliancesLiveApiTest extends BaseAbiquoStrategyLiveApiT
assertNotNull(vapps);
assertTrue(size(vapps) > 0);
}
-
- public void testExecutePredicateWithoutResults() {
- Iterable<VirtualAppliance> vapps = strategy.execute(VirtualAppliancePredicates.name("UNEXISTING"));
- assertNotNull(vapps);
- assertEquals(size(vapps), 0);
- }
-
- public void testExecutePredicateWithResults() {
- Iterable<VirtualAppliance> vapps = strategy.execute(VirtualAppliancePredicates.name(env.virtualAppliance
- .getName()));
- assertNotNull(vapps);
- assertEquals(size(vapps), 1);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java
index 314f714..a3a6aca 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java
@@ -23,7 +23,6 @@ import static org.testng.Assert.assertTrue;
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.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -49,27 +48,14 @@ public class ListVirtualDatacentersLiveApiTest extends BaseAbiquoStrategyLiveApi
assertTrue(size(vdcs) > 0);
}
- public void testExecutePredicateWithoutResults() {
- Iterable<VirtualDatacenter> vdcs = strategy.execute(VirtualDatacenterPredicates.name("UNEXISTING"));
- assertNotNull(vdcs);
- assertEquals(size(vdcs), 0);
- }
-
- public void testExecutePredicateWithResults() {
- Iterable<VirtualDatacenter> vdcs = strategy.execute(VirtualDatacenterPredicates.name(env.virtualDatacenter
- .getName()));
- assertNotNull(vdcs);
- assertEquals(size(vdcs), 1);
- }
-
- public void testExecutePredicateOptionsWithResults() {
+ public void testExecuteOptionsWithResults() {
Iterable<VirtualDatacenter> vdcs = strategy.execute(VirtualDatacenterOptions.builder()
.datacenterId(env.datacenter.getId()).enterpriseId(env.defaultEnterprise.getId()).build());
assertNotNull(vdcs);
assertEquals(size(vdcs), 1);
}
- public void testExecutePredicateOptionsWithoutResults() {
+ public void testExecuteOptionsWithoutResults() {
Iterable<VirtualDatacenter> vdcs = strategy.execute(VirtualDatacenterOptions.builder()
.enterpriseId(env.enterprise.getId()).build());
assertNotNull(vdcs);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java
index 09568d7..a5aed62 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java
@@ -17,14 +17,12 @@
package org.jclouds.abiquo.strategy.cloud;
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 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.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -52,19 +50,6 @@ public class ListVirtualMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTes
assertTrue(size(vms) > 0);
}
- public void testExecutePredicateWithoutResults() {
- Iterable<VirtualMachine> vms = strategy.execute(VirtualMachinePredicates.internalName("UNEXISTING"));
- assertNotNull(vms);
- assertEquals(size(vms), 0);
- }
-
- public void testExecutePredicateWithResults() {
- Iterable<VirtualMachine> vms = strategy.execute(VirtualMachinePredicates.internalName(env.virtualMachine
- .getInternalName()));
- assertNotNull(vms);
- assertEquals(size(vms), 1);
- }
-
public void testExecuteWhenExceedsPagination() {
List<VirtualMachine> vms = Lists.newArrayList();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java
index 9d1275f..cc5f9b9 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java
@@ -17,12 +17,10 @@
package org.jclouds.abiquo.strategy.enterprise;
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.cloud.VirtualMachineTemplate;
-import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances;
import org.testng.annotations.BeforeClass;
@@ -48,19 +46,4 @@ public class ListVirtualMachineTemplatesLiveApiTest extends BaseAbiquoStrategyLi
assertNotNull(templates);
assertTrue(size(templates) > 0);
}
-
- public void testExecutePredicateWithoutResults() {
- Iterable<VirtualMachineTemplate> templates = strategy.execute(env.defaultEnterprise,
- VirtualMachineTemplatePredicates.name("UNEXISTING"));
- assertNotNull(templates);
- assertEquals(size(templates), 0);
- }
-
- public void testExecutePredicateWithResults() {
- Iterable<VirtualMachineTemplate> templates = strategy.execute(env.defaultEnterprise,
- VirtualMachineTemplatePredicates.name(env.template.getName()));
- assertNotNull(templates);
- // Repository can have multiple templates with the same name
- assertTrue(size(templates) > 0);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java
index 059c336..18ece95 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java
@@ -17,12 +17,10 @@
package org.jclouds.abiquo.strategy.infrastructure;
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.Machine;
-import org.jclouds.abiquo.predicates.infrastructure.MachinePredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -47,16 +45,4 @@ public class ListMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
assertNotNull(machines);
assertTrue(size(machines) > 0);
}
-
- public void testExecutePredicateWithoutResults() {
- Iterable<Machine> machines = strategy.execute(MachinePredicates.name("UNEXISTING"));
- assertNotNull(machines);
- assertEquals(size(machines), 0);
- }
-
- public void testExecutePredicateWithResults() {
- Iterable<Machine> machines = strategy.execute(MachinePredicates.name(env.machine.getName()));
- assertNotNull(machines);
- assertEquals(size(machines), 1);
- }
}
[7/8] JCLOUDS-156: Cleanup Abiquo provider
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java
index b570815..ac2400a 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java
@@ -16,8 +16,6 @@
*/
package org.jclouds.abiquo.domain.enterprise;
-import static com.google.common.collect.Iterables.filter;
-
import java.util.List;
import org.jclouds.abiquo.AbiquoApi;
@@ -30,10 +28,7 @@ import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Machine;
-import org.jclouds.abiquo.domain.network.ExternalIp;
import org.jclouds.abiquo.domain.network.ExternalNetwork;
-import org.jclouds.abiquo.domain.network.Network;
-import org.jclouds.abiquo.domain.network.UnmanagedIp;
import org.jclouds.abiquo.domain.network.UnmanagedNetwork;
import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates;
import org.jclouds.http.HttpResponse;
@@ -142,40 +137,6 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
}
/**
- * Retrieve a filtered list of virtual datacenters by this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievealistofvitualdatacentersbyanEnterprise"
- * > http://community.abiquo.com/display/ABI20/EnterpriseResource#
- * EnterpriseResource-
- * RetrievealistofvitualdatacentersbyanEnterprise</a>
- * @return Filtered list of virtual datacenters in this enterprise.
- */
- public List<VirtualDatacenter> listVirtualDatacenters(final Predicate<VirtualDatacenter> filter) {
- return ImmutableList.copyOf(filter(listVirtualDatacenters(), filter));
- }
-
- /**
- * Retrieve a the first virtual datacenter matching the filter within the
- * list of virtual datacenters by this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievealistofvitualdatacentersbyanEnterprise"
- * > http://community.abiquo.com/display/ABI20/EnterpriseResource#
- * EnterpriseResource-
- * RetrievealistofvitualdatacentersbyanEnterprise</a>
- * @return First virtual datacenter matching the filter or <code>null</code>
- * if the is none.
- */
- public VirtualDatacenter findVirtualDatacenter(final Predicate<VirtualDatacenter> filter) {
- return Iterables.getFirst(filter(listVirtualDatacenters(), filter), null);
- }
-
- /**
* Retrieve the list of template definition lists of the enterprise.
*
* @see API: <a href=
@@ -191,41 +152,6 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
}
/**
- * Retrieve a filtered list of template definition lists from this
- * enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealltemplatedefinitionlists"
- * > http://community.abiquo.com/display/ABI20/
- * TemplateDefinitionListResource#
- * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists</a>
- * @return Filtered list of template definition lists of the enterprise.
- */
- public List<TemplateDefinitionList> listTemplateDefinitionLists(final Predicate<TemplateDefinitionList> filter) {
- return ImmutableList.copyOf(filter(listTemplateDefinitionLists(), filter));
- }
-
- /**
- * Retrieve the first template definition list matching the filter within the
- * list.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealltemplatedefinitionlists"
- * > http://community.abiquo.com/display/ABI20/
- * TemplateDefinitionListResource#
- * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists</a>
- * @return First template definition list matching the filter or
- * <code>null</code> if the is none.
- */
- public TemplateDefinitionList findTemplateDefinitionList(final Predicate<TemplateDefinitionList> filter) {
- return Iterables.getFirst(filter(listTemplateDefinitionLists(), filter), null);
- }
-
- /**
* Retrieve a single template definition list.
*
* @param id
@@ -259,38 +185,6 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
}
/**
- * Retrieve a filtered list of datacenter limits by enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterLimitsResource#DatacenterLimitsResource-Retrievelimitsbyenterprise"
- * > http://community.abiquo.com/display/ABI20/DatacenterLimitsResource#
- * DatacenterLimitsResource-Retrievelimitsbyenterprise</a>
- * @return Filtered list of datacenter limits by enterprise.
- */
- public List<Limits> listLimits(final Predicate<Limits> filter) {
- return ImmutableList.copyOf(filter(listLimits(), filter));
- }
-
- /**
- * Retrieve the first datacenter limits matching the filter within the list
- * of datacenter limits by enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterLimitsResource#DatacenterLimitsResource-Retrievelimitsbyenterprise"
- * > http://community.abiquo.com/display/ABI20/DatacenterLimitsResource#
- * DatacenterLimitsResource-Retrievelimitsbyenterprise</a>
- * @return First datacenter limits matching the filter or <code>null</code>
- * if there is none.
- */
- public Limits findLimits(final Predicate<Limits> filter) {
- return Iterables.getFirst(filter(listLimits(), filter), null);
- }
-
- /**
* Retrieve the defined properties of the given enterprise.
*
* @see API: <a href=
@@ -321,40 +215,6 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
}
/**
- * Retrieve a filtered list of users of this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrievealistofusers"
- * >
- * http://community.abiquo.com/display/ABI20/UserResource#UserResource-
- * Retrievealistofusers </a>
- * @return Filtered list of users of this enterprise.
- */
- public List<User> listUsers(final Predicate<User> filter) {
- return ImmutableList.copyOf(filter(listUsers(), filter));
- }
-
- /**
- * Retrieve the first user matching the filter within the list of users of
- * this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrievealistofusers"
- * >
- * http://community.abiquo.com/display/ABI20/UserResource#UserResource-
- * Retrievealistofusers </a>
- * @return First user matching the filter or <code>null</code> if there is
- * none.
- */
- public User findUser(final Predicate<User> filter) {
- return Iterables.getFirst(filter(listUsers(), filter), null);
- }
-
- /**
* Retrieve a single user.
*
* @param id
@@ -381,46 +241,12 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
return wrap(context, Role.class, dto.getCollection());
}
- /**
- * Retrieve a filtered list of roles defined by this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @return Filtered list of roles by this enterprise.
- */
- public List<Role> listRoles(final Predicate<Role> filter) {
- return ImmutableList.copyOf(filter(listRoles(), filter));
- }
-
- /**
- * Retrieve the first role matching the filter within the list of roles
- * defined by this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @return First role matching the filter or <code>null</code> if there is
- * none.
- */
- public Role findRole(final Predicate<Role> filter) {
- return Iterables.getFirst(filter(listRoles(), filter), null);
- }
-
public List<VirtualMachineTemplate> listTemplatesInRepository(final Datacenter datacenter) {
VirtualMachineTemplatesDto dto = context.getApi().getVirtualMachineTemplateApi()
.listVirtualMachineTemplates(target.getId(), datacenter.getId());
return wrap(context, VirtualMachineTemplate.class, dto.getCollection());
}
- public List<VirtualMachineTemplate> listTemplatesInRepository(final Datacenter datacenter,
- final Predicate<VirtualMachineTemplate> filter) {
- return ImmutableList.copyOf(filter(listTemplatesInRepository(datacenter), filter));
- }
-
- public VirtualMachineTemplate findTemplateInRepository(final Datacenter datacenter,
- final Predicate<VirtualMachineTemplate> filter) {
- return Iterables.getFirst(filter(listTemplatesInRepository(datacenter), filter), null);
- }
-
public VirtualMachineTemplate getTemplateInRepository(final Datacenter datacenter, final Integer id) {
VirtualMachineTemplateDto template = context.getApi().getVirtualMachineTemplateApi()
.getVirtualMachineTemplate(target.getId(), datacenter.getId(), id);
@@ -432,29 +258,11 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
return ImmutableList.copyOf(strategy.execute(this));
}
- public List<VirtualMachineTemplate> listTemplates(final Predicate<VirtualMachineTemplate> filter) {
- ListVirtualMachineTemplates strategy = context.utils().injector().getInstance(ListVirtualMachineTemplates.class);
- return ImmutableList.copyOf(strategy.execute(this, filter));
- }
-
- public VirtualMachineTemplate findTemplate(final Predicate<VirtualMachineTemplate> filter) {
- ListVirtualMachineTemplates strategy = context.utils().injector().getInstance(ListVirtualMachineTemplates.class);
- return Iterables.getFirst(strategy.execute(this, filter), null);
- }
-
public List<Datacenter> listAllowedDatacenters() {
DatacentersDto datacenters = context.getApi().getEnterpriseApi().listAllowedDatacenters(target.getId());
return wrap(context, Datacenter.class, datacenters.getCollection());
}
- public List<Datacenter> listAllowedDatacenters(final Predicate<Datacenter> filter) {
- return ImmutableList.copyOf(filter(listAllowedDatacenters(), filter));
- }
-
- public Datacenter findAllowedDatacenter(final Predicate<Datacenter> filter) {
- return Iterables.getFirst(filter(listAllowedDatacenters(), filter), null);
- }
-
/**
* @see API: <a href=
* "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-Getthelistofexternalnetworks"
@@ -472,15 +280,6 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
return wrap(context, ExternalNetwork.class, parser.apply(response).getCollection());
}
- public List<ExternalNetwork> listExternalNetworks(final Datacenter datacenter,
- final Predicate<Network<ExternalIp>> filter) {
- return ImmutableList.copyOf(filter(listExternalNetworks(datacenter), filter));
- }
-
- public ExternalNetwork findExternalNetwork(final Datacenter datacenter, final Predicate<Network<ExternalIp>> filter) {
- return Iterables.getFirst(filter(listExternalNetworks(datacenter), filter), null);
- }
-
public List<UnmanagedNetwork> listUnmanagedNetworks(final Datacenter datacenter) {
DatacenterLimitsDto limitForDatacenter = getLimits(datacenter);
@@ -494,16 +293,6 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
return wrap(context, UnmanagedNetwork.class, parser.apply(response).getCollection());
}
- public List<UnmanagedNetwork> listUnmanagedNetworks(final Datacenter datacenter,
- final Predicate<Network<UnmanagedIp>> filter) {
- return ImmutableList.copyOf(filter(listUnmanagedNetworks(datacenter), filter));
- }
-
- public UnmanagedNetwork findUnmanagedNetwork(final Datacenter datacenter,
- final Predicate<Network<UnmanagedIp>> filter) {
- return Iterables.getFirst(filter(listUnmanagedNetworks(datacenter), filter), null);
- }
-
/**
* Retrieve the list of virtual appliances by this enterprise.
*
@@ -520,40 +309,6 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
}
/**
- * Retrieve a filtered list of virtual appliances by this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievethelistofvirtualappliancesbyanEnterprise"
- * > http://community.abiquo.com/display/ABI20/EnterpriseResource#
- * EnterpriseResource-
- * RetrievethelistofvirtualappliancesbyanEnterprise</a>
- * @return Filtered list of virtual appliances by this enterprise.
- */
- public List<VirtualAppliance> listVirtualAppliances(final Predicate<VirtualAppliance> filter) {
- return ImmutableList.copyOf(filter(listVirtualAppliances(), filter));
- }
-
- /**
- * Retrieve the first virtual appliance matching the filter within the list
- * of virtual appliances in this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievethelistofvirtualappliancesbyanEnterprise"
- * > http://community.abiquo.com/display/ABI20/EnterpriseResource#
- * EnterpriseResource-
- * RetrievethelistofvirtualappliancesbyanEnterprise</a>
- * @return First virtual machine matching the filter or <code>null</code> if
- * the is none.
- */
- public VirtualAppliance findVirtualAppliance(final Predicate<VirtualAppliance> filter) {
- return Iterables.getFirst(filter(listVirtualAppliances(), filter), null);
- }
-
- /**
* Retrieve the list of virtual machines by this enterprise.
*
* @see API: <a href=
@@ -567,51 +322,11 @@ public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> {
return wrap(context, VirtualMachine.class, machines.getCollection());
}
- /**
- * Retrieve a filtered list of virtual machines by this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievealistofvirtualmachinesbyanEnterprise"
- * > http://community.abiquo.com/display/ABI20/EnterpriseResource#
- * EnterpriseResource- RetrievealistofvirtualmachinesbyanEnterprise</a>
- * @return Filtered list of virtual machines by this enterprise.
- */
- public List<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter) {
- return ImmutableList.copyOf(filter(listVirtualMachines(), filter));
- }
-
- /**
- * Retrieve the first virtual machine matching the filter within the list of
- * virtual machines in this enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievealistofvirtualmachinesbyanEnterprise"
- * > http://community.abiquo.com/display/ABI20/EnterpriseResource#
- * EnterpriseResource- RetrievealistofvirtualmachinesbyanEnterprise</a>
- * @return First virtual machine matching the filter or <code>null</code> if
- * the is none.
- */
- public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
- }
-
public List<Machine> listReservedMachines() {
MachinesDto machines = context.getApi().getEnterpriseApi().listReservedMachines(target);
return wrap(context, Machine.class, machines.getCollection());
}
- public List<VirtualMachine> listReservedMachines(final Predicate<VirtualMachine> filter) {
- return ImmutableList.copyOf(filter(listVirtualMachines(), filter));
- }
-
- public VirtualMachine findReservedMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
- }
-
// Actions
/**
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java
index f8c2cf7..ba9b279 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.domain.enterprise;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import java.util.List;
@@ -25,15 +24,11 @@ import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.DomainWrapper;
import org.jclouds.abiquo.domain.config.Privilege;
import org.jclouds.abiquo.reference.ValidationErrors;
-
import org.jclouds.rest.ApiContext;
import com.abiquo.model.rest.RESTLink;
import com.abiquo.server.core.enterprise.PrivilegesDto;
import com.abiquo.server.core.enterprise.RoleDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* Adds high level functionality to {@link RoleDto}.
@@ -137,14 +132,6 @@ public class Role extends DomainWrapper<RoleDto> {
return wrap(context, Privilege.class, dto.getCollection());
}
- public List<Privilege> listPrivileges(final Predicate<Privilege> filter) {
- return ImmutableList.copyOf(filter(listPrivileges(), filter));
- }
-
- public Privilege findPrivileges(final Predicate<Privilege> filter) {
- return Iterables.getFirst(filter(listPrivileges(), filter), null);
- }
-
// Builder
public static Builder builder(final ApiContext<AbiquoApi> context) {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java
index 43490e3..4519f5c 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.domain.enterprise;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import java.util.List;
import java.util.StringTokenizer;
@@ -36,9 +35,7 @@ import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
import com.abiquo.server.core.enterprise.RoleDto;
import com.abiquo.server.core.enterprise.UserDto;
import com.google.common.base.Joiner;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
/**
@@ -128,14 +125,6 @@ public class User extends DomainWrapper<UserDto> {
return ImmutableList.copyOf(listVirtualDatacenters.execute(ids));
}
- public List<VirtualDatacenter> listPermittedVirtualDatacenters(final Predicate<VirtualDatacenter> filter) {
- return ImmutableList.copyOf(filter(listPermittedVirtualDatacenters(), filter));
- }
-
- public VirtualDatacenter findPermittedVirtualDatacenter(final Predicate<VirtualDatacenter> filter) {
- return Iterables.getFirst(filter(listPermittedVirtualDatacenters(), filter), null);
- }
-
/**
* Give access to all virtualdatacenters in the enterprise (requires update).
*/
@@ -191,14 +180,6 @@ public class User extends DomainWrapper<UserDto> {
return wrap(context, VirtualMachine.class, machines.getCollection());
}
- public List<VirtualMachine> listMachines(final Predicate<VirtualMachine> filter) {
- return ImmutableList.copyOf(filter(listMachines(), filter));
- }
-
- public VirtualMachine findMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(filter(listMachines(), filter), null);
- }
-
// Builder
public static Builder builder(final ApiContext<AbiquoApi> context, final Enterprise enterprise, final Role role) {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java
index e6f7f13..bc7e0ce 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java
@@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.exception;
import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
-import static org.jclouds.abiquo.predicates.ErrorPredicates.code;
import java.util.List;
@@ -27,6 +26,7 @@ import javax.ws.rs.core.Response.Status;
import com.abiquo.model.transport.error.ErrorDto;
import com.abiquo.model.transport.error.ErrorsDto;
+import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
/**
@@ -111,4 +111,13 @@ public class AbiquoException extends RuntimeException {
public String getMessage() {
return errors.toString();
}
+
+ private static Predicate<ErrorDto> code(final String code) {
+ return new Predicate<ErrorDto>() {
+ @Override
+ public boolean apply(ErrorDto input) {
+ return input.getCode().equals(code);
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java
deleted file mode 100644
index cf924f2..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import static com.google.common.collect.Iterables.find;
-
-import java.util.List;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.predicates.infrastructure.DatastorePredicates;
-import org.jclouds.abiquo.predicates.infrastructure.NetworkInterfacePredicates;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.HypervisorType;
-import com.abiquo.model.enumerator.MachineIpmiState;
-import com.abiquo.model.enumerator.MachineState;
-import com.abiquo.server.core.infrastructure.DatastoresDto;
-import com.abiquo.server.core.infrastructure.MachineDto;
-import com.abiquo.server.core.infrastructure.MachineIpmiStateDto;
-import com.abiquo.server.core.infrastructure.MachineStateDto;
-
-/**
- * Adds high level functionality to {@link MachineDto}. This class defines
- * common methods for unmanaged {@link Machine} and managed {@link Blade}
- * physical machines.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/MachineResource">
- * http://community.abiquo.com/display/ABI20/MachineResource</a>
- */
-public abstract class AbstractPhysicalMachine extends DomainWrapper<MachineDto> {
- /** The default virtual ram used in MB. */
- protected static final int DEFAULT_VRAM_USED = 1;
-
- /** The default virtual cpu used in MB. */
- protected static final int DEFAULT_VCPU_USED = 1;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected AbstractPhysicalMachine(final ApiContext<AbiquoApi> context, final MachineDto target) {
- super(context, target);
- }
-
- public void delete() {
- context.getApi().getInfrastructureApi().deleteMachine(target);
- target = null;
- }
-
- public void update() {
- target = context.getApi().getInfrastructureApi().updateMachine(target);
- }
-
- public MachineState check() {
- MachineStateDto dto = context.getApi().getInfrastructureApi().checkMachineState(target, true);
- MachineState state = dto.getState();
- target.setState(state);
- return state;
- }
-
- public MachineIpmiState checkIpmi() {
- MachineIpmiStateDto dto = context.getApi().getInfrastructureApi().checkMachineIpmiState(target);
- return dto.getState();
- }
-
- // Children access
-
- public List<Datastore> getDatastores() {
- return wrap(context, Datastore.class, target.getDatastores().getCollection());
- }
-
- public Datastore findDatastore(final String name) {
- return find(getDatastores(), DatastorePredicates.name(name), null);
- }
-
- public List<NetworkInterface> getNetworkInterfaces() {
- return wrap(context, NetworkInterface.class, target.getNetworkInterfaces().getCollection());
- }
-
- public NetworkInterface findNetworkInterface(final String name) {
- return find(getNetworkInterfaces(), NetworkInterfacePredicates.name(name), null);
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getIp() {
- return target.getIp();
- }
-
- public String getIpmiIp() {
- return target.getIpmiIP();
- }
-
- public String getIpmiPassword() {
- return target.getIpmiPassword();
- }
-
- public Integer getIpmiPort() {
- return target.getIpmiPort();
- }
-
- public String getIpmiUser() {
- return target.getIpmiUser();
- }
-
- public String getIpService() {
- return target.getIpService();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getPassword() {
- return target.getPassword();
- }
-
- public Integer getPort() {
- return target.getPort();
- }
-
- public MachineState getState() {
- return target.getState();
- }
-
- public HypervisorType getType() {
- return target.getType();
- }
-
- public String getUser() {
- return target.getUser();
- }
-
- public Integer getVirtualCpuCores() {
- return target.getVirtualCpuCores();
- }
-
- public Integer getVirtualCpusUsed() {
- return target.getVirtualCpusUsed();
- }
-
- public Integer getVirtualRamInMb() {
- return target.getVirtualRamInMb();
- }
-
- public Integer getVirtualRamUsedInMb() {
- return target.getVirtualRamUsedInMb();
- }
-
- public void setDatastores(final List<Datastore> datastores) {
- DatastoresDto datastoresDto = new DatastoresDto();
- datastoresDto.getCollection().addAll(DomainWrapper.unwrap(datastores));
- target.setDatastores(datastoresDto);
- }
-
- public void setDescription(final String description) {
- target.setDescription(description);
- }
-
- public void setIp(final String ip) {
- target.setIp(ip);
- }
-
- public void setIpmiIp(final String ipmiIp) {
- target.setIpmiIP(ipmiIp);
- }
-
- public void setIpmiPassword(final String ipmiPassword) {
- target.setIpmiPassword(ipmiPassword);
- }
-
- public void setIpmiPort(final Integer ipmiPort) {
- target.setIpmiPort(ipmiPort);
- }
-
- public void setIpmiUser(final String ipmiUser) {
- target.setIpmiUser(ipmiUser);
- }
-
- public void setIpService(final String ipService) {
- target.setIpService(ipService);
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public void setPassword(final String password) {
- target.setPassword(password);
- }
-
- public void setPort(final Integer port) {
- target.setPort(port);
- }
-
- public void setState(final MachineState state) {
- target.setState(state);
- }
-
- public void setType(final HypervisorType type) {
- target.setType(type);
- }
-
- public void setUser(final String user) {
- target.setUser(user);
- }
-
- public void setVirtualCpuCores(final Integer virtualCpuCores) {
- target.setVirtualCpuCores(virtualCpuCores);
- }
-
- public void setVirtualCpusUsed(final Integer virtualCpusUsed) {
- target.setVirtualCpusUsed(virtualCpusUsed);
- }
-
- public void setVirtualRamInMb(final Integer virtualRamInMb) {
- target.setVirtualRamInMb(virtualRamInMb);
- }
-
- public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb) {
- target.setVirtualRamUsedInMb(virtualRamUsedInMb);
- }
-
- public String getDescription() {
- return target.getDescription();
- }
-
- // Aux operations
-
- public NetworkInterface findAvailableVirtualSwitch(final String virtualswitch) {
- return find(getNetworkInterfaces(), NetworkInterfacePredicates.name(virtualswitch));
- }
-
- @Override
- public String toString() {
- return "Machine [id=" + getId() + ", ip=" + getIp() + ", ipmiIp=" + getIpmiIp() + ", ipmiPassword="
- + getIpmiPassword() + ", ipmiPort=" + getIpmiPort() + ", ipmiUser=" + getIpmiUser() + ", ipService="
- + getIpService() + ", name=" + getName() + ", password=" + getPassword() + ", port=" + getPort()
- + ", state=" + getState() + ", type=" + getType() + ", user=" + getUser() + ", virtualCpuCores="
- + getVirtualCpuCores() + ", virtualCpusUsed=" + getVirtualCpusUsed() + ", getVirtualRamInMb()="
- + getVirtualRamInMb() + ", virtualRamUsedInMb=" + getVirtualRamUsedInMb() + ", description="
- + getDescription() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java
deleted file mode 100644
index 89c3e21..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.infrastructure.BladeLocatorLedDto;
-import com.abiquo.server.core.infrastructure.LogicServerDto;
-import com.abiquo.server.core.infrastructure.MachineDto;
-import com.abiquo.server.core.infrastructure.UcsRackDto;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to a {@link MachineDto} managed in a UCS rack.
- * This resource allows you to access blades in managed racks in the cloud
- * infrastructure.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/MachineResource">
- * http://community.abiquo.com/display/ABI20/MachineResource</a>
- */
-public class Blade extends AbstractPhysicalMachine {
- /** The rack where the machine belongs. */
- protected UcsRackDto rack;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected Blade(final ApiContext<AbiquoApi> context, final MachineDto target) {
- super(context, target);
- }
-
- // Parent access
-
- /**
- * Retrieve the UCS rack where the blade is.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaUCSRack"
- * >
- * http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * RetrieveaUCSRack</a>
- */
- public ManagedRack getRack() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.RACK), ValidationErrors.MISSING_REQUIRED_LINK + " "
- + ParentLinkName.RACK);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<UcsRackDto> parser = new ParseXMLWithJAXB<UcsRackDto>(context.utils().xml(),
- TypeLiteral.get(UcsRackDto.class));
-
- return wrap(context, ManagedRack.class, parser.apply(response));
- }
-
- /**
- * Retrieve the logic server associated with this machine in the Cisco UCS
- * rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveslogicserverassociatedwithamachineinaCiscoUCS"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource-
- * RetrieveslogicserverassociatedwithamachineinaCiscoUCS</a>
- */
- public LogicServer getLogicServer() {
- LogicServerDto server = context.getApi().getInfrastructureApi().getLogicServer(target);
-
- return wrap(context, LogicServer.class, server);
- }
-
- // Actions
-
- /**
- * Turn the blade associated to the provided logic server off. The blade must
- * belong to a Logic Server. This action sets the state of a given machine to
- * STOPPED. Also sends a stop request to Cisco UCS to shut down the machine.
- * The given machine must be a Physical Machine inside a Cisco UCS.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-PoweroffanexistingmachineinCiscoUCS"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- PoweroffanexistingmachineinCiscoUCS</a>
- */
- public void powerOff() {
- context.getApi().getInfrastructureApi().powerOff(target);
- }
-
- /**
- * Turn the blade associated to the provided logic server on. The machine
- * must belong to an UCS Rack. The blade must belong to a Logic Server.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-PoweronanexistingmachineinCiscoUCS"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- PoweronanexistingmachineinCiscoUCS</a>
- */
- public void powerOn() {
- context.getApi().getInfrastructureApi().powerOn(target);
- }
-
- /**
- * Turn blade led on. The machine must belong to an UCS Rack. The blade must
- * belong to a Logic Server.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-LightoffthelocatorledofanexistingmachineinaCiscoUCS"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource-
- * LightoffthelocatorledofanexistingmachineinaCiscoUCS</a>
- */
- public void ledOn() {
- context.getApi().getInfrastructureApi().ledOn(target);
- }
-
- /**
- * Turn blade led off. The machine must belong to an UCS Rack. The blade must
- * belong to a Logic Server.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource-LightoffthelocatorledofanexistingmachineinaCiscoUCS"
- * > http://community.abiquo.com/display/ABI20/MachineResource-
- * LightoffthelocatorledofanexistingmachineinaCiscoUCS</a>
- */
- public void ledOff() {
- context.getApi().getInfrastructureApi().ledOff(target);
- }
-
- /**
- * Retrieve the led locator information as a {@link BladeLocatorLed}.
- *
- * @return Blade locator led representation.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Retrievethelocatorledoftheblade"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- Retrievethelocatorledoftheblade</a>
- */
- public BladeLocatorLed getLocatorLed() {
- BladeLocatorLedDto led = context.getApi().getInfrastructureApi().getLocatorLed(target);
-
- return wrap(context, BladeLocatorLed.class, led);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java
deleted file mode 100644
index 6735df2..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.BladeLocatorLedDto;
-
-/**
- * Adds high level functionality to {@link BladeLocatorLedDto}.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-Retrievethelocatorledoftheblade"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- Retrievethelocatorledoftheblade</a>
- */
-public class BladeLocatorLed extends DomainWrapper<BladeLocatorLedDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected BladeLocatorLed(final ApiContext<AbiquoApi> context, final BladeLocatorLedDto target) {
- super(context, target);
- }
-
- // Delegate Methods
-
- public String getAdminStatus() {
- return target.getAdminStatus();
- }
-
- public String getBladeDn() {
- return target.getBladeDn();
- }
-
- public String getColor() {
- return target.getColor();
- }
-
- public String getDn() {
- return target.getDn();
- }
-
- @Override
- public String toString() {
- return "BladeLocatorLed [Dn=" + getDn() + ", BladeDn=" + getBladeDn() + ", Color=" + getColor()
- + ", AdminStatus=" + getAdminStatus() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java
index 1debb12..25f8664 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java
@@ -16,9 +16,7 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
-import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
-import static com.google.common.collect.Iterables.getFirst;
import static com.google.common.collect.Iterables.transform;
import java.util.List;
@@ -35,7 +33,7 @@ import org.jclouds.abiquo.domain.network.Network;
import org.jclouds.abiquo.domain.network.NetworkServiceType;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.options.NetworkOptions;
-import org.jclouds.abiquo.predicates.network.NetworkServiceTypePredicates;
+import org.jclouds.abiquo.predicates.NetworkServiceTypePredicates;
import org.jclouds.rest.ApiContext;
import com.abiquo.model.enumerator.HypervisorType;
@@ -57,8 +55,6 @@ import com.abiquo.server.core.infrastructure.MachinesDto;
import com.abiquo.server.core.infrastructure.RackDto;
import com.abiquo.server.core.infrastructure.RacksDto;
import com.abiquo.server.core.infrastructure.RemoteServicesDto;
-import com.abiquo.server.core.infrastructure.UcsRackDto;
-import com.abiquo.server.core.infrastructure.UcsRacksDto;
import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto;
import com.abiquo.server.core.infrastructure.network.NetworkServiceTypesDto;
import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
@@ -69,7 +65,6 @@ import com.abiquo.server.core.infrastructure.storage.StorageDevicesDto;
import com.abiquo.server.core.infrastructure.storage.StorageDevicesMetadataDto;
import com.abiquo.server.core.infrastructure.storage.TiersDto;
import com.google.common.base.Function;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
/**
@@ -183,38 +178,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of unmanaged racks in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofRacks"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofRacks</a>
- * @return Filtered list of unmanaged racks in this datacenter.
- */
- public List<Rack> listRacks(final Predicate<Rack> filter) {
- return ImmutableList.copyOf(filter(listRacks(), filter));
- }
-
- /**
- * Retrieve the first unmanaged rack matching the filter within the list of
- * racks in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofRacks"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofRacks</a>
- * @return First unmanaged rack matching the filter or <code>null</code> if
- * the is none.
- */
- public Rack findRack(final Predicate<Rack> filter) {
- return getFirst(filter(listRacks(), filter), null);
- }
-
- /**
* Retrieve a single unmanaged rack.
*
* @param id
@@ -233,70 +196,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve the list of managed racks in this datacenter.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofUCSracks"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofUCSracks</a>
- * @return List of managed racks in this datacenter.
- */
- public List<ManagedRack> listManagedRacks() {
- UcsRacksDto racks = context.getApi().getInfrastructureApi().listManagedRacks(target);
- return wrap(context, ManagedRack.class, racks.getCollection());
- }
-
- /**
- * Retrieve a filtered list of managed racks in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofUCSracks"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofUCSracks</a>
- * @return Filtered list of managed racks in this datacenter.
- */
- public List<ManagedRack> listManagedRacks(final Predicate<ManagedRack> filter) {
- return ImmutableList.copyOf(filter(listManagedRacks(), filter));
- }
-
- /**
- * Retrieve the first managed rack matching the filter within the list of
- * racks in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofUCSracks"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofUCSracks</a>
- * @return First managed rack matching the filter or <code>null</code> if
- * there is none.
- */
- public ManagedRack findManagedRack(final Predicate<ManagedRack> filter) {
- return getFirst(filter(listManagedRacks(), filter), null);
- }
-
- /**
- * Retrieve a single managed rack.
- *
- * @param id
- * Unique ID of the rack in this datacenter.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaUCSRack"
- * >
- * http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * RetrieveaUCSRack</a>
- * @return Unmanaged rack with the given id or <code>null</code> if it does
- * not exist.
- */
- public ManagedRack getManagedRack(final Integer id) {
- UcsRackDto rack = context.getApi().getInfrastructureApi().getManagedRack(target, id);
- return wrap(context, ManagedRack.class, rack);
- }
-
- /**
* Retrieve the list of supported storage devices.
* <p>
* This method will get the list of the storage devices that are supported in
@@ -312,34 +211,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve the list of supported storage devices matching the filter.
- * <p>
- * This method will get the list of the storage devices that are supported in
- * the datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @return List of supported storage devices. This list has only the default
- * information for the storage devices, such as the management and
- * iscsi ports, or the default credentials to access the device.
- */
- public List<StorageDeviceMetadata> listSupportedStorageDevices(final Predicate<StorageDeviceMetadata> filter) {
- return ImmutableList.copyOf(filter(listSupportedStorageDevices(), filter));
- }
-
- /**
- * Retrieve a single supported storage devices matching the filter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @return First supported storage device matching the filter or
- * <code>null</code> if there is none.
- */
- public StorageDeviceMetadata findSupportedStorageDevice(final Predicate<StorageDeviceMetadata> filter) {
- return getFirst(filter(listSupportedStorageDevices(), filter), null);
- }
-
- /**
* Retrieve the list of storage devices in this datacenter.
*
* @see API: <a href=
@@ -354,38 +225,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of storage devices in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrievethelistofstoragedevices"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Retrievethelistofstoragedevices</a>
- * @return Filtered list of storage devices in this datacenter.
- */
- public List<StorageDevice> listStorageDevices(final Predicate<StorageDevice> filter) {
- return ImmutableList.copyOf(filter(listStorageDevices(), filter));
- }
-
- /**
- * Retrieve the first storage device matching the filter within the list of
- * devices in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrievethelistofstoragedevices"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Retrievethelistofstoragedevices</a>
- * @return First storage device matching the filter or <code>null</code> if
- * there is none.
- */
- public StorageDevice findStorageDevice(final Predicate<StorageDevice> filter) {
- return getFirst(filter(listStorageDevices(), filter), null);
- }
-
- /**
* Retrieve a single storage device.
*
* @param id
@@ -415,30 +254,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of network service types in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @return Filtered list of storage devices in this datacenter.
- */
- public List<NetworkServiceType> listNetworkServiceTypes(final Predicate<NetworkServiceType> filter) {
- return ImmutableList.copyOf(filter(listNetworkServiceTypes(), filter));
- }
-
- /**
- * Retrieve the first network service type matching the filter within the
- * list of nsts in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @return First network service type matching the filter or
- * <code>null</code> if there is none.
- */
- public NetworkServiceType findNetworkServiceType(final Predicate<NetworkServiceType> filter) {
- return getFirst(filter(listNetworkServiceTypes(), filter), null);
- }
-
- /**
* Retrieve a single network service type.
*
* @param id
@@ -476,38 +291,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
return wrap(context, RemoteService.class, remoteServices.getCollection());
}
- /**
- * Retrieve a filtered list of remote services of this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-RetrievealistofRemoteServices"
- * > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
- * RemoteServiceResource- RetrievealistofRemoteServices</a>
- * @return Filtered list of remote services in this datacenter.
- */
- public List<RemoteService> listRemoteServices(final Predicate<RemoteService> filter) {
- return ImmutableList.copyOf(filter(listRemoteServices(), filter));
- }
-
- /**
- * Retrieve the first remote service matching the filter within the list of
- * remote services in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource-RetrievealistofRemoteServices"
- * > http://community.abiquo.com/display/ABI20/RemoteServiceResource#
- * RemoteServiceResource- RetrievealistofRemoteServices</a>
- * @return First remote service matching the filter or <code>null</code> if
- * there is none.
- */
- public RemoteService findRemoteService(final Predicate<RemoteService> filter) {
- return getFirst(filter(listRemoteServices(), filter), null);
- }
-
private void createRemoteServices() {
createRemoteService(RemoteServiceType.BPM_SERVICE);
createRemoteService(RemoteServiceType.DHCP_SERVICE);
@@ -539,42 +322,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of datacenter limits by enterprises. The
- * Datacenter Limits resource allows you to assign datacenters and allocated
- * resources in them to be used by an enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrievelimitsbydatacenter"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrievelimitsbydatacenter</a>
- * @return Filtered list of datacenter limits by all enterprises.
- */
- public List<Limits> listLimits(final Predicate<Limits> filter) {
- return ImmutableList.copyOf(filter(listLimits(), filter));
- }
-
- /**
- * Retrieve the first datacenter limits matching the filter within the list
- * of datacenter limits by enterprise. The Datacenter Limits resource allows
- * you to assign datacenters and allocated resources in them to be used by an
- * enterprise.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrievelimitsbydatacenter"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrievelimitsbydatacenter</a>
- * @return First datacenter limits matching the filter or <code>null</code>
- * if there is none.
- */
- public Limits findLimits(final Predicate<Limits> filter) {
- return getFirst(filter(listLimits(), filter), null);
- }
-
- /**
* Retrieve the list of tiers in ths datacenter.
*
* @see API: <a href=
@@ -590,39 +337,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of tiers in this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers"
- * >
- * http://community.abiquo.com/display/ABI20/TierResource#TierResource-
- * Retrievethelistoftiers </a>
- * @return Filtered list of tiers in this datacenter.
- */
- public List<Tier> listTiers(final Predicate<Tier> filter) {
- return ImmutableList.copyOf(filter(listTiers(), filter));
- }
-
- /**
- * Retrieve the first tier matching the filter within the list of tiers in
- * this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrievethelistofstoragedevices"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Retrievethelistofstoragedevices</a>
- * @return First tier matching the filter or <code>null</code> if there is
- * none.
- */
- public Tier findTier(final Predicate<Tier> filter) {
- return getFirst(filter(listTiers(), filter), null);
- }
-
- /**
* Retrieve the list of public, external and unmanaged networks in this
* datacenter.
*
@@ -639,38 +353,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of public, external and unmanaged networks in
- * this datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource-Getthelistofpublicnetworks"
- * > http://community.abiquo.com/display/ABI20/PublicNetworkResource#
- * PublicNetworkResource- Getthelistofpublicnetworks</a>
- */
- public List<Network<?>> listNetworks(final Predicate<Network<?>> filter) {
- return ImmutableList.copyOf(filter(listNetworks(), filter));
- }
-
- /**
- * Retrieve the first network matching the filter within the list of
- * networks.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource-Getthelistofpublicnetworks"
- * > http://community.abiquo.com/display/ABI20/PublicNetworkResource#
- * PublicNetworkResource- Getthelistofpublicnetworks</a>
- * @return Filtered list of public, external and unmanaged networks in this
- * datacenter.
- */
- public Network<?> findNetwork(final Predicate<Network<?>> filter) {
- return getFirst(filter(listNetworks(), filter), null);
- }
-
- /**
* Retrieve the list of networks of this datacenter matching the given type.
*
* @param type
@@ -688,43 +370,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of networks of this datacenter matching the given
- * type.
- *
- * @param type
- * Network type filter.
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource-Getthelistofpublicnetworks"
- * > http://community.abiquo.com/display/ABI20/PublicNetworkResource#
- * PublicNetworkResource- Getthelistofpublicnetworks</a>
- * @return Filtered list of networks of this datacenter matching the given
- * type.
- */
- public List<Network<?>> listNetworks(final NetworkType type, final Predicate<Network<?>> filter) {
- return ImmutableList.copyOf(filter(listNetworks(type), filter));
- }
-
- /**
- * Retrieve the first network of the given type matching the filter.
- *
- * @param type
- * Network type filter.
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource-Getthelistofpublicnetworks"
- * > http://community.abiquo.com/display/ABI20/PublicNetworkResource#
- * PublicNetworkResource- Getthelistofpublicnetworks</a>
- * @return First network of the given type matching the filter or
- * <code>null</code> if there is none.
- */
- public Network<?> findNetwork(final NetworkType type, final Predicate<Network<?>> filter) {
- return getFirst(filter(listNetworks(type), filter), null);
- }
-
- /**
* Retrieve a single public, external or unmanaged network from this
* datacenter.
* {@link org.jclouds.abiquo.domain.network.Network#toExternalNetwork},
@@ -781,42 +426,9 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
*/
public List<HypervisorType> listAvailableHypervisors() {
HypervisorTypesDto types = context.getApi().getInfrastructureApi().getHypervisorTypes(target);
-
return getHypervisorTypes(types);
}
- /**
- * Retrieve a filtered list of available hypervisor types in the datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveavailablehypervisortypes"
- * http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrieveavailablehypervisortypes</a>
- * @return Filtered list of available hypervisor types in the datacenter.
- */
- public List<HypervisorType> listAvailableHypervisors(final Predicate<HypervisorType> filter) {
- return ImmutableList.copyOf(filter(listAvailableHypervisors(), filter));
- }
-
- /**
- * Retrieve the first hypervisor type matching the filter within the list of
- * types.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveavailablehypervisortypes"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrieveavailablehypervisortypes</a>
- * @return First hypervisor type matching the filter or <code>null</code> if
- * there is none.
- */
- public HypervisorType findHypervisor(final Predicate<HypervisorType> filter) {
- return getFirst(filter(listAvailableHypervisors(), filter), null);
- }
-
private List<HypervisorType> getHypervisorTypes(final HypervisorTypesDto dtos) {
return ImmutableList.copyOf(transform(dtos.getCollection(), new Function<HypervisorTypeDto, HypervisorType>() {
@Override
@@ -1082,48 +694,6 @@ public class Datacenter extends DomainWrapper<DatacenterDto> {
}
/**
- * Retrieve a filtered list of virtual machine templates in the repository of
- * this datacenter.
- *
- * @param enterprise
- * Owner of the templates.
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineTemplateResource#VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates"
- * > http://community.abiquo.com/display/ABI20/
- * VirtualMachineTemplateResource#
- * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates</a>
- * @return Filtered list of virtual machine templates in the repository of
- * this datacenter.
- */
- public List<VirtualMachineTemplate> listTemplatesInRepository(final Enterprise enterprise,
- final Predicate<VirtualMachineTemplate> filter) {
- return ImmutableList.copyOf(filter(listTemplatesInRepository(enterprise), filter));
- }
-
- /**
- * Retrieve the first virtual machine template within the list of templates
- * of this datacenter from the given enterprise.
- *
- * @param enterprise
- * Owner of the templates.
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineTemplateResource#VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates"
- * > http://community.abiquo.com/display/ABI20/
- * VirtualMachineTemplateResource#
- * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates</a>
- * @return First virtual machine template matching the filter or
- * <code>null</code> if there is none.
- */
- public VirtualMachineTemplate findTemplateInRepository(final Enterprise enterprise,
- final Predicate<VirtualMachineTemplate> filter) {
- return getFirst(filter(listTemplatesInRepository(enterprise), filter), null);
- }
-
- /**
* Retrieve a single virtual machine template in of this datacenter from the
* given enterprise.
*
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java
deleted file mode 100644
index 4c63125..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.FsmDto;
-
-/**
- * Adds high level functionality to {@link FsmDto}.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- * @see API: <a href="http://community.abiquo.com/display/ABI20/Rack+Resource">
- * http://community.abiquo.com/display/ABI20/Rack+Resource</a>
- */
-public class Fsm extends DomainWrapper<FsmDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected Fsm(final ApiContext<AbiquoApi> context, final FsmDto target) {
- super(context, target);
- }
-
- // Delegate Methods
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public String getDn() {
- return target.getDn();
- }
-
- public String getError() {
- return target.getError();
- }
-
- public String getProgress() {
- return target.getProgress();
- }
-
- public String getStatus() {
- return target.getStatus();
- }
-
- @Override
- public String toString() {
- return "Fsm [Dn=" + getDn() + ", Description=" + getDescription() + ", Error=" + getError() + ", Progress="
- + getProgress() + ", Status=" + getStatus() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java
deleted file mode 100644
index 78ce59a..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import java.util.List;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.LogicServerDto;
-import com.abiquo.server.core.infrastructure.LogicServerPolicyDto;
-
-/**
- * Adds high level functionality to {@link LogicServerDto}.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- * @see API: <a href="http://community.abiquo.com/display/ABI20/Rack+Resource">
- * http://community.abiquo.com/display/ABI20/Rack+Resource</a>
- */
-public class LogicServer extends DomainWrapper<LogicServerDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected LogicServer(final ApiContext<AbiquoApi> context, final LogicServerDto target) {
- super(context, target);
- }
-
- // Delegate Methods
-
- public String getName() {
- return target.getName();
- }
-
- public void setType(final String value) {
- target.setType(value);
- }
-
- public String getAssociated() {
- return target.getAssociated();
- }
-
- public String getType() {
- return target.getType();
- }
-
- public String getAssociatedTo() {
- return target.getAssociatedTo();
- }
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public void setDescription(final String value) {
- target.setDescription(value);
- }
-
- public List<LogicServerPolicyDto> getCollection() {
- return target.getCollection();
- }
-
- @Override
- public String toString() {
- return "LogicServer [name=" + getName() + ", associated=" + getAssociated() + ", type=" + getType()
- + ", associatedTo=" + getAssociatedTo() + ", description=" + getDescription() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java
index 3b7b0ad..dd851a8 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java
@@ -17,17 +17,14 @@
package org.jclouds.abiquo.domain.infrastructure;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.find;
import java.util.List;
import org.jclouds.abiquo.AbiquoApi;
+import org.jclouds.abiquo.domain.DomainWrapper;
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions;
-import org.jclouds.abiquo.predicates.infrastructure.DatastorePredicates;
-import org.jclouds.abiquo.predicates.infrastructure.NetworkInterfacePredicates;
import org.jclouds.abiquo.reference.ValidationErrors;
import org.jclouds.abiquo.reference.rest.ParentLinkName;
import org.jclouds.http.HttpResponse;
@@ -35,6 +32,7 @@ import org.jclouds.http.functions.ParseXMLWithJAXB;
import org.jclouds.rest.ApiContext;
import com.abiquo.model.enumerator.HypervisorType;
+import com.abiquo.model.enumerator.MachineIpmiState;
import com.abiquo.model.enumerator.MachineState;
import com.abiquo.model.rest.RESTLink;
import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
@@ -42,12 +40,10 @@ import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
import com.abiquo.server.core.enterprise.EnterpriseDto;
import com.abiquo.server.core.infrastructure.DatastoresDto;
import com.abiquo.server.core.infrastructure.MachineDto;
+import com.abiquo.server.core.infrastructure.MachineIpmiStateDto;
import com.abiquo.server.core.infrastructure.MachineStateDto;
import com.abiquo.server.core.infrastructure.RackDto;
import com.abiquo.server.core.infrastructure.network.NetworkInterfacesDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.inject.TypeLiteral;
/**
@@ -60,7 +56,13 @@ import com.google.inject.TypeLiteral;
* href="http://community.abiquo.com/display/ABI20/MachineResource">
* http://community.abiquo.com/display/ABI20/MachineResource</a>
*/
-public class Machine extends AbstractPhysicalMachine {
+public class Machine extends DomainWrapper<MachineDto> {
+ /** The default virtual ram used in MB. */
+ protected static final int DEFAULT_VRAM_USED = 1;
+
+ /** The default virtual cpu used in MB. */
+ protected static final int DEFAULT_VCPU_USED = 1;
+
/** The rack where the machine belongs. */
protected Rack rack;
@@ -91,7 +93,15 @@ public class Machine extends AbstractPhysicalMachine {
target = context.getApi().getInfrastructureApi().createMachine(rack.unwrap(), target);
}
- @Override
+ public void delete() {
+ context.getApi().getInfrastructureApi().deleteMachine(target);
+ target = null;
+ }
+
+ public void update() {
+ target = context.getApi().getInfrastructureApi().updateMachine(target);
+ }
+
public MachineState check() {
MachineStateDto dto = context.getApi().getInfrastructureApi().checkMachineState(target, true);
MachineState state = dto.getState();
@@ -99,6 +109,11 @@ public class Machine extends AbstractPhysicalMachine {
return state;
}
+ public MachineIpmiState checkIpmi() {
+ MachineIpmiStateDto dto = context.getApi().getInfrastructureApi().checkMachineIpmiState(target);
+ return dto.getState();
+ }
+
// Parent access
/**
* Retrieve the unmanaged rack where the machine is.
@@ -123,26 +138,14 @@ public class Machine extends AbstractPhysicalMachine {
// Children access
- @Override
public List<Datastore> getDatastores() {
return wrap(context, Datastore.class, target.getDatastores().getCollection());
}
- @Override
- public Datastore findDatastore(final String name) {
- return find(getDatastores(), DatastorePredicates.name(name), null);
- }
-
- @Override
public List<NetworkInterface> getNetworkInterfaces() {
return wrap(context, NetworkInterface.class, target.getNetworkInterfaces().getCollection());
}
- @Override
- public NetworkInterface findNetworkInterface(final String name) {
- return find(getNetworkInterfaces(), NetworkInterfacePredicates.name(name), null);
- }
-
/**
* Gets the list of virtual machines in the physical machine.
*
@@ -160,30 +163,10 @@ public class Machine extends AbstractPhysicalMachine {
return wrap(context, VirtualMachine.class, vms.getCollection());
}
- /**
- * Gets the list of virtual machines in the physical machine matching the
- * given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The list of virtual machines in the physical machine matching the
- * given filter.
- */
- public List<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter) {
- return ImmutableList.copyOf(filter(listVirtualMachines(), filter));
- }
-
- /**
- * Gets a single virtual machine in the physical machine matching the given
- * filter.
- *
- * @param filter
- * The filter to apply.
- * @return The virtual machine or <code>null</code> if none matched the given
- * filter.
- */
- public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
+ public VirtualMachine getVirtualMachine(final Integer virtualMachineId) {
+ VirtualMachineWithNodeExtendedDto vm = context.getApi().getInfrastructureApi()
+ .getVirtualMachine(target, virtualMachineId);
+ return wrap(context, VirtualMachine.class, vm);
}
/**
@@ -205,34 +188,6 @@ public class Machine extends AbstractPhysicalMachine {
}
/**
- * Gets the list of virtual machines in the physical machine matching the
- * given filter synchronizing virtual machines from remote hypervisor with
- * abiquo's database.
- *
- * @param filter
- * The filter to apply.
- * @return The list of remote virtual machines in the physical machine
- * matching the given filter.
- */
- public List<VirtualMachine> listRemoteVirtualMachines(final Predicate<VirtualMachine> filter) {
- return ImmutableList.copyOf(filter(listVirtualMachines(), filter));
- }
-
- /**
- * Gets a single virtual machine in the physical machine matching the given
- * filter synchronizing virtual machines from remote hypervisor with abiquo's
- * database.
- *
- * @param filter
- * The filter to apply.
- * @return The virtual machine or <code>null</code> if none matched the given
- * filter.
- */
- public VirtualMachine findRemoteVirtualMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
- }
-
- /**
* Reserve the machine for the given enterprise.
* <p>
* When a {@link Machine} is reserved for an {@link Enterprise}, only the
@@ -508,14 +463,165 @@ public class Machine extends AbstractPhysicalMachine {
// Delegate methods
+ public Integer getId() {
+ return target.getId();
+ }
+
+ public String getIp() {
+ return target.getIp();
+ }
+
+ public String getIpmiIp() {
+ return target.getIpmiIP();
+ }
+
+ public String getIpmiPassword() {
+ return target.getIpmiPassword();
+ }
+
+ public Integer getIpmiPort() {
+ return target.getIpmiPort();
+ }
+
+ public String getIpmiUser() {
+ return target.getIpmiUser();
+ }
+
+ public String getIpService() {
+ return target.getIpService();
+ }
+
+ public String getName() {
+ return target.getName();
+ }
+
+ public String getPassword() {
+ return target.getPassword();
+ }
+
+ public Integer getPort() {
+ return target.getPort();
+ }
+
+ public MachineState getState() {
+ return target.getState();
+ }
+
+ public HypervisorType getType() {
+ return target.getType();
+ }
+
+ public String getUser() {
+ return target.getUser();
+ }
+
+ public Integer getVirtualCpuCores() {
+ return target.getVirtualCpuCores();
+ }
+
+ public Integer getVirtualCpusUsed() {
+ return target.getVirtualCpusUsed();
+ }
+
+ public Integer getVirtualRamInMb() {
+ return target.getVirtualRamInMb();
+ }
+
+ public Integer getVirtualRamUsedInMb() {
+ return target.getVirtualRamUsedInMb();
+ }
+
+ public void setDatastores(final List<Datastore> datastores) {
+ DatastoresDto datastoresDto = new DatastoresDto();
+ datastoresDto.getCollection().addAll(DomainWrapper.unwrap(datastores));
+ target.setDatastores(datastoresDto);
+ }
+
+ public void setDescription(final String description) {
+ target.setDescription(description);
+ }
+
+ public void setIp(final String ip) {
+ target.setIp(ip);
+ }
+
+ public void setIpmiIp(final String ipmiIp) {
+ target.setIpmiIP(ipmiIp);
+ }
+
+ public void setIpmiPassword(final String ipmiPassword) {
+ target.setIpmiPassword(ipmiPassword);
+ }
+
+ public void setIpmiPort(final Integer ipmiPort) {
+ target.setIpmiPort(ipmiPort);
+ }
+
+ public void setIpmiUser(final String ipmiUser) {
+ target.setIpmiUser(ipmiUser);
+ }
+
+ public void setIpService(final String ipService) {
+ target.setIpService(ipService);
+ }
+
+ public void setName(final String name) {
+ target.setName(name);
+ }
+
+ public void setPassword(final String password) {
+ target.setPassword(password);
+ }
+
+ public void setPort(final Integer port) {
+ target.setPort(port);
+ }
+
+ public void setState(final MachineState state) {
+ target.setState(state);
+ }
+
+ public void setType(final HypervisorType type) {
+ target.setType(type);
+ }
+
+ public void setUser(final String user) {
+ target.setUser(user);
+ }
+
+ public void setVirtualCpuCores(final Integer virtualCpuCores) {
+ target.setVirtualCpuCores(virtualCpuCores);
+ }
+
+ public void setVirtualCpusUsed(final Integer virtualCpusUsed) {
+ target.setVirtualCpusUsed(virtualCpusUsed);
+ }
+
+ public void setVirtualRamInMb(final Integer virtualRamInMb) {
+ target.setVirtualRamInMb(virtualRamInMb);
+ }
+
+ public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb) {
+ target.setVirtualRamUsedInMb(virtualRamUsedInMb);
+ }
+
+ public String getDescription() {
+ return target.getDescription();
+ }
+
public void setRack(final Rack rack) {
this.rack = rack;
}
- public VirtualMachine getVirtualMachine(final Integer virtualMachineId) {
- VirtualMachineWithNodeExtendedDto vm = context.getApi().getInfrastructureApi()
- .getVirtualMachine(target, virtualMachineId);
- return wrap(context, VirtualMachine.class, vm);
+ @Override
+ public String toString() {
+ return "Machine [id=" + getId() + ", ip=" + getIp() + ", ipmiIp=" + getIpmiIp() + ", ipmiPassword="
+ + getIpmiPassword() + ", ipmiPort=" + getIpmiPort() + ", ipmiUser=" + getIpmiUser() + ", ipService="
+ + getIpService() + ", name=" + getName() + ", password=" + getPassword() + ", port=" + getPort()
+ + ", state=" + getState() + ", type=" + getType() + ", user=" + getUser() + ", virtualCpuCores="
+ + getVirtualCpuCores() + ", virtualCpusUsed=" + getVirtualCpusUsed() + ", getVirtualRamInMb()="
+ + getVirtualRamInMb() + ", virtualRamUsedInMb=" + getVirtualRamUsedInMb() + ", description="
+ + getDescription() + "]";
}
}
[3/8] JCLOUDS-156: Cleanup Abiquo provider
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
index 7bc99a1..2fd033c 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
@@ -73,11 +73,6 @@ public class ListVirtualDatacenters implements ListRootEntities<VirtualDatacente
return execute(userExecutor);
}
- @Override
- public Iterable<VirtualDatacenter> execute(final Predicate<VirtualDatacenter> selector) {
- return execute(userExecutor, selector);
- }
-
public Iterable<VirtualDatacenter> execute(final VirtualDatacenterOptions virtualDatacenterOptions) {
VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions);
return wrap(context, VirtualDatacenter.class, result.getCollection());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
index 50cd9aa..aeb8ac0 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
@@ -79,11 +79,6 @@ public class ListVirtualMachines implements ListRootEntities<VirtualMachine> {
return execute(userExecutor);
}
- @Override
- public Iterable<VirtualMachine> execute(final Predicate<VirtualMachine> selector) {
- return execute(userExecutor, selector);
- }
-
public Iterable<VirtualMachine> execute(ListeningExecutorService executor) {
return execute(executor, VirtualMachineOptions.builder().disablePagination().build());
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
index 79b5ada..d82d3ad 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
@@ -75,12 +75,6 @@ public class ListVirtualMachineTemplates implements ListEntities<VirtualMachineT
return execute(userExecutor, parent);
}
- @Override
- public Iterable<VirtualMachineTemplate> execute(final Enterprise parent,
- final Predicate<VirtualMachineTemplate> selector) {
- return execute(userExecutor, parent, selector);
- }
-
public Iterable<VirtualMachineTemplate> execute(ListeningExecutorService executor, final Enterprise parent) {
// Find virtual machine templates in concurrent requests
Iterable<Datacenter> dcs = parent.listAllowedDatacenters();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
index f4656e6..df98a03 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
@@ -77,11 +77,6 @@ public class ListMachines implements ListRootEntities<Machine> {
return execute(userExecutor);
}
- @Override
- public Iterable<Machine> execute(final Predicate<Machine> selector) {
- return execute(userExecutor, selector);
- }
-
public Iterable<Machine> execute(ListeningExecutorService executor) {
// Find machines in concurrent requests
DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
index e7a51c2..59601cd 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
@@ -51,7 +51,6 @@ public class AbiquoDelegateApiTest extends BaseAbiquoApiTest<AbiquoApi> {
assertNotNull(syncApi.getCloudApi());
assertNotNull(syncApi.getVirtualMachineTemplateApi());
assertNotNull(syncApi.getTaskApi());
- assertNotNull(syncApi.getPricingApi());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java b/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java
deleted file mode 100644
index 4992c6b..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.binders.infrastructure.ucs;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.Test;
-
-import com.abiquo.server.core.infrastructure.LogicServerDto;
-
-/**
- * Unit tests for the {@link BindLogicServerParameters} binder.
- *
- * @author Francesc Montserrat
- */
-@Test(groups = "unit", testName = "BindLogicServerParametersTest")
-public class BindLogicServerParametersTest {
- @Test(expectedExceptions = NullPointerException.class)
- public void testInvalidNullInput() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testInvalidTypeInput() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, new Object());
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testBindLogicServerWithEmptyName() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- LogicServerDto dto = new LogicServerDto();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, dto);
- }
-
- public void testBindLogicServer() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- LogicServerDto dto = new LogicServerDto();
- dto.setName("name");
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- HttpRequest newRequest = binder.bindToRequest(request, dto);
- assertEquals(newRequest.getRequestLine(), "GET http://localhost?lsName=name HTTP/1.1");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java b/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java
deleted file mode 100644
index 7735b48..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.binders.infrastructure.ucs;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.Test;
-
-import com.abiquo.server.core.infrastructure.OrganizationDto;
-
-/**
- * Unit tests for the {@link BindOrganizationParameters} binder.
- *
- * @author Francesc Montserrat
- */
-@Test(groups = "unit", testName = "BindOrganizationParametersTest")
-public class BindOrganizationParametersTest {
- @Test(expectedExceptions = NullPointerException.class)
- public void testInvalidNullInput() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testInvalidTypeInput() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, new Object());
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testBindLogicServerWithEmptyName() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- OrganizationDto dto = new OrganizationDto();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, dto);
- }
-
- public void testBindLogicServer() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- OrganizationDto dto = new OrganizationDto();
- dto.setDn("org");
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- HttpRequest newRequest = binder.bindToRequest(request, dto);
- assertEquals(newRequest.getRequestLine(), "GET http://localhost?org=org HTTP/1.1");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
index 82df566..2c46e51 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
@@ -21,12 +21,9 @@ import static org.jclouds.abiquo.domain.DomainUtils.link;
import com.abiquo.model.enumerator.RemoteServiceType;
import com.abiquo.model.rest.RESTLink;
import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.LogicServerDto;
import com.abiquo.server.core.infrastructure.MachineDto;
-import com.abiquo.server.core.infrastructure.OrganizationDto;
import com.abiquo.server.core.infrastructure.RackDto;
import com.abiquo.server.core.infrastructure.RemoteServiceDto;
-import com.abiquo.server.core.infrastructure.UcsRackDto;
import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto;
import com.abiquo.server.core.infrastructure.storage.StoragePoolDto;
import com.abiquo.server.core.infrastructure.storage.TierDto;
@@ -56,18 +53,6 @@ public class InfrastructureResources {
return rack;
}
- public static UcsRackDto managedRackPost() {
- UcsRackDto rack = new UcsRackDto();
- rack.setName("Aloha");
- rack.setShortDescription("A hawaian rack");
- rack.setHaEnabled(false);
- rack.setVlanIdMin(6);
- rack.setVlanIdMax(3024);
- rack.setVlanPerVdcReserved(6);
- rack.setNrsq(80);
- return rack;
- }
-
public static MachineDto machinePost() {
MachineDto machine = new MachineDto();
machine.setName("Kamehameha");
@@ -136,46 +121,6 @@ public class InfrastructureResources {
return rack;
}
- public static UcsRackDto managedRackPut() {
- UcsRackDto rack = managedRackPost();
- rack.setId(1);
- rack.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1"));
- rack.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/racks/1"));
- rack.addLink(new RESTLink("fsm", "http://localhost/api/admin/datacenters/1/racks/1/fsm"));
- rack.addLink(new RESTLink("logicservers", "http://localhost/api/admin/datacenters/1/racks/1/logicservers"));
- rack.addLink(new RESTLink("ls-templates", "http://localhost/api/admin/datacenters/1/racks/1/lstemplates"));
- rack.addLink(new RESTLink("organizations", "http://localhost/api/admin/datacenters/1/racks/1/organizations"));
- rack.addLink(new RESTLink("ls-associate",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/associate"));
- rack.addLink(new RESTLink("ls-associateclone",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/assocclone"));
- rack.addLink(new RESTLink("ls-associatetemplate",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/associatetemplate"));
- rack.addLink(new RESTLink("ls-clone", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/clone"));
- rack.addLink(new RESTLink("ls-delete", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/delete"));
- rack.addLink(new RESTLink("ls-dissociate",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/dissociate"));
- return rack;
- }
-
- public static LogicServerDto logicServerPut() {
- LogicServerDto logicServer = new LogicServerDto();
- logicServer.setName("server");
- logicServer.setAssociated("associated");
- logicServer.setType("instance");
-
- return logicServer;
- }
-
- public static OrganizationDto organizationPut() {
- OrganizationDto org = new OrganizationDto();
- org.setName("org");
- org.setDn("org-root/org-Finance");
- org.setLevel("1");
-
- return org;
- }
-
public static TierDto tierPut() {
TierDto tier = new TierDto();
tier.setId(1);
@@ -269,20 +214,6 @@ public class InfrastructureResources {
return buffer.toString();
}
- public static String managedRackPostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<ucsrack>");
- buffer.append("<haEnabled>false</haEnabled>");
- buffer.append("<name>Aloha</name>");
- buffer.append("<nrsq>80</nrsq>");
- buffer.append("<shortDescription>A hawaian rack</shortDescription>");
- buffer.append("<vlanIdMax>3024</vlanIdMax>");
- buffer.append("<vlanIdMin>6</vlanIdMin>");
- buffer.append("<vlanPerVdcReserved>6</vlanPerVdcReserved>");
- buffer.append("</ucsrack>");
- return buffer.toString();
- }
-
public static String storagePoolPostPayload() {
StringBuilder buffer = new StringBuilder();
buffer.append("<storagePool>");
@@ -402,33 +333,6 @@ public class InfrastructureResources {
return buffer.toString();
}
- public static String managedRackPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<ucsrack>");
- buffer.append(link("/admin/datacenters/1", "datacenter"));
- buffer.append(link("/admin/datacenters/1/racks/1", "edit"));
- buffer.append(link("/admin/datacenters/1/racks/1/fsm", "fsm"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers", "logicservers"));
- buffer.append(link("/admin/datacenters/1/racks/1/lstemplates", "ls-templates"));
- buffer.append(link("/admin/datacenters/1/racks/1/organizations", "organizations"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associate", "ls-associate"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/assocclone", "ls-associateclone"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associatetemplate", "ls-associatetemplate"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/clone", "ls-clone"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/delete", "ls-delete"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/dissociate", "ls-dissociate"));
- buffer.append("<haEnabled>false</haEnabled>");
- buffer.append("<id>1</id>");
- buffer.append("<name>Aloha</name>");
- buffer.append("<nrsq>80</nrsq>");
- buffer.append("<shortDescription>A hawaian rack</shortDescription>");
- buffer.append("<vlanIdMax>3024</vlanIdMax>");
- buffer.append("<vlanIdMin>6</vlanIdMin>");
- buffer.append("<vlanPerVdcReserved>6</vlanPerVdcReserved>");
- buffer.append("</ucsrack>");
- return buffer.toString();
- }
-
public static String storageDevicePutPayload() {
StringBuilder buffer = new StringBuilder();
buffer.append("<device>");
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java
deleted file mode 100644
index f8fe258..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain;
-
-import static org.jclouds.abiquo.domain.DomainUtils.link;
-
-import java.math.BigDecimal;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.pricing.CostCodeCurrenciesDto;
-import com.abiquo.server.core.pricing.CostCodeCurrencyDto;
-import com.abiquo.server.core.pricing.CostCodeDto;
-import com.abiquo.server.core.pricing.CurrencyDto;
-import com.abiquo.server.core.pricing.PricingCostCodeDto;
-import com.abiquo.server.core.pricing.PricingTemplateDto;
-import com.abiquo.server.core.pricing.PricingTierDto;
-
-/**
- * Enterprise domain utilities.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-public class PricingResources {
-
- public static CurrencyDto currencyPost() {
- CurrencyDto currency = new CurrencyDto();
- currency.setName("yuan");
- currency.setSymbol("DUMMY");
- currency.setDigits(3);
- return currency;
- }
-
- public static CurrencyDto currencyPut() {
- CurrencyDto currency = new CurrencyDto();
- currency.setName("yuan");
- currency.setSymbol("DUMMY");
- currency.setDigits(3);
- currency.setId(1);
- currency.addLink(new RESTLink("edit", "http://localhost/api/config/currencies/1"));
- return currency;
- }
-
- public static String currencyPostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<currency>");
- buffer.append("<symbol>DUMMY</symbol>");
- buffer.append("<digits>3</digits>");
- buffer.append("<name>yuan</name>");
- buffer.append("</currency>");
- return buffer.toString();
- }
-
- public static String currencyPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<currency>");
- buffer.append(link("/config/currencies/1", "edit"));
- buffer.append("<symbol>DUMMY</symbol>");
- buffer.append("<digits>3</digits>");
- buffer.append("<id>1</id>");
- buffer.append("<name>yuan</name>");
- buffer.append("</currency>");
- return buffer.toString();
- }
-
- public static Object costcodePost() {
- CostCodeDto costcode = new CostCodeDto();
- costcode.setName("cost code");
- costcode.setDescription("description");
- return costcode;
- }
-
- public static Object costcodePut() {
- CostCodeDto costcode = new CostCodeDto();
- costcode.setName("cost code");
- costcode.setDescription("description");
- costcode.setId(1);
- costcode.addLink(new RESTLink("edit", "http://localhost/api/config/costcodes/1"));
- return costcode;
- }
-
- public static String costcodePostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<costCode>");
- buffer.append("<name>cost code</name>");
- buffer.append("<description>description</description>");
- buffer.append("</costCode>");
- return buffer.toString();
- }
-
- public static String costcodePutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<costCode>");
- buffer.append(link("/config/costcodes/1", "edit"));
- buffer.append("<description>description</description>");
- buffer.append("<id>1</id>");
- buffer.append("<name>cost code</name>");
- buffer.append("</costCode>");
- return buffer.toString();
- }
-
- public static Object pricingtemplatePost() {
- PricingTemplateDto pricingtemplate = new PricingTemplateDto();
- pricingtemplate.setName("pricing template");
- pricingtemplate.setDescription("pt_description");
- pricingtemplate.setHdGB(new BigDecimal(0));
- pricingtemplate.setStandingChargePeriod(new BigDecimal(0));
- pricingtemplate.setVlan(new BigDecimal(0));
- pricingtemplate.setChargingPeriod(1);
- pricingtemplate.setMinimumChargePeriod(new BigDecimal(0));
- pricingtemplate.setShowChangesBefore(true);
- pricingtemplate.setShowMinimumCharge(false);
- pricingtemplate.setMinimumCharge(2);
- pricingtemplate.setPublicIp(new BigDecimal(0));
- pricingtemplate.setVcpu(new BigDecimal(0));
- pricingtemplate.setMemoryGB(new BigDecimal(0));
- pricingtemplate.setDefaultTemplate(true);
- pricingtemplate.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1"));
- return pricingtemplate;
- }
-
- public static Object pricingtemplatePut() {
- PricingTemplateDto pricingtemplate = new PricingTemplateDto();
- pricingtemplate.setName("pricing template");
- pricingtemplate.setDescription("pt_description");
- pricingtemplate.setHdGB(new BigDecimal(0));
- pricingtemplate.setStandingChargePeriod(new BigDecimal(0));
- pricingtemplate.setVlan(new BigDecimal(0));
- pricingtemplate.setChargingPeriod(1);
- pricingtemplate.setMinimumChargePeriod(new BigDecimal(0));
- pricingtemplate.setShowChangesBefore(true);
- pricingtemplate.setShowMinimumCharge(false);
- pricingtemplate.setMinimumCharge(2);
- pricingtemplate.setPublicIp(new BigDecimal(0));
- pricingtemplate.setVcpu(new BigDecimal(0));
- pricingtemplate.setMemoryGB(new BigDecimal(0));
- pricingtemplate.setDefaultTemplate(true);
- pricingtemplate.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1"));
- pricingtemplate.setId(1);
- pricingtemplate.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1"));
- return pricingtemplate;
- }
-
- public static String pricingtemplatePostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingTemplate>");
- buffer.append("<name>pricing template</name>");
- buffer.append("<description>pt_description</description>");
- buffer.append("<hdGB>0</hdGB>");
- buffer.append("<standingChargePeriod>0</standingChargePeriod>");
- buffer.append("<vlan>0</vlan>");
- buffer.append("<chargingPeriod>1</chargingPeriod>");
- buffer.append("<minimumChargePeriod>0</minimumChargePeriod>");
- buffer.append("<showChangesBefore>true</showChangesBefore>");
- buffer.append("<showMinimumCharge>false</showMinimumCharge>");
- buffer.append("<minimumCharge>2</minimumCharge>");
- buffer.append("<memoryGB>0</memoryGB>");
- buffer.append("<publicIp>0</publicIp>");
- buffer.append("<vcpu>0</vcpu>");
- buffer.append("<memoryMB>0</memoryMB>");
- buffer.append("<defaultTemplate>true</defaultTemplate>");
- buffer.append("<link href='http://localhost/api/config/currencies/1' rel='currency'/>");
- buffer.append("</pricingTemplate>");
- return buffer.toString();
- }
-
- public static String pricingtemplatePutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingTemplate>");
- buffer.append("<name>pricing template</name>");
- buffer.append("<description>pt_description</description>");
- buffer.append("<hdGB>0</hdGB>");
- buffer.append("<standingChargePeriod>0</standingChargePeriod>");
- buffer.append("<vlan>0</vlan>");
- buffer.append("<chargingPeriod>1</chargingPeriod>");
- buffer.append("<minimumChargePeriod>0</minimumChargePeriod>");
- buffer.append("<showChangesBefore>true</showChangesBefore>");
- buffer.append("<showMinimumCharge>false</showMinimumCharge>");
- buffer.append("<minimumCharge>2</minimumCharge>");
- buffer.append("<memoryGB>0</memoryGB>");
- buffer.append("<publicIp>0</publicIp>");
- buffer.append("<vcpu>0</vcpu>");
- buffer.append("<memoryMB>0</memoryMB>");
- buffer.append("<defaultTemplate>true</defaultTemplate>");
- buffer.append("<link href='http://localhost/api/config/currencies/1' rel='currency'/>");
- buffer.append("<id>1</id>");
- buffer.append(link("/config/pricingtemplates/1", "edit"));
- buffer.append("</pricingTemplate>");
- return buffer.toString();
- }
-
- public static Object costcodecurrencyPut() {
- CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto();
- costcodecurrency.addLink(new RESTLink("edit", "http://localhost/api/config/costcodes/1/currencies"));
- costcodecurrency.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1"));
- costcodecurrency.setPrice(new BigDecimal("300"));
- CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto();
- costcodecurrencies.add(costcodecurrency);
- return costcodecurrencies;
- }
-
- public static String costcodecurrencyPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<costCodeCurrencies>");
- buffer.append("<costCodeCurrency>");
- buffer.append("<price>300</price>");
- buffer.append("<link href='http://localhost/api/config/costcodes/1/currencies' rel='edit'/>");
- buffer.append("<link href='http://localhost/api/config/currencies/1' rel='currency'/>");
- buffer.append("</costCodeCurrency>");
-
- buffer.append("</costCodeCurrencies>");
- return buffer.toString();
- }
-
- public static Object pricingCostcodePut() {
- PricingCostCodeDto pricingcostcode = new PricingCostCodeDto();
- pricingcostcode.setId(1);
- pricingcostcode.setPrice(new BigDecimal("400"));
- pricingcostcode.addLink(new RESTLink("costcode", "http://localhost/api/config/costcodes/1"));
- pricingcostcode.addLink(new RESTLink("pricingtemplate", "http://localhost/api/config/pricingtemplates/1"));
- pricingcostcode.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1/costcodes/1"));
- return pricingcostcode;
- }
-
- public static String pricingCostCodePutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingCostCode>");
- buffer.append("<link href='http://localhost/api/config/costcodes/1' rel='costcode'/>");
- buffer.append("<link href='http://localhost/api/config/pricingtemplates/1' rel='pricingtemplate'/>");
- buffer.append("<price>400</price>");
- buffer.append("<id>1</id>");
- buffer.append(link("/config/pricingtemplates/1/costcodes/1", "edit"));
- buffer.append("</pricingCostCode>");
- return buffer.toString();
- }
-
- public static Object pricingTierPut() {
- PricingTierDto pricingtier = new PricingTierDto();
- pricingtier.setId(1);
- pricingtier.setPrice(new BigDecimal("600"));
- pricingtier.addLink(new RESTLink("tier", "http://localhost/api/admin/datacenters/1/storage/tiers/2"));
- pricingtier.addLink(new RESTLink("pricingtemplate", "http://localhost/api/config/pricingtemplates/1"));
- pricingtier.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1/tiers/2"));
- return pricingtier;
- }
-
- public static String pricingTierPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingTier>");
- buffer.append("<link href='http://localhost/api/admin/datacenters/1/storage/tiers/2' rel='tier'/>");
- buffer.append("<link href='http://localhost/api/config/pricingtemplates/1' rel='pricingtemplate'/>");
- buffer.append("<price>600</price>");
- buffer.append("<id>1</id>");
- buffer.append(link("/config/pricingtemplates/1/tiers/2", "edit"));
- buffer.append("</pricingTier>");
- return buffer.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
index b99c9cb..38f139a 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
@@ -16,9 +16,9 @@
*/
package org.jclouds.abiquo.domain.admin;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.util.List;
@@ -30,12 +30,11 @@ import org.jclouds.abiquo.domain.config.Privilege;
import org.jclouds.abiquo.domain.enterprise.Role;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PrivilegePredicates;
-import org.jclouds.abiquo.predicates.enterprise.RolePredicates;
import org.testng.annotations.Test;
import com.abiquo.server.core.enterprise.PrivilegeDto;
import com.abiquo.server.core.enterprise.RoleDto;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
/**
@@ -73,28 +72,33 @@ public class RoleLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testCreateEnterpriseRole() {
- Role entRole = Role.Builder.fromRole(env.role).build();
+ final Role entRole = Role.Builder.fromRole(env.role).build();
entRole.setName(entRole.getName() + "enterprise");
entRole.setEnterprise(env.enterprise);
entRole.save();
- entRole = env.enterprise.findRole(RolePredicates.name(entRole.getName()));
-
- assertNotNull(entRole);
+ find(env.enterprise.listRoles(), new Predicate<Role>() {
+ @Override
+ public boolean apply(Role input) {
+ return input.getName().equals(entRole.getName());
+ }
+ });
}
public void testAddPrivilege() {
PrivilegeDto dto = env.configApi.getPrivilege(8);
- Privilege privilege = DomainWrapper.wrap(env.context.getApiContext(), Privilege.class, dto);
+ final Privilege privilege = DomainWrapper.wrap(env.context.getApiContext(), Privilege.class, dto);
List<Privilege> privileges = Lists.newArrayList(env.role.listPrivileges());
privileges.add(privilege);
env.role.setPrivileges(privileges);
-
env.role.update();
- privilege = env.role.findPrivileges(PrivilegePredicates.name(dto.getName()));
-
- assertNotNull(privilege);
+ find(env.role.listPrivileges(), new Predicate<Privilege>() {
+ @Override
+ public boolean apply(Privilege input) {
+ return input.getName().equals(privilege.getName());
+ }
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
index f9856f7..4be19aa 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.getLast;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
@@ -27,12 +28,12 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.features.services.MonitoringService;
import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.abiquo.server.core.cloud.VirtualApplianceState;
import com.abiquo.server.core.cloud.VirtualMachineState;
+import com.google.common.base.Predicate;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Longs;
@@ -109,9 +110,15 @@ public class VirtualApplianceLiveTest extends BaseAbiquoLiveApiTest {
@Test(dependsOnMethods = "testUndeployVirtualAppliance")
public void testDeleteVirtualAppliance() {
+ final String name = vapp.getName();
vapp.delete();
- assertNull(view.getCloudService().findVirtualAppliance(
- VirtualAppliancePredicates.name(PREFIX + "Virtual Appliance Updated")));
+
+ assertNull(find(view.getCloudService().listVirtualAppliances(), new Predicate<VirtualAppliance>() {
+ @Override
+ public boolean apply(VirtualAppliance input) {
+ return input.getName().equals(name);
+ }
+ }, null));
}
private static Ordering<VirtualMachineTemplate> templateBySize() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
index 5f542a0..c6c6fdd 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.size;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
@@ -33,12 +34,11 @@ import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.PublicIp;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
import org.testng.annotations.Test;
import com.abiquo.model.enumerator.HypervisorType;
import com.abiquo.server.core.cloud.VirtualDatacenterDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link VirtualDatacenter} domain class.
@@ -130,15 +130,24 @@ public class VirtualDatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testPurchaseIp() {
- PublicIp publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0);
+ final PublicIp publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0);
assertNotNull(publicIp);
env.virtualDatacenter.purchasePublicIp(publicIp);
- PublicIp apiIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(publicIp.getIp()));
- assertNotNull(apiIp);
+ PublicIp apiIp = find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(publicIp.getIp());
+ }
+ });
env.virtualDatacenter.releasePublicIp(apiIp);
- apiIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(publicIp.getIp()));
+ apiIp = find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(publicIp.getIp());
+ }
+ }, null);
assertNull(apiIp);
}
@@ -159,16 +168,6 @@ public class VirtualDatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
@Test(dependsOnMethods = "testGetAvailableTemplates")
- public void testFindAvailableTemplate() {
- VirtualMachineTemplate templateFound = env.virtualDatacenter
- .findAvailableTemplate(VirtualMachineTemplatePredicates.id(template.getId()));
-
- assertNotNull(template);
- assertNotNull(templateFound);
- assertEquals(templateFound.getId(), template.getId());
- }
-
- @Test(dependsOnMethods = "testGetAvailableTemplates")
public void testGetAvailableTemplate() {
VirtualMachineTemplate templateFound = env.virtualDatacenter.getAvailableTemplate(template.getId());
assertNotNull(templateFound);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
index aaba872..1d2aedd 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.getLast;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.jclouds.abiquo.util.Assert.assertHasError;
@@ -34,13 +35,12 @@ import org.jclouds.abiquo.domain.network.Ip;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.features.services.MonitoringService;
import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VirtualMachinePredicates;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.abiquo.server.core.cloud.VirtualMachineState;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Longs;
@@ -99,8 +99,12 @@ public class VirtualMachineLiveTest extends BaseAbiquoLiveApiTest {
AsyncTask task = vm.update();
assertNull(task);
- VirtualMachine updated = vapp.findVirtualMachine(VirtualMachinePredicates.nameLabel(PREFIX + "VM Kane Updated"));
- assertNotNull(updated);
+ find(vapp.listVirtualMachines(), new Predicate<VirtualMachine>() {
+ @Override
+ public boolean apply(VirtualMachine input) {
+ return input.getNameLabel().equals(PREFIX + "VM Kane Updated");
+ }
+ });
}
@Test(dependsOnMethods = "testUpdateVirtualMachineWhenNotDeployed")
@@ -123,13 +127,19 @@ public class VirtualMachineLiveTest extends BaseAbiquoLiveApiTest {
@Test(dependsOnMethods = "testChangeVirtualMachineState")
public void testReconfigure() {
- Ip<?, ?> ip = getLast(vdc.getDefaultNetwork().listUnusedIps());
+ final Ip<?, ?> ip = getLast(vdc.getDefaultNetwork().listUnusedIps());
AsyncTask task = vm.setNics(Lists.<Ip<?, ?>> newArrayList(ip));
assertNotNull(task);
monitoringService.getVirtualMachineMonitor().awaitState(MAX_WAIT, TimeUnit.MINUTES, VirtualMachineState.OFF, vm);
- assertNotNull(vm.findAttachedNic(IpPredicates.address(ip.getIp())));
+
+ find(vm.listAttachedNics(), new Predicate<Ip<?, ?>>() {
+ @Override
+ public boolean apply(Ip<?, ?> input) {
+ return input.getIp().equals(ip.getIp());
+ }
+ });
}
@Test(dependsOnMethods = "testReconfigure")
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
index baa6aee..c1fc61b 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -36,11 +37,11 @@ import org.jclouds.abiquo.domain.network.UnmanagedIp;
import org.jclouds.abiquo.domain.network.UnmanagedNetwork;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
/**
@@ -73,9 +74,12 @@ public class VirtualMachineNetworkingLiveApiTest extends BaseAbiquoApiLiveApiTes
publicIpInfrastructure = env.virtualDatacenter.listAvailablePublicIps().get(0);
env.virtualDatacenter.purchasePublicIp(publicIpInfrastructure);
- publicIpCloud = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates
- .<PublicIp> address(publicIpInfrastructure.getIp()));
- assertNotNull(publicIpCloud);
+ publicIpCloud = find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(publicIpInfrastructure.getIp());
+ }
+ });
}
@AfterClass
@@ -87,9 +91,15 @@ public class VirtualMachineNetworkingLiveApiTest extends BaseAbiquoApiLiveApiTes
assertEquals(nics.size(), 1);
assertEquals(nics.get(0).getId(), privateIp.getId());
- String address = publicIpCloud.getIp();
+ final String address = publicIpCloud.getIp();
env.virtualDatacenter.releasePublicIp(publicIpCloud);
- assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(address)));
+
+ assertNull(find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(address);
+ }
+ }, null));
}
// TODO: Infrastructure edit link for public ips can not be used to attach
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
index 05d2889..82a2708 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -27,9 +28,10 @@ import java.util.List;
import org.jclouds.abiquo.domain.infrastructure.Tier;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
+
/**
* Live integration tests for the {@link VirtualMachine} storage operations.
*
@@ -110,7 +112,12 @@ public class VirtualMachineStorageLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
private Volume createVolume() {
- Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName()));
+ Tier tier = find(env.virtualDatacenter.listStorageTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals(env.tier.getName());
+ }
+ });
Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier)
.name(PREFIX + "Hawaian volume").sizeInMb(32).build();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
index 1a20e3a..a671989 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -29,11 +30,10 @@ import org.jclouds.abiquo.domain.infrastructure.Tier;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VolumePredicates;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link Volume} domain class.
@@ -44,7 +44,12 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testCreateVolume() {
// We need the vdc-relative tier
- Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName()));
+ Tier tier = find(env.virtualDatacenter.listStorageTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals(env.tier.getName());
+ }
+ });
Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier)
.name(PREFIX + "Hawaian volume").sizeInMb(32).build();
@@ -71,8 +76,7 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
@Test(dependsOnMethods = "testFilterVolumes")
public void testUpdateVolume() {
- Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name(PREFIX + "Hawaian volume"));
- assertNotNull(volume);
+ Volume volume = find(env.virtualDatacenter.listVolumes(), volumeName(PREFIX + "Hawaian volume"));
volume.setName("Hawaian volume updated");
AsyncTask task = volume.update();
@@ -94,9 +98,7 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
newVdc.save();
assertNotNull(newVdc.getId());
- Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated"));
- assertNotNull(volume);
-
+ Volume volume = find(env.virtualDatacenter.listVolumes(), volumeName("Hawaian volume updated"));
volume.moveTo(newVdc);
// Check that the underlying Dto has been updated to the new VDC
@@ -115,8 +117,7 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
@Test(dependsOnMethods = "testMoveVolume")
public void testDeleteVolume() {
- Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated"));
- assertNotNull(volume);
+ Volume volume = find(env.virtualDatacenter.listVolumes(), volumeName("Hawaian volume updated"));
Integer id = volume.getId();
volume.delete();
@@ -124,4 +125,13 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertNull(env.virtualDatacenter.getVolume(id));
}
+ private static Predicate<Volume> volumeName(final String name) {
+ return new Predicate<Volume>() {
+ @Override
+ public boolean apply(Volume input) {
+ return input.getName().equals(name);
+ }
+ };
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
index 2341e3f..33cb292 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
@@ -16,14 +16,15 @@
*/
package org.jclouds.abiquo.domain.config;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.CategoryPredicates;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
+
/**
* Live integration tests for the {@link Category} domain class.
*
@@ -35,10 +36,12 @@ public class CategoryLiveApiTest extends BaseAbiquoApiLiveApiTest {
Category category = Category.builder(env.context.getApiContext()).name(PREFIX + "-test-category").build();
category.save();
- Category apiCategory = env.context.getAdministrationService().findCategory(
- CategoryPredicates.name(PREFIX + "-test-category"));
- assertNotNull(apiCategory);
- assertEquals(category.getName(), apiCategory.getName());
+ Category apiCategory = find(env.context.getAdministrationService().listCategories(), new Predicate<Category>() {
+ @Override
+ public boolean apply(Category input) {
+ return input.getName().equals(PREFIX + "-test-category");
+ }
+ });
apiCategory.delete();
}
@@ -54,11 +57,12 @@ public class CategoryLiveApiTest extends BaseAbiquoApiLiveApiTest {
category.setName(PREFIX + "-test-category-updated");
category.update();
- Category apiCategory = env.context.getAdministrationService().findCategory(
- CategoryPredicates.name(PREFIX + "-test-category-updated"));
-
- assertNotNull(apiCategory);
- assertEquals(PREFIX + "-test-category-updated", apiCategory.getName());
+ find(env.context.getAdministrationService().listCategories(), new Predicate<Category>() {
+ @Override
+ public boolean apply(Category input) {
+ return input.getName().equals(PREFIX + "-test-category-updated");
+ }
+ });
category.setName(name);
category.update();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java
deleted file mode 100644
index 0a55f88..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.jclouds.abiquo.util.Assert.assertHasError;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-import javax.ws.rs.core.Response.Status;
-
-import com.google.common.collect.Lists;
-
-import org.jclouds.abiquo.domain.exception.AbiquoException;
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PricingPredicates;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Live integration tests for the {@link CostCode} domain class.
- *
- * @author Susana Acedo
- */
-@Test(groups = "api", testName = "CostCodeLiveApiTest")
-public class CostCodeLiveApiTest extends BaseAbiquoApiLiveApiTest {
- private CostCode costcode;
-
- private Currency currency;
-
- private CostCodePrice costcodeprice;
-
- private List<CostCodePrice> defaultPrices;
-
- @BeforeClass
- public void setupCostCode() {
- currency = Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency").symbol("test-$")
- .digits(2).build();
- currency.save();
-
- costcode = CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode")
- .description("description").build();
-
- costcode.save();
- }
-
- @AfterClass
- public void tearDownCostCode() {
- currency.delete();
- costcode.delete();
- }
-
- public void testCreateRepeated() {
- CostCode repeated = CostCode.Builder.fromCostCode(costcode).build();
-
- try {
- repeated.save();
- fail("Should not be able to create costcodes with the same name");
- } catch (AbiquoException ex) {
- assertHasError(ex, Status.CONFLICT, "COSTCODE-2");
- }
- }
-
- public void testUpdate() {
- costcode.setName(PREFIX + "costcode-updated");
- costcode.update();
-
- CostCode apiCostCode = env.context.getPricingService().findCostCode(
- PricingPredicates.costCode(PREFIX + "costcode-updated"));
-
- assertNotNull(apiCostCode);
- assertEquals(PREFIX + "costcode-updated", apiCostCode.getName());
-
- }
-
- public void testCreateCostCodewithDefaultPrices() {
- CostCode costcode2 = CostCode.builder(env.context.getApiContext()).name(PREFIX + "ccdefaultprice")
- .description("description").build();
-
- costcodeprice = new CostCodePrice(currency, new BigDecimal(100));
- this.defaultPrices = Lists.newArrayList();
- defaultPrices.add(costcodeprice);
- costcode2.setDefaultPrices(defaultPrices);
- // When a cost code is created it is also created a costcodecurrency with
- // price 0 and after
- // that if a list of prices(CostCodePrice) has been sent this costcode is
- // updated with the
- // new price
- costcode2.save();
-
- // check that costcode has been created
- CostCode apiCostCode = env.context.getPricingService().findCostCode(
- PricingPredicates.costCode(PREFIX + "ccdefaultprice"));
-
- assertNotNull(apiCostCode);
- assertEquals(PREFIX + "ccdefaultprice", apiCostCode.getName());
-
- // check that the price has been modified in the
- Iterable<CostCodeCurrency> costcodecurrencies = env.context.getPricingService().getCostCodeCurrencies(
- costcode2.getId(), currency.getId());
- for (CostCodeCurrency costcodecurrency : costcodecurrencies) {
- assertEquals(costcodecurrency.getPrice().compareTo(new BigDecimal(100)), 0);
- }
-
- costcode2.delete();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java
deleted file mode 100644
index 2bb7e1f..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PricingPredicates;
-import org.testng.annotations.Test;
-
-/**
- * Live integration tests for the {@link Currency} domain class.
- *
- * @author Susana Acedo
- */
-@Test(groups = "api", testName = "CurrencyLiveApiTest")
-public class CurrencyLiveApiTest extends BaseAbiquoApiLiveApiTest {
- public void testCreateAndGet() {
- Currency currency = Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency").symbol("test-$")
- .digits(2).build();
- currency.save();
-
- Currency apiCurrency = env.context.getPricingService().findCurrency(
- PricingPredicates.currency(PREFIX + "test-currency"));
- assertNotNull(apiCurrency);
- assertEquals(currency.getName(), apiCurrency.getName());
-
- apiCurrency.delete();
- }
-
- @Test(dependsOnMethods = "testCreateAndGet")
- public void testUpdate() {
- Iterable<Currency> currencies = env.context.getPricingService().listCurrencies();
- assertNotNull(currencies);
-
- Currency currency = currencies.iterator().next();
- String name = currency.getName();
-
- currency.setName(PREFIX + "t-currency-upd");
- currency.update();
-
- Currency apiCurrency = env.context.getPricingService().findCurrency(
- PricingPredicates.currency(PREFIX + "t-currency-upd"));
-
- assertNotNull(apiCurrency);
- assertEquals(PREFIX + "t-currency-upd", apiCurrency.getName());
-
- currency.setName(name);
- currency.update();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java
deleted file mode 100644
index 9155f49..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.jclouds.abiquo.util.Assert.assertHasError;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.math.BigDecimal;
-import java.util.Collection;
-import java.util.Date;
-
-import javax.ws.rs.core.Response.Status;
-
-import org.jclouds.abiquo.domain.exception.AbiquoException;
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PricingPredicates;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.abiquo.model.enumerator.PricingPeriod;
-
-/**
- * Live integration tests for the {@link PricingTemplate} domain class.
- *
- * @author Susana Acedo
- */
-@Test(groups = "api", testName = "PricingTemplateLiveApiTest")
-public class PricingTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest {
- private PricingTemplate pricingTemplate;
-
- private Currency currency;
-
- private CostCode costcode;
-
- private BigDecimal zero = new BigDecimal(0);
-
- @BeforeClass
- public void setupPricingTemplate() {
- Iterable<Currency> currencies = env.context.getPricingService().listCurrencies();
- currency = currencies.iterator().next();
-
- costcode = CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode")
- .description("description").build();
-
- costcode.save();
-
- pricingTemplate = PricingTemplate.builder(env.context.getApiContext(), currency).name("pricing_template")
- .description("description").hdGB(zero).standingChargePeriod(zero).vlan(zero)
- .chargingPeriod(PricingPeriod.MONTH).minimumChargePeriod(zero).showChangesBefore(true)
- .showMinimumCharge(false).minimumCharge(PricingPeriod.WEEK).publicIp(zero).vcpu(zero).memoryGB(zero)
- .defaultTemplate(true).lastUpdate(new Date()).build();
-
- pricingTemplate.save();
- }
-
- @AfterClass
- public void tearDownPricingTemplate() {
- pricingTemplate.delete();
- costcode.delete();
- }
-
- public void testCreateRepeated() {
- PricingTemplate repeated = PricingTemplate.Builder.fromPricingTemplate(pricingTemplate).build();
-
- try {
- repeated.save();
- fail("Should not be able to create pricingtemplates with the same name");
- } catch (AbiquoException ex) {
- assertHasError(ex, Status.CONFLICT, "PRICINGTEMPLATE-2");
- }
- }
-
- public void testUpdate() {
- pricingTemplate.setName(PREFIX + "pt-updated");
- pricingTemplate.update();
-
- PricingTemplate apiPricingTemplate = env.context.getPricingService().findPricingTemplate(
- PricingPredicates.pricingTemplate(PREFIX + "pt-updated"));
-
- assertNotNull(apiPricingTemplate);
- assertEquals(PREFIX + "pt-updated", apiPricingTemplate.getName());
-
- }
-
- // when a pricing template is created, pricing cost codes for each existent
- // cost code are also
- // created with price 0
- public void getPricingCostCodes() {
- Collection<PricingCostCode> pricingCostCodes = env.context.getPricingService().getPricingCostCodes(
- pricingTemplate.getId());
- assertEquals(pricingCostCodes.size(), 1);
- assertNotNull(pricingCostCodes);
- for (PricingCostCode pc : pricingCostCodes) {
- assertEquals(pc.getPrice().compareTo(zero), 0);
- }
- }
-
- // when a pricing template is created, pricing tiers are also created with
- // price 0
- public void getPricingTiers() {
- Collection<PricingTier> pricingTiers =
-
- env.context.getPricingService().getPricingTiers(pricingTemplate.getId());
- assertEquals(pricingTiers.size(), 4);
- assertNotNull(pricingTiers);
- for (PricingTier pt : pricingTiers) {
- assertEquals(pt.getPrice().compareTo(zero), 0);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
index d9af7f3..b5909a5 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
@@ -16,6 +16,8 @@
*/
package org.jclouds.abiquo.domain.enterprise;
+import static com.google.common.collect.Iterables.filter;
+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.assertNull;
@@ -23,11 +25,12 @@ import static org.testng.Assert.assertNull;
import java.util.List;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.enterprise.TemplateDefinitionListPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
+
/**
* Live integration tests for the {@link TemplateDefinitionList} domain class.
*
@@ -41,10 +44,15 @@ public class TemplateDefinitionListLiveApiTest extends BaseAbiquoApiLiveApiTest
list.setName(list.getName() + "Updated");
list.update();
- List<TemplateDefinitionList> lists = env.enterprise.listTemplateDefinitionLists(TemplateDefinitionListPredicates
- .name("myListUpdated"));
+ Iterable<TemplateDefinitionList> lists = filter(env.enterprise.listTemplateDefinitionLists(),
+ new Predicate<TemplateDefinitionList>() {
+ @Override
+ public boolean apply(TemplateDefinitionList input) {
+ return input.getName().equals("myListUpdated");
+ }
+ });
- assertEquals(lists.size(), 1);
+ assertEquals(size(lists), 1);
}
public void testListStates() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
index 02dadec..4250431 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
@@ -16,7 +16,9 @@
*/
package org.jclouds.abiquo.domain.enterprise;
-import static org.jclouds.abiquo.predicates.enterprise.UserPredicates.nick;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.size;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -26,10 +28,10 @@ import javax.ws.rs.core.Response.Status;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.enterprise.UserPredicates;
import org.testng.annotations.Test;
import com.abiquo.server.core.enterprise.UserDto;
+import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
/**
@@ -69,7 +71,7 @@ public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest {
env.user.setRole(env.anotherRole);
env.user.update();
- Role role2 = env.enterprise.findUser(UserPredicates.nick(env.user.getNick())).getRole();
+ Role role2 = find(env.enterprise.listUsers(), nick(env.user.getNick())).getRole();
assertEquals(env.anotherRole.getId(), role2.getId());
assertEquals(role2.getName(), "Another role");
@@ -82,11 +84,11 @@ public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest {
Iterable<User> users = env.enterprise.listUsers();
assertEquals(Iterables.size(users), 2);
- users = env.enterprise.listUsers(nick(env.user.getNick()));
- assertEquals(Iterables.size(users), 1);
+ users = filter(env.enterprise.listUsers(), nick(env.user.getNick()));
+ assertEquals(size(users), 1);
- users = env.enterprise.listUsers(nick(env.user.getName() + "FAIL"));
- assertEquals(Iterables.size(users), 0);
+ users = filter(env.enterprise.listUsers(), nick(env.user.getName() + "FAIL"));
+ assertEquals(size(users), 0);
}
public void testGetCurrentUser() {
@@ -94,4 +96,13 @@ public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertNotNull(user);
assertEquals(user.getNick(), env.context.getApiContext().getIdentity());
}
+
+ private static Predicate<User> nick(final String nick) {
+ return new Predicate<User>() {
+ @Override
+ public boolean apply(User input) {
+ return input.getNick().equals(nick);
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
index d4e2dcf..5fd46e1 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.event;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -29,12 +30,12 @@ import org.jclouds.abiquo.domain.enterprise.User;
import org.jclouds.abiquo.domain.event.options.EventOptions;
import org.jclouds.abiquo.domain.infrastructure.Tier;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
import com.abiquo.model.enumerator.ComponentType;
import com.abiquo.model.enumerator.EventType;
import com.abiquo.model.enumerator.SeverityType;
+import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
/**
@@ -81,8 +82,12 @@ public class EventLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testListEventsFilteredByStoragePool() {
- Tier tier = env.datacenter.findTier(TierPredicates.name("Default Tier 2"));
- assertNotNull(tier);
+ Tier tier = find(env.datacenter.listTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals("Default Tier 2");
+ }
+ });
try {
env.storagePool.setTier(tier);
@@ -215,7 +220,13 @@ public class EventLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
private Volume createVolume() {
- Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName()));
+ Tier tier = find(env.virtualDatacenter.listStorageTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals(env.tier.getName());
+ }
+ });
+
Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier)
.name(PREFIX + "Event vol").sizeInMb(32).build();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java
deleted file mode 100644
index 636ead6..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.util.Config;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-
-/**
- * Live integration tests for the {@link Blade} domain class.
- *
- * @author Ignasi Barrera
- */
-@Test(groups = "ucs", testName = "BladeLiveUcsTest")
-public class BladeLiveUcsTest extends BaseAbiquoApiLiveApiTest {
- Blade blade;
-
- public void testFindAvailableVirtualSwitch() {
- String vswitch = Config.get("abiquo.hypervisor.vswitch");
- NetworkInterface found = env.machine.findAvailableVirtualSwitch(vswitch);
- assertEquals(found, vswitch);
- }
-
- public void testGetRack() {
- ManagedRack rack = blade.getRack();
- assertNotNull(rack);
- assertEquals(rack.getId(), env.ucsRack.getId());
- }
-
- public void testListBlades() {
- Iterable<Blade> blades = env.ucsRack.listMachines();
- assertTrue(Iterables.size(blades) > 0);
- }
-
- public void testGetLogicServer() {
- LogicServer logicServer = blade.getLogicServer();
- assertNotNull(logicServer);
- assertNotNull(logicServer.getName());
- }
-
- public void testLedOn() {
- blade.ledOn();
- BladeLocatorLed led = blade.getLocatorLed();
- assertNotNull(led);
- assertEquals(led.getAdminStatus(), "on");
- }
-
- public void testLedOff() {
- blade.ledOff();
- BladeLocatorLed led = blade.getLocatorLed();
- assertNotNull(led);
- assertEquals(led.getAdminStatus(), "off");
- }
-
- @BeforeClass
- public void setup() {
- blade = env.ucsRack.listMachines().get(0);
- assertNotNull(blade);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
index 535860b..e4eafd7 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -32,7 +33,6 @@ import org.jclouds.abiquo.domain.cloud.VirtualMachine;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.RemoteServicePredicates;
import org.jclouds.abiquo.util.Config;
import org.testng.annotations.Test;
@@ -40,6 +40,7 @@ import com.abiquo.model.enumerator.HypervisorType;
import com.abiquo.model.enumerator.MachineState;
import com.abiquo.model.enumerator.RemoteServiceType;
import com.abiquo.server.core.infrastructure.MachineDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link Machine} domain class.
@@ -50,8 +51,12 @@ import com.abiquo.server.core.infrastructure.MachineDto;
public class MachineLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testDiscoverMachineWithouRemoteService() {
// Delete node collector
- RemoteService nc = env.datacenter.findRemoteService(RemoteServicePredicates
- .type(RemoteServiceType.NODE_COLLECTOR));
+ RemoteService nc = find(env.datacenter.listRemoteServices(), new Predicate<RemoteService>() {
+ @Override
+ public boolean apply(RemoteService input) {
+ return input.getType().equals(RemoteServiceType.NODE_COLLECTOR);
+ }
+ });
nc.delete();
try {
@@ -103,18 +108,6 @@ public class MachineLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertEquals(machine.getState(), state);
}
- public void testFindDatastore() {
- Datastore datastore = env.machine.getDatastores().get(0);
- Datastore found = env.machine.findDatastore(datastore.getName());
- assertEquals(found.getName(), datastore.getName());
- }
-
- public void testFindAvailableVirtualSwitch() {
- String vswitch = Config.get("abiquo.hypervisor.vswitch");
- NetworkInterface found = env.machine.findAvailableVirtualSwitch(vswitch);
- assertEquals(found.getName(), vswitch);
- }
-
public void testGetRack() {
Rack rack = env.machine.getRack();
assertNotNull(rack);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java
deleted file mode 100644
index 4c4e491..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.LogicServerPredicates;
-import org.jclouds.abiquo.predicates.infrastructure.ManagedRackPredicates;
-import org.testng.annotations.Test;
-
-import com.abiquo.server.core.infrastructure.UcsRackDto;
-import com.google.common.collect.Iterables;
-
-/**
- * Live integration tests for the {@link ManagedRack} domain class.
- *
- * @author Francesc Montserrat
- */
-@Test(groups = "ucs", testName = "ManagedRackLiveUcsTest")
-public class ManagedRackLiveUcsTest extends BaseAbiquoApiLiveApiTest {
- private LogicServer logicServer;
-
- private Organization organization;
-
- public void testUpdate() {
- env.ucsRack.setShortDescription("Updated description");
- env.ucsRack.update();
-
- // Recover the updated rack
- UcsRackDto updated = env.infrastructureApi.getManagedRack(env.datacenter.unwrap(), env.ucsRack.getId());
-
- assertEquals(updated.getShortDescription(), "Updated description");
- }
-
- public void testListManagedRacks() {
- Iterable<ManagedRack> racks = env.datacenter.listManagedRacks();
- assertEquals(Iterables.size(racks), 1);
-
- racks = env.datacenter.listManagedRacks(ManagedRackPredicates.name(env.ucsRack.getName()));
- assertEquals(Iterables.size(racks), 1);
- }
-
- public void testFindRack() {
- ManagedRack rack = env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName()));
- assertNotNull(rack);
-
- rack = env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName() + "FAIL"));
- assertNull(rack);
- }
-
- public void testCloneLogicServer() {
- List<LogicServer> originals = env.ucsRack.listServiceProfiles();
- assertNotNull(originals);
- assertTrue(originals.size() > 0);
- LogicServer original = originals.get(0);
-
- List<Organization> organizations = env.ucsRack.listOrganizations();
- assertNotNull(organizations);
- assertTrue(organizations.size() > 0);
- organization = organizations.get(0);
-
- env.ucsRack.cloneLogicServer(original, organization, "jclouds");
-
- logicServer = env.ucsRack
- .findServiceProfile(LogicServerPredicates.name(organization.getDn() + "/" + "ls-jclouds"));
- assertNotNull(logicServer);
-
- String name = logicServer.getName();
- assertEquals(name.substring(name.length() - 7, name.length()), "jclouds");
- }
-
- @Test(dependsOnMethods = "testCloneLogicServer")
- public void testListFsms() {
- List<Fsm> fsms = env.ucsRack.listFsm(logicServer.getName());
- assertNotNull(fsms);
- assertTrue(fsms.size() > 0);
- }
-
- @Test(dependsOnMethods = { "testCloneLogicServer", "testListFsms" })
- public void testDeleteLogicServer() {
- String name = logicServer.getName();
-
- env.ucsRack.deleteLogicServer(logicServer);
-
- LogicServer profile = env.ucsRack.findServiceProfile(LogicServerPredicates.name(name));
- assertNull(profile);
- }
-}
[2/8] JCLOUDS-156: Cleanup Abiquo provider
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java
index 9cdcff3..71f87f7 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java
@@ -16,16 +16,15 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
-import static org.jclouds.abiquo.predicates.infrastructure.RackPredicates.name;
+import static com.google.common.collect.Iterables.filter;
+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.assertNull;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
import org.testng.annotations.Test;
import com.abiquo.server.core.infrastructure.RackDto;
-import com.google.common.collect.Iterables;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link Rack} domain class.
@@ -47,21 +46,22 @@ public class RackLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testListRacks() {
Iterable<Rack> racks = env.datacenter.listRacks();
- assertEquals(Iterables.size(racks), 1);
+ assertEquals(size(racks), 1);
- racks = env.datacenter.listRacks(name(env.rack.getName()));
- assertEquals(Iterables.size(racks), 1);
+ racks = filter(env.datacenter.listRacks(), name(env.rack.getName()));
+ assertEquals(size(racks), 1);
- racks = env.datacenter.listRacks(name(env.rack.getName() + "FAIL"));
- assertEquals(Iterables.size(racks), 0);
+ racks = filter(env.datacenter.listRacks(), name(env.rack.getName() + "FAIL"));
+ assertEquals(size(racks), 0);
}
- public void testFindRack() {
- Rack rack = env.datacenter.findRack(name(env.rack.getName()));
- assertNotNull(rack);
-
- rack = env.datacenter.findRack(name(env.rack.getName() + "FAIL"));
- assertNull(rack);
+ private static Predicate<Rack> name(final String name) {
+ return new Predicate<Rack>() {
+ @Override
+ public boolean apply(Rack input) {
+ return input.getName().equals(name);
+ }
+ };
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java
index c837208..4c75f62 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java
@@ -16,10 +16,11 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
-import static org.jclouds.abiquo.predicates.infrastructure.RemoteServicePredicates.type;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.size;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -35,7 +36,7 @@ import org.testng.annotations.Test;
import com.abiquo.model.enumerator.RemoteServiceType;
import com.abiquo.server.core.infrastructure.RemoteServiceDto;
-import com.google.common.collect.Iterables;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link RemoteService} domain class.
@@ -46,7 +47,7 @@ import com.google.common.collect.Iterables;
public class RemoteServiceLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testUpdate() {
// Update the remote service
- RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.VIRTUAL_FACTORY));
+ RemoteService rs = find(env.datacenter.listRemoteServices(), type(RemoteServiceType.VIRTUAL_FACTORY));
rs.setUri(rs.getUri());
rs.update();
@@ -58,7 +59,7 @@ public class RemoteServiceLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testDelete() {
- RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.BPM_SERVICE));
+ RemoteService rs = find(env.datacenter.listRemoteServices(), type(RemoteServiceType.BPM_SERVICE));
rs.delete();
// Recover the deleted remote service
@@ -76,12 +77,12 @@ public class RemoteServiceLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testIsAvailableNonCheckeable() {
- RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.DHCP_SERVICE));
+ RemoteService rs = find(env.datacenter.listRemoteServices(), type(RemoteServiceType.DHCP_SERVICE));
assertTrue(rs.isAvailable());
}
public void testIsAvailable() {
- RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.NODE_COLLECTOR));
+ RemoteService rs = find(env.datacenter.listRemoteServices(), type(RemoteServiceType.NODE_COLLECTOR));
assertTrue(rs.isAvailable());
}
@@ -98,15 +99,19 @@ public class RemoteServiceLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testListRemoteServices() {
Iterable<RemoteService> remoteServices = env.datacenter.listRemoteServices();
- assertEquals(Iterables.size(remoteServices), env.remoteServices.size());
+ assertEquals(size(remoteServices), env.remoteServices.size());
- remoteServices = env.datacenter.listRemoteServices(type(RemoteServiceType.NODE_COLLECTOR));
- assertEquals(Iterables.size(remoteServices), 1);
+ remoteServices = filter(env.datacenter.listRemoteServices(), type(RemoteServiceType.NODE_COLLECTOR));
+ assertEquals(size(remoteServices), 1);
}
- public void testFindRemoteService() {
- RemoteService remoteService = env.datacenter.findRemoteService(type(RemoteServiceType.NODE_COLLECTOR));
- assertNotNull(remoteService);
+ private static Predicate<RemoteService> type(final RemoteServiceType type) {
+ return new Predicate<RemoteService>() {
+ @Override
+ public boolean apply(RemoteService input) {
+ return input.getType().equals(type);
+ }
+ };
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java
index 1cf339f..c8cc8d6 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java
@@ -16,16 +16,15 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
+import static com.google.common.collect.Iterables.filter;
+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.assertNull;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.StorageDevicePredicates;
import org.testng.annotations.Test;
import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto;
-import com.google.common.collect.Iterables;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link StorageDevice} domain class.
@@ -49,24 +48,22 @@ public class StorageDeviceLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testListStorageDevices() {
Iterable<StorageDevice> storageDevices = env.datacenter.listStorageDevices();
- assertEquals(Iterables.size(storageDevices), 1);
+ assertEquals(size(storageDevices), 1);
- storageDevices = env.datacenter.listStorageDevices(StorageDevicePredicates.name(env.storageDevice.getName()));
- assertEquals(Iterables.size(storageDevices), 1);
+ storageDevices = filter(env.datacenter.listStorageDevices(), name(env.storageDevice.getName()));
+ assertEquals(size(storageDevices), 1);
- storageDevices = env.datacenter.listStorageDevices(StorageDevicePredicates.name(env.storageDevice.getName()
- + "FAIL"));
- assertEquals(Iterables.size(storageDevices), 0);
+ storageDevices = filter(env.datacenter.listStorageDevices(), name(env.storageDevice.getName() + "FAIL"));
+ assertEquals(size(storageDevices), 0);
}
- public void testFindStorageDevice() {
- StorageDevice storageDevice = env.datacenter.findStorageDevice(StorageDevicePredicates.name(env.storageDevice
- .getName()));
- assertNotNull(storageDevice);
-
- storageDevice = env.datacenter.findStorageDevice(StorageDevicePredicates.name(env.storageDevice.getName()
- + "FAIL"));
- assertNull(storageDevice);
+ private static Predicate<StorageDevice> name(final String name) {
+ return new Predicate<StorageDevice>() {
+ @Override
+ public boolean apply(StorageDevice input) {
+ return input.getName().equals(name);
+ }
+ };
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java
index 2d49d95..7c2d2d9 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java
@@ -16,16 +16,16 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+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.assertNull;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.StoragePoolPredicates;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link StorageDevice} domain class.
@@ -43,8 +43,12 @@ public class StoragePoolLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testUpdate() {
try {
- Tier tier3 = env.datacenter.findTier(TierPredicates.name("Default Tier 3"));
- assertNotNull(tier3);
+ Tier tier3 = find(env.datacenter.listTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals("Default Tier 3");
+ }
+ });
env.storagePool.setTier(tier3);
env.storagePool.update();
@@ -59,26 +63,26 @@ public class StoragePoolLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testListStoragePool() {
Iterable<StoragePool> storagePools = env.storageDevice.listStoragePools();
- assertEquals(Iterables.size(storagePools), 1);
+ assertEquals(size(storagePools), 1);
- storagePools = env.storageDevice.listStoragePools(StoragePoolPredicates.name(env.storagePool.getName()));
- assertEquals(Iterables.size(storagePools), 1);
+ storagePools = filter(env.storageDevice.listStoragePools(), name(env.storagePool.getName()));
+ assertEquals(size(storagePools), 1);
- storagePools = env.storageDevice.listStoragePools(StoragePoolPredicates.name(env.storagePool.getName() + "FAIL"));
- assertEquals(Iterables.size(storagePools), 0);
- }
-
- public void testFindStoragePool() {
- StoragePool storagePool = env.storageDevice
- .findStoragePool(StoragePoolPredicates.name(env.storagePool.getName()));
- assertNotNull(storagePool);
-
- storagePool = env.storageDevice.findStoragePool(StoragePoolPredicates.name(env.storagePool.getName() + "FAIL"));
- assertNull(storagePool);
+ storagePools = filter(env.storageDevice.listStoragePools(), name(env.storagePool.getName() + "FAIL"));
+ assertEquals(size(storagePools), 0);
}
public void testRefreshStoragePool() {
env.storagePool.refresh();
}
+ private static Predicate<StoragePool> name(final String name) {
+ return new Predicate<StoragePool>() {
+ @Override
+ public boolean apply(StoragePool input) {
+ return input.getName().equals(name);
+ }
+ };
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java
index 1a139b6..c04b3b6 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java
@@ -16,14 +16,16 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.size;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link StorageDevice} domain class.
@@ -42,20 +44,28 @@ public class TierLiveApiTest extends BaseAbiquoApiLiveApiTest {
tier.setName("Updated tier");
tier.update();
- // Recover the updated tier
- Tier updated = env.datacenter.findTier(TierPredicates.name("Updated tier"));
- assertEquals(updated.getName(), "Updated tier");
+ // Verify the tier has been updated
+ find(env.datacenter.listTiers(), name("Updated tier"));
- // Set original name
+ // Restore the original name
tier.setName(previousName);
tier.update();
}
public void testListTiers() {
Iterable<Tier> tiers = env.datacenter.listTiers();
- assertEquals(Iterables.size(tiers), 4);
+ assertEquals(size(tiers), 4);
- tiers = env.datacenter.listTiers(TierPredicates.name("FAIL"));
- assertEquals(Iterables.size(tiers), 0);
+ tiers = filter(env.datacenter.listTiers(), name("FAIL"));
+ assertEquals(size(tiers), 0);
+ }
+
+ private static Predicate<Tier> name(final String name) {
+ return new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals(name);
+ }
+ };
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java
index 69ca332..e0056dc 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.network;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
@@ -29,13 +30,13 @@ import javax.ws.rs.core.Response.Status;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.domain.network.options.IpOptions;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
-import org.jclouds.abiquo.predicates.network.NetworkPredicates;
+import org.jclouds.abiquo.predicates.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.abiquo.server.core.infrastructure.network.ExternalIpsDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link ExternalNetwork} domain class.
@@ -91,8 +92,12 @@ public class ExternalNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertEquals(externalNetwork.getSecondaryDNS(), "8.8.8.8");
// Refresh the external network
- ExternalNetwork en = env.enterprise.findExternalNetwork(env.datacenter,
- NetworkPredicates.<ExternalIp> name(externalNetwork.getName()));
+ ExternalNetwork en = find(env.enterprise.listExternalNetworks(env.datacenter), new Predicate<ExternalNetwork>() {
+ @Override
+ public boolean apply(ExternalNetwork input) {
+ return input.getName().equals(externalNetwork.getName());
+ }
+ });
assertEquals(en.getId(), externalNetwork.getId());
assertEquals(en.getName(), "External network Updated");
@@ -141,7 +146,7 @@ public class ExternalNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testGetNetworkFromIp() {
- ExternalIp ip = externalNetwork.findIp(IpPredicates.<ExternalIp> notUsed());
+ ExternalIp ip = find(externalNetwork.listIps(), IpPredicates.<ExternalIp> notUsed());
ExternalNetwork network = ip.getNetwork();
assertEquals(network.getId(), externalNetwork.getId());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java
index 20f9541..ac1fb2b 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.network;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
@@ -30,7 +31,7 @@ import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.domain.network.options.IpOptions;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
+import org.jclouds.abiquo.predicates.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -131,7 +132,7 @@ public class PrivateNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testGetNetworkFromIp() {
- PrivateIp ip = privateNetwork.findIp(IpPredicates.<PrivateIp> notUsed());
+ PrivateIp ip = find(privateNetwork.listIps(), IpPredicates.<PrivateIp> notUsed());
PrivateNetwork network = ip.getNetwork();
assertEquals(network.getId(), privateNetwork.getId());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java
index f221e14..203aba6 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.network;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
@@ -29,7 +30,7 @@ import javax.ws.rs.core.Response.Status;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.domain.network.options.IpOptions;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
+import org.jclouds.abiquo.predicates.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -135,7 +136,7 @@ public class PublicNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testGetNetworkFromIp() {
- PublicIp ip = publicNetwork.findIp(IpPredicates.<PublicIp> notUsed());
+ PublicIp ip = find(publicNetwork.listIps(), IpPredicates.<PublicIp> notUsed());
PublicNetwork network = ip.getNetwork();
assertEquals(network.getId(), publicNetwork.getId());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java
index 239caca..96981b3 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.network;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
@@ -30,13 +31,13 @@ import javax.ws.rs.core.Response.Status;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.domain.network.options.IpOptions;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
-import org.jclouds.abiquo.predicates.network.NetworkPredicates;
+import org.jclouds.abiquo.predicates.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link UnmanagedNetwork} domain class.
@@ -93,8 +94,13 @@ public class UnmanagedNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertEquals(unmanagedNetwork.getSecondaryDNS(), "8.8.8.8");
// Refresh the unmanaged network
- UnmanagedNetwork en = env.enterprise.findUnmanagedNetwork(env.datacenter,
- NetworkPredicates.<UnmanagedIp> name(unmanagedNetwork.getName()));
+ UnmanagedNetwork en = find(env.enterprise.listUnmanagedNetworks(env.datacenter),
+ new Predicate<UnmanagedNetwork>() {
+ @Override
+ public boolean apply(UnmanagedNetwork input) {
+ return input.getName().equals(unmanagedNetwork.getName());
+ }
+ });
assertEquals(en.getId(), unmanagedNetwork.getId());
assertEquals(en.getName(), "Unmanaged network Updated");
@@ -143,7 +149,7 @@ public class UnmanagedNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testGetNetworkFromIp() {
- UnmanagedIp ip = unmanagedNetwork.findIp(IpPredicates.<UnmanagedIp> notUsed());
+ UnmanagedIp ip = find(unmanagedNetwork.listIps(), IpPredicates.<UnmanagedIp> notUsed(), null);
// Unmanaged networks do not have IPs until attached to VMs
assertNull(ip);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java b/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java
index 86fdd48..4a3579c 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java
@@ -17,6 +17,7 @@
package org.jclouds.abiquo.environment;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
@@ -33,14 +34,12 @@ import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
import org.jclouds.abiquo.domain.cloud.VirtualMachine;
import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.domain.network.PrivateIp;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.features.CloudApi;
import org.jclouds.abiquo.features.services.EventService;
-import org.jclouds.abiquo.predicates.enterprise.EnterprisePredicates;
-import org.jclouds.abiquo.predicates.network.NetworkPredicates;
import org.testng.collections.Lists;
+import com.google.common.base.Predicate;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Longs;
@@ -127,7 +126,12 @@ public class CloudTestEnvironment extends InfrastructureTestEnvironment {
}
protected void findDefaultEnterprise() {
- defaultEnterprise = context.getAdministrationService().findEnterprise(EnterprisePredicates.name("Abiquo"));
+ defaultEnterprise = find(context.getAdministrationService().listEnterprises(), new Predicate<Enterprise>() {
+ @Override
+ public boolean apply(Enterprise input) {
+ return input.getName().equals("Abiquo");
+ }
+ });
}
protected void createVirtualDatacenter() {
@@ -142,8 +146,12 @@ public class CloudTestEnvironment extends InfrastructureTestEnvironment {
virtualDatacenter.save();
assertNotNull(virtualDatacenter.getId());
- privateNetwork = virtualDatacenter
- .findPrivateNetwork(NetworkPredicates.<PrivateIp> name(privateNetwork.getName()));
+ privateNetwork = find(virtualDatacenter.listPrivateNetworks(), new Predicate<PrivateNetwork>() {
+ @Override
+ public boolean apply(PrivateNetwork input) {
+ return input.getName().equals(privateNetwork.getName());
+ }
+ });
}
protected void createVirtualAppliance() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java b/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java
index b8101fc..0c2add5 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java
@@ -38,7 +38,6 @@ import org.jclouds.abiquo.domain.enterprise.User;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Datastore;
import org.jclouds.abiquo.domain.infrastructure.Machine;
-import org.jclouds.abiquo.domain.infrastructure.ManagedRack;
import org.jclouds.abiquo.domain.infrastructure.NetworkInterface;
import org.jclouds.abiquo.domain.infrastructure.Rack;
import org.jclouds.abiquo.domain.infrastructure.RemoteService;
@@ -55,17 +54,10 @@ import org.jclouds.abiquo.features.ConfigApi;
import org.jclouds.abiquo.features.EnterpriseApi;
import org.jclouds.abiquo.features.InfrastructureApi;
import org.jclouds.abiquo.features.services.AdministrationService;
-import org.jclouds.abiquo.predicates.enterprise.RolePredicates;
-import org.jclouds.abiquo.predicates.enterprise.UserPredicates;
-import org.jclouds.abiquo.predicates.infrastructure.RemoteServicePredicates;
-import org.jclouds.abiquo.predicates.infrastructure.StorageDeviceMetadataPredicates;
-import org.jclouds.abiquo.predicates.infrastructure.StoragePoolPredicates;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.jclouds.abiquo.util.Config;
import com.abiquo.model.enumerator.HypervisorType;
-import com.abiquo.model.enumerator.RemoteServiceType;
-import com.google.common.collect.Iterables;
+import com.google.common.base.Predicate;
import com.google.common.io.LineProcessor;
import com.google.common.io.Resources;
@@ -124,8 +116,6 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
public Role anotherRole;
- public ManagedRack ucsRack;
-
public InfrastructureTestEnvironment(final AbiquoContext context) {
super();
this.context = context;
@@ -173,7 +163,6 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
deleteStoragePool();
deleteStorageDevice();
deleteMachine();
- deleteUcsRack();
deleteRack();
deleteDatacenter();
deleteEnterprise();
@@ -209,14 +198,26 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
HypervisorType type = HypervisorType.valueOf(Config.get("abiquo.hypervisor.type"));
String user = Config.get("abiquo.hypervisor.user");
String pass = Config.get("abiquo.hypervisor.pass");
+ final String vswitchName = Config.get("abiquo.hypervisor.vswitch");
+ final String datastoreName = Config.get("abiquo.hypervisor.datastore");
machine = datacenter.discoverSingleMachine(ip, type, user, pass);
NetworkServiceType nst = datacenter.defaultNetworkServiceType();
- NetworkInterface vswitch = machine.findAvailableVirtualSwitch(Config.get("abiquo.hypervisor.vswitch"));
+ NetworkInterface vswitch = find(machine.getNetworkInterfaces(), new Predicate<NetworkInterface>() {
+ @Override
+ public boolean apply(NetworkInterface input) {
+ return input.getName().equals(vswitchName);
+ }
+ });
vswitch.setNetworkServiceType(nst);
- Datastore datastore = machine.findDatastore(Config.get("abiquo.hypervisor.datastore"));
+ Datastore datastore = find(machine.getDatastores(), new Predicate<Datastore>() {
+ @Override
+ public boolean apply(Datastore input) {
+ return input.getName().equals(datastoreName);
+ }
+ });
datastore.setEnabled(true);
machine.setRack(rack);
@@ -230,27 +231,19 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
assertNotNull(rack.getId());
}
- public void createUcsRack() {
- String ip = Config.get("abiquo.ucs.address");
- Integer port = Integer.parseInt(Config.get("abiquo.ucs.port"));
- String user = Config.get("abiquo.ucs.user");
- String pass = Config.get("abiquo.ucs.pass");
-
- ucsRack = ManagedRack.builder(context.getApiContext(), datacenter).ipAddress(ip).port(port).user(user)
- .name("ucs rack").password(pass).build();
-
- ucsRack.save();
- assertNotNull(ucsRack.getId());
- }
-
protected void createStorageDevice() {
String ip = Config.get("abiquo.storage.address");
- String type = Config.get("abiquo.storage.type");
+ final String type = Config.get("abiquo.storage.type");
String user = Config.get("abiquo.storage.user");
String pass = Config.get("abiquo.storage.pass");
List<StorageDeviceMetadata> devices = datacenter.listSupportedStorageDevices();
- StorageDeviceMetadata metadata = Iterables.find(devices, StorageDeviceMetadataPredicates.type(type));
+ StorageDeviceMetadata metadata = find(devices, new Predicate<StorageDeviceMetadata>() {
+ @Override
+ public boolean apply(StorageDeviceMetadata input) {
+ return input.getType().equals(type);
+ }
+ });
storageDevice = StorageDevice.builder(context.getApiContext(), datacenter) //
.name(PREFIX + "Storage Device")//
@@ -266,10 +259,20 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
}
protected void createStoragePool() {
- String pool = Config.get("abiquo.storage.pool");
+ final String pool = Config.get("abiquo.storage.pool");
- storagePool = storageDevice.findRemoteStoragePool(StoragePoolPredicates.name(pool));
- tier = datacenter.findTier(TierPredicates.name("Default Tier 1"));
+ storagePool = find(storageDevice.listRemoteStoragePools(), new Predicate<StoragePool>() {
+ @Override
+ public boolean apply(StoragePool input) {
+ return input.getName().equals(pool);
+ }
+ });
+ tier = find(datacenter.listTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals("Default Tier 1");
+ }
+ });
storagePool.setTier(tier);
storagePool.save();
@@ -278,8 +281,9 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
}
protected void createUsers() {
- Role userRole = administrationService.findRole(RolePredicates.name("USER"));
- Role enterpriseAdminRole = administrationService.findRole(RolePredicates.name("ENTERPRISE_ADMIN"));
+ Iterable<Role> roles = administrationService.listRoles();
+ Role userRole = find(roles, role("USER"));
+ Role enterpriseAdminRole = find(roles, role("ENTERPRISE_ADMIN"));
user = User.builder(context.getApiContext(), enterprise, userRole).name(randomName(), randomName())
.nick("jclouds").authType("ABIQUO").description(randomName()).email(randomName() + "@abiquo.com")
@@ -370,14 +374,14 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
String nick = user.getNick();
user.delete();
// Nick is unique in an enterprise
- assertNull(enterprise.findUser(UserPredicates.nick(nick)));
+ assertNull(find(enterprise.listUsers(), nick(nick), null));
}
if (enterpriseAdmin != null) {
String nick = enterpriseAdmin.getNick();
enterpriseAdmin.delete();
// Nick is unique in an enterprise
- assertNull(enterprise.findUser(UserPredicates.nick(nick)));
+ assertNull(find(enterprise.listUsers(), nick(nick), null));
}
}
@@ -422,14 +426,6 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
}
}
- protected void deleteUcsRack() {
- if (ucsRack != null && datacenter != null) {
- Integer idRack = ucsRack.getId();
- ucsRack.delete();
- assertNull(infrastructureApi.getManagedRack(datacenter.unwrap(), idRack));
- }
- }
-
protected void deleteDatacenter() {
if (datacenter != null) {
// Remove limits first
@@ -479,7 +475,21 @@ public class InfrastructureTestEnvironment implements TestEnvironment {
});
}
- public RemoteService findRemoteService(final RemoteServiceType type) {
- return find(remoteServices, RemoteServicePredicates.type(type));
+ private static Predicate<Role> role(final String role) {
+ return new Predicate<Role>() {
+ @Override
+ public boolean apply(Role input) {
+ return input.getName().equals(role);
+ }
+ };
+ }
+
+ private static Predicate<User> nick(final String nick) {
+ return new Predicate<User>() {
+ @Override
+ public boolean apply(User input) {
+ return input.getNick().equals(nick);
+ }
+ };
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java b/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java
deleted file mode 100644
index 0c1c89b..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.events.handlers;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.jclouds.abiquo.events.monitor.MonitorEvent;
-import org.jclouds.abiquo.events.monitor.MonitorEvent.Type;
-import org.testng.annotations.Test;
-
-/**
- * Unit tests for the {@link BlockingEventHandler} handler.
- *
- * @author Ignasi Barrera
- */
-@Test(groups = "unit", testName = "BlockingEventHandlerTest")
-public class BlockingEventHandlerTest {
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testConstructorWithoutObjects() {
- new BlockingEventHandler<Object>();
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testConstructorWithNullObjects() {
- new BlockingEventHandler<Object>((Object[]) null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testConstructorWithtEmptyObjects() {
- new BlockingEventHandler<Object>(new Object[] {});
- }
-
- public void testHandles() {
- Object object = new Object();
- BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
-
- assertTrue(handler.handles(new MonitorEvent<Object>(Type.COMPLETED, object)));
- assertFalse(handler.handles(new MonitorEvent<Object>(Type.COMPLETED, new Object())));
- }
-
- public void testReleaseDoesNothingIfNotLocked() {
- Object object = new Object();
- BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
- handler.release(object);
- }
-
- public void testRelease() {
- final Object object = new Object();
- final BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
-
- // Unlock the handler (in a separate thread) after a certain delay
- Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() {
- @Override
- public void run() {
- handler.release(object);
- assertTrue(handler.lockedObjects.isEmpty());
- }
-
- }, 500L, TimeUnit.MILLISECONDS);
-
- handler.lock();
- }
-
- public void testHandle() {
- final Object object = new Object();
- final BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
-
- // Unlock the handler (in a separate thread) after a certain delay
- Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() {
- @Override
- public void run() {
- handler.handle(new MonitorEvent<Object>(Type.COMPLETED, object));
- assertTrue(handler.lockedObjects.isEmpty());
- }
-
- }, 500L, TimeUnit.MILLISECONDS);
-
- handler.lock();
- }
-
- public void testLockDoesNothingIfNoObjects() {
- Object object = new Object();
- BlockingEventHandler<Object> handler = new BlockingEventHandler<Object>(object);
- handler.lockedObjects.clear();
-
- handler.lock(); // Lock should do nothing
-
- assertNull(handler.completeSignal);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiTest.java
index 04bb6ac..3064935 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiTest.java
@@ -35,7 +35,6 @@ import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions;
import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
import org.jclouds.abiquo.domain.network.options.IpOptions;
import org.jclouds.abiquo.domain.network.options.NetworkOptions;
-import org.jclouds.abiquo.domain.options.search.FilterOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.functions.ParseXMLWithJAXB;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
@@ -53,24 +52,16 @@ import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
import com.abiquo.server.core.enterprise.DatacentersLimitsDto;
import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.infrastructure.BladeLocatorLedDto;
import com.abiquo.server.core.infrastructure.DatacenterDto;
import com.abiquo.server.core.infrastructure.DatacentersDto;
-import com.abiquo.server.core.infrastructure.FsmsDto;
-import com.abiquo.server.core.infrastructure.LogicServerDto;
-import com.abiquo.server.core.infrastructure.LogicServersDto;
import com.abiquo.server.core.infrastructure.MachineDto;
import com.abiquo.server.core.infrastructure.MachineIpmiStateDto;
import com.abiquo.server.core.infrastructure.MachineStateDto;
import com.abiquo.server.core.infrastructure.MachinesDto;
-import com.abiquo.server.core.infrastructure.OrganizationDto;
-import com.abiquo.server.core.infrastructure.OrganizationsDto;
import com.abiquo.server.core.infrastructure.RackDto;
import com.abiquo.server.core.infrastructure.RacksDto;
import com.abiquo.server.core.infrastructure.RemoteServiceDto;
import com.abiquo.server.core.infrastructure.RemoteServicesDto;
-import com.abiquo.server.core.infrastructure.UcsRackDto;
-import com.abiquo.server.core.infrastructure.UcsRacksDto;
import com.abiquo.server.core.infrastructure.network.ExternalIpDto;
import com.abiquo.server.core.infrastructure.network.ExternalIpsDto;
import com.abiquo.server.core.infrastructure.network.PublicIpDto;
@@ -317,325 +308,6 @@ public class InfrastructureApiTest extends BaseAbiquoApiTest<InfrastructureApi>
checkFilters(request);
}
- /*********************** Managed Rack ***********************/
-
- public void testListManagedRacks() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "listManagedRacks", DatacenterDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.datacenterPut())));
-
- assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + UcsRacksDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testCreateManagedRack() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "createManagedRack", DatacenterDto.class,
- UcsRackDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(
- method,
- ImmutableList.<Object> of(InfrastructureResources.datacenterPut(),
- InfrastructureResources.managedRackPost())));
-
- assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(InfrastructureResources.managedRackPostPayload()), UcsRackDto.class,
- UcsRackDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetManagedRack() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "getManagedRack", DatacenterDto.class, Integer.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.datacenterPut(), 1)));
-
- assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testUpdateManagedRack() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "updateManagedRack", UcsRackDto.class);
-
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut())));
-
- assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, withHeader(InfrastructureResources.managedRackPutPayload()), UcsRackDto.class,
- UcsRackDto.BASE_MEDIA_TYPE, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListServiceProfiles() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "listServiceProfiles", UcsRackDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut())));
-
- assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/logicservers HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListServiceProfilesWithOptions() throws SecurityException, NoSuchMethodException, IOException {
- FilterOptions options = FilterOptions.builder().startWith(1).limit(2).build();
-
- Invokable<?, ?> method = method(InfrastructureApi.class, "listServiceProfiles", UcsRackDto.class,
- FilterOptions.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(), options)));
-
- assertRequestLineEquals(request,
- "GET http://localhost/api/admin/datacenters/1/racks/1/logicservers?startwith=1&limit=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListOrganizations() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "listOrganizations", UcsRackDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut())));
-
- assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/organizations HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + OrganizationsDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListOrganizationsWithOptions() throws SecurityException, NoSuchMethodException, IOException {
- FilterOptions options = FilterOptions.builder().has("org").build();
-
- Invokable<?, ?> method = method(InfrastructureApi.class, "listOrganizations", UcsRackDto.class,
- FilterOptions.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(), options)));
-
- assertRequestLineEquals(request,
- "GET http://localhost/api/admin/datacenters/1/racks/1/organizations?has=org HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + OrganizationsDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListServiceProfileTemplates() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "listServiceProfileTemplates", UcsRackDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut())));
-
- assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/lstemplates HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListServiceProfileTemplatesWithOptions() throws SecurityException, NoSuchMethodException,
- IOException {
- FilterOptions options = FilterOptions.builder().ascendant(true).build();
-
- Invokable<?, ?> method = method(InfrastructureApi.class, "listServiceProfileTemplates", UcsRackDto.class,
- FilterOptions.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(), options)));
-
- assertRequestLineEquals(request,
- "GET http://localhost/api/admin/datacenters/1/racks/1/lstemplates?asc=true HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testAssociateLogicServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "associateLogicServer", UcsRackDto.class,
- LogicServerDto.class, OrganizationDto.class, String.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(
- method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(),
- InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "blade")));
-
- assertRequestLineEquals(
- request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/associate?bladeDn=blade&lsName=server&org=org-root/org-Finance HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testAssociateTemplate() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "associateTemplate", UcsRackDto.class,
- LogicServerDto.class, OrganizationDto.class, String.class, String.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(
- InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(),
- InfrastructureResources.organizationPut(), "newname", "blade")));
-
- assertRequestLineEquals(
- request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/associatetemplate?newName=newname&bladeDn=blade&lsName=server&org=org-root/org-Finance HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testCloneAndAssociateLogicServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "cloneAndAssociateLogicServer", UcsRackDto.class,
- LogicServerDto.class, OrganizationDto.class, String.class, String.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(
- InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(),
- InfrastructureResources.organizationPut(), "newname", "blade")));
-
- assertRequestLineEquals(
- request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/assocclone?newName=newname&bladeDn=blade&lsName=server&org=org-root/org-Finance HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDissociateLogicServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "dissociateLogicServer", UcsRackDto.class,
- LogicServerDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(
- method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(),
- InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut())));
-
- assertRequestLineEquals(request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/dissociate?lsName=server HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testCloneLogicServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "cloneLogicServer", UcsRackDto.class,
- LogicServerDto.class, OrganizationDto.class, String.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(
- method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(),
- InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "name")));
-
- assertRequestLineEquals(
- request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/clone?newName=name&lsName=server&org=org-root/org-Finance HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteLogicServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "deleteLogicServer", UcsRackDto.class,
- LogicServerDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(
- method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(),
- InfrastructureResources.logicServerPut())));
-
- assertRequestLineEquals(request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/delete?lsName=server HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListFsms() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "listFsms", UcsRackDto.class, String.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.managedRackPut(), "dn")));
-
- assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/fsm?dn=dn HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + FsmsDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
/*********************** Remote Service **********************/
public void testListRemoteServices() throws SecurityException, NoSuchMethodException, IOException {
@@ -1130,109 +802,6 @@ public class InfrastructureApiTest extends BaseAbiquoApiTest<InfrastructureApi>
checkFilters(request);
}
- /*********************** Blade ***********************/
-
- public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "powerOff", MachineDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.machinePut())));
-
- assertRequestLineEquals(request,
- "PUT http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweroff HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "powerOn", MachineDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.machinePut())));
-
- assertRequestLineEquals(request,
- "PUT http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweron HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetLogicServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "getLogicServer", MachineDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.machinePut())));
-
- assertRequestLineEquals(request,
- "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/logicserver HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + LogicServerDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testLedOn() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "ledOn", MachineDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.machinePut())));
-
- assertRequestLineEquals(request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/ledon HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testLedOff() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "ledOff", MachineDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.machinePut())));
-
- assertRequestLineEquals(request,
- "POST http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/ledoff HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetLocatorLed() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(InfrastructureApi.class, "getLocatorLed", MachineDto.class);
- GeneratedHttpRequest request = processor.apply(Invocation.create(method,
- ImmutableList.<Object> of(InfrastructureResources.machinePut())));
-
- assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/led HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: " + BladeLocatorLedDto.BASE_MEDIA_TYPE + "\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
/*********************** Storage Device ***********************/
public void testListStorageDevices() throws SecurityException, NoSuchMethodException, IOException {
[4/8] JCLOUDS-156: Cleanup Abiquo provider
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java
deleted file mode 100644
index 00a1f02..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
-
-import com.abiquo.server.core.cloud.VirtualApplianceState;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link VirtualAppliance} filters.
- *
- * @author SerafÃn Sedano
- */
-public class VirtualAppliancePredicates {
- public static Predicate<VirtualAppliance> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<VirtualAppliance>() {
- @Override
- public boolean apply(final VirtualAppliance virtualAppliance) {
- return Arrays.asList(names).contains(virtualAppliance.getName());
- }
- };
- }
-
- public static Predicate<VirtualAppliance> state(final VirtualApplianceState... states) {
- checkNotNull(states, "states must be defined");
-
- return new Predicate<VirtualAppliance>() {
- @Override
- public boolean apply(final VirtualAppliance virtualAppliance) {
- return Arrays.asList(states).contains(virtualAppliance.getState());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java
deleted file mode 100644
index de91d69..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.transform;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.jclouds.abiquo.domain.cloud.Conversion;
-import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
-import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-
-import com.abiquo.model.enumerator.ConversionState;
-import com.abiquo.model.enumerator.HypervisorType;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-
-/**
- * Container for {@link VirtualDatacenter} filters.
- *
- * @author Ignasi Barrera
- */
-public class VirtualDatacenterPredicates {
- public static Predicate<VirtualDatacenter> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<VirtualDatacenter>() {
- @Override
- public boolean apply(final VirtualDatacenter virtualDatacenter) {
- return Arrays.asList(names).contains(virtualDatacenter.getName());
- }
- };
- }
-
- public static Predicate<VirtualDatacenter> type(final HypervisorType... types) {
- checkNotNull(types, "types must be defined");
-
- return new Predicate<VirtualDatacenter>() {
- @Override
- public boolean apply(final VirtualDatacenter virtualDatacenter) {
- return Arrays.asList(types).contains(virtualDatacenter.getHypervisorType());
- }
- };
- }
-
- public static Predicate<VirtualDatacenter> datacenter(final Datacenter... datacenters) {
- checkNotNull(datacenters, "datacenters must be defined");
-
- final List<Integer> ids = Lists.newArrayList(transform(Arrays.asList(datacenters),
- new Function<Datacenter, Integer>() {
- @Override
- public Integer apply(final Datacenter input) {
- return input.getId();
- }
- }));
-
- return new Predicate<VirtualDatacenter>() {
- @Override
- public boolean apply(final VirtualDatacenter virtualDatacenter) {
- // Avoid using the getDatacenter() method since it will generate an
- // unnecessary API
- // call. We can get the ID from the datacenter link.
- Integer datacenterId = checkNotNull(virtualDatacenter.unwrap().getIdFromLink(ParentLinkName.DATACENTER),
- ValidationErrors.MISSING_REQUIRED_LINK);
-
- return ids.contains(datacenterId);
- }
- };
- }
-
- /**
- * Check if the given template type is compatible with the given virtual
- * datacenter type taking into account the conversions of the template.
- *
- * @param template
- * The template to check.
- * @return Predicate to check if the template or its conversions are
- * compatibles with the given virtual datacenter.
- */
- public static Predicate<VirtualDatacenter> compatibleWithTemplateOrConversions(final VirtualMachineTemplate template) {
- return new Predicate<VirtualDatacenter>() {
- @Override
- public boolean apply(final VirtualDatacenter vdc) {
- HypervisorType type = vdc.getHypervisorType();
- boolean compatible = type.isCompatible(template.getDiskFormatType());
- if (!compatible) {
- List<Conversion> compatibleConversions = template.listConversions(type, ConversionState.FINISHED);
- compatible = compatibleConversions != null && !compatibleConversions.isEmpty();
- }
- return compatible;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java
deleted file mode 100644
index 6746e76..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.cloud.VirtualMachine;
-
-import com.abiquo.server.core.cloud.VirtualMachineState;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link VirtualMachine} filters.
- *
- * @author Ignasi Barrera
- */
-public class VirtualMachinePredicates {
- public static Predicate<VirtualMachine> internalName(final String... internalName) {
- checkNotNull(internalName, "names must be defined");
-
- return new Predicate<VirtualMachine>() {
- @Override
- public boolean apply(final VirtualMachine virtualMachine) {
- return Arrays.asList(internalName).contains(virtualMachine.getInternalName());
- }
- };
- }
-
- public static Predicate<VirtualMachine> nameLabel(final String... nameLabels) {
- checkNotNull(nameLabels, "names must be defined");
-
- return new Predicate<VirtualMachine>() {
- @Override
- public boolean apply(final VirtualMachine virtualMachine) {
- return Arrays.asList(nameLabels).contains(virtualMachine.getNameLabel());
- }
- };
- }
-
- public static Predicate<VirtualMachine> state(final VirtualMachineState... states) {
- checkNotNull(states, "states must be defined");
-
- return new Predicate<VirtualMachine>() {
- @Override
- public boolean apply(final VirtualMachine virtualMachine) {
- // The getState() method will generate an API call
- return Arrays.asList(states).contains(virtualMachine.getState());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java
deleted file mode 100644
index 49b8d6e..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
-
-import com.abiquo.model.enumerator.DiskFormatType;
-import com.abiquo.model.enumerator.HypervisorType;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link VirtualMachineTemplate} filters.
- *
- * @author Francesc Montserrat
- */
-public class VirtualMachineTemplatePredicates {
- public static Predicate<VirtualMachineTemplate> id(final Integer... ids) {
- checkNotNull(ids, "ids must be defined");
-
- return new Predicate<VirtualMachineTemplate>() {
- @Override
- public boolean apply(final VirtualMachineTemplate template) {
- return Arrays.asList(ids).contains(template.getId());
- }
- };
- }
-
- public static Predicate<VirtualMachineTemplate> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<VirtualMachineTemplate>() {
- @Override
- public boolean apply(final VirtualMachineTemplate template) {
- return Arrays.asList(names).contains(template.getName());
- }
- };
- }
-
- public static Predicate<VirtualMachineTemplate> diskFormat(final DiskFormatType... formats) {
- checkNotNull(formats, "formats must be defined");
-
- return new Predicate<VirtualMachineTemplate>() {
- @Override
- public boolean apply(final VirtualMachineTemplate template) {
- return Arrays.asList(formats).contains(template.getDiskFormatType());
- }
- };
- }
-
- public static Predicate<VirtualMachineTemplate> compatible(final HypervisorType type) {
- checkNotNull(type, "type must be defined");
-
- return new Predicate<VirtualMachineTemplate>() {
- @Override
- public boolean apply(final VirtualMachineTemplate template) {
- return type.isCompatible(template.getDiskFormatType());
- }
- };
- }
-
- public static Predicate<VirtualMachineTemplate> isShared() {
- return new Predicate<VirtualMachineTemplate>() {
- @Override
- public boolean apply(final VirtualMachineTemplate input) {
- return input.unwrap().isShared();
- }
- };
- }
-
- public static Predicate<VirtualMachineTemplate> isInstance() {
- return new Predicate<VirtualMachineTemplate>() {
- @Override
- public boolean apply(final VirtualMachineTemplate input) {
- return input.unwrap().searchLink("master") != null;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java
deleted file mode 100644
index e708ace..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.cloud.Volume;
-
-import com.abiquo.model.enumerator.VolumeState;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-
-/**
- * Container for {@link Volume} filters.
- *
- * @author Ignasi Barrera
- */
-public class VolumePredicates {
- public static Predicate<Volume> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Volume>() {
- @Override
- public boolean apply(final Volume volume) {
- return Arrays.asList(names).contains(volume.getName());
- }
- };
- }
-
- public static Predicate<Volume> greaterThan(final long sizeInMb) {
- checkNotNull(sizeInMb, "sizeInMb must be defined");
-
- return new Predicate<Volume>() {
- @Override
- public boolean apply(final Volume volume) {
- return volume.getSizeInMB() > sizeInMb;
- }
- };
- }
-
- public static Predicate<Volume> greaterThanOrEqual(final long sizeInMb) {
- checkNotNull(sizeInMb, "sizeInMb must be defined");
-
- return new Predicate<Volume>() {
- @Override
- public boolean apply(final Volume volume) {
- return volume.getSizeInMB() >= sizeInMb;
- }
- };
- }
-
- public static Predicate<Volume> lesserThan(final long sizeInMb) {
- return Predicates.not(greaterThanOrEqual(sizeInMb));
- }
-
- public static Predicate<Volume> lesserThanOrEquals(final long sizeInMb) {
- return Predicates.not(greaterThan(sizeInMb));
- }
-
- public static Predicate<Volume> state(final VolumeState... states) {
- checkNotNull(states, "states must be defined");
-
- return new Predicate<Volume>() {
- @Override
- public boolean apply(final Volume volume) {
- return Arrays.asList(states).contains(VolumeState.valueOf(volume.getState()));
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java
deleted file mode 100644
index b15da49..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.config.Category;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Category} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class CategoryPredicates {
- public static Predicate<Category> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Category>() {
- @Override
- public boolean apply(final Category category) {
- return Arrays.asList(names).contains(category.getName());
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java
deleted file mode 100644
index c306a65..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.config.License;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link License} filters.
- *
- * @author Ignasi Barrera
- */
-public class LicensePredicates {
-
- public static Predicate<License> code(final String... codes) {
- checkNotNull(codes, "customers must be defined");
-
- return new Predicate<License>() {
- @Override
- public boolean apply(final License license) {
- return Arrays.asList(codes).contains(license.getCode());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java
deleted file mode 100644
index 22ece23..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.config.CostCode;
-import org.jclouds.abiquo.domain.config.Currency;
-import org.jclouds.abiquo.domain.config.PricingTemplate;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for pricing related filters.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-public class PricingPredicates {
- public static Predicate<Currency> currency(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Currency>() {
- @Override
- public boolean apply(final Currency currency) {
- return Arrays.asList(names).contains(currency.getName());
- }
- };
- }
-
- public static Predicate<CostCode> costCode(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<CostCode>() {
- @Override
- public boolean apply(final CostCode costcode) {
- return Arrays.asList(names).contains(costcode.getName());
- }
- };
- }
-
- public static Predicate<PricingTemplate> pricingTemplate(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<PricingTemplate>() {
- @Override
- public boolean apply(final PricingTemplate pricingTemplate) {
- return Arrays.asList(names).contains(pricingTemplate.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java
deleted file mode 100644
index dd89528..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.config.Privilege;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Privilege} filters.
- *
- * @author Ignasi Barrera
- */
-public class PrivilegePredicates {
- public static Predicate<Privilege> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Privilege>() {
- @Override
- public boolean apply(final Privilege privilege) {
- return Arrays.asList(names).contains(privilege.getName());
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java
deleted file mode 100644
index 88d93e7..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.config.SystemProperty;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link SystemProperty} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class SystemPropertyPredicates {
- public static Predicate<SystemProperty> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<SystemProperty>() {
- @Override
- public boolean apply(final SystemProperty property) {
- return Arrays.asList(names).contains(property.getName());
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java
deleted file mode 100644
index 5f8424e..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.enterprise;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Enterprise} filters.
- *
- * @author Ignasi Barrera
- */
-public class EnterprisePredicates {
- public static Predicate<Enterprise> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Enterprise>() {
- @Override
- public boolean apply(final Enterprise enterprise) {
- return Arrays.asList(names).contains(enterprise.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java
deleted file mode 100644
index af4aac9..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.enterprise;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.enterprise.Role;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Role} filters.
- *
- * @author Ignasi Barrera
- */
-public class RolePredicates {
- public static Predicate<Role> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Role>() {
- @Override
- public boolean apply(final Role role) {
- return Arrays.asList(names).contains(role.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java
deleted file mode 100644
index 7ba9216..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.enterprise;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.enterprise.TemplateDefinitionList;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link TemplateDefinitionList} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class TemplateDefinitionListPredicates {
- public static Predicate<TemplateDefinitionList> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<TemplateDefinitionList>() {
- @Override
- public boolean apply(final TemplateDefinitionList templateList) {
- return Arrays.asList(names).contains(templateList.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java
deleted file mode 100644
index 76e225f..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.enterprise;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.enterprise.User;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link User} filters.
- *
- * @author Ignasi Barrera
- */
-public class UserPredicates {
- public static Predicate<User> nick(final String... nicks) {
- checkNotNull(nicks, "nicks must be defined");
-
- return new Predicate<User>() {
- @Override
- public boolean apply(final User user) {
- return Arrays.asList(nicks).contains(user.getNick());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java
deleted file mode 100644
index e769fb0..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.Blade;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Blade} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class BladePredicates {
- public static Predicate<Blade> name(final String... names) {
- checkNotNull(names, "name must be defined");
-
- return new Predicate<Blade>() {
- @Override
- public boolean apply(final Blade machine) {
- return Arrays.asList(names).contains(machine.getName());
- }
- };
- }
-
- public static Predicate<Blade> ip(final String ip) {
- return ips(checkNotNull(ip, "ip must be defined"));
- }
-
- public static Predicate<Blade> ips(final String... ips) {
- checkNotNull(ips, "ips must be defined");
-
- return new Predicate<Blade>() {
- @Override
- public boolean apply(final Blade machine) {
- return Arrays.asList(ips).contains(machine.getIp());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java
deleted file mode 100644
index b77d2ce..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Datacenter} filters.
- *
- * @author Ignasi Barrera
- */
-public class DatacenterPredicates {
- public static Predicate<Datacenter> id(final Integer... ids) {
- checkNotNull(ids, "ids must be defined");
-
- return new Predicate<Datacenter>() {
- @Override
- public boolean apply(final Datacenter datacenter) {
- return Arrays.asList(ids).contains(datacenter.getId());
- }
- };
- }
-
- public static Predicate<Datacenter> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Datacenter>() {
- @Override
- public boolean apply(final Datacenter datacenter) {
- return Arrays.asList(names).contains(datacenter.getName());
- }
- };
- }
-
- public static Predicate<Datacenter> location(final String... locations) {
- checkNotNull(locations, "locations must be defined");
-
- return new Predicate<Datacenter>() {
- @Override
- public boolean apply(final Datacenter datacenter) {
- return Arrays.asList(locations).contains(datacenter.getLocation());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java
deleted file mode 100644
index 78af71d..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.Datastore;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Datastore} filters.
- *
- * @author Ignasi Barrera
- */
-public class DatastorePredicates {
- public static Predicate<Datastore> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Datastore>() {
- @Override
- public boolean apply(final Datastore datastore) {
- return Arrays.asList(names).contains(datastore.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java
deleted file mode 100644
index 09acc8c..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import com.abiquo.model.enumerator.HypervisorType;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link HypervisorType} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class HypervisorPredicates {
- public static Predicate<HypervisorType> type(final HypervisorType... types) {
- checkNotNull(types, "types must be defined");
-
- return new Predicate<HypervisorType>() {
- @Override
- public boolean apply(final HypervisorType type) {
- return Arrays.asList(types).contains(type);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java
deleted file mode 100644
index 497868e..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.LogicServer;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link LogicServer} filters.
- *
- * @author Francesc Montserrat
- */
-public class LogicServerPredicates {
- public static Predicate<LogicServer> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<LogicServer>() {
- @Override
- public boolean apply(final LogicServer logicServer) {
- return Arrays.asList(names).contains(logicServer.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java
deleted file mode 100644
index 38a1542..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.Machine;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Machine} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class MachinePredicates {
- public static Predicate<Machine> name(final String... names) {
- checkNotNull(names, "name must be defined");
-
- return new Predicate<Machine>() {
- @Override
- public boolean apply(final Machine machine) {
- return Arrays.asList(names).contains(machine.getName());
- }
- };
- }
-
- public static Predicate<Machine> ip(final String ip) {
- return ips(checkNotNull(ip, "ip must be defined"));
- }
-
- public static Predicate<Machine> ips(final String... ips) {
- checkNotNull(ips, "ips must be defined");
-
- return new Predicate<Machine>() {
- @Override
- public boolean apply(final Machine machine) {
- return Arrays.asList(ips).contains(machine.getIp());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java
deleted file mode 100644
index 1b47566..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.ManagedRack;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link ManagedRack} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class ManagedRackPredicates {
- public static Predicate<ManagedRack> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<ManagedRack>() {
- @Override
- public boolean apply(final ManagedRack rack) {
- return Arrays.asList(names).contains(rack.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/NetworkInterfacePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/NetworkInterfacePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/NetworkInterfacePredicates.java
deleted file mode 100644
index 289652e..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/NetworkInterfacePredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.NetworkInterface;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link NetworkInterface} filters.
- *
- * @author Jaume Devesa
- */
-public class NetworkInterfacePredicates {
- public static Predicate<NetworkInterface> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<NetworkInterface>() {
- @Override
- public boolean apply(final NetworkInterface ni) {
- return Arrays.asList(names).contains(ni.getName());
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java
deleted file mode 100644
index 35074dc..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.Rack;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Rack} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class RackPredicates {
- public static Predicate<Rack> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Rack>() {
- @Override
- public boolean apply(final Rack rack) {
- return Arrays.asList(names).contains(rack.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java
deleted file mode 100644
index aa28571..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.RemoteService;
-
-import com.abiquo.model.enumerator.RemoteServiceType;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link RemoteService} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class RemoteServicePredicates {
- public static Predicate<RemoteService> type(final RemoteServiceType... types) {
- checkNotNull(types, "types must be defined");
-
- return new Predicate<RemoteService>() {
- @Override
- public boolean apply(final RemoteService remoteService) {
- return Arrays.asList(types).contains(remoteService.getType());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java
deleted file mode 100644
index e14e9d6..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.StorageDeviceMetadata;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link StorageDeviceMetadata} filters.
- *
- * @author Ignasi Barrera
- */
-public class StorageDeviceMetadataPredicates {
-
- public static Predicate<StorageDeviceMetadata> type(final String... types) {
- checkNotNull(types, "types must be defined");
-
- return new Predicate<StorageDeviceMetadata>() {
- @Override
- public boolean apply(final StorageDeviceMetadata metadata) {
- return Arrays.asList(types).contains(metadata.getType());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java
deleted file mode 100644
index 0623537..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.StorageDevice;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link StorageDevice} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class StorageDevicePredicates {
- public static Predicate<StorageDevice> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<StorageDevice>() {
- @Override
- public boolean apply(final StorageDevice storageDevice) {
- return Arrays.asList(names).contains(storageDevice.getName());
- }
- };
- }
-
- public static Predicate<StorageDevice> managementIp(final String... ips) {
- checkNotNull(ips, "managementIps must be defined");
-
- return new Predicate<StorageDevice>() {
- @Override
- public boolean apply(final StorageDevice storageDevice) {
- return Arrays.asList(ips).contains(storageDevice.getManagementIp());
- }
- };
- }
-
- public static Predicate<StorageDevice> type(final String... types) {
- checkNotNull(types, "types must be defined");
-
- return new Predicate<StorageDevice>() {
- @Override
- public boolean apply(final StorageDevice storageDevice) {
- return Arrays.asList(types).contains(storageDevice.getType());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java
deleted file mode 100644
index 7fda6b5..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.StoragePool;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link StoragePool} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class StoragePoolPredicates {
- public static Predicate<StoragePool> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<StoragePool>() {
- @Override
- public boolean apply(final StoragePool storagePool) {
- return Arrays.asList(names).contains(storagePool.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java
deleted file mode 100644
index 726a3ce..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.infrastructure.Tier;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Tier} filters.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- */
-public class TierPredicates {
- public static Predicate<Tier> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Tier>() {
- @Override
- public boolean apply(final Tier tier) {
- return Arrays.asList(names).contains(tier.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java
deleted file mode 100644
index 5ac19d1..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.network.AbstractPublicIp;
-import org.jclouds.abiquo.domain.network.Ip;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Network} filters.
- *
- * @author Francesc Montserrat
- */
-public class IpPredicates {
- public static <T extends Ip<?, ?>> Predicate<T> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(final T address) {
- return Arrays.asList(names).contains(address.getName());
- }
- };
- }
-
- public static <T extends Ip<?, ?>> Predicate<T> address(final String... addresses) {
- checkNotNull(addresses, "addresses must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(final T address) {
- return Arrays.asList(addresses).contains(address.getIp());
- }
- };
- }
-
- public static <T extends AbstractPublicIp<?, ?>> Predicate<T> available() {
- return new Predicate<T>() {
- @Override
- public boolean apply(final T address) {
- return address.isAvailable();
- }
- };
- }
-
- public static <T extends Ip<?, ?>> Predicate<T> notUsed() {
- return new Predicate<T>() {
- @Override
- public boolean apply(final T address) {
- return address.unwrap().searchLink("virtualmachine") == null;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java
deleted file mode 100644
index a5e737f..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.network.Ip;
-import org.jclouds.abiquo.domain.network.Network;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Network} filters.
- *
- * @author Francesc Montserrat
- */
-public class NetworkPredicates {
- public static <T extends Ip<?, ?>> Predicate<Network<T>> name(final String... names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<Network<T>>() {
- @Override
- public boolean apply(final Network<T> network) {
- return Arrays.asList(names).contains(network.getName());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkServiceTypePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkServiceTypePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkServiceTypePredicates.java
deleted file mode 100644
index 8439b88..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkServiceTypePredicates.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.network;
-
-import org.jclouds.abiquo.domain.network.NetworkServiceType;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link NetworkServiceType} filters.
- *
- * @author Jaume Devesa
- */
-public class NetworkServiceTypePredicates {
- public static Predicate<NetworkServiceType> isDefault() {
- return new Predicate<NetworkServiceType>() {
- @Override
- public boolean apply(final NetworkServiceType ni) {
- return ni.isDefaultNST();
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java
deleted file mode 100644
index a45735c..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.network.Nic;
-
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link Nic} filters.
- *
- * @author Francesc Montserrat
- */
-public class NicPredicates {
- public static Predicate<Nic> ip(final String... ips) {
- checkNotNull(ips, "ips must be defined");
-
- return new Predicate<Nic>() {
- @Override
- public boolean apply(final Nic nic) {
- return Arrays.asList(ips).contains(nic.getIp());
- }
- };
- }
-
- public static Predicate<Nic> mac(final String... macs) {
- checkNotNull(macs, "macs must be defined");
-
- return new Predicate<Nic>() {
- @Override
- public boolean apply(final Nic nic) {
- return Arrays.asList(macs).contains(nic.getMac());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java
deleted file mode 100644
index 95bb6fd..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.task;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.task.AsyncTask;
-
-import com.abiquo.server.core.task.enums.TaskState;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link AsyncTask} filters.
- *
- * @author Ignasi Barrera
- */
-public class AsyncTaskPredicates {
- public static Predicate<AsyncTask> state(final TaskState... states) {
- checkNotNull(states, "states must be defined");
-
- return new Predicate<AsyncTask>() {
- @Override
- public boolean apply(final AsyncTask task) {
- return Arrays.asList(states).contains(task.getState());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java b/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java
index 9289b1b..996812b 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java
@@ -42,8 +42,6 @@ public class ParentLinkName {
public static final String DATACENTER_REPOSITORY = "datacenterrepository";
- public static final String COST_CODE = "costcode";
-
public static final String CATEGORY = "category";
public static final String ICON = "icon";
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java
index e49d023..5597af7 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java
@@ -18,8 +18,6 @@ package org.jclouds.abiquo.strategy;
import org.jclouds.abiquo.domain.DomainWrapper;
-import com.google.common.base.Predicate;
-
/**
* List all entities of the given type.
*
@@ -27,6 +25,4 @@ import com.google.common.base.Predicate;
*/
public interface ListEntities<T extends DomainWrapper<?>, P extends DomainWrapper<?>> {
Iterable<T> execute(P parent);
-
- Iterable<T> execute(P parent, Predicate<T> selector);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java
index 38fe6d1..defb068 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java
@@ -18,8 +18,6 @@ package org.jclouds.abiquo.strategy;
import org.jclouds.abiquo.domain.DomainWrapper;
-import com.google.common.base.Predicate;
-
/**
* List all entities of the given type.
*
@@ -27,6 +25,4 @@ import com.google.common.base.Predicate;
*/
public interface ListRootEntities<T extends DomainWrapper<?>> {
Iterable<T> execute();
-
- Iterable<T> execute(Predicate<T> selector);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java
index de2900a..0bf459c 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.strategy.cloud;
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;
@@ -40,7 +39,6 @@ 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;
@@ -66,11 +64,6 @@ public class ListAttachedNics implements ListEntities<Ip<?, ?>, VirtualMachine>
return listIps(nicLinks);
}
- @Override
- public Iterable<Ip<?, ?>> execute(final VirtualMachine parent, final Predicate<Ip<?, ?>> selector) {
- return filter(execute(parent), selector);
- }
-
private Iterable<Ip<?, ?>> listIps(final Iterable<RESTLink> nicLinks) {
return transform(nicLinks, new Function<RESTLink, Ip<?, ?>>() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java
index 02015df..00261a9 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java
@@ -77,11 +77,6 @@ public class ListVirtualAppliances implements ListRootEntities<VirtualAppliance>
return execute(userExecutor);
}
- @Override
- public Iterable<VirtualAppliance> execute(final Predicate<VirtualAppliance> selector) {
- return execute(userExecutor, selector);
- }
-
private Iterable<VirtualApplianceDto> listConcurrentVirtualAppliances(final ListeningExecutorService executor,
final Iterable<VirtualDatacenter> vdcs) {
ListenableFuture<List<VirtualAppliancesDto>> futures = allAsList(transform(vdcs,
[6/8] JCLOUDS-156: Cleanup Abiquo provider
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java
deleted file mode 100644
index 29d5a39..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java
+++ /dev/null
@@ -1,708 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
-
-import java.util.List;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.reference.ValidationErrors;
-
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.FsmsDto;
-import com.abiquo.server.core.infrastructure.LogicServersDto;
-import com.abiquo.server.core.infrastructure.MachinesDto;
-import com.abiquo.server.core.infrastructure.OrganizationsDto;
-import com.abiquo.server.core.infrastructure.RackDto;
-import com.abiquo.server.core.infrastructure.UcsRackDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-/**
- * Adds high level functionality to {@link RackDto}.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- * @see API: <a href="http://community.abiquo.com/display/ABI20/RackResource">
- * http://community.abiquo.com/display/ABI20/RackResource</a>
- */
-public class ManagedRack extends DomainWrapper<UcsRackDto> {
- /** The default minimum VLAN id. */
- private static final int DEFAULT_VLAN_ID_MIN = 2;
-
- /** The default maximum VLAN id. */
- private static final int DEFAULT_VLAN_ID_MAX = 4094;
-
- /** The default maximum VLAN per virtual datacenter. */
- private static final int DEFAULT_VLAN_PER_VDC = 1;
-
- /** The default nrsq factor. */
- private static final int DEFAULT_NRSQ = 10;
-
- /** The datacenter where the rack belongs. */
- private Datacenter datacenter;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected ManagedRack(final ApiContext<AbiquoApi> context, final UcsRackDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- /**
- * Delete the managed rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-DeleteaRack"
- * >
- * http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource
- * #RackResource- DeleteaRack</a>
- */
- public void delete() {
- context.getApi().getInfrastructureApi().deleteRack(target);
- target = null;
- }
-
- /**
- * Create a new managed rack in Abiquo. This method wil discover the blades
- * configured in the UCS. If the data provided for the connection is invalid
- * a UcsRack will be created in Abiquo but with no Physical Machines attached
- * to it.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-CreateanewUCSRack"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * -CreateanewUCSRack< /a>
- */
- public void save() {
- target = context.getApi().getInfrastructureApi().createManagedRack(datacenter.unwrap(), target);
- }
-
- /**
- * Update rack information in the server with the data from this rack. The IP
- * data member cannot be updated. If changed will be ignored and the old IP
- * will remain.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource#RackResource-UpdateanexistingUCSrack"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * #RackResource- UpdateanexistingUCSrack</a>
- */
- public void update() {
- target = context.getApi().getInfrastructureApi().updateManagedRack(target);
- }
-
- // Parent access
- /**
- * Retrieve the datacenter where this rack is.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveadatacenter"
- * > http://community.abiquo.com/display/ABI20/DatacenterResource#
- * DatacenterResource- Retrieveadatacenter</a>
- */
- public Datacenter getDatacenter() {
- Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
- return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(datacenterId));
- }
-
- // Children access
-
- /**
- * Retrieve the list of blades in this rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- RetrievealistofMachines</a>
- */
- public List<Blade> listMachines() {
- MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target);
- return wrap(context, Blade.class, machines.getCollection());
- }
-
- /**
- * Retrieve a filtered list of blades in this rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- RetrievealistofMachines</a>
- */
- public List<Blade> listMachines(final Predicate<Blade> filter) {
- return ImmutableList.copyOf(filter(listMachines(), filter));
- }
-
- /**
- * Retrieve the first blade matching the filter within the list of machines
- * in this rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- RetrievealistofMachines</a>
- */
- public Blade findMachine(final Predicate<Blade> filter) {
- return Iterables.getFirst(filter(listMachines(), filter), null);
- }
-
- /**
- * Retrieve the list of service profiles in this UCS rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofallservicesprofilesinaUCSrack"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofallservicesprofilesinaUCSrack</a>
- */
- public List<LogicServer> listServiceProfiles() {
- LogicServersDto profiles = context.getApi().getInfrastructureApi().listServiceProfiles(target);
- return wrap(context, LogicServer.class, profiles.getCollection());
- }
-
- /**
- * Retrieve a filtered list of service profiles in this UCS rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofallservicesprofilesinaUCSrack"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofallservicesprofilesinaUCSrack</a>
- */
- public List<LogicServer> listServiceProfiles(final Predicate<LogicServer> filter) {
- return ImmutableList.copyOf(filter(listServiceProfiles(), filter));
- }
-
- /**
- * Retrieve the first service profile matching the filter within the list of
- * profiles in this rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrievealistofallservicesprofilesinaUCSrack"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrievealistofallservicesprofilesinaUCSrack</a>
- */
- public LogicServer findServiceProfile(final Predicate<LogicServer> filter) {
- return Iterables.getFirst(filter(listServiceProfiles(), filter), null);
- }
-
- /**
- * Retrieve the list of service profile templates in this UCS rack.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource-RetrievealistofallServicesProfilesTemplatesinaUCSRack"
- * > http://community.abiquo.com/display/ABI20/RackResource-
- * RetrievealistofallServicesProfilesTemplatesinaUCSRack</a>
- */
- public List<LogicServer> listServiceProfileTemplates() {
- LogicServersDto templates = context.getApi().getInfrastructureApi().listServiceProfileTemplates(target);
- return wrap(context, LogicServer.class, templates.getCollection());
- }
-
- /**
- * Retrieve a filtered list of service profile templates in this UCS rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource-RetrievealistofallServicesProfilesTemplatesinaUCSRack"
- * > http://community.abiquo.com/display/ABI20/RackResource-
- * RetrievealistofallServicesProfilesTemplatesinaUCSRack</a>
- */
- public List<LogicServer> listServiceProfileTemplates(final Predicate<LogicServer> filter) {
- return ImmutableList.copyOf(filter(listServiceProfileTemplates(), filter));
- }
-
- /**
- * Retrieve the first service profile template matching the filter within the
- * list of templates in this rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource-RetrievealistofallServicesProfilesTemplatesinaUCSRack"
- * > http://community.abiquo.com/display/ABI20/RackResource-
- * RetrievealistofallServicesProfilesTemplatesinaUCSRack</a>
- */
- public LogicServer findServiceProfileTemplate(final Predicate<LogicServer> filter) {
- return Iterables.getFirst(filter(listServiceProfileTemplates(), filter), null);
- }
-
- /**
- * Retrieve the list of organization in this UCS rack. The credentials in the
- * UcsRack configuration might not have enough rights in the UCS to retrieve
- * all organizations. Then only the allowed ones are returned. This data is
- * not persisted in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * RetrieveallorganizationsfromaUCS">
- * http://community.abiquo.com/display/ABI20/</a>
- */
- public List<Organization> listOrganizations() {
- OrganizationsDto organizations = context.getApi().getInfrastructureApi().listOrganizations(target);
- return wrap(context, Organization.class, organizations.getCollection());
- }
-
- /**
- * Retrieve a filtered list of organization in this UCS rack. The credentials
- * in the UcsRack configuration might not have enough rights in the UCS to
- * retrieve all organizations. Then only the allowed ones are returned. This
- * data is not persisted in Abiquo.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * RetrieveallorganizationsfromaUCS" >
- * http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * RetrieveallorganizationsfromaUCS</a>
- */
- public List<Organization> listOrganizations(final Predicate<Organization> filter) {
- return ImmutableList.copyOf(filter(listOrganizations(), filter));
- }
-
- /**
- * Retrieve the first organization matching the filter within the list of
- * organization in this rack. The credentials in the UcsRack configuration
- * might not have enough rights in the UCS to retrieve all organizations.
- * Then only the allowed ones are returned. This data is not persisted in
- * Abiquo.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * RetrieveallorganizationsfromaUCS">
- * http://community.abiquo.com/display/ABI20/RackResource#RackResource-
- * RetrieveallorganizationsfromaUCS</a>
- */
- public Organization findOrganization(final Predicate<Organization> filter) {
- return Iterables.getFirst(filter(listOrganizations(), filter), null);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveFSMofanentityinUCS"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - RetrieveFSMofanentityinUCS</a>
- */
- public List<Fsm> listFsm(final String entityName) {
- FsmsDto fsms = context.getApi().getInfrastructureApi().listFsms(target, entityName);
- return wrap(context, Fsm.class, fsms.getCollection());
- }
-
- // Actions
-
- /**
- * Clone a Service Profile this rack. This data is not persisted in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-ClonelogicserverinUCS"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - ClonelogicserverinUCS</a>
- */
- public void cloneLogicServer(final LogicServer logicServer, final Organization organization, final String newName) {
- context.getApi().getInfrastructureApi()
- .cloneLogicServer(this.unwrap(), logicServer.unwrap(), organization.unwrap(), newName);
- }
-
- /**
- * Associate a Service Profile and a Blade in UCS. If the Service Profile is
- * already associated then the request cannot be completed. This data is not
- * persisted in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-AssociatelogicserverwithabladeinUCS"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - AssociatelogicserverwithabladeinUCS</a>
- */
- public void associateLogicServer(final String bladeName, final LogicServer logicServer,
- final Organization organization) {
- context.getApi().getInfrastructureApi()
- .associateLogicServer(this.unwrap(), logicServer.unwrap(), organization.unwrap(), bladeName);
- }
-
- /**
- * Clone and associate a Service Profile and a Blade in UCS. If the Blade is
- * already associated then Abiquo will dissociate it first. If the request
- * cannot be completed successfully the Blade might be left with no Service
- * Profile associated. This data is not persisted in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-CloneandassociateLogicServerwithabladeinUCS"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - CloneandassociateLogicServerwithabladeinUCS</a>
- */
- public void cloneAndAssociateLogicServer(final String bladeName, final LogicServer logicServer,
- final Organization organization, final String logicServerName) {
- context
- .getApi()
- .getInfrastructureApi()
- .cloneAndAssociateLogicServer(this.unwrap(), logicServer.unwrap(), organization.unwrap(), bladeName,
- logicServerName);
- }
-
- /**
- * Instantiate and associate a Service Profile Template and a Blade in UCS.
- * If the Service Profile is already associated the request cannot be
- * successful. If the Blade is already associated then Abiquo will dissociate
- * it first. If the request cannot be completed successfully the Blade might
- * be left with no Service Profile associated. This data is not persisted in
- * Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-AssociateabladewithaLogicServerTemplate"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - AssociateabladewithaLogicServerTemplate</a>
- */
- public void associateLogicServerTemplate(final String bladeName, final LogicServer logicServer,
- final Organization organization, final String logicServerName) {
- context.getApi().getInfrastructureApi()
- .associateTemplate(this.unwrap(), logicServer.unwrap(), organization.unwrap(), bladeName, logicServerName);
- }
-
- /**
- * Dissociates a Service Profile and a Blade in UCS. This data is not
- * persisted in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-DisassociatelogicserverfromabladeinUCS"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - DisassociatelogicserverfromabladeinUCS</a>
- */
- public void disassociateLogicServer(final LogicServer logicServer) {
- context.getApi().getInfrastructureApi().dissociateLogicServer(this.unwrap(), logicServer.unwrap());
- }
-
- /**
- * Deletes a Service Profile in UCS. This data is not persisted in Abiquo.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/RackResource#RackResource-DeletelogicserverwithabladeinUCS"
- * > http://community.abiquo.com/display/ABI20/RackResource#RackResource
- * - DeletelogicserverwithabladeinUCS</a>
- */
- public void deleteLogicServer(final LogicServer logicServer) {
- context.getApi().getInfrastructureApi().deleteLogicServer(this.unwrap(), logicServer.unwrap());
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- return new Builder(context, datacenter);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Integer id;
-
- private String name;
-
- private String shortDescription;
-
- private boolean haEnabled = false;
-
- private Integer nrsq = DEFAULT_NRSQ;
-
- private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX;
-
- private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN;
-
- private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC;
-
- private String vlansIdAvoided;
-
- private Integer port;
-
- private String ip;
-
- private String password;
-
- private String user;
-
- private String defaultTemplate;
-
- private Integer maxMachinesOn;
-
- private Datacenter datacenter;
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- super();
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- this.context = context;
- }
-
- public Builder port(final Integer port) {
- this.port = port;
- return this;
- }
-
- public Builder ipAddress(final String ip) {
- this.ip = ip;
- return this;
- }
-
- public Builder password(final String password) {
- this.password = password;
- return this;
- }
-
- public Builder user(final String user) {
- this.user = user;
- return this;
- }
-
- public Builder defaultTemplate(final String defaultTemplate) {
- this.defaultTemplate = defaultTemplate;
- return this;
- }
-
- public Builder maxMachinesOn(final Integer maxMachinesOn) {
- this.maxMachinesOn = maxMachinesOn;
- return this;
- }
-
- public Builder id(final Integer id) {
- this.id = id;
- return this;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder shortDescription(final String shortDescription) {
- this.shortDescription = shortDescription;
- return this;
- }
-
- public Builder haEnabled(final boolean haEnabled) {
- this.haEnabled = haEnabled;
- return this;
- }
-
- public Builder nrsq(final int nrsq) {
- this.nrsq = nrsq;
- return this;
- }
-
- public Builder vlanIdMax(final int vlanIdMax) {
- this.vlanIdMax = vlanIdMax;
- return this;
- }
-
- public Builder vlanIdMin(final int vlanIdMin) {
- this.vlanIdMin = vlanIdMin;
- return this;
- }
-
- public Builder vlanPerVdcReserved(final int vlanPerVdcExpected) {
- this.vlanPerVdcReserved = vlanPerVdcExpected;
- return this;
- }
-
- public Builder vlansIdAvoided(final String vlansIdAvoided) {
- this.vlansIdAvoided = vlansIdAvoided;
- return this;
- }
-
- public Builder datacenter(final Datacenter datacenter) {
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- return this;
- }
-
- public ManagedRack build() {
- UcsRackDto dto = new UcsRackDto();
- dto.setId(id);
- dto.setName(name);
- dto.setShortDescription(shortDescription);
- dto.setHaEnabled(haEnabled);
- dto.setNrsq(nrsq);
- dto.setVlanIdMax(vlanIdMax);
- dto.setVlanIdMin(vlanIdMin);
- dto.setVlanPerVdcReserved(vlanPerVdcReserved);
- dto.setVlansIdAvoided(vlansIdAvoided);
- dto.setPort(port);
- dto.setIp(ip);
- dto.setPassword(password);
- dto.setUser(user);
- dto.setDefaultTemplate(defaultTemplate);
- dto.setMaxMachinesOn(maxMachinesOn);
-
- ManagedRack rack = new ManagedRack(context, dto);
- rack.datacenter = datacenter;
- return rack;
- }
-
- public static Builder fromRack(final ManagedRack in) {
- return ManagedRack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName())
- .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq())
- .vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin())
- .vlanPerVdcReserved(in.getVlanPerVdcReserved()).vlansIdAvoided(in.getVlansIdAvoided())
- .port(in.getPort()).ipAddress(in.getIp()).password(in.getPassword()).user(in.getUser())
- .defaultTemplate(in.getDefaultTemplate()).maxMachinesOn(in.getMaxMachinesOn());
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getShortDescription() {
- return target.getShortDescription();
- }
-
- public void setShortDescription(final String description) {
- target.setShortDescription(description);
- }
-
- public void setHaEnabled(final boolean haEnabled) {
- target.setHaEnabled(haEnabled);
- }
-
- public boolean isHaEnabled() {
- return target.isHaEnabled();
- }
-
- public Integer getNrsq() {
- return target.getNrsq();
- }
-
- public Integer getVlanIdMax() {
- return target.getVlanIdMax();
- }
-
- public Integer getVlanIdMin() {
- return target.getVlanIdMin();
- }
-
- public Integer getVlanPerVdcReserved() {
- return target.getVlanPerVdcReserved();
- }
-
- public String getVlansIdAvoided() {
- return target.getVlansIdAvoided();
- }
-
- public void setNrsq(final Integer nrsq) {
- target.setNrsq(nrsq);
- }
-
- public void setVlanIdMax(final Integer vlanIdMax) {
- target.setVlanIdMax(vlanIdMax);
- }
-
- public void setVlanIdMin(final Integer vlanIdMin) {
- target.setVlanIdMin(vlanIdMin);
- }
-
- public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved) {
- target.setVlanPerVdcReserved(vlanPerVdcReserved);
- }
-
- public void setVlansIdAvoided(final String vlansIdAvoided) {
- target.setVlansIdAvoided(vlansIdAvoided);
- }
-
- public String getIp() {
- return target.getIp();
- }
-
- public String getLongDescription() {
- return target.getLongDescription();
- }
-
- public Integer getMaxMachinesOn() {
- return target.getMaxMachinesOn();
- }
-
- public String getPassword() {
- return target.getPassword();
- }
-
- public Integer getPort() {
- return target.getPort();
- }
-
- public String getUser() {
- return target.getUser();
- }
-
- public void setDefaultTemplate(final String defaultTemplate) {
- target.setDefaultTemplate(defaultTemplate);
- }
-
- public String getDefaultTemplate() {
- return target.getDefaultTemplate();
- }
-
- public void setIp(final String ip) {
- target.setIp(ip);
- }
-
- public void setMaxMachinesOn(final Integer maxMachinesOn) {
- target.setMaxMachinesOn(maxMachinesOn);
- }
-
- public void setPassword(final String password) {
- target.setPassword(password);
- }
-
- public void setPort(final Integer port) {
- target.setPort(port);
- }
-
- public void setUser(final String user) {
- target.setUser(user);
- }
-
- @Override
- public String toString() {
- return "ManagedRack [id=" + getId() + ", name=" + getName() + ", shortDescription=" + getShortDescription()
- + ", haEnabled=" + isHaEnabled() + ", nrsq=" + getNrsq() + ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin="
- + getVlanIdMin() + ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided="
- + getVlansIdAvoided() + ", ip=" + getIp() + ", longDescription=" + getLongDescription()
- + ", maxMachinesOn=" + getMaxMachinesOn() + ", password=**PROTECTED**, port=" + getPort() + ", user="
- + getUser() + ", defaultTemplate=" + getDefaultTemplate() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java
deleted file mode 100644
index df8cdb3..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.infrastructure;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.OrganizationDto;
-
-/**
- * Adds high level functionality to {@link OrganizationDto}.
- *
- * @author Ignasi Barrera
- * @author Francesc Montserrat
- * @see API: <a href="http://community.abiquo.com/display/ABI20/RackResource">
- * http://community.abiquo.com/display/ABI20/RackResource</a>
- */
-public class Organization extends DomainWrapper<OrganizationDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected Organization(final ApiContext<AbiquoApi> context, final OrganizationDto target) {
- super(context, target);
- }
-
- // Delegate Methods
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public String getDn() {
- return target.getDn();
- }
-
- public String getLevel() {
- return target.getLevel();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public String getStatus() {
- return target.getStatus();
- }
-
- public void setDescription(final String value) {
- target.setDescription(value);
- }
-
- public void setDn(final String dn) {
- target.setDn(dn);
- }
-
- public void setLevel(final String value) {
- target.setLevel(value);
- }
-
- public void setName(final String value) {
- target.setName(value);
- }
-
- public void setStatus(final String value) {
- target.setStatus(value);
- }
-
- @Override
- public String toString() {
- return "Organization [name=" + getName() + ", description=" + getDescription() + ", dn=" + getDn() + ", level="
- + getLevel() + ", status=" + getStatus() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java
index 5c2dc21..d8f31c2 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.domain.infrastructure;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import java.util.List;
@@ -30,9 +29,6 @@ import org.jclouds.rest.ApiContext;
import com.abiquo.server.core.infrastructure.MachineDto;
import com.abiquo.server.core.infrastructure.MachinesDto;
import com.abiquo.server.core.infrastructure.RackDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* Adds high level functionality to {@link RackDto}. Represents unmanaged racks
@@ -137,35 +133,6 @@ public class Rack extends DomainWrapper<RackDto> {
}
/**
- * Retrieve a filtered list of physical machines in this rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- RetrievealistofMachines</a>
- */
- public List<Machine> listMachines(final Predicate<Machine> filter) {
- return ImmutableList.copyOf(filter(listMachines(), filter));
- }
-
- /**
- * Retrieve the first physical machine matching the filter within the list of
- * machines in this rack.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrievealistofMachines"
- * > http://community.abiquo.com/display/ABI20/MachineResource#
- * MachineResource- RetrievealistofMachines</a>
- */
- public Machine findMachine(final Predicate<Machine> filter) {
- return Iterables.getFirst(filter(listMachines(), filter), null);
- }
-
- /**
* Retrieve a single physical machine.
*
* @param id
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java
index 3fb2f6b..166cf82 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.domain.infrastructure;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import java.util.List;
@@ -25,7 +24,6 @@ import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.DomainWrapper;
import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
import org.jclouds.abiquo.reference.ValidationErrors;
-
import org.jclouds.abiquo.reference.rest.ParentLinkName;
import org.jclouds.rest.ApiContext;
@@ -34,9 +32,6 @@ import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto;
import com.abiquo.server.core.infrastructure.storage.StoragePoolDto;
import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto;
import com.abiquo.server.core.infrastructure.storage.TiersDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* Adds high level functionality to {@link StorageDeviceDto}. The Storage Device
@@ -140,39 +135,6 @@ public class StorageDevice extends DomainWrapper<StorageDeviceDto> {
}
/**
- * Retrieve a filtered list of storage pools in this device (synchronized
- * with the device).
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return Filtered synchronized list of storage pools in this device.
- */
- public List<StoragePool> listRemoteStoragePools(final Predicate<StoragePool> filter) {
- return ImmutableList.copyOf(filter(listRemoteStoragePools(), filter));
- }
-
- /**
- * Retrieve the first storage pool matching the filter within the list of
- * storage pools in this device (synchronized with the device).
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return First storage pool (synchronized) matching the filter or
- * <code>null</code> if there is none.
- */
- public StoragePool findRemoteStoragePool(final Predicate<StoragePool> filter) {
- return Iterables.getFirst(filter(listRemoteStoragePools(), filter), null);
- }
-
- /**
* Retrieve the list of storage pools in this device from Abiquo database
* (may not be synchronized with the device).
*
@@ -189,39 +151,6 @@ public class StorageDevice extends DomainWrapper<StorageDeviceDto> {
}
/**
- * Retrieve a filtered list of storage pools in this device from Abiquo
- * database (may not be synchronized with the device).
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return Filtered unsynchronized list of storage pools in this device.
- */
- public List<StoragePool> listStoragePools(final Predicate<StoragePool> filter) {
- return ImmutableList.copyOf(filter(listStoragePools(), filter));
- }
-
- /**
- * Retrieve the first storage pool matching the filter within the list of
- * storage pools in this device (unsynchronized with the device).
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return First storage pool (unsynchronized) matching the filter or
- * <code>null</code> if there is none.
- */
- public StoragePool findStoragePool(final Predicate<StoragePool> filter) {
- return Iterables.getFirst(filter(listStoragePools(), filter), null);
- }
-
- /**
* Retrieve a single storage pool in this device from Abiquo database.
*
* @param id
@@ -262,39 +191,6 @@ public class StorageDevice extends DomainWrapper<StorageDeviceDto> {
return DomainWrapper.wrap(context, Tier.class, dto.getCollection());
}
- /**
- * Retrieve a filtered list of tiers in the datacenter using this device.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers"
- * >
- * http://community.abiquo.com/display/ABI20/TierResource#TierResource-
- * Retrievethelistoftiers </a>
- * @return Filtered list of tiers in the datacenter using this device.
- */
- public List<Tier> listTiersFromDatacenter(final Predicate<Tier> filter) {
- return ImmutableList.copyOf(filter(listTiersFromDatacenter(), filter));
- }
-
- /**
- * Retrieve the first tier matching the filter within the list of tiers in
- * the datacenter.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource-Retrievethelistofstoragedevices"
- * > http://community.abiquo.com/display/ABI20/StorageDeviceResource#
- * StorageDeviceResource- Retrievethelistofstoragedevices</a>
- * @return First tier matching the filter or <code>null</code> if there is
- * none.
- */
- public Tier findTierInDatacenter(final Predicate<Tier> filter) {
- return Iterables.getFirst(filter(listTiersFromDatacenter(), filter), null);
- }
-
public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
return new Builder(context, datacenter);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java
index e88edc7..0bc615a 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java
@@ -16,22 +16,16 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
-import static com.google.common.collect.Iterables.filter;
-
import java.util.List;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.DomainWrapper;
-
import org.jclouds.abiquo.reference.rest.ParentLinkName;
import org.jclouds.rest.ApiContext;
import com.abiquo.server.core.infrastructure.DatacenterDto;
import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto;
import com.abiquo.server.core.infrastructure.storage.TierDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* Adds high level functionality to {@link TierDto}. The Tier Resource offers
@@ -84,38 +78,6 @@ public class Tier extends DomainWrapper<TierDto> {
return wrap(context, StoragePool.class, storagePools.getCollection());
}
- /**
- * Retrieve a filtered list of storage pools in this tier.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return Filtered list of storage pools in this tier.
- */
- public List<StoragePool> listStoragePools(final Predicate<StoragePool> filter) {
- return ImmutableList.copyOf(filter(listStoragePools(), filter));
- }
-
- /**
- * Retrieve the first storage pool matching the filter within the list of
- * pools in this tier.
- *
- * @param filter
- * Filter to be applied to the list.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource-Retrievestoragepools"
- * > http://community.abiquo.com/display/ABI20/StoragePoolResource#
- * StoragePoolResource- Retrievestoragepools</a>
- * @return First storage pool matching the filter or <code>null</code> if
- * there is none.
- */
- public StoragePool findStoragePool(final Predicate<StoragePool> filter) {
- return Iterables.getFirst(filter(listStoragePools(), filter), null);
- }
-
// Parent access
/**
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java
index 3e1eeec..0f1a4e7 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java
@@ -25,16 +25,14 @@ import java.util.List;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.DomainWrapper;
import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
+import org.jclouds.abiquo.predicates.IpPredicates;
import org.jclouds.abiquo.reference.ValidationErrors;
import org.jclouds.rest.ApiContext;
import com.abiquo.model.enumerator.NetworkType;
import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
import com.google.common.base.Function;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* Adds generic high level functionality to {@link VLANNetworkDto}.
@@ -67,20 +65,8 @@ public abstract class Network<T extends Ip<?, ?>> extends DomainWrapper<VLANNetw
return listIps(IpOptions.builder().disablePagination().build());
}
- public List<T> listIps(final Predicate<T> filter) {
- return ImmutableList.copyOf(filter(listIps(), filter));
- }
-
- public T findIp(final Predicate<T> filter) {
- return Iterables.getFirst(filter(listIps(), filter), null);
- }
-
public List<T> listUnusedIps() {
- return listIps(IpPredicates.<T> notUsed());
- }
-
- public T findUnusedIp(final Predicate<T> filter) {
- return Iterables.getFirst(filter(listUnusedIps(), filter), null);
+ return ImmutableList.copyOf(filter(listIps(), IpPredicates.<T> notUsed()));
}
// Builder
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java b/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java
deleted file mode 100644
index aac4273..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.events.handlers;
-
-import javax.annotation.Resource;
-
-import org.jclouds.abiquo.events.monitor.MonitorEvent;
-import org.jclouds.logging.Logger;
-
-/**
- * Base class for all {@link MonitorEvent} handlers.
- *
- * @author Ignasi Barrera
- */
-public abstract class AbstractEventHandler<T> {
- @Resource
- protected Logger logger = Logger.NULL;
-
- /**
- * Checks if the current handler must handle the dispatched event.
- *
- * @param event
- * The event being dispatched.
- * @return Boolean indicating if the event must be handled by the current
- * handler.
- */
- protected abstract boolean handles(MonitorEvent<T> event);
-
- // Public getters and setters to allow non-guice code to set the appropriate
- // logger
-
- public Logger getLogger() {
- return logger;
- }
-
- public void setLogger(final Logger logger) {
- this.logger = logger;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java b/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java
deleted file mode 100644
index 116e3cc..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.events.handlers;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import org.jclouds.abiquo.events.monitor.MonitorEvent;
-import org.jclouds.logging.Logger;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Lists;
-import com.google.common.eventbus.Subscribe;
-
-/**
- * An event handler that blocks the thread until all monitored objects have been
- * finished being watched.
- * <p>
- * Due to <a
- * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
- * Issue 786</a> {@link #handle(MonitorEvent)} is marked <code>final</code>to
- * avoid having duplicate events.
- *
- * @author Ignasi Barrera
- * @param <T>
- * The monitored object.
- */
-public class BlockingEventHandler<T> extends AbstractEventHandler<T> {
- /** The signal used to lock the thread. */
- @VisibleForTesting
- CountDownLatch completeSignal;
-
- /**
- * The objects being locked.
- * <p>
- * This class handles events in a thread safe way. Otherwise this collections
- * should be synchronised.
- */
- protected List<T> lockedObjects;
-
- public BlockingEventHandler(final T... lockedObjects) {
- this(Logger.NULL, lockedObjects);
- }
-
- public BlockingEventHandler(final Logger logger, final T... lockedObjects) {
- super();
- checkArgument(checkNotNull(lockedObjects, "lockedObjects").length > 0, "must provide at least one object");
- this.logger = checkNotNull(logger, "logger");
- this.lockedObjects = Lists.newArrayList(lockedObjects);
- this.logger.debug("created BlockingEventHandler locking %s objects", lockedObjects.length);
- }
-
- @Override
- protected boolean handles(final MonitorEvent<T> event) {
- logger.debug("checking if %s event on %s must be handled by %s", event.getType(), event.getTarget(), this);
- boolean handles = lockedObjects.contains(event.getTarget());
- logger.debug("%s event on %s must %sbe handled", event.getType(), event.getTarget(), handles ? "" : "not ");
- return handles;
- }
-
- /**
- * Handles the dispatched event in a thread safe way.
- * <p>
- * Due to <a
- * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
- * Issue 786</a> {@link #handle(MonitorEvent)} is marked <code>final</code>to
- * avoid having duplicate events.
- *
- * @see {@link #doBeforeRelease(MonitorEvent)}
- */
- @Subscribe
- public final void handle(final MonitorEvent<T> event) {
- if (handles(event)) {
- logger.debug("handling %s", event);
-
- try {
- doBeforeRelease(event);
- } finally {
- // Always release the lock, even if the handler code fails
- release(event.getTarget());
- }
- }
- }
-
- /**
- * Blocks the thread until all locked objects have been released.
- */
- public void lock() {
- // When invoking the lock, it is possible that all events have
- // already been consumed. If there are no objects to monitor,
- // just ignore the lock.
- if (!lockedObjects.isEmpty()) {
- try {
- completeSignal = new CountDownLatch(lockedObjects.size());
- logger.debug("creating lock for %s object(s)", lockedObjects.size());
- completeSignal.await();
- } catch (InterruptedException ex) {
- Throwables.propagate(ex);
- }
- } else {
- logger.debug("there is nothing to watch. Ignoring lock.");
- }
- }
-
- /**
- * Releases the lock on the given object.
- */
- protected void release(final T target) {
- logger.debug("releasing %s", target);
- lockedObjects.remove(target);
-
- // The completeSignal might be null if the events have been consumed
- // before acquiring the lock
- if (completeSignal != null) {
- completeSignal.countDown();
- logger.debug("releasing lock for %s. %s remaining objects", target, completeSignal.getCount());
- }
- }
-
- /**
- * Convenience method to bypass the <a
- * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
- * Issue 786</a> that forces the subscriber method to be <code>final</code>.
- */
- protected void doBeforeRelease(final MonitorEvent<T> event) {
- // Let subclasses may override it to customize behavior
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java
deleted file mode 100644
index 81d7516..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.events.monitor;
-
-/**
- * Event dispatched when a monitoring job completes without error.
- *
- * @author Ignasi Barrera
- */
-public class CompletedEvent<T> extends MonitorEvent<T> {
- public CompletedEvent(final T target) {
- super(MonitorEvent.Type.COMPLETED, target);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java
deleted file mode 100644
index 3a7d5b9..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.events.monitor;
-
-/**
- * Event dispatched when a monitoring job completes with errors.
- *
- * @author Ignasi Barrera
- */
-public class FailedEvent<T> extends MonitorEvent<T> {
- public FailedEvent(final T target) {
- super(MonitorEvent.Type.FAILED, target);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java
deleted file mode 100644
index 7cf46d3..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.events.monitor;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * base class for all monitor events.
- *
- * @author Ignasi Barrera
- */
-public class MonitorEvent<T> {
- /**
- * The type of the event.
- */
- public static enum Type {
- COMPLETED, FAILED, TIMEOUT;
- }
-
- /** The type of the event. */
- private Type type;
-
- /** The target object being monitored. */
- private T target;
-
- public MonitorEvent(final Type type, final T target) {
- super();
- this.type = checkNotNull(type, "type");
- this.target = checkNotNull(target, "target");
- }
-
- public Type getType() {
- return type;
- }
-
- public void setType(final Type type) {
- this.type = type;
- }
-
- public T getTarget() {
- return target;
- }
-
- public void setTarget(final T target) {
- this.target = target;
- }
-
- @Override
- public String toString() {
- return "MonitorEvent [type=" + type + ", target=" + target + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java
deleted file mode 100644
index d86391c..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.events.monitor;
-
-/**
- * Event dispatched when a monitoring job times out.
- *
- * @author Ignasi Barrera
- */
-public class TimeoutEvent<T> extends MonitorEvent<T> {
- public TimeoutEvent(final T target) {
- super(MonitorEvent.Type.TIMEOUT, target);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java b/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java
index 953e216..391d48d 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java
@@ -39,15 +39,12 @@ import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath;
import org.jclouds.abiquo.binders.infrastructure.AppendMachineIdToPath;
import org.jclouds.abiquo.binders.infrastructure.AppendRemoteServiceTypeToPath;
import org.jclouds.abiquo.binders.infrastructure.BindSupportedDevicesLinkToPath;
-import org.jclouds.abiquo.binders.infrastructure.ucs.BindLogicServerParameters;
-import org.jclouds.abiquo.binders.infrastructure.ucs.BindOrganizationParameters;
import org.jclouds.abiquo.domain.infrastructure.options.DatacenterOptions;
import org.jclouds.abiquo.domain.infrastructure.options.IpmiOptions;
import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions;
import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
import org.jclouds.abiquo.domain.network.options.IpOptions;
import org.jclouds.abiquo.domain.network.options.NetworkOptions;
-import org.jclouds.abiquo.domain.options.search.FilterOptions;
import org.jclouds.abiquo.functions.infrastructure.ParseDatacenterId;
import org.jclouds.abiquo.http.filters.AbiquoAuthentication;
import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType;
@@ -68,24 +65,16 @@ import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
import com.abiquo.server.core.enterprise.DatacentersLimitsDto;
import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.infrastructure.BladeLocatorLedDto;
import com.abiquo.server.core.infrastructure.DatacenterDto;
import com.abiquo.server.core.infrastructure.DatacentersDto;
-import com.abiquo.server.core.infrastructure.FsmsDto;
-import com.abiquo.server.core.infrastructure.LogicServerDto;
-import com.abiquo.server.core.infrastructure.LogicServersDto;
import com.abiquo.server.core.infrastructure.MachineDto;
import com.abiquo.server.core.infrastructure.MachineIpmiStateDto;
import com.abiquo.server.core.infrastructure.MachineStateDto;
import com.abiquo.server.core.infrastructure.MachinesDto;
-import com.abiquo.server.core.infrastructure.OrganizationDto;
-import com.abiquo.server.core.infrastructure.OrganizationsDto;
import com.abiquo.server.core.infrastructure.RackDto;
import com.abiquo.server.core.infrastructure.RacksDto;
import com.abiquo.server.core.infrastructure.RemoteServiceDto;
import com.abiquo.server.core.infrastructure.RemoteServicesDto;
-import com.abiquo.server.core.infrastructure.UcsRackDto;
-import com.abiquo.server.core.infrastructure.UcsRacksDto;
import com.abiquo.server.core.infrastructure.network.ExternalIpDto;
import com.abiquo.server.core.infrastructure.network.ExternalIpsDto;
import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto;
@@ -538,280 +527,6 @@ public interface InfrastructureApi extends Closeable {
@DELETE
void deleteRack(@EndpointLink("edit") @BinderParam(BindToPath.class) RackDto rack);
- /*********************** Managed Rack **********************/
-
- /**
- * List all managed racks for a datacenter.
- *
- * @param datacenter
- * The datacenter.
- * @return The list of managed racks for the datacenter.
- */
- @Named("ucs:listracks")
- @GET
- @Consumes(UcsRacksDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- UcsRacksDto listManagedRacks(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter);
-
- /**
- * Create a new managed rack in a datacenter.
- *
- * @param datacenter
- * The datacenter.
- * @param rack
- * The managed rack to be created.
- * @return The created rack.
- */
- @Named("ucs:createrack")
- @POST
- @Produces(UcsRackDto.BASE_MEDIA_TYPE)
- @Consumes(UcsRackDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- UcsRackDto createManagedRack(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter,
- @BinderParam(BindToXMLPayload.class) UcsRackDto rack);
-
- /**
- * Get the given managed rack from the given datacenter.
- *
- * @param datacenter
- * The datacenter.
- * @param rackId
- * The id of the rack.
- * @return The rack or <code>null</code> if it does not exist.
- */
- @Named("ucs:getrack")
- @GET
- @Consumes(UcsRackDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- UcsRackDto getManagedRack(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter,
- @BinderParam(AppendToPath.class) Integer rackId);
-
- /**
- * Updates an existing managed rack from the given datacenter.
- *
- * @param rack
- * The new attributes for the rack.
- * @return The updated rack.
- */
- @Named("ucs:updaterack")
- @PUT
- @Consumes(UcsRackDto.BASE_MEDIA_TYPE)
- @Produces(UcsRackDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- UcsRackDto updateManagedRack(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) UcsRackDto rack);
-
- /**
- * List all service profiles of the ucs rack.
- *
- * @param rack
- * The ucs rack.
- * @return The list of service profiles for the rack.
- */
- @Named("ucs:listserviceprofiles")
- @GET
- @Consumes(LogicServersDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- LogicServersDto listServiceProfiles(@EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack);
-
- /**
- * List service profiles of the ucs rack with filtering options.
- *
- * @param rack
- * The ucs rack.
- * @param options
- * Optional query params.
- * @return The list of service profiles for the rack.
- */
- @Named("ucs:listserviceprofiles")
- @GET
- @Consumes(LogicServersDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- LogicServersDto listServiceProfiles(@EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack,
- FilterOptions options);
-
- /**
- * List all service profile templates of the ucs rack.
- *
- * @param rack
- * The ucs rack.
- * @return The list of service profile templates for the rack.
- */
- @Named("ucs:listserviceprofiletemplates")
- @GET
- @Consumes(LogicServersDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- LogicServersDto listServiceProfileTemplates(
- @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack);
-
- /**
- * List all service profile templates of the ucs rack with options.
- *
- * @param rack
- * The ucs rack.
- * @param options
- * Optional query params.
- * @return The list of service profile templates for the rack.
- */
- @Named("ucs:listserviceproviletemplates")
- @GET
- @Consumes(LogicServersDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- LogicServersDto listServiceProfileTemplates(
- @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack, FilterOptions options);
-
- /**
- * List all organizations of the ucs rack.
- *
- * @param rack
- * The ucs rack.
- * @return The list of organizations for the rack.
- */
- @Named("ucs:listorganizations")
- @GET
- @Consumes(OrganizationsDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- OrganizationsDto listOrganizations(@EndpointLink("organizations") @BinderParam(BindToPath.class) UcsRackDto rack);
-
- /**
- * List all organizations of the ucs rack with options.
- *
- * @param rack
- * The ucs rack.
- * @param options
- * Optional query params.
- * @return The list of organizations for the rack.
- */
- @Named("ucs:listorganizations")
- @GET
- @Consumes(OrganizationsDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- OrganizationsDto listOrganizations(@EndpointLink("organizations") @BinderParam(BindToPath.class) UcsRackDto rack,
- FilterOptions options);
-
- /**
- * Clone a service profile.
- *
- * @param rack
- * The managed rack where the service profile will be created.
- * @param logicServer
- * The original logic server.
- * @param organization
- * The organization to be associated.
- * @param newName
- * The name of the new service profile.
- */
- @Named("ucs:clonelogicserver")
- @POST
- void cloneLogicServer(@EndpointLink("ls-clone") @BinderParam(BindToPath.class) UcsRackDto rack,
- @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer,
- @BinderParam(BindOrganizationParameters.class) OrganizationDto organization,
- @QueryParam("newName") String newName);
-
- /**
- * Delete a service profile.
- *
- * @param rack
- * The managed rack where the service profile will be created.
- * @param logicServer
- * The original logic server.
- */
- @Named("ucs:deletelogicserver")
- @POST
- void deleteLogicServer(@EndpointLink("ls-delete") @BinderParam(BindToPath.class) UcsRackDto rack,
- @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer);
-
- /**
- * Associate a service profile with a blade.
- *
- * @param rack
- * The managed rack where the service profile is.
- * @param logicServer
- * The logic server.
- * @param organization
- * The organization to be associated.
- * @param bladeName
- * The name of the blade.
- */
- @Named("ucs:associatelogicserver")
- @POST
- void associateLogicServer(@EndpointLink("ls-associate") @BinderParam(BindToPath.class) UcsRackDto rack,
- @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer,
- @BinderParam(BindOrganizationParameters.class) OrganizationDto organization,
- @QueryParam("bladeDn") String bladeName);
-
- /**
- * Associate a service profile with a blade instantiating a service profile
- * template.
- *
- * @param rack
- * The managed rack where the service profile is.
- * @param logicServer
- * The logic server.
- * @param organization
- * The organization to be associated.
- * @param newName
- * Name of the new service profile.
- * @param bladeName
- * The name of the blade.
- */
- @Named("ucs:associatetemplate")
- @POST
- void associateTemplate(@EndpointLink("ls-associatetemplate") @BinderParam(BindToPath.class) UcsRackDto rack,
- @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer,
- @BinderParam(BindOrganizationParameters.class) OrganizationDto organization,
- @QueryParam("newName") String newName, @QueryParam("bladeDn") String bladeName);
-
- /**
- * Clone a service profile and associate it with a blade.
- *
- * @param rack
- * The managed rack where the service profile is.
- * @param logicServer
- * The logic server.
- * @param organization
- * The organization to be associated.
- * @param newName
- * Name of the new service profile.
- * @param bladeName
- * The name of the blade.
- */
- @Named("ucs:cloneandassociatelogicserver")
- @POST
- void cloneAndAssociateLogicServer(@EndpointLink("ls-associateclone") @BinderParam(BindToPath.class) UcsRackDto rack,
- @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer,
- @BinderParam(BindOrganizationParameters.class) OrganizationDto organization,
- @QueryParam("newName") String newName, @QueryParam("bladeDn") String bladeName);
-
- /**
- * Dissociate a service profile from a blade.
- *
- * @param rack
- * The managed rack where the service profile is.
- * @param logicServer
- * The logic server.
- */
- @Named("ucs:dissociatelogicserver")
- @POST
- void dissociateLogicServer(@EndpointLink("ls-dissociate") @BinderParam(BindToPath.class) UcsRackDto rack,
- @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer);
-
- /**
- * Get FSM list of an entity
- *
- * @param rack
- * The managed rack where the entity belongs.
- * @param dn
- * Distinguished name of the entity.
- * @param fsm
- * The fsm.
- */
- @Named("ucs:listfsms")
- @GET
- @Consumes(FsmsDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- FsmsDto listFsms(@EndpointLink("fsm") @BinderParam(BindToPath.class) UcsRackDto rack, @QueryParam("dn") String dn);
-
/*********************** Remote Service ********************** */
/**
@@ -1038,74 +753,6 @@ public interface InfrastructureApi extends Closeable {
@JAXBResponseParser
MachinesDto listMachines(@EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack);
- /*********************** Blade ***********************/
-
- /**
- * Power off a physical machine in a UCS rack.
- *
- * @param machine
- * The physical machine.
- */
- @Named("machine:poweroff")
- @PUT
- void powerOff(@EndpointLink("poweroff") @BinderParam(BindToPath.class) MachineDto machine);
-
- /**
- * Power on a physical machine in a UCS rack.
- *
- * @param machine
- * The physical machine.
- */
- @Named("machine:poweron")
- @PUT
- void powerOn(@EndpointLink("poweron") @BinderParam(BindToPath.class) MachineDto machine);
-
- /**
- * Get the logic server associated with a machine in a Cisco UCS rack.
- *
- * @param machine
- * The physical machine.
- * @return The logic server.
- */
- @Named("machine:getlogicserver")
- @GET
- @Consumes(LogicServerDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- LogicServerDto getLogicServer(@EndpointLink("logicserver") @BinderParam(BindToPath.class) MachineDto machine);
-
- /**
- * Turn off locator led of a physical machine in a UCS rack.
- *
- * @param machine
- * The physical machine.
- */
- @Named("machine:ledon")
- @POST
- void ledOn(@EndpointLink("ledon") @BinderParam(BindToPath.class) MachineDto machine);
-
- /**
- * Light locator led of a physical machine in a UCS rack.
- *
- * @param machine
- * The physical machine.
- */
- @Named("machine:ledoff")
- @POST
- void ledOff(@EndpointLink("ledoff") @BinderParam(BindToPath.class) MachineDto machine);
-
- /**
- * Get led locator info from a physical machine in a UCS rack.
- *
- * @param machine
- * The physical machine.
- * @return Led locator information.
- */
- @Named("machine:getlocatorled")
- @GET
- @Consumes(BladeLocatorLedDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- BladeLocatorLedDto getLocatorLed(@EndpointLink("led") @BinderParam(BindToPath.class) MachineDto machine);
-
/**
* List all virtual machines in a physical machine.
*
[5/8] JCLOUDS-156: Cleanup Abiquo provider
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java b/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java
deleted file mode 100644
index 83da1ed..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.features;
-
-import java.io.Closeable;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.abiquo.binders.BindToPath;
-import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath;
-import org.jclouds.abiquo.http.filters.AbiquoAuthentication;
-import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType;
-import org.jclouds.abiquo.rest.annotations.EndpointLink;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.JAXBResponseParser;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.binders.BindToXMLPayload;
-
-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;
-
-/**
- * Provides synchronous access to Abiquo Pricing API.
- *
- * @see API: <a href="http://community.abiquo.com/display/ABI20/APIReference">
- * http://community.abiquo.com/display/ABI20/APIReference</a>
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class })
-@Path("/config")
-public interface PricingApi extends Closeable {
-
- /*********************** Currency ********************** */
-
- /**
- * List all currencies
- *
- * @return The list of currencies
- */
- @Named("currency:list")
- @GET
- @Path("/currencies")
- @Consumes(CurrenciesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CurrenciesDto listCurrencies();
-
- /**
- * Get the given currency
- *
- * @param currencyId
- * The id of the currency
- * @return The currency
- */
- @Named("currency:get")
- @GET
- @Path("/currencies/{currency}")
- @Consumes(CurrencyDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- CurrencyDto getCurrency(@PathParam("currency") Integer currencyId);
-
- /**
- * Create a new currency
- *
- * @param currency
- * The currency to be created.
- * @return The created currency.
- */
- @Named("currency:create")
- @POST
- @Path("/currencies")
- @Produces(CurrencyDto.BASE_MEDIA_TYPE)
- @Consumes(CurrencyDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CurrencyDto createCurrency(@BinderParam(BindToXMLPayload.class) CurrencyDto currency);
-
- /**
- * Updates an existing currency
- *
- * @param currency
- * The new attributes for the currency
- * @return The updated currency
- */
- @Named("currency:update")
- @PUT
- @Produces(CurrencyDto.BASE_MEDIA_TYPE)
- @Consumes(CurrencyDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CurrencyDto updateCurrency(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CurrencyDto currency);
-
- /**
- * Deletes an existing currency
- *
- * @param currency
- * The currency to delete
- */
- @Named("currency:delete")
- @DELETE
- void deleteCurrency(@EndpointLink("edit") @BinderParam(BindToPath.class) CurrencyDto currency);
-
- /*********************** CostCode ********************** */
-
- /**
- * List all costcodes
- *
- * @return The list of costcodes
- */
- @Named("costcode:list")
- @GET
- @Path("/costcodes")
- @Consumes(CostCodesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodesDto listCostCodes();
-
- /**
- * Get the given costcode
- *
- * @param costcodeId
- * The id of the costcode
- * @return The costcode
- */
- @Named("costcode:get")
- @GET
- @Path("/costcodes/{costcode}")
- @Consumes(CostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- CostCodeDto getCostCode(@PathParam("costcode") Integer costcodeId);
-
- /**
- * Create a new costcode
- *
- * @param costcode
- * The costcode to be created.
- * @return The created costcode.
- */
- @Named("costcode:create")
- @POST
- @Path("/costcodes")
- @Produces(CostCodeDto.BASE_MEDIA_TYPE)
- @Consumes(CostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodeDto createCostCode(@BinderParam(BindToXMLPayload.class) CostCodeDto costcode);
-
- /**
- * Updates an existing costcode
- *
- * @param costcode
- * The new attributes for the costcode
- * @return The updated costcode
- */
- @Named("costcode:update")
- @PUT
- @Produces(CostCodeDto.BASE_MEDIA_TYPE)
- @Consumes(CostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodeDto updateCostCode(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CostCodeDto costcode);
-
- /**
- * Deletes an existing costcode
- *
- * @param currency
- * The costcode to delete
- */
- @Named("costcode:delete")
- @DELETE
- void deleteCostCode(@EndpointLink("edit") @BinderParam(BindToPath.class) CostCodeDto costcode);
-
- /*********************** PricingTemplate ********************** */
-
- /**
- * List all pricingtemplates
- *
- * @return The list of pricingtemplates
- */
- @Named("pricingtemplate:list")
- @GET
- @Path("/pricingtemplates")
- @Consumes(PricingTemplatesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTemplatesDto listPricingTemplates();
-
- /**
- * Get the given pricingtemplate
- *
- * @param pricingTemplateId
- * The id of the pricingtemplate
- * @return The pricingtemplate
- */
- @Named("pricingtemplate:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}")
- @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingTemplateDto getPricingTemplate(@PathParam("pricingtemplate") Integer pricingTemplateId);
-
- /**
- * Create a new pricing template
- *
- * @param pricingtemplate
- * The pricingtemplate to be created
- * @return The created pricingtemplate
- */
- @Named("pricingtemplate:create")
- @POST
- @Path("/pricingtemplates")
- @Produces(PricingTemplateDto.BASE_MEDIA_TYPE)
- @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTemplateDto createPricingTemplate(@BinderParam(BindToXMLPayload.class) PricingTemplateDto pricingtemplate);
-
- /**
- * Updates an existing pricing template
- *
- * @param pricingtemplate
- * The new attributes for the pricingtemplate
- * @return The updated pricingtemplate
- */
- @Named("pricingtemplate:update")
- @PUT
- @Produces(PricingTemplateDto.BASE_MEDIA_TYPE)
- @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTemplateDto updatePricingTemplate(
- @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTemplateDto pricingtemplate);
-
- /**
- * Deletes an existing pricingtemplate
- *
- * @param pricingtemplate
- * The pricingtemplate to delete
- */
- @Named("pricingtemplate:delete")
- @DELETE
- void deletePricingTemplate(@EndpointLink("edit") @BinderParam(BindToPath.class) PricingTemplateDto pricingtemplate);
-
- /*********************** CostCodeCurrency ********************** */
-
- /**
- * Get the given costcodecurrency
- *
- * @param costcodecurrencyId
- * The id of the costcodecurrency
- * @return The costcodecurrency
- */
- @Named("costcodecurrency:get")
- @GET
- @Path("/costcodes/{costcode}/currencies")
- @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- CostCodeCurrenciesDto getCostCodeCurrencies(@PathParam("costcode") Integer costcodeId,
- @QueryParam("idCurrency") Integer currencyId);
-
- /**
- * Updates cost code currencies
- *
- * @param costcodeCurrency
- * The new attributes for the costcodecurrencies
- * @return The updated costcodecurrencies
- */
- @Named("costcodecurrency:update")
- @PUT
- @Path("/costcodes/{costcode}/currencies")
- @Produces(CostCodeCurrenciesDto.BASE_MEDIA_TYPE)
- @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodeCurrenciesDto updateCostCodeCurrencies(@PathParam("costcode") Integer costcodeId,
- @BinderParam(BindToXMLPayload.class) CostCodeCurrenciesDto costcodecurrencies);
-
- /*********************** PricingTemplateCostCode ********************** */
-
- /**
- * Get the pricing cost codes for a pricing template
- *
- * @param pricingTemplateId
- * @return pricingcostcodes
- */
- @Named("pricingcostcode:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/costcodes")
- @Consumes(PricingCostCodesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingCostCodesDto getPricingCostCodes(@PathParam("pricingtemplate") Integer pricingTemplateId);
-
- /**
- * Get the given pricing cost code
- *
- * @param pricingCostCodeId
- * the id of the pricing cost code
- * @return The pricingcostcode
- */
- @Named("pricingcostcode:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}")
- @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingCostCodeDto getPricingCostCode(@PathParam("pricingtemplate") Integer pricingTemplateId,
- @PathParam("costcode") Integer pricingCostcodeId);
-
- /**
- * Updates an existing pricingcostcode
- *
- * @param costcodeCurrency
- * The new attributes for the pricingcostcode
- * @return The updated pricingcostcode
- */
- @Named("pricingcostcode:update")
- @PUT
- @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}")
- @Produces(PricingCostCodeDto.BASE_MEDIA_TYPE)
- @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingCostCodeDto updatePricingCostCode(
- @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingCostCodeDto pricingcostcode,
- @PathParam("pricingtemplate") Integer pricingTemplateId, @PathParam("costcode") Integer pricingCostcodeId);
-
- /*********************** PricingTemplateTier ********************** */
-
- /**
- * Get the pricing tiers for a pricing template
- *
- * @param pricingTemplateId
- * @return pricingtiers
- */
- @Named("pricingtier:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/tiers")
- @Consumes(PricingTiersDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingTiersDto getPricingTiers(@PathParam("pricingtemplate") Integer pricingTemplateId);
-
- /**
- * Get the given pricing tier
- *
- * @param pricingTierId
- * The id of the pricing tier
- * @return The pricingtier
- */
- @Named("pricingtier:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}")
- @Consumes(PricingTierDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingTierDto getPricingTier(@PathParam("pricingtemplate") Integer pricingTemplateId,
- @PathParam("tier") Integer pricingTierId);
-
- /**
- * Updates an existing pricing tier
- *
- * @param costcodeCurrency
- * The new attributes for the pricing tier
- * @return The updated pricing tier
- */
- @Named("pricingtier:update")
- @PUT
- @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}")
- @Produces(PricingTierDto.BASE_MEDIA_TYPE)
- @Consumes(PricingTierDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTierDto updatePricingTier(
- @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTierDto pricingtier,
- @PathParam("pricingtemplate") Integer pricingTemplateId, @PathParam("tier") Integer pricingTierId);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
index 836b98b..2278708 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
@@ -28,7 +28,6 @@ import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Machine;
import org.jclouds.abiquo.internal.BaseAdministrationService;
-import com.google.common.base.Predicate;
import com.google.inject.ImplementedBy;
/**
@@ -47,17 +46,6 @@ public interface AdministrationService {
Iterable<Datacenter> listDatacenters();
/**
- * Get the list of datacenters matching the given filter.
- */
- Iterable<Datacenter> listDatacenters(final Predicate<Datacenter> filter);
-
- /**
- * Get the first datacenter that matches the given filter or
- * <code>null</code> if none is found.
- */
- Datacenter findDatacenter(final Predicate<Datacenter> filter);
-
- /**
* Get the datacenter with the given id.
*/
Datacenter getDatacenter(final Integer datacenterId);
@@ -69,17 +57,6 @@ public interface AdministrationService {
*/
public Iterable<Machine> listMachines();
- /**
- * Get the list of all machines in the infrastructure matching the given
- * filter.
- */
- public Iterable<Machine> listMachines(Predicate<Machine> filter);
-
- /**
- * Get the first machine in the infrastructure that matches the given filter.
- */
- public Machine findMachine(Predicate<Machine> filter);
-
/*********************** Enterprise ***********************/
/**
@@ -88,17 +65,6 @@ public interface AdministrationService {
Iterable<Enterprise> listEnterprises();
/**
- * Get the list of enterprises matching the given filter.
- */
- Iterable<Enterprise> listEnterprises(final Predicate<Enterprise> filter);
-
- /**
- * Get the first enterprises that matches the given filter or
- * <code>null</code> if none is found.
- */
- Enterprise findEnterprise(final Predicate<Enterprise> filter);
-
- /**
* Get the enterprise with the given id.
*/
Enterprise getEnterprise(final Integer enterpriseId);
@@ -117,17 +83,6 @@ public interface AdministrationService {
Iterable<Role> listRoles();
/**
- * Get the list of roles matching the given filter.
- */
- Iterable<Role> listRoles(final Predicate<Role> filter);
-
- /**
- * Get the first role that matches the given filter or <code>null</code> if
- * none is found.
- */
- Role findRole(final Predicate<Role> filter);
-
- /**
* Get the role with the given id.
*/
Role getRole(final Integer roleId);
@@ -140,17 +95,6 @@ public interface AdministrationService {
Iterable<Privilege> listPrivileges();
/**
- * Get the list of privileges matching the given filter.
- */
- Iterable<Privilege> listPrivileges(final Predicate<Privilege> filter);
-
- /**
- * Get the first privilege that matches the given filter or <code>null</code>
- * if none is found.
- */
- Privilege findPrivilege(final Predicate<Privilege> filter);
-
- /**
* Get a privilege given its id.
*
* @param privilegeId
@@ -187,17 +131,6 @@ public interface AdministrationService {
*/
Iterable<License> listLicenses(boolean active);
- /**
- * Get the list of licenses matching the given filter.
- */
- Iterable<License> listLicenses(final Predicate<License> filter);
-
- /**
- * Get the first license that matches the given filter or <code>null</code>
- * if none is found.
- */
- License findLicense(final Predicate<License> filter);
-
/*********************** System Properties ***********************/
/**
@@ -206,17 +139,6 @@ public interface AdministrationService {
Iterable<SystemProperty> listSystemProperties();
/**
- * Get the list of system properties matching the given filter.
- */
- Iterable<SystemProperty> listSystemProperties(final Predicate<SystemProperty> filter);
-
- /**
- * Get the first system property that matches the given filter or
- * <code>null</code> if none is found.
- */
- SystemProperty findSystemProperty(final Predicate<SystemProperty> filter);
-
- /**
* Get the system property with the give name or <code>null</code> if none is
* found.
*/
@@ -235,17 +157,6 @@ public interface AdministrationService {
Iterable<Category> listCategories();
/**
- * Get the list of categories matching the given filter.
- */
- Iterable<Category> listCategories(final Predicate<Category> filter);
-
- /**
- * Get the first categories that matches the given filter or
- * <code>null</code> if none is found.
- */
- Category findCategory(final Predicate<Category> filter);
-
- /**
* Get the category identified by the given id.
*
* @param categoryId
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
index c81c2fa..fc1aeed 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
@@ -24,7 +24,6 @@ import org.jclouds.abiquo.domain.cloud.VirtualMachine;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.internal.BaseCloudService;
-import com.google.common.base.Predicate;
import com.google.inject.ImplementedBy;
/**
@@ -53,17 +52,6 @@ public interface CloudService {
Iterable<VirtualDatacenter> listVirtualDatacenters(final Enterprise enterprise);
/**
- * Get the list of virtual datacenters matching the given filter.
- */
- Iterable<VirtualDatacenter> listVirtualDatacenters(final Predicate<VirtualDatacenter> filter);
-
- /**
- * Get the first virtual datacenter that matches the given filter or
- * <code>null</code> if none is found.
- */
- VirtualDatacenter findVirtualDatacenter(final Predicate<VirtualDatacenter> filter);
-
- /**
* Get the virtual datacenter with the given id.
*/
VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId);
@@ -80,16 +68,6 @@ public interface CloudService {
*/
Iterable<VirtualAppliance> listVirtualAppliances();
- /**
- * Get the list of the virtual appliances matching the given filter.
- */
- Iterable<VirtualAppliance> listVirtualAppliances(Predicate<VirtualAppliance> filter);
-
- /**
- * Get the first virtual appliance that matches the given filter.
- */
- VirtualAppliance findVirtualAppliance(Predicate<VirtualAppliance> filter);
-
/*********************** Virtual Machine ***********************/
/**
@@ -97,13 +75,4 @@ public interface CloudService {
*/
Iterable<VirtualMachine> listVirtualMachines();
- /**
- * Get the list of the virtual machines matching the given filter.
- */
- Iterable<VirtualMachine> listVirtualMachines(Predicate<VirtualMachine> filter);
-
- /**
- * Get the first virtual machine that matches the given filter.
- */
- VirtualMachine findVirtualMachine(Predicate<VirtualMachine> filter);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
index 4602c5a..2a3d558 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
@@ -18,13 +18,13 @@ package org.jclouds.abiquo.features.services;
import java.util.concurrent.TimeUnit;
-import org.jclouds.abiquo.events.handlers.AbstractEventHandler;
import org.jclouds.abiquo.internal.BaseMonitoringService;
import org.jclouds.abiquo.monitor.AsyncTaskMonitor;
import org.jclouds.abiquo.monitor.ConversionMonitor;
import org.jclouds.abiquo.monitor.MonitorStatus;
import org.jclouds.abiquo.monitor.VirtualApplianceMonitor;
import org.jclouds.abiquo.monitor.VirtualMachineMonitor;
+import org.jclouds.abiquo.monitor.handlers.AbstractEventHandler;
import com.google.common.base.Function;
import com.google.inject.ImplementedBy;
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java
deleted file mode 100644
index 1c2004b..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.features.services;
-
-import java.util.Collection;
-
-import org.jclouds.abiquo.domain.config.CostCode;
-import org.jclouds.abiquo.domain.config.CostCodeCurrency;
-import org.jclouds.abiquo.domain.config.Currency;
-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.internal.BasePricingService;
-
-import com.google.common.base.Predicate;
-import com.google.inject.ImplementedBy;
-
-/**
- * Provides high level Abiquo administration operations.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-@ImplementedBy(BasePricingService.class)
-public interface PricingService {
-
- /*********************** Currency ***********************/
-
- /**
- * Get the list of currencies.
- */
- Iterable<Currency> listCurrencies();
-
- /**
- * Get the list of currencies matching the given filter.
- */
- Iterable<Currency> listCurrencies(final Predicate<Currency> filter);
-
- /**
- * Get the first currencies that matches the given filter or
- * <code>null</code> if none is found.
- */
- Currency findCurrency(final Predicate<Currency> 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 ***********************/
-
- /**
- * Get the list of costcodes.
- */
- Iterable<CostCode> listCostCodes();
-
- /**
- * Get the list of costcodes matching the given filter.
- */
- Iterable<CostCode> listCostCodes(final Predicate<CostCode> filter);
-
- /**
- * Get the first costcodes that matches the given filter or <code>null</code>
- * if none is found.
- */
- CostCode findCostCode(final Predicate<CostCode> 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.
- */
- Iterable<PricingTemplate> listPricingTemplates();
-
- /**
- * Get the list of pricingtemplates matching the given filter.
- */
- Iterable<PricingTemplate> listPricingTemplates(final Predicate<PricingTemplate> filter);
-
- /**
- * Get the first pricingtemplates that matches the given filter or
- * <code>null</code> if none is found.
- */
- PricingTemplate findPricingTemplate(final Predicate<PricingTemplate> 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
- */
- Iterable<CostCodeCurrency> getCostCodeCurrencies(Integer costcodeid, Integer currencyid);
-
- /*********************** PricingCostCode ***********************/
-
- /**
- * Get pricing cost codes
- */
- Collection<PricingCostCode> getPricingCostCodes(Integer pricingTemplateId);
-
- /**
- * Get a pricing cost code
- */
- PricingCostCode getPricingCostCode(Integer pricingTemplateId, Integer pricingCostCodeId);
-
- /*********************** PricingTier ***********************/
-
- /**
- * Get pricing tiers
- */
- Collection<PricingTier> getPricingTiers(Integer pricingTemplateId);
-
- /**
- * Get a pricing tier
- */
- PricingTier getPricingTier(Integer pricingTemplateId, Integer pricingTierId);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
index 3473468..7588879 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
@@ -22,8 +22,6 @@ import org.jclouds.abiquo.domain.cloud.options.VolumeOptions;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.infrastructure.LogicServer;
-import org.jclouds.abiquo.domain.infrastructure.ManagedRack;
import org.jclouds.abiquo.domain.infrastructure.StorageDevice;
import org.jclouds.abiquo.domain.infrastructure.StoragePool;
import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
@@ -31,7 +29,6 @@ import org.jclouds.abiquo.domain.network.PrivateIp;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.PublicIp;
import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.domain.options.search.FilterOptions;
import org.jclouds.abiquo.internal.BaseSearchService;
import com.google.inject.ImplementedBy;
@@ -125,26 +122,4 @@ public interface SearchService {
* The set of filtering and pagination options of the search.
*/
Iterable<PublicIp> searchPurchasedPublicIps(final VirtualDatacenter virtualDatacenter, final IpOptions options);
-
- /*********************** Logic Server ***********************/
-
- /**
- * Get the list of service profiles for managed rack.
- *
- * @param managedRack
- * The given rack.
- * @param options
- * The set of filtering and pagination options of the search.
- */
- Iterable<LogicServer> searchServiceProfiles(final ManagedRack rack, final FilterOptions options);
-
- /**
- * Get the list of service profile templates for managed rack.
- *
- * @param managedRack
- * The given rack.
- * @param options
- * The set of filtering and pagination options of the search.
- */
- Iterable<LogicServer> searchServiceProfileTemplates(final ManagedRack rack, final FilterOptions options);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
index 66a541c..9ab82e4 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
@@ -28,7 +28,6 @@ import org.jclouds.abiquo.features.services.AdministrationService;
import org.jclouds.abiquo.features.services.CloudService;
import org.jclouds.abiquo.features.services.EventService;
import org.jclouds.abiquo.features.services.MonitoringService;
-import org.jclouds.abiquo.features.services.PricingService;
import org.jclouds.abiquo.features.services.SearchService;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.Utils;
@@ -56,21 +55,17 @@ public class AbiquoContextImpl extends ComputeServiceContextImpl implements Abiq
private final EventService eventService;
- private final PricingService pricingService;
-
@Inject
public AbiquoContextImpl(@Provider final Context wrapped, @Provider final TypeToken<? extends Context> wrappedType,
final ComputeService computeService, final Utils utils, final ApiContext<AbiquoApi> providerSpecificContext,
final AdministrationService administrationService, final CloudService cloudService,
- final SearchService searchService, final MonitoringService monitoringService, final EventService eventService,
- final PricingService pricingService) {
+ final SearchService searchService, final MonitoringService monitoringService, final EventService eventService) {
super(wrapped, wrappedType, computeService, utils);
this.administrationService = checkNotNull(administrationService, "administrationService");
this.cloudService = checkNotNull(cloudService, "cloudService");
this.searchService = checkNotNull(searchService, "searchService");
this.monitoringService = checkNotNull(monitoringService, "monitoringService");
this.eventService = checkNotNull(eventService, "eventService");
- this.pricingService = checkNotNull(pricingService, "pricingService");
}
@Override
@@ -102,9 +97,4 @@ public class AbiquoContextImpl extends ComputeServiceContextImpl implements Abiq
public EventService getEventService() {
return eventService;
}
-
- @Override
- public PricingService getPricingService() {
- return pricingService;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
index b5bb885..ceffaa4 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
@@ -17,7 +17,6 @@
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;
@@ -57,9 +56,7 @@ 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;
-import com.google.common.collect.Iterables;
/**
* Provides high level Abiquo administration operations.
@@ -99,16 +96,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Datacenter> listDatacenters(final Predicate<Datacenter> filter) {
- return filter(listDatacenters(), filter);
- }
-
- @Override
- public Datacenter findDatacenter(final Predicate<Datacenter> filter) {
- return getFirst(listDatacenters(filter), null);
- }
-
- @Override
public Datacenter getDatacenter(final Integer datacenterId) {
DatacenterDto datacenter = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
return wrap(context, Datacenter.class, datacenter);
@@ -121,16 +108,6 @@ public class BaseAdministrationService implements AdministrationService {
return listMachines.execute();
}
- @Override
- public Iterable<Machine> listMachines(final Predicate<Machine> filter) {
- return listMachines.execute(filter);
- }
-
- @Override
- public Machine findMachine(final Predicate<Machine> filter) {
- return Iterables.getFirst(listMachines(filter), null);
- }
-
/*********************** Enterprise ***********************/
@Override
@@ -140,16 +117,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Enterprise> listEnterprises(final Predicate<Enterprise> filter) {
- return filter(listEnterprises(), filter);
- }
-
- @Override
- public Enterprise findEnterprise(final Predicate<Enterprise> filter) {
- return Iterables.getFirst(listEnterprises(filter), null);
- }
-
- @Override
public Enterprise getEnterprise(final Integer enterpriseId) {
EnterpriseDto enterprise = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId);
return wrap(context, Enterprise.class, enterprise);
@@ -175,16 +142,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Role> listRoles(final Predicate<Role> filter) {
- return filter(listRoles(), filter);
- }
-
- @Override
- public Role findRole(final Predicate<Role> filter) {
- return getFirst(listRoles(filter), null);
- }
-
- @Override
public Role getRole(final Integer roleId) {
RoleDto role = context.getApi().getAdminApi().getRole(roleId);
return wrap(context, Role.class, role);
@@ -199,16 +156,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Privilege> listPrivileges(final Predicate<Privilege> filter) {
- return filter(listPrivileges(), filter);
- }
-
- @Override
- public Privilege findPrivilege(final Predicate<Privilege> 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);
@@ -241,16 +188,6 @@ public class BaseAdministrationService implements AdministrationService {
return wrap(context, License.class, result.getCollection());
}
- @Override
- public Iterable<License> listLicenses(final Predicate<License> filter) {
- return filter(listLicenses(), filter);
- }
-
- @Override
- public License findLicense(final Predicate<License> filter) {
- return getFirst(listLicenses(filter), null);
- }
-
/*********************** System Properties ***********************/
@Override
@@ -260,16 +197,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<SystemProperty> listSystemProperties(final Predicate<SystemProperty> filter) {
- return filter(listSystemProperties(), filter);
- }
-
- @Override
- public SystemProperty findSystemProperty(final Predicate<SystemProperty> filter) {
- return getFirst(listSystemProperties(filter), null);
- }
-
- @Override
public SystemProperty getSystemProperty(final String name) {
PropertyOptions options = PropertyOptions.builder().name(name).build();
SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options);
@@ -290,16 +217,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Category> listCategories(final Predicate<Category> filter) {
- return filter(listCategories(), filter);
- }
-
- @Override
- public Category findCategory(final Predicate<Category> filter) {
- return Iterables.getFirst(listCategories(filter), null);
- }
-
- @Override
public Category getCategory(Integer categoryId) {
CategoryDto result = context.getApi().getConfigApi().getCategory(categoryId);
return wrap(context, Category.class, result);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
index 5a434c7..6d0ca53 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
@@ -39,8 +39,6 @@ import org.jclouds.rest.ApiContext;
import com.abiquo.server.core.cloud.VirtualDatacenterDto;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
/**
* Provides high level Abiquo cloud operations.
@@ -89,11 +87,6 @@ public class BaseCloudService implements CloudService {
}
@Override
- public Iterable<VirtualDatacenter> listVirtualDatacenters(final Predicate<VirtualDatacenter> filter) {
- return listVirtualDatacenters.execute(filter);
- }
-
- @Override
public VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId) {
VirtualDatacenterDto virtualDatacenter = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
return wrap(context, VirtualDatacenter.class, virtualDatacenter);
@@ -104,11 +97,6 @@ public class BaseCloudService implements CloudService {
return listVirtualDatacenters.execute(virtualDatacenterIds);
}
- @Override
- public VirtualDatacenter findVirtualDatacenter(final Predicate<VirtualDatacenter> filter) {
- return Iterables.getFirst(listVirtualDatacenters(filter), null);
- }
-
/*********************** Virtual Appliance ********************** */
@Override
@@ -116,30 +104,10 @@ public class BaseCloudService implements CloudService {
return listVirtualAppliances.execute();
}
- @Override
- public Iterable<VirtualAppliance> listVirtualAppliances(final Predicate<VirtualAppliance> filter) {
- return listVirtualAppliances.execute(filter);
- }
-
- @Override
- public VirtualAppliance findVirtualAppliance(final Predicate<VirtualAppliance> filter) {
- return Iterables.getFirst(listVirtualAppliances(filter), null);
- }
-
/*********************** Virtual Machine ********************** */
@Override
public Iterable<VirtualMachine> listVirtualMachines() {
return listVirtualMachines.execute();
}
-
- @Override
- public Iterable<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter) {
- return listVirtualMachines.execute(filter);
- }
-
- @Override
- public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(listVirtualMachines(filter), null);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
index eb682e8..5ee4d2c 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
@@ -29,17 +29,17 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.events.handlers.AbstractEventHandler;
-import org.jclouds.abiquo.events.handlers.BlockingEventHandler;
-import org.jclouds.abiquo.events.monitor.CompletedEvent;
-import org.jclouds.abiquo.events.monitor.FailedEvent;
-import org.jclouds.abiquo.events.monitor.TimeoutEvent;
import org.jclouds.abiquo.features.services.MonitoringService;
import org.jclouds.abiquo.monitor.AsyncTaskMonitor;
import org.jclouds.abiquo.monitor.ConversionMonitor;
import org.jclouds.abiquo.monitor.MonitorStatus;
import org.jclouds.abiquo.monitor.VirtualApplianceMonitor;
import org.jclouds.abiquo.monitor.VirtualMachineMonitor;
+import org.jclouds.abiquo.monitor.events.CompletedEvent;
+import org.jclouds.abiquo.monitor.events.FailedEvent;
+import org.jclouds.abiquo.monitor.events.TimeoutEvent;
+import org.jclouds.abiquo.monitor.handlers.AbstractEventHandler;
+import org.jclouds.abiquo.monitor.handlers.BlockingEventHandler;
import org.jclouds.logging.Logger;
import org.jclouds.rest.ApiContext;
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java
deleted file mode 100644
index d5f2159..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.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;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.config.CostCode;
-import org.jclouds.abiquo.domain.config.CostCodeCurrency;
-import org.jclouds.abiquo.domain.config.Currency;
-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.rest.ApiContext;
-
-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;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- * Provides access to Abiquo pricing features.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-@Singleton
-public class BasePricingService implements PricingService {
- @VisibleForTesting
- protected ApiContext<AbiquoApi> context;
-
- @Inject
- protected BasePricingService(final ApiContext<AbiquoApi> context) {
- this.context = checkNotNull(context, "context");
- }
-
- /*********************** Currency ********************** */
-
- @Override
- public Iterable<Currency> listCurrencies() {
- CurrenciesDto result = context.getApi().getPricingApi().listCurrencies();
- return wrap(context, Currency.class, result.getCollection());
- }
-
- @Override
- public Iterable<Currency> listCurrencies(final Predicate<Currency> filter) {
- return filter(listCurrencies(), filter);
- }
-
- @Override
- public Currency findCurrency(final Predicate<Currency> filter) {
- 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<CostCode> listCostCodes() {
- CostCodesDto result = context.getApi().getPricingApi().listCostCodes();
- return wrap(context, CostCode.class, result.getCollection());
- }
-
- @Override
- public Iterable<CostCode> listCostCodes(final Predicate<CostCode> filter) {
- return filter(listCostCodes(), filter);
- }
-
- @Override
- public CostCode findCostCode(final Predicate<CostCode> filter) {
- 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<PricingTemplate> listPricingTemplates() {
- PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates();
- return wrap(context, PricingTemplate.class, result.getCollection());
- }
-
- @Override
- public Iterable<PricingTemplate> listPricingTemplates(final Predicate<PricingTemplate> filter) {
- return filter(listPricingTemplates(), filter);
- }
-
- @Override
- public PricingTemplate findPricingTemplate(final Predicate<PricingTemplate> filter) {
- 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 ********************** */
-
- @Override
- public Iterable<CostCodeCurrency> getCostCodeCurrencies(final Integer costcodeId, final Integer currencyId) {
- CostCodeCurrenciesDto result = context.getApi().getPricingApi().getCostCodeCurrencies(costcodeId, currencyId);
- return wrap(context, CostCodeCurrency.class, result.getCollection());
- }
-
- /*********************** Pricing Cost Code ********************** */
-
- @Override
- public Collection<PricingCostCode> getPricingCostCodes(final Integer pricingTemplateId) {
- PricingCostCodesDto result = context.getApi().getPricingApi().getPricingCostCodes(pricingTemplateId);
- return wrap(context, PricingCostCode.class, result.getCollection());
- }
-
- @Override
- public PricingCostCode getPricingCostCode(final Integer pricingTemplateId, final Integer pricingCostCodeId) {
- PricingCostCodeDto pricingcostcode = context.getApi().getPricingApi()
- .getPricingCostCode(pricingTemplateId, pricingCostCodeId);
- return wrap(context, PricingCostCode.class, pricingcostcode);
- }
-
- /*********************** Pricing Tier********************** */
-
- @Override
- public Collection<PricingTier> getPricingTiers(final Integer pricingTemplateId) {
- PricingTiersDto result = context.getApi().getPricingApi().getPricingTiers(pricingTemplateId);
- return wrap(context, PricingTier.class, result.getCollection());
- }
-
- @Override
- public PricingTier getPricingTier(final Integer pricingTemplateId, final Integer pricingTierId) {
- PricingTierDto pricingtier = context.getApi().getPricingApi().getPricingTier(pricingTemplateId, pricingTierId);
- return wrap(context, PricingTier.class, pricingtier);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
index 803f94b..42070e9 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
@@ -31,8 +31,6 @@ import org.jclouds.abiquo.domain.cloud.options.VolumeOptions;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.infrastructure.LogicServer;
-import org.jclouds.abiquo.domain.infrastructure.ManagedRack;
import org.jclouds.abiquo.domain.infrastructure.StorageDevice;
import org.jclouds.abiquo.domain.infrastructure.StoragePool;
import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
@@ -40,12 +38,10 @@ import org.jclouds.abiquo.domain.network.PrivateIp;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.PublicIp;
import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.domain.options.search.FilterOptions;
import org.jclouds.abiquo.features.services.SearchService;
import org.jclouds.rest.ApiContext;
import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.infrastructure.LogicServerDto;
import com.abiquo.server.core.infrastructure.network.PrivateIpDto;
import com.abiquo.server.core.infrastructure.network.PublicIpDto;
import com.abiquo.server.core.infrastructure.storage.StoragePoolDto;
@@ -133,20 +129,4 @@ public class BaseSearchService implements SearchService {
return wrap(context, PublicIp.class, ips);
}
- @Override
- public Iterable<LogicServer> searchServiceProfiles(final ManagedRack rack, final FilterOptions options) {
- List<LogicServerDto> profiles = context.getApi().getInfrastructureApi()
- .listServiceProfiles(rack.unwrap(), options).getCollection();
-
- return wrap(context, LogicServer.class, profiles);
- }
-
- @Override
- public Iterable<LogicServer> searchServiceProfileTemplates(final ManagedRack rack, final FilterOptions options) {
- List<LogicServerDto> profiles = context.getApi().getInfrastructureApi()
- .listServiceProfileTemplates(rack.unwrap(), options).getCollection();
-
- return wrap(context, LogicServer.class, profiles);
- }
-
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java
new file mode 100644
index 0000000..352f304
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.monitor.events;
+
+/**
+ * Event dispatched when a monitoring job completes without error.
+ *
+ * @author Ignasi Barrera
+ */
+public class CompletedEvent<T> extends MonitorEvent<T> {
+ public CompletedEvent(final T target) {
+ super(MonitorEvent.Type.COMPLETED, target);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java
new file mode 100644
index 0000000..af18d1d
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.monitor.events;
+
+/**
+ * Event dispatched when a monitoring job completes with errors.
+ *
+ * @author Ignasi Barrera
+ */
+public class FailedEvent<T> extends MonitorEvent<T> {
+ public FailedEvent(final T target) {
+ super(MonitorEvent.Type.FAILED, target);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java
new file mode 100644
index 0000000..0d43335
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.monitor.events;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * base class for all monitor events.
+ *
+ * @author Ignasi Barrera
+ */
+public class MonitorEvent<T> {
+ /**
+ * The type of the event.
+ */
+ public static enum Type {
+ COMPLETED, FAILED, TIMEOUT;
+ }
+
+ /** The type of the event. */
+ private Type type;
+
+ /** The target object being monitored. */
+ private T target;
+
+ public MonitorEvent(final Type type, final T target) {
+ super();
+ this.type = checkNotNull(type, "type");
+ this.target = checkNotNull(target, "target");
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(final Type type) {
+ this.type = type;
+ }
+
+ public T getTarget() {
+ return target;
+ }
+
+ public void setTarget(final T target) {
+ this.target = target;
+ }
+
+ @Override
+ public String toString() {
+ return "MonitorEvent [type=" + type + ", target=" + target + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java
new file mode 100644
index 0000000..e46c3d6
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.monitor.events;
+
+/**
+ * Event dispatched when a monitoring job times out.
+ *
+ * @author Ignasi Barrera
+ */
+public class TimeoutEvent<T> extends MonitorEvent<T> {
+ public TimeoutEvent(final T target) {
+ super(MonitorEvent.Type.TIMEOUT, target);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java
new file mode 100644
index 0000000..a1bec36
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.monitor.handlers;
+
+import javax.annotation.Resource;
+
+import org.jclouds.abiquo.monitor.events.MonitorEvent;
+import org.jclouds.logging.Logger;
+
+/**
+ * Base class for all {@link MonitorEvent} handlers.
+ *
+ * @author Ignasi Barrera
+ */
+public abstract class AbstractEventHandler<T> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ /**
+ * Checks if the current handler must handle the dispatched event.
+ *
+ * @param event
+ * The event being dispatched.
+ * @return Boolean indicating if the event must be handled by the current
+ * handler.
+ */
+ protected abstract boolean handles(MonitorEvent<T> event);
+
+ // Public getters and setters to allow non-guice code to set the appropriate
+ // logger
+
+ public Logger getLogger() {
+ return logger;
+ }
+
+ public void setLogger(final Logger logger) {
+ this.logger = logger;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java
new file mode 100644
index 0000000..0419e1a
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.monitor.handlers;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+import org.jclouds.abiquo.monitor.events.MonitorEvent;
+import org.jclouds.logging.Logger;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * An event handler that blocks the thread until all monitored objects have been
+ * finished being watched.
+ * <p>
+ * Due to <a
+ * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
+ * Issue 786</a> {@link #handle(MonitorEvent)} is marked <code>final</code>to
+ * avoid having duplicate events.
+ *
+ * @author Ignasi Barrera
+ * @param <T>
+ * The monitored object.
+ */
+public class BlockingEventHandler<T> extends AbstractEventHandler<T> {
+ /** The signal used to lock the thread. */
+ @VisibleForTesting
+ CountDownLatch completeSignal;
+
+ /**
+ * The objects being locked.
+ * <p>
+ * This class handles events in a thread safe way. Otherwise this collections
+ * should be synchronised.
+ */
+ protected List<T> lockedObjects;
+
+ public BlockingEventHandler(final T... lockedObjects) {
+ this(Logger.NULL, lockedObjects);
+ }
+
+ public BlockingEventHandler(final Logger logger, final T... lockedObjects) {
+ super();
+ checkArgument(checkNotNull(lockedObjects, "lockedObjects").length > 0, "must provide at least one object");
+ this.logger = checkNotNull(logger, "logger");
+ this.lockedObjects = Lists.newArrayList(lockedObjects);
+ this.logger.debug("created BlockingEventHandler locking %s objects", lockedObjects.length);
+ }
+
+ @Override
+ protected boolean handles(final MonitorEvent<T> event) {
+ logger.debug("checking if %s event on %s must be handled by %s", event.getType(), event.getTarget(), this);
+ boolean handles = lockedObjects.contains(event.getTarget());
+ logger.debug("%s event on %s must %sbe handled", event.getType(), event.getTarget(), handles ? "" : "not ");
+ return handles;
+ }
+
+ /**
+ * Handles the dispatched event in a thread safe way.
+ * <p>
+ * Due to <a
+ * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
+ * Issue 786</a> {@link #handle(MonitorEvent)} is marked <code>final</code>to
+ * avoid having duplicate events.
+ *
+ * @see {@link #doBeforeRelease(MonitorEvent)}
+ */
+ @Subscribe
+ public final void handle(final MonitorEvent<T> event) {
+ if (handles(event)) {
+ logger.debug("handling %s", event);
+
+ try {
+ doBeforeRelease(event);
+ } finally {
+ // Always release the lock, even if the handler code fails
+ release(event.getTarget());
+ }
+ }
+ }
+
+ /**
+ * Blocks the thread until all locked objects have been released.
+ */
+ public void lock() {
+ // When invoking the lock, it is possible that all events have
+ // already been consumed. If there are no objects to monitor,
+ // just ignore the lock.
+ if (!lockedObjects.isEmpty()) {
+ try {
+ completeSignal = new CountDownLatch(lockedObjects.size());
+ logger.debug("creating lock for %s object(s)", lockedObjects.size());
+ completeSignal.await();
+ } catch (InterruptedException ex) {
+ Throwables.propagate(ex);
+ }
+ } else {
+ logger.debug("there is nothing to watch. Ignoring lock.");
+ }
+ }
+
+ /**
+ * Releases the lock on the given object.
+ */
+ protected void release(final T target) {
+ logger.debug("releasing %s", target);
+ lockedObjects.remove(target);
+
+ // The completeSignal might be null if the events have been consumed
+ // before acquiring the lock
+ if (completeSignal != null) {
+ completeSignal.countDown();
+ logger.debug("releasing lock for %s. %s remaining objects", target, completeSignal.getCount());
+ }
+ }
+
+ /**
+ * Convenience method to bypass the <a
+ * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
+ * Issue 786</a> that forces the subscriber method to be <code>final</code>.
+ */
+ protected void doBeforeRelease(final MonitorEvent<T> event) {
+ // Let subclasses may override it to customize behavior
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java
deleted file mode 100644
index c2b06a9..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import com.abiquo.model.transport.error.ErrorDto;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link ErrorDto} filters.
- *
- * @author Ignasi Barrera
- */
-public class ErrorPredicates {
- public static Predicate<ErrorDto> code(final String... codes) {
- checkNotNull(codes, "codes must be defined");
-
- return new Predicate<ErrorDto>() {
- @Override
- public boolean apply(final ErrorDto error) {
- return Arrays.asList(codes).contains(error.getCode());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java
new file mode 100644
index 0000000..3a918f9
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.predicates;
+
+import org.jclouds.abiquo.domain.network.AbstractPublicIp;
+import org.jclouds.abiquo.domain.network.Ip;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link Network} filters.
+ *
+ * @author Francesc Montserrat
+ */
+public class IpPredicates {
+
+ public static <T extends AbstractPublicIp<?, ?>> Predicate<T> available() {
+ return new Predicate<T>() {
+ @Override
+ public boolean apply(final T address) {
+ return address.isAvailable();
+ }
+ };
+ }
+
+ public static <T extends Ip<?, ?>> Predicate<T> notUsed() {
+ return new Predicate<T>() {
+ @Override
+ public boolean apply(final T address) {
+ return address.unwrap().searchLink("virtualmachine") == null;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
index cfcc818..524fcfe 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
@@ -18,8 +18,6 @@ package org.jclouds.abiquo.predicates;
import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.Arrays;
-
import com.abiquo.model.rest.RESTLink;
import com.google.common.base.Predicate;
@@ -29,13 +27,12 @@ import com.google.common.base.Predicate;
* @author Ignasi Barrera
*/
public class LinkPredicates {
- public static Predicate<RESTLink> rel(final String... rels) {
- checkNotNull(rels, "rels must be defined");
-
+ public static Predicate<RESTLink> rel(final String rel) {
+ checkNotNull(rel, "rel must be defined");
return new Predicate<RESTLink>() {
@Override
public boolean apply(final RESTLink link) {
- return Arrays.asList(rels).contains(link.getRel());
+ return link.getRel().equals(rel);
}
};
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java
new file mode 100644
index 0000000..1e8b16e
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.predicates;
+
+import org.jclouds.abiquo.domain.network.NetworkServiceType;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link NetworkServiceType} filters.
+ *
+ * @author Jaume Devesa
+ */
+public class NetworkServiceTypePredicates {
+ public static Predicate<NetworkServiceType> isDefault() {
+ return new Predicate<NetworkServiceType>() {
+ @Override
+ public boolean apply(final NetworkServiceType ni) {
+ return ni.isDefaultNST();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java
new file mode 100644
index 0000000..ac71720
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.jclouds.abiquo.domain.cloud.Conversion;
+import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
+import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
+import org.jclouds.abiquo.domain.infrastructure.Datacenter;
+import org.jclouds.abiquo.reference.ValidationErrors;
+import org.jclouds.abiquo.reference.rest.ParentLinkName;
+
+import com.abiquo.model.enumerator.ConversionState;
+import com.abiquo.model.enumerator.HypervisorType;
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link VirtualDatacenter} filters.
+ *
+ * @author Ignasi Barrera
+ */
+public class VirtualDatacenterPredicates {
+
+ public static Predicate<VirtualDatacenter> datacenter(final Datacenter datacenter) {
+ checkNotNull(datacenter, "datacenter must be defined");
+
+ return new Predicate<VirtualDatacenter>() {
+ @Override
+ public boolean apply(final VirtualDatacenter virtualDatacenter) {
+ // Avoid using the getDatacenter() method since it will generate an
+ // unnecessary API
+ // call. We can get the ID from the datacenter link.
+ Integer datacenterId = checkNotNull(virtualDatacenter.unwrap().getIdFromLink(ParentLinkName.DATACENTER),
+ ValidationErrors.MISSING_REQUIRED_LINK);
+
+ return datacenterId.equals(datacenter.getId());
+ }
+ };
+ }
+
+ /**
+ * Check if the given template type is compatible with the given virtual
+ * datacenter type taking into account the conversions of the template.
+ *
+ * @param template
+ * The template to check.
+ * @return Predicate to check if the template or its conversions are
+ * compatibles with the given virtual datacenter.
+ */
+ public static Predicate<VirtualDatacenter> compatibleWithTemplateOrConversions(final VirtualMachineTemplate template) {
+ return new Predicate<VirtualDatacenter>() {
+ @Override
+ public boolean apply(final VirtualDatacenter vdc) {
+ HypervisorType type = vdc.getHypervisorType();
+ boolean compatible = type.isCompatible(template.getDiskFormatType());
+ if (!compatible) {
+ List<Conversion> compatibleConversions = template.listConversions(type, ConversionState.FINISHED);
+ compatible = compatibleConversions != null && !compatibleConversions.isEmpty();
+ }
+ return compatible;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java
new file mode 100644
index 0000000..445566e
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.abiquo.predicates;
+
+import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link VirtualMachineTemplate} filters.
+ *
+ * @author Francesc Montserrat
+ */
+public class VirtualMachineTemplatePredicates {
+
+ public static Predicate<VirtualMachineTemplate> isShared() {
+ return new Predicate<VirtualMachineTemplate>() {
+ @Override
+ public boolean apply(final VirtualMachineTemplate input) {
+ return input.unwrap().isShared();
+ }
+ };
+ }
+
+ public static Predicate<VirtualMachineTemplate> isInstance() {
+ return new Predicate<VirtualMachineTemplate>() {
+ @Override
+ public boolean apply(final VirtualMachineTemplate input) {
+ return input.unwrap().searchLink("master") != null;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java
deleted file mode 100644
index 777df74..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.cloud.Conversion;
-
-import com.abiquo.model.enumerator.ConversionState;
-import com.abiquo.model.enumerator.DiskFormatType;
-import com.abiquo.model.enumerator.HypervisorType;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link VirtualMachineTemplate} filters.
- *
- * @author Francesc Montserrat
- */
-public class ConversionPredicates {
-
- public static Predicate<Conversion> sourceFormat(final DiskFormatType... formats) {
- checkNotNull(formats, "formats must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return Arrays.asList(formats).contains(conversion.getSourceFormat());
- }
- };
- }
-
- public static Predicate<Conversion> targetFormat(final DiskFormatType... formats) {
- checkNotNull(formats, "formats must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return Arrays.asList(formats).contains(conversion.getTargetFormat());
- }
- };
- }
-
- public static Predicate<Conversion> state(final ConversionState... states) {
- checkNotNull(states, "states must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return Arrays.asList(states).contains(conversion.getState());
- }
- };
- }
-
- public static Predicate<Conversion> compatible(final HypervisorType type) {
- checkNotNull(type, "type must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return type.isCompatible(conversion.getTargetFormat());
- }
- };
- }
-
-}
[8/8] git commit: JCLOUDS-156: Cleanup Abiquo provider
Posted by na...@apache.org.
JCLOUDS-156: Cleanup Abiquo provider
Removed legacy and trivial code from the Abiquo provider:
* Removed all trivial predicate classes.
* Removed all find* and list* methods in the domain objects that did
nothing but delegating to Guava Iterables.
* Removed UCS and Pricing Apis, since they are out of the scope of the
provider.
* Moved monitor events to the existing monitor package.
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/commit/c5e108a8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/tree/c5e108a8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/diff/c5e108a8
Branch: refs/heads/master
Commit: c5e108a836255b6dc1178ef74221fdedd6c66d3c
Parents: 91960ff
Author: Ignasi Barrera <ig...@gmail.com>
Authored: Sat Jun 29 13:06:25 2013 +0200
Committer: Ignasi Barrera <ig...@gmail.com>
Committed: Tue Jul 2 18:25:06 2013 +0200
----------------------------------------------------------------------
.../main/java/org/jclouds/abiquo/AbiquoApi.java | 9 +-
.../java/org/jclouds/abiquo/AbiquoContext.java | 8 -
.../ucs/BindLogicServerParameters.java | 48 --
.../ucs/BindOrganizationParameters.java | 49 --
.../strategy/AbiquoComputeServiceAdapter.java | 24 +-
...irtualDatacentersForImageAndConversions.java | 8 +-
...bleVirtualDatacentersForImageBaseFormat.java | 6 +-
.../abiquo/domain/DomainWithTasksWrapper.java | 13 -
.../abiquo/domain/cloud/VirtualAppliance.java | 30 -
.../abiquo/domain/cloud/VirtualDatacenter.java | 164 +----
.../abiquo/domain/cloud/VirtualMachine.java | 25 -
.../domain/cloud/VirtualMachineTemplate.java | 38 -
.../jclouds/abiquo/domain/config/CostCode.java | 170 -----
.../abiquo/domain/config/CostCodeCurrency.java | 47 --
.../abiquo/domain/config/CostCodePrice.java | 58 --
.../jclouds/abiquo/domain/config/Currency.java | 144 ----
.../abiquo/domain/config/PricingCostCode.java | 111 ---
.../abiquo/domain/config/PricingTemplate.java | 375 ----------
.../abiquo/domain/config/PricingTier.java | 111 ---
.../abiquo/domain/enterprise/Enterprise.java | 285 --------
.../jclouds/abiquo/domain/enterprise/Role.java | 13 -
.../jclouds/abiquo/domain/enterprise/User.java | 19 -
.../domain/exception/AbiquoException.java | 11 +-
.../infrastructure/AbstractPhysicalMachine.java | 266 -------
.../abiquo/domain/infrastructure/Blade.java | 167 -----
.../domain/infrastructure/BladeLocatorLed.java | 68 --
.../domain/infrastructure/Datacenter.java | 432 +----------
.../abiquo/domain/infrastructure/Fsm.java | 70 --
.../domain/infrastructure/LogicServer.java | 85 ---
.../abiquo/domain/infrastructure/Machine.java | 260 +++++--
.../domain/infrastructure/ManagedRack.java | 708 -------------------
.../domain/infrastructure/Organization.java | 89 ---
.../abiquo/domain/infrastructure/Rack.java | 33 -
.../domain/infrastructure/StorageDevice.java | 104 ---
.../abiquo/domain/infrastructure/Tier.java | 38 -
.../jclouds/abiquo/domain/network/Network.java | 18 +-
.../events/handlers/AbstractEventHandler.java | 54 --
.../events/handlers/BlockingEventHandler.java | 146 ----
.../abiquo/events/monitor/CompletedEvent.java | 29 -
.../abiquo/events/monitor/FailedEvent.java | 29 -
.../abiquo/events/monitor/MonitorEvent.java | 67 --
.../abiquo/events/monitor/TimeoutEvent.java | 29 -
.../abiquo/features/InfrastructureApi.java | 353 ---------
.../org/jclouds/abiquo/features/PricingApi.java | 404 -----------
.../services/AdministrationService.java | 89 ---
.../abiquo/features/services/CloudService.java | 31 -
.../features/services/MonitoringService.java | 2 +-
.../features/services/PricingService.java | 153 ----
.../abiquo/features/services/SearchService.java | 25 -
.../abiquo/internal/AbiquoContextImpl.java | 12 +-
.../internal/BaseAdministrationService.java | 83 ---
.../abiquo/internal/BaseCloudService.java | 32 -
.../abiquo/internal/BaseMonitoringService.java | 10 +-
.../abiquo/internal/BasePricingService.java | 178 -----
.../abiquo/internal/BaseSearchService.java | 20 -
.../abiquo/monitor/events/CompletedEvent.java | 29 +
.../abiquo/monitor/events/FailedEvent.java | 29 +
.../abiquo/monitor/events/MonitorEvent.java | 67 ++
.../abiquo/monitor/events/TimeoutEvent.java | 29 +
.../monitor/handlers/AbstractEventHandler.java | 54 ++
.../monitor/handlers/BlockingEventHandler.java | 146 ++++
.../abiquo/predicates/ErrorPredicates.java | 42 --
.../jclouds/abiquo/predicates/IpPredicates.java | 48 ++
.../abiquo/predicates/LinkPredicates.java | 9 +-
.../NetworkServiceTypePredicates.java | 37 +
.../predicates/VirtualDatacenterPredicates.java | 81 +++
.../VirtualMachineTemplatePredicates.java | 47 ++
.../predicates/cloud/ConversionPredicates.java | 81 ---
.../cloud/VirtualAppliancePredicates.java | 55 --
.../cloud/VirtualDatacenterPredicates.java | 114 ---
.../cloud/VirtualMachinePredicates.java | 67 --
.../cloud/VirtualMachineTemplatePredicates.java | 96 ---
.../predicates/cloud/VolumePredicates.java | 86 ---
.../predicates/config/CategoryPredicates.java | 45 --
.../predicates/config/LicensePredicates.java | 44 --
.../predicates/config/PricingPredicates.java | 68 --
.../predicates/config/PrivilegePredicates.java | 44 --
.../config/SystemPropertyPredicates.java | 45 --
.../enterprise/EnterprisePredicates.java | 43 --
.../predicates/enterprise/RolePredicates.java | 43 --
.../TemplateDefinitionListPredicates.java | 44 --
.../predicates/enterprise/UserPredicates.java | 43 --
.../infrastructure/BladePredicates.java | 59 --
.../infrastructure/DatacenterPredicates.java | 65 --
.../infrastructure/DatastorePredicates.java | 43 --
.../infrastructure/HypervisorPredicates.java | 43 --
.../infrastructure/LogicServerPredicates.java | 43 --
.../infrastructure/MachinePredicates.java | 59 --
.../infrastructure/ManagedRackPredicates.java | 44 --
.../NetworkInterfacePredicates.java | 44 --
.../infrastructure/RackPredicates.java | 44 --
.../infrastructure/RemoteServicePredicates.java | 45 --
.../StorageDeviceMetadataPredicates.java | 44 --
.../infrastructure/StorageDevicePredicates.java | 66 --
.../infrastructure/StoragePoolPredicates.java | 44 --
.../infrastructure/TierPredicates.java | 44 --
.../abiquo/predicates/network/IpPredicates.java | 73 --
.../predicates/network/NetworkPredicates.java | 44 --
.../network/NetworkServiceTypePredicates.java | 37 -
.../predicates/network/NicPredicates.java | 54 --
.../predicates/task/AsyncTaskPredicates.java | 44 --
.../abiquo/reference/rest/ParentLinkName.java | 2 -
.../jclouds/abiquo/strategy/ListEntities.java | 4 -
.../abiquo/strategy/ListRootEntities.java | 4 -
.../abiquo/strategy/cloud/ListAttachedNics.java | 7 -
.../strategy/cloud/ListVirtualAppliances.java | 5 -
.../strategy/cloud/ListVirtualDatacenters.java | 5 -
.../strategy/cloud/ListVirtualMachines.java | 5 -
.../enterprise/ListVirtualMachineTemplates.java | 6 -
.../strategy/infrastructure/ListMachines.java | 5 -
.../jclouds/abiquo/AbiquoDelegateApiTest.java | 1 -
.../ucs/BindLogicServerParametersTest.java | 65 --
.../ucs/BindOrganizationParametersTest.java | 65 --
.../abiquo/domain/InfrastructureResources.java | 96 ---
.../jclouds/abiquo/domain/PricingResources.java | 273 -------
.../abiquo/domain/admin/RoleLiveApiTest.java | 28 +-
.../domain/cloud/VirtualApplianceLiveTest.java | 13 +-
.../cloud/VirtualDatacenterLiveApiTest.java | 31 +-
.../domain/cloud/VirtualMachineLiveTest.java | 22 +-
.../VirtualMachineNetworkingLiveApiTest.java | 22 +-
.../cloud/VirtualMachineStorageLiveApiTest.java | 11 +-
.../abiquo/domain/cloud/VolumeLiveApiTest.java | 30 +-
.../domain/config/CategoryLiveApiTest.java | 26 +-
.../domain/config/CostCodeLiveApiTest.java | 126 ----
.../domain/config/CurrencyLiveApiTest.java | 67 --
.../config/PricingTemplateLiveApiTest.java | 128 ----
.../TemplateDefinitionListLiveApiTest.java | 16 +-
.../domain/enterprise/UserLiveApiTest.java | 25 +-
.../abiquo/domain/event/EventLiveApiTest.java | 19 +-
.../domain/infrastructure/BladeLiveUcsTest.java | 81 ---
.../infrastructure/MachineLiveApiTest.java | 23 +-
.../infrastructure/ManagedRackLiveUcsTest.java | 108 ---
.../domain/infrastructure/RackLiveApiTest.java | 30 +-
.../RemoteServiceLiveApiTest.java | 31 +-
.../StorageDeviceLiveApiTest.java | 33 +-
.../infrastructure/StoragePoolLiveApiTest.java | 44 +-
.../domain/infrastructure/TierLiveApiTest.java | 28 +-
.../network/ExternalNetworkLiveApiTest.java | 15 +-
.../network/PrivateNetworkLiveApiTest.java | 5 +-
.../network/PublicNetworkLiveApiTest.java | 5 +-
.../network/UnmanagedNetworkLiveApiTest.java | 16 +-
.../environment/CloudTestEnvironment.java | 20 +-
.../InfrastructureTestEnvironment.java | 102 +--
.../handlers/BlockingEventHandlerTest.java | 109 ---
.../abiquo/features/InfrastructureApiTest.java | 431 -----------
.../jclouds/abiquo/features/PricingApiTest.java | 434 ------------
.../abiquo/internal/AsyncMonitorTest.java | 2 +-
.../internal/BaseAbiquoApiLiveApiTest.java | 7 -
.../handlers/BlockingEventHandlerTest.java | 110 +++
.../cloud/ListAttachedNicsLiveApiTest.java | 32 +-
.../cloud/ListVirtualAppliancesLiveApiTest.java | 15 -
.../ListVirtualDatacentersLiveApiTest.java | 18 +-
.../cloud/ListVirtualMachinesLiveApiTest.java | 15 -
.../ListVirtualMachineTemplatesLiveApiTest.java | 17 -
.../infrastructure/ListMachinesLiveApiTest.java | 14 -
155 files changed, 1293 insertions(+), 9884 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java
index 56f019f..4381515 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java
@@ -18,6 +18,7 @@ package org.jclouds.abiquo;
import java.io.Closeable;
+import javax.inject.Named;
import javax.ws.rs.GET;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
@@ -28,7 +29,6 @@ import org.jclouds.abiquo.features.ConfigApi;
import org.jclouds.abiquo.features.EnterpriseApi;
import org.jclouds.abiquo.features.EventApi;
import org.jclouds.abiquo.features.InfrastructureApi;
-import org.jclouds.abiquo.features.PricingApi;
import org.jclouds.abiquo.features.TaskApi;
import org.jclouds.abiquo.features.VirtualMachineTemplateApi;
import org.jclouds.abiquo.http.filters.AbiquoAuthentication;
@@ -110,18 +110,13 @@ public interface AbiquoApi extends Closeable {
EventApi getEventApi();
/**
- * Provides synchronous access to Pricing features.
- */
- @Delegate
- PricingApi getPricingApi();
-
- /**
* Perform a GET request to the given link.
*
* @param link
* The link to get.
* @return The response.
*/
+ @Named("link:get")
@GET
@Fallback(NullOnNotFoundOr404.class)
HttpResponse get(@BinderParam(BindLinkToPathAndAcceptHeader.class) final RESTLink link);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java
index 723b841..7f0d679 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java
@@ -20,7 +20,6 @@ import org.jclouds.abiquo.features.services.AdministrationService;
import org.jclouds.abiquo.features.services.CloudService;
import org.jclouds.abiquo.features.services.EventService;
import org.jclouds.abiquo.features.services.MonitoringService;
-import org.jclouds.abiquo.features.services.PricingService;
import org.jclouds.abiquo.features.services.SearchService;
import org.jclouds.abiquo.internal.AbiquoContextImpl;
import org.jclouds.compute.ComputeServiceContext;
@@ -80,11 +79,4 @@ public interface AbiquoContext extends ComputeServiceContext {
* This service provides an entry point to event management tasks.
*/
EventService getEventService();
-
- /**
- * Returns the pricing service.
- * <p>
- * This service provides an entry point to pricing management tasks.
- */
- PricingService getPricingService();
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java
deleted file mode 100644
index 806cdd7..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.binders.infrastructure.ucs;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-import com.abiquo.server.core.infrastructure.LogicServerDto;
-
-/**
- * Binds logic server query parameters to request. This method assumes that the
- * input object is a {@link LogicServerDto}.
- *
- * @author Francesc Montserrat
- * @author Ignasi Barrera
- */
-@Singleton
-public class BindLogicServerParameters implements Binder {
- @SuppressWarnings("unchecked")
- @Override
- public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
- checkArgument(checkNotNull(input, "input") instanceof LogicServerDto,
- "this binder is only valid for LogicServerDto objects");
-
- LogicServerDto server = (LogicServerDto) input;
-
- return (R) request.toBuilder().addQueryParam("lsName", checkNotNull(server.getName(), "server.name")).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java
deleted file mode 100644
index de5df6d..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.binders.infrastructure.ucs;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-import com.abiquo.server.core.infrastructure.OrganizationDto;
-
-/**
- * Binds organization query parameters to request. This method assumes that the
- * input object is a {@link OrganizationDto}.
- *
- * @author Francesc Montserrat
- * @author Ignasi Barrera
- */
-@Singleton
-public class BindOrganizationParameters implements Binder {
-
- @SuppressWarnings("unchecked")
- @Override
- public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
- checkArgument(checkNotNull(input, "input") instanceof OrganizationDto,
- "this binder is only valid for OrganizationDto objects");
-
- OrganizationDto org = (OrganizationDto) input;
-
- return (R) request.toBuilder().addQueryParam("org", checkNotNull(org.getDn(), "org.dn")).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java b/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java
index 6d12bcd..92cee74 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Iterables.contains;
import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.transform;
import java.util.List;
@@ -43,9 +44,7 @@ import org.jclouds.abiquo.features.services.AdministrationService;
import org.jclouds.abiquo.features.services.CloudService;
import org.jclouds.abiquo.features.services.MonitoringService;
import org.jclouds.abiquo.monitor.VirtualMachineMonitor;
-import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates;
-import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
+import org.jclouds.abiquo.predicates.IpPredicates;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceAdapter;
@@ -120,7 +119,13 @@ public class AbiquoComputeServiceAdapter
.getId()));
// Load the virtual appliance or create it if it does not exist
- VirtualAppliance vapp = vdc.findVirtualAppliance(VirtualAppliancePredicates.name(tag));
+ VirtualAppliance vapp = find(vdc.listVirtualAppliances(), new Predicate<VirtualAppliance>() {
+ @Override
+ public boolean apply(VirtualAppliance input) {
+ return input.getName().equals(tag);
+ }
+ }, null);
+
if (vapp == null) {
vapp = VirtualAppliance.builder(context, vdc).name(tag).build();
vapp.save();
@@ -143,7 +148,7 @@ public class AbiquoComputeServiceAdapter
// If no public ip is available in the virtual datacenter, the virtual
// machine will be assigned by default an ip address in the default
// private VLAN for the virtual datacenter
- PublicIp publicIp = vdc.findPurchasedPublicIp(IpPredicates.<PublicIp> notUsed());
+ PublicIp publicIp = find(vdc.listPurchasedPublicIps(), IpPredicates.<PublicIp> notUsed(), null);
if (publicIp != null) {
List<PublicIp> ips = Lists.newArrayList();
ips.add(publicIp);
@@ -189,7 +194,12 @@ public class AbiquoComputeServiceAdapter
@Override
public VirtualMachineTemplate getImage(final String id) {
Enterprise enterprise = adminService.getCurrentEnterprise();
- return enterprise.findTemplate(VirtualMachineTemplatePredicates.id(Integer.valueOf(id)));
+ return find(enterprise.listTemplates(), new Predicate<VirtualMachineTemplate>() {
+ @Override
+ public boolean apply(VirtualMachineTemplate input) {
+ return input.getId().equals(id);
+ }
+ }, null);
}
@Override
@@ -199,7 +209,7 @@ public class AbiquoComputeServiceAdapter
@Override
public VirtualMachine getNode(final String id) {
- return cloudService.findVirtualMachine(vmId(id));
+ return find(cloudService.listVirtualMachines(), vmId(id), null);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java b/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java
index 407ebfa..949d9b7 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java
@@ -19,7 +19,7 @@ package org.jclouds.abiquo.compute.strategy.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.abiquo.predicates.cloud.VirtualDatacenterPredicates.compatibleWithTemplateOrConversions;
+import static org.jclouds.abiquo.predicates.VirtualDatacenterPredicates.compatibleWithTemplateOrConversions;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -30,7 +30,7 @@ import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.features.services.CloudService;
-import org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates;
+import org.jclouds.abiquo.predicates.VirtualDatacenterPredicates;
import org.jclouds.abiquo.reference.rest.ParentLinkName;
import org.jclouds.rest.ApiContext;
@@ -67,8 +67,8 @@ public class FindCompatibleVirtualDatacentersForImageAndConversions implements F
datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY));
Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto);
- Iterable<VirtualDatacenter> vdcs = cloudService.listVirtualDatacenters(VirtualDatacenterPredicates
- .datacenter(datacenter));
+ Iterable<VirtualDatacenter> vdcs = filter(cloudService.listVirtualDatacenters(),
+ VirtualDatacenterPredicates.datacenter(datacenter));
return filter(vdcs, compatibleWithTemplateOrConversions(template));
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java b/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java
index 9873ec0..c6dd0ea 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java
@@ -29,7 +29,7 @@ import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.features.services.CloudService;
-import org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates;
+import org.jclouds.abiquo.predicates.VirtualDatacenterPredicates;
import org.jclouds.abiquo.reference.rest.ParentLinkName;
import org.jclouds.rest.ApiContext;
@@ -71,8 +71,8 @@ public class FindCompatibleVirtualDatacentersForImageBaseFormat implements FindC
datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY));
Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto);
- Iterable<VirtualDatacenter> vdcs = cloudService.listVirtualDatacenters(VirtualDatacenterPredicates
- .datacenter(datacenter));
+ Iterable<VirtualDatacenter> vdcs = filter(cloudService.listVirtualDatacenters(),
+ VirtualDatacenterPredicates.datacenter(datacenter));
return filter(vdcs, new Predicate<VirtualDatacenter>() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java
index b0cd9cb..5f6ddec 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java
@@ -16,8 +16,6 @@
*/
package org.jclouds.abiquo.domain;
-import static com.google.common.collect.Iterables.filter;
-
import java.util.Collections;
import java.util.List;
@@ -28,9 +26,6 @@ import org.jclouds.rest.ApiContext;
import com.abiquo.model.transport.SingleResourceTransportDto;
import com.abiquo.server.core.task.TaskDto;
import com.abiquo.server.core.task.TasksDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Longs;
@@ -60,12 +55,4 @@ public abstract class DomainWithTasksWrapper<T extends SingleResourceTransportDt
return tasks;
}
-
- public List<AsyncTask> listTasks(final Predicate<AsyncTask> filter) {
- return ImmutableList.copyOf(filter(listTasks(), filter));
- }
-
- public AsyncTask findTask(final Predicate<AsyncTask> filter) {
- return Iterables.getFirst(filter(listTasks(), filter), null);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java
index c0fe11f..fb9aa3d 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.domain.cloud;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import java.util.List;
@@ -39,9 +38,6 @@ import com.abiquo.server.core.cloud.VirtualMachineTaskDto;
import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* Represents a virtual appliance.
@@ -165,32 +161,6 @@ public class VirtualAppliance extends DomainWrapper<VirtualApplianceDto> {
}
/**
- * Gets the list of virtual machines in the virtual appliance matching the
- * given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The list of virtual machines in the virtual appliance matching the
- * given filter.
- */
- public List<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter) {
- return ImmutableList.copyOf(filter(listVirtualMachines(), filter));
- }
-
- /**
- * Gets a single virtual machine in the virtual appliance matching the given
- * filter.
- *
- * @param filter
- * The filter to apply.
- * @return The virtual machine or <code>null</code> if none matched the given
- * filter.
- */
- public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(filter(listVirtualMachines(), filter), null);
- }
-
- /**
* Gets a concrete virtual machine in the virtual appliance.
*
* @param id
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java
index c5ed0e5..c8e03f1 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java
@@ -17,7 +17,7 @@
package org.jclouds.abiquo.domain.cloud;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
import java.util.List;
@@ -30,11 +30,9 @@ import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Tier;
import org.jclouds.abiquo.domain.network.ExternalNetwork;
import org.jclouds.abiquo.domain.network.Network;
-import org.jclouds.abiquo.domain.network.PrivateIp;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.PublicIp;
import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.predicates.infrastructure.DatacenterPredicates;
import org.jclouds.abiquo.reference.ValidationErrors;
import org.jclouds.abiquo.reference.rest.ParentLinkName;
import org.jclouds.rest.ApiContext;
@@ -56,8 +54,6 @@ import com.abiquo.server.core.infrastructure.storage.TiersDto;
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto;
import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
/**
* Represents a virtual datacenter.
@@ -140,8 +136,13 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
* DatacenterResource- RetrieveaDatacenter</a>
*/
public Datacenter getDatacenter() {
- Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
- datacenter = getEnterprise().findAllowedDatacenter(DatacenterPredicates.id(datacenterId));
+ final Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER);
+ datacenter = find(getEnterprise().listAllowedDatacenters(), new Predicate<Datacenter>() {
+ @Override
+ public boolean apply(Datacenter input) {
+ return input.getId().equals(datacenterId);
+ }
+ });
return datacenter;
}
@@ -177,40 +178,6 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
}
/**
- * Lists all the virtual appliances in the virtual datacenter that match the
- * given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The list of virtual appliances in the virtual datacenter that
- * match the given filter.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource#VirtualApplianceResource-RetrievethelistofVirtualAppliances"
- * >http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource
- * # VirtualApplianceResource-RetrievethelistofVirtualAppliances</a>
- */
- public List<VirtualAppliance> listVirtualAppliances(final Predicate<VirtualAppliance> filter) {
- return ImmutableList.copyOf(filter(listVirtualAppliances(), filter));
- }
-
- /**
- * Gets the first virtual appliance in the virtual datacenter that match the
- * given filter.
- *
- * @param filter
- * The filter to apply.
- * @return the first virtual appliance in the virtual datacenter that match
- * the given filter or <code>null</code> if none is found.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource#VirtualApplianceResource-RetrievethelistofVirtualAppliances"
- * >http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource
- * # VirtualApplianceResource-RetrievethelistofVirtualAppliances</a>
- */
- public VirtualAppliance findVirtualAppliance(final Predicate<VirtualAppliance> filter) {
- return Iterables.getFirst(filter(listVirtualAppliances(), filter), null);
- }
-
- /**
* Gets the virtual appliance with the given id in the current virtual
* datacenter.
*
@@ -239,40 +206,6 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
}
/**
- * Lists the storage tiers that are available to the virtual datacenter and
- * match the given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The list of storage tiers that are available to the virtual
- * datacenter and match the given filter.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource#VirtualDatacenterResource-Retrieveenabledtiers"
- * > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+
- * Resource# VirtualDatacenterResource-Retrieveenabledtiers</a>
- */
- public List<Tier> listStorageTiers(final Predicate<Tier> filter) {
- return ImmutableList.copyOf(filter(listStorageTiers(), filter));
- }
-
- /**
- * Finds the first the storage tier that is available to the virtual
- * datacenter and matches the given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The first the storage tier that is available to the virtual
- * datacenter and matches the given filter.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource#VirtualDatacenterResource-Retrieveenabledtiers"
- * > http://community.abiquo.com/display/ABI20/Virtual+Datacenter+
- * Resource# VirtualDatacenterResource-Retrieveenabledtiers</a>
- */
- public Tier findStorageTier(final Predicate<Tier> filter) {
- return Iterables.getFirst(filter(listStorageTiers(), filter), null);
- }
-
- /**
* Gets the storage tier with the given id from the current virtual
* datacenter.
*
@@ -299,40 +232,6 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
return wrap(context, Volume.class, volumes.getCollection());
}
- /**
- * Lists all persistent volumes in the virtual datacenter that match the
- * given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The list of all persistent volumes in the virtual datacenter that
- * match the given filter.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Volume+Resource#VolumeResource-Retrievethelistofvolumes"
- * > http://community.abiquo.com/display/ABI20/Volume+Resource#
- * VolumeResource- Retrievethelistofvolumes</a>
- */
- public List<Volume> listVolumes(final Predicate<Volume> filter) {
- return ImmutableList.copyOf(filter(listVolumes(), filter));
- }
-
- /**
- * Finds the first persistent volume in the virtual datacenter that matches
- * the given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The first persistent volumes in the virtual datacenter that
- * matches the given filter.
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Volume+Resource#VolumeResource-Retrievethelistofvolumes"
- * > http://community.abiquo.com/display/ABI20/Volume+Resource#
- * VolumeResource- Retrievethelistofvolumes</a>
- */
- public Volume findVolume(final Predicate<Volume> filter) {
- return Iterables.getFirst(filter(listVolumes(), filter), null);
- }
-
public Volume getVolume(final Integer id) {
VolumeManagementDto volume = context.getApi().getCloudApi().getVolume(target, id);
return wrap(context, Volume.class, volume);
@@ -349,14 +248,6 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
return wrap(context, HardDisk.class, hardDisks.getCollection());
}
- public List<HardDisk> listHardDisks(final Predicate<HardDisk> filter) {
- return ImmutableList.copyOf(filter(listHardDisks(), filter));
- }
-
- public HardDisk findHardDisk(final Predicate<HardDisk> filter) {
- return Iterables.getFirst(filter(listHardDisks(), filter), null);
- }
-
public HardDisk getHardDisk(final Integer id) {
DiskManagementDto hardDisk = context.getApi().getCloudApi().getHardDisk(target, id);
return wrap(context, HardDisk.class, hardDisk);
@@ -387,22 +278,11 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
return wrap(context, PrivateNetwork.class, networks.getCollection());
}
- public List<PrivateNetwork> listPrivateNetworks(final Predicate<Network<PrivateIp>> filter) {
- return ImmutableList.copyOf(filter(listPrivateNetworks(), filter));
- }
-
- public PrivateNetwork findPrivateNetwork(final Predicate<Network<PrivateIp>> filter) {
- return Iterables.getFirst(filter(listPrivateNetworks(), filter), null);
- }
-
public PrivateNetwork getPrivateNetwork(final Integer id) {
VLANNetworkDto network = context.getApi().getCloudApi().getPrivateNetwork(target, id);
return wrap(context, PrivateNetwork.class, network);
}
- /**
- * TODO needs to be in the wiki
- */
public List<VirtualMachineTemplate> listAvailableTemplates() {
VirtualMachineTemplatesDto templates = context.getApi().getCloudApi().listAvailableTemplates(target);
@@ -415,14 +295,6 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
return wrap(context, VirtualMachineTemplate.class, templates.getCollection());
}
- public List<VirtualMachineTemplate> listAvailableTemplates(final Predicate<VirtualMachineTemplate> filter) {
- return ImmutableList.copyOf(filter(listAvailableTemplates(), filter));
- }
-
- public VirtualMachineTemplate findAvailableTemplate(final Predicate<VirtualMachineTemplate> filter) {
- return Iterables.getFirst(filter(listAvailableTemplates(), filter), null);
- }
-
public VirtualMachineTemplate getAvailableTemplate(final Integer id) {
VirtualMachineTemplatesDto templates = context.getApi().getCloudApi()
.listAvailableTemplates(target, VirtualMachineTemplateOptions.builder().idTemplate(id).build());
@@ -452,20 +324,10 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
*/
public List<PublicIp> listAvailablePublicIps() {
IpOptions options = IpOptions.builder().build();
-
PublicIpsDto ips = context.getApi().getCloudApi().listAvailablePublicIps(target, options);
-
return wrap(context, PublicIp.class, ips.getCollection());
}
- public List<PublicIp> listAvailablePublicIps(final Predicate<PublicIp> filter) {
- return ImmutableList.copyOf(filter(listAvailablePublicIps(), filter));
- }
-
- public PublicIp findAvailablePublicIp(final Predicate<PublicIp> filter) {
- return Iterables.getFirst(filter(listAvailablePublicIps(), filter), null);
- }
-
/**
* @see API: <a href=
* "http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource#VirtualDatacenterResource-ListofpurchasedPublicIPsbyVirtualDatacenter"
@@ -476,20 +338,10 @@ public class VirtualDatacenter extends DomainWithLimitsWrapper<VirtualDatacenter
*/
public List<PublicIp> listPurchasedPublicIps() {
IpOptions options = IpOptions.builder().build();
-
PublicIpsDto ips = context.getApi().getCloudApi().listPurchasedPublicIps(target, options);
-
return wrap(context, PublicIp.class, ips.getCollection());
}
- public List<PublicIp> listPurchasedPublicIps(final Predicate<PublicIp> filter) {
- return ImmutableList.copyOf(filter(listPurchasedPublicIps(), filter));
- }
-
- public PublicIp findPurchasedPublicIp(final Predicate<PublicIp> filter) {
- return Iterables.getFirst(filter(listPurchasedPublicIps(), filter), null);
- }
-
public void purchasePublicIp(final PublicIp ip) {
checkNotNull(ip.unwrap().searchLink("purchase"), ValidationErrors.MISSING_REQUIRED_LINK);
context.getApi().getCloudApi().purchasePublicIp(ip.unwrap());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java
index 9e675ef..eac026e 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.domain.cloud;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import java.util.Arrays;
import java.util.List;
@@ -285,42 +284,18 @@ public class VirtualMachine extends DomainWithTasksWrapper<VirtualMachineWithNod
return wrap(context, HardDisk.class, hardDisks.getCollection());
}
- public List<HardDisk> listAttachedHardDisks(final Predicate<HardDisk> filter) {
- return ImmutableList.copyOf(filter(listAttachedHardDisks(), filter));
- }
-
- public HardDisk findAttachedHardDisk(final Predicate<HardDisk> filter) {
- return Iterables.getFirst(filter(listAttachedHardDisks(), filter), null);
- }
-
public List<Volume> listAttachedVolumes() {
refresh();
VolumesManagementDto volumes = context.getApi().getCloudApi().listAttachedVolumes(target);
return wrap(context, Volume.class, volumes.getCollection());
}
- public List<Volume> listAttachedVolumes(final Predicate<Volume> filter) {
- return ImmutableList.copyOf(filter(listAttachedVolumes(), filter));
- }
-
- public Volume findAttachedVolume(final Predicate<Volume> filter) {
- return Iterables.getFirst(filter(listAttachedVolumes(), filter), null);
- }
-
public List<Ip<?, ?>> listAttachedNics() {
// The strategy will refresh the vm. There is no need to do it here
ListAttachedNics strategy = context.utils().injector().getInstance(ListAttachedNics.class);
return ImmutableList.copyOf(strategy.execute(this));
}
- public List<Ip<?, ?>> listAttachedNics(final Predicate<Ip<?, ?>> filter) {
- return ImmutableList.copyOf(filter(listAttachedNics(), filter));
- }
-
- public Ip<?, ?> findAttachedNic(final Predicate<Ip<?, ?>> filter) {
- return Iterables.getFirst(filter(listAttachedNics(), filter), null);
- }
-
// Actions
public AsyncTask deploy() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java
index 8cac027..3a0e809 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.domain.cloud;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import java.util.Date;
import java.util.List;
@@ -28,7 +27,6 @@ import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.DomainWrapper;
import org.jclouds.abiquo.domain.cloud.options.ConversionOptions;
import org.jclouds.abiquo.domain.config.Category;
-import org.jclouds.abiquo.domain.config.CostCode;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Tier;
@@ -49,10 +47,6 @@ import com.abiquo.server.core.appslibrary.ConversionsDto;
import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto;
import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto;
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
-import com.abiquo.server.core.pricing.CostCodeDto;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.inject.TypeLiteral;
/**
@@ -223,32 +217,6 @@ public class VirtualMachineTemplate extends DomainWrapper<VirtualMachineTemplate
}
/**
- * List all the conversions for the virtual machine template matching the
- * given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The list all the conversions for the virtual machine template
- * matching the given filter.
- */
- public List<Conversion> listConversions(final Predicate<Conversion> filter) {
- return ImmutableList.copyOf(filter(listConversions(), filter));
- }
-
- /**
- * Gets a single conversion in the virtual machine template matching the
- * given filter.
- *
- * @param filter
- * The filter to apply.
- * @return The conversion or <code>null</code> if none matched the given
- * filter.
- */
- public Conversion findConversion(final Predicate<Conversion> filter) {
- return Iterables.getFirst(filter(listConversions(), filter), null);
- }
-
- /**
* List conversions for a virtual machine template.
*
* @see API: <a href=
@@ -293,12 +261,6 @@ public class VirtualMachineTemplate extends DomainWrapper<VirtualMachineTemplate
return taskRef == null ? null : getTask(taskRef);
}
- public CostCode getCostCode() {
- Integer costcodeId = target.getIdFromLink(ParentLinkName.COST_CODE);
- CostCodeDto costcode = context.getApi().getPricingApi().getCostCode(costcodeId);
- return wrap(context, CostCode.class, costcode);
- }
-
// Delegate methods
public Integer getCpuRequired() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java
deleted file mode 100644
index 17eadf7..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import java.util.List;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.pricing.CostCodeCurrenciesDto;
-import com.abiquo.server.core.pricing.CostCodeCurrencyDto;
-import com.abiquo.server.core.pricing.CostCodeDto;
-import com.google.common.collect.Lists;
-
-/**
- * A cost code is a kind of label where concrete prices can be assigned.
- * <p>
- * Cloud administrators can create several cost codes and assign a price to each
- * one, to have a flexible way to configure custom billings for each resource.
- * <p>
- * Cost codes can be assigned to {@link VirtualMachineTemplate}s and other
- * resources to provide pricing information about them.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-public class CostCode extends DomainWrapper<CostCodeDto> {
-
- private List<CostCodePrice> defaultPrices;
-
- /**
- * Constructor to be used only by the builder. This resource cannot be
- * created.
- */
- private CostCode(final ApiContext<AbiquoApi> context, final CostCodeDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- public void delete() {
- context.getApi().getPricingApi().deleteCostCode(target);
- target = null;
- }
-
- public void save() {
- target = context.getApi().getPricingApi().createCostCode(target);
-
- if (defaultPrices != null && !defaultPrices.isEmpty()) {
- CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto();
- for (CostCodePrice ccp : defaultPrices) {
- CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto();
- Currency currency = ccp.getCurrency();
-
- costcodecurrency.addLink(new RESTLink("currency", currency.unwrap().getEditLink().getHref()));
- costcodecurrency.setPrice(ccp.getPrice());
- costcodecurrencies.add(costcodecurrency);
- }
- context.getApi().getPricingApi().updateCostCodeCurrencies(getId(), costcodecurrencies);
- }
-
- }
-
- public void update() {
- target = context.getApi().getPricingApi().updateCostCode(target);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context) {
- return new Builder(context);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private String name;
-
- private String description;
-
- private List<CostCodePrice> defaultPrices = Lists.newArrayList();
-
- public Builder(final ApiContext<AbiquoApi> context) {
- super();
- this.context = context;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder description(final String description) {
- this.description = description;
- return this;
- }
-
- public Builder defaultPrices(final List<CostCodePrice> prices) {
- this.defaultPrices.addAll(prices);
- return this;
- }
-
- public CostCode build() {
- CostCodeDto dto = new CostCodeDto();
- dto.setName(name);
- dto.setDescription(description);
- CostCode costcode = new CostCode(context, dto);
- costcode.setDefaultPrices(defaultPrices);
- return costcode;
- }
-
- public static Builder fromCostCode(final CostCode in) {
- Builder builder = CostCode.builder(in.context).name(in.getName()).description(in.getDescription())
- .defaultPrices(in.getDefaultPrices());
- return builder;
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public void setDescription(final String description) {
- target.setDescription(description);
- }
-
- public List<CostCodePrice> getDefaultPrices() {
- return defaultPrices;
- }
-
- public void setDefaultPrices(final List<CostCodePrice> defaultPrices) {
- this.defaultPrices = defaultPrices;
- }
-
- @Override
- public String toString() {
- return "CostCode [id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java
deleted file mode 100644
index 387f1f2..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import java.math.BigDecimal;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.pricing.CostCodeCurrencyDto;
-
-public class CostCodeCurrency extends DomainWrapper<CostCodeCurrencyDto> {
-
- protected CostCodeCurrency(final ApiContext<AbiquoApi> context, final CostCodeCurrencyDto target) {
- super(context, target);
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public BigDecimal getPrice() {
- return target.getPrice();
- }
-
- @Override
- public String toString() {
- return "CostCodeCurrency [id=" + getId() + ", price=" + getPrice() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java
deleted file mode 100644
index 86a08b4..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import java.math.BigDecimal;
-
-/**
- * Gives a price to a {@link CostCode}.
- *
- * @author Susana Acedo
- */
-public class CostCodePrice {
- private Currency currency;
-
- private BigDecimal price;
-
- public CostCodePrice(final Currency currency, final BigDecimal price) {
- super();
- this.currency = currency;
- this.price = price;
- }
-
- public Currency getCurrency() {
- return currency;
- }
-
- public void setCurrency(final Currency currency) {
- this.currency = currency;
- }
-
- public BigDecimal getPrice() {
- return price;
- }
-
- public void setPrice(final BigDecimal price) {
- this.price = price;
- }
-
- @Override
- public String toString() {
- return "CostCodePrice [currency=" + currency + ", price=" + price + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java
deleted file mode 100644
index f3d03d7..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.pricing.CurrencyDto;
-
-/**
- * Adds high level functionality to {@link CurrencyDto}.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-public class Currency extends DomainWrapper<CurrencyDto> {
-
- /**
- * Constructor to be used only by the builder. This resource cannot be
- * created.
- */
- private Currency(final ApiContext<AbiquoApi> context, final CurrencyDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- public void delete() {
- context.getApi().getPricingApi().deleteCurrency(target);
- target = null;
- }
-
- public void save() {
- target = context.getApi().getPricingApi().createCurrency(target);
- }
-
- public void update() {
- target = context.getApi().getPricingApi().updateCurrency(target);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context) {
- return new Builder(context);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private String name;
-
- private String symbol;
-
- private int digits;
-
- public Builder(final ApiContext<AbiquoApi> context) {
- super();
- this.context = context;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder symbol(final String symbol) {
- this.symbol = symbol;
- return this;
- }
-
- public Builder digits(final int digits) {
- this.digits = digits;
- return this;
- }
-
- public Currency build() {
- CurrencyDto dto = new CurrencyDto();
- dto.setName(name);
- dto.setSymbol(symbol);
- dto.setDigits(digits);
- Currency currency = new Currency(context, dto);
-
- return currency;
- }
-
- public static Builder fromCurrency(final Currency in) {
- Builder builder = Currency.builder(in.context).name(in.getName()).symbol(in.getSymbol())
- .digits(in.getDigits());
-
- return builder;
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public String getSymbol() {
- return target.getSymbol();
- }
-
- public void setSymbol(final String symbol) {
- target.setSymbol(symbol);
- }
-
- public int getDigits() {
- return target.getDigits();
- }
-
- public void setDigits(final int digits) {
- target.setDigits(digits);
- }
-
- @Override
- public String toString() {
- return "Currency [id=" + getId() + ", name=" + getName() + ", symbol=" + getSymbol() + ", digits=" + getDigits()
- + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java
deleted file mode 100644
index 665d004..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.math.BigDecimal;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.pricing.PricingCostCodeDto;
-
-/**
- * Associates a {@link CostCode} with a pricing template.
- *
- * @author Susana Acedo
- */
-public class PricingCostCode extends DomainWrapper<PricingCostCodeDto> {
- private CostCode costcode;
-
- private PricingTemplate pricingTemplate;
-
- protected PricingCostCode(final ApiContext<AbiquoApi> context, final PricingCostCodeDto target) {
- super(context, target);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final PricingTemplate pricingtemplate,
- final CostCode costcode) {
- return new Builder(context, pricingtemplate, costcode);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Integer id;
-
- private PricingTemplate pricingTemplate;
-
- private CostCode costcode;
-
- private BigDecimal price;
-
- public Builder(final ApiContext<AbiquoApi> context, final PricingTemplate pricingTemplate, final CostCode costcode) {
- super();
- this.pricingTemplate = checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE + PricingTemplate.class);
- this.costcode = checkNotNull(costcode, ValidationErrors.NULL_RESOURCE + CostCode.class);
- this.context = context;
- }
-
- public Builder price(final BigDecimal price) {
- this.price = price;
- return this;
- }
-
- public PricingCostCode build() {
- PricingCostCodeDto dto = new PricingCostCodeDto();
- dto.setId(id);
- dto.setPrice(price);
-
- RESTLink link = costcode.unwrap().searchLink("edit");
- checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
- dto.addLink(new RESTLink("costcode", link.getHref()));
-
- PricingCostCode pricingcostcode = new PricingCostCode(context, dto);
- pricingcostcode.pricingTemplate = pricingTemplate;
- pricingcostcode.costcode = costcode;
-
- return pricingcostcode;
- }
-
- public static Builder fromPricingCostCode(final PricingCostCode in) {
- return PricingCostCode.builder(in.context, in.pricingTemplate, in.costcode).price(in.getPrice());
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public BigDecimal getPrice() {
- return target.getPrice();
- }
-
- @Override
- public String toString() {
- return "PricingCostCode [id=" + getId() + ", price=" + getPrice() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java
deleted file mode 100644
index 6860ee1..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.PricingPeriod;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.pricing.PricingTemplateDto;
-
-/**
- * A pricing template is a complete pricing schema that can be assigned to an
- * {@link Enterprise}.
- * <p>
- * This pricing schema will provide detailed billing information for each
- * resource consumed by the users of the enterprise.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-
-public class PricingTemplate extends DomainWrapper<PricingTemplateDto> {
-
- /** The currency used by the pricing template. */
- protected Currency currency;
-
- /**
- * Constructor to be used only by the builder. This resource cannot be
- * created.
- */
- private PricingTemplate(final ApiContext<AbiquoApi> context, final PricingTemplateDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- public void delete() {
- context.getApi().getPricingApi().deletePricingTemplate(target);
- target = null;
- }
-
- public void save() {
- target = context.getApi().getPricingApi().createPricingTemplate(target);
- }
-
- public void update() {
- target = context.getApi().getPricingApi().updatePricingTemplate(target);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Currency currency) {
- return new Builder(context, currency);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Currency currency;
-
- private String name;
-
- private String description;
-
- private BigDecimal hdGB;
-
- private BigDecimal standingChargePeriod;
-
- private BigDecimal vlan;
-
- private PricingPeriod chargingPeriod;
-
- private BigDecimal minimumChargePeriod;
-
- private boolean showChangesBefore;
-
- private boolean showMinimumCharge;
-
- private PricingPeriod minimumCharge;
-
- private BigDecimal publicIp;
-
- private BigDecimal vcpu;
-
- private BigDecimal memoryGB;
-
- private boolean defaultTemplate;
-
- private Date lastUpdate;
-
- public Builder(final ApiContext<AbiquoApi> context, final Currency currency) {
- super();
- this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class);
- this.context = context;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder description(final String description) {
- this.description = description;
- return this;
- }
-
- public Builder hdGB(final BigDecimal hdGB) {
- this.hdGB = hdGB;
- return this;
- }
-
- public Builder standingChargePeriod(final BigDecimal standingChargePeriod) {
- this.standingChargePeriod = standingChargePeriod;
- return this;
- }
-
- public Builder chargingPeriod(final PricingPeriod chargingPeriod) {
- this.chargingPeriod = chargingPeriod;
- return this;
- }
-
- public Builder vlan(final BigDecimal vlan) {
- this.vlan = vlan;
- return this;
- }
-
- public Builder minimumChargePeriod(final BigDecimal minimumChargePeriod) {
- this.minimumChargePeriod = minimumChargePeriod;
- return this;
- }
-
- public Builder minimumCharge(final PricingPeriod minimumCharge) {
- this.minimumCharge = minimumCharge;
- return this;
- }
-
- public Builder showChangesBefore(final boolean showChangesBefore) {
- this.showChangesBefore = showChangesBefore;
- return this;
- }
-
- public Builder showMinimumCharge(final boolean showMinimumCharge) {
- this.showMinimumCharge = showMinimumCharge;
- return this;
- }
-
- public Builder publicIp(final BigDecimal publicIp) {
- this.publicIp = publicIp;
- return this;
- }
-
- public Builder vcpu(final BigDecimal vcpu) {
- this.vcpu = vcpu;
- return this;
- }
-
- public Builder memoryGB(final BigDecimal memoryGB) {
- this.memoryGB = memoryGB;
- return this;
- }
-
- public Builder defaultTemplate(final boolean defaultTemplate) {
- this.defaultTemplate = defaultTemplate;
- return this;
- }
-
- public Builder lastUpdate(final Date lastUpdate) {
- this.lastUpdate = lastUpdate;
- return this;
- }
-
- public Builder currency(final Currency currency) {
- this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class);
- return this;
- }
-
- public PricingTemplate build() {
- PricingTemplateDto dto = new PricingTemplateDto();
- dto.setName(name);
- dto.setDescription(description);
- dto.setHdGB(hdGB);
- dto.setStandingChargePeriod(standingChargePeriod);
- dto.setVlan(vlan);
- dto.setChargingPeriod(chargingPeriod.ordinal());
- dto.setMinimumCharge(minimumCharge.ordinal());
- dto.setMinimumChargePeriod(minimumChargePeriod);
- dto.setShowChangesBefore(showChangesBefore);
- dto.setShowMinimumCharge(showMinimumCharge);
- dto.setPublicIp(publicIp);
- dto.setVcpu(vcpu);
- dto.setMemoryGB(memoryGB);
- dto.setDefaultTemplate(defaultTemplate);
- dto.setLastUpdate(lastUpdate);
-
- RESTLink link = currency.unwrap().searchLink("edit");
- checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
- dto.addLink(new RESTLink("currency", link.getHref()));
-
- PricingTemplate pricingTemplate = new PricingTemplate(context, dto);
- pricingTemplate.currency = currency;
-
- return pricingTemplate;
- }
-
- public static Builder fromPricingTemplate(final PricingTemplate in) {
- Builder builder = PricingTemplate.builder(in.context, in.currency).name(in.getName())
- .description(in.getDescription()).hdGB(in.getHdGB()).standingChargePeriod(in.getStandingChargePeriod())
- .vcpu(in.getVlan()).chargingPeriod(in.getChargingPeriod()).minimumCharge(in.getMinimumCharge())
- .minimumChargePeriod(in.getMinimumChargePeriod()).showChangesBefore(in.isShowChangesBefore())
- .showMinimumCharge(in.isShowMinimumCharge()).publicIp(in.getPublicIp()).vcpu(in.getVcpu())
- .memoryGB(in.getMemoryGB()).defaultTemplate(in.isDefaultTemplate()).lastUpdate(in.getLastUpdate());
- return builder;
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public void setDescription(final String description) {
- target.setDescription(description);
- }
-
- public BigDecimal getHdGB() {
- return target.getHdGB();
- }
-
- public void setHdGB(final BigDecimal hdGB) {
- target.setHdGB(hdGB);
- }
-
- public BigDecimal getStandingChargePeriod() {
- return target.getStandingChargePeriod();
- }
-
- public void setStandingChargePeriod(final BigDecimal standingChargePeriod) {
- target.setStandingChargePeriod(standingChargePeriod);
- }
-
- public BigDecimal getVlan() {
- return target.getVlan();
- }
-
- public void setVlan(final BigDecimal vlan) {
- target.getVlan();
- }
-
- public BigDecimal getMinimumChargePeriod() {
- return target.getMinimumChargePeriod();
- }
-
- public void setMinimumChargePeriod(final BigDecimal minimumChargePeriod) {
- target.setMinimumChargePeriod(minimumChargePeriod);
- }
-
- public boolean isShowChangesBefore() {
- return target.isShowChangesBefore();
- }
-
- public void setShowChangesBefore(final boolean showChangesBefore) {
- target.setShowChangesBefore(showChangesBefore);
- }
-
- public boolean isShowMinimumCharge() {
- return target.isShowMinimumCharge();
- }
-
- public void setShowMinimumCharge(final boolean showMinimumCharge) {
- target.setShowMinimumCharge(showMinimumCharge);
- }
-
- public PricingPeriod getMinimumCharge() {
- return PricingPeriod.fromId(target.getMinimumCharge());
- }
-
- public void setMinimumCharge(final PricingPeriod minimumCharge) {
- target.setMinimumCharge(minimumCharge.ordinal());
- }
-
- public PricingPeriod getChargingPeriod() {
- return PricingPeriod.fromId(target.getChargingPeriod());
- }
-
- public void setChargingPeriod(final PricingPeriod chargingPeriod) {
- target.setChargingPeriod(chargingPeriod.ordinal());
- }
-
- public BigDecimal getPublicIp() {
- return target.getPublicIp();
- }
-
- public void setPublicIp(final BigDecimal publicIp) {
- target.setPublicIp(publicIp);
- }
-
- public BigDecimal getVcpu() {
- return target.getVcpu();
- }
-
- public void setVcpu(final BigDecimal vcpu) {
- target.setVcpu(vcpu);
- }
-
- public BigDecimal getMemoryGB() {
- return target.getMemoryGB();
- }
-
- public void setMemoryGB(final BigDecimal memoryGB) {
- target.setMemoryGB(memoryGB);
- }
-
- public boolean isDefaultTemplate() {
- return target.isDefaultTemplate();
- }
-
- public void setDefaultTemplate(final boolean defaultTemplate) {
- target.setDefaultTemplate(defaultTemplate);
- }
-
- public Date getLastUpdate() {
- return target.getLastUpdate();
- }
-
- public void setLastUpdate(final Date lastUpdate) {
- target.setLastUpdate(lastUpdate);
- }
-
- @Override
- public String toString() {
- return "PricingTemplate [id=" + getId() + ", name=" + getName() + ", description=" + getDescription()
- + ", hdGB =" + getHdGB() + ", standingChargePeriod =" + getStandingChargePeriod() + ", vlan = " + getVlan()
- + ", chargingPeriod =" + getChargingPeriod() + ", minimumChargePeriod=" + getMinimumChargePeriod()
- + ", showChangesBefore =" + isShowChangesBefore() + ", showMinimumCharge= " + isShowMinimumCharge()
- + ", minimumCharge = " + getMinimumCharge() + ", publicIp = " + getPublicIp() + ", vcpu =" + getVcpu()
- + ", memoryGB= " + getMemoryGB() + ", defaultTemplate= " + isDefaultTemplate() + ", lastUpdate = "
- + getLastUpdate() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java
deleted file mode 100644
index 7001f58..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.config;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.math.BigDecimal;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.infrastructure.Tier;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.pricing.PricingTierDto;
-
-/**
- * Associates an storage {@link Tier} with a {@link PricingTemplate}.
- *
- * @author Susana Acedo
- */
-public class PricingTier extends DomainWrapper<PricingTierDto> {
- private Tier tier;
-
- private PricingTemplate pricingTemplate;
-
- protected PricingTier(final ApiContext<AbiquoApi> context, final PricingTierDto target) {
- super(context, target);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final PricingTemplate pricingtemplate,
- final Tier tier) {
- return new Builder(context, pricingtemplate, tier);
- }
-
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Integer id;
-
- private PricingTemplate pricingTemplate;
-
- private Tier tier;
-
- private BigDecimal price;
-
- public Builder(final ApiContext<AbiquoApi> context, final PricingTemplate pricingTemplate, final Tier tier) {
- super();
- this.pricingTemplate = checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE + PricingTemplate.class);
- this.tier = checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class);
- this.context = context;
- }
-
- public Builder price(final BigDecimal price) {
- this.price = price;
- return this;
- }
-
- public PricingTier build() {
- PricingTierDto dto = new PricingTierDto();
- dto.setId(id);
- dto.setPrice(price);
-
- RESTLink link = tier.unwrap().searchLink("edit");
- checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
- dto.addLink(new RESTLink("tier", link.getHref()));
-
- PricingTier pricingTier = new PricingTier(context, dto);
- pricingTier.pricingTemplate = pricingTemplate;
- pricingTier.tier = tier;
-
- return pricingTier;
- }
-
- public static Builder fromPricingTier(final PricingTier in) {
- return PricingTier.builder(in.context, in.pricingTemplate, in.tier).price(in.getPrice());
- }
- }
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public BigDecimal getPrice() {
- return target.getPrice();
- }
-
- @Override
- public String toString() {
- return "PricingTier [id=" + getId() + ", price=" + getPrice() + "]";
- }
-}