JCLOUDS-526: Removing Nova QuotaClassApi

The quota-classes API in Nova has been removed (and apparently never worked)
This commit is contained in:
jasdeep-hundal 2014-04-08 15:12:12 -07:00 committed by Andrew Phillips
parent 5fabd87685
commit b2be149946
11 changed files with 4 additions and 422 deletions

View File

@ -28,7 +28,6 @@ import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
@ -177,13 +176,6 @@ public interface NovaApi extends Closeable {
Optional<? extends QuotaApi> getQuotaExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Quota Classes features.
*/
@Delegate
Optional<? extends QuotaClassApi> getQuotaClassExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Volume features.
*/

View File

@ -29,7 +29,6 @@ import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi;
@ -183,13 +182,6 @@ public interface NovaAsyncApi extends Closeable {
Optional<? extends QuotaAsyncApi> getQuotaExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Quota Classes features.
*/
@Delegate
Optional<? extends QuotaClassAsyncApi> getQuotaClassExtensionForZone(
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Volume features.
*/

View File

@ -46,8 +46,6 @@ import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi;
import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi;
import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi;
@ -90,7 +88,7 @@ import com.google.inject.Provides;
/**
* Configures the Nova connection.
*
*
* @author Adrian Cole
*/
@ConfiguresRestClient
@ -113,12 +111,11 @@ public class NovaRestClientModule<S extends NovaApi, A extends NovaAsyncApi> ext
.put(HostAggregateApi.class, HostAggregateAsyncApi.class)
.put(FlavorExtraSpecsApi.class, FlavorExtraSpecsAsyncApi.class)
.put(QuotaApi.class, QuotaAsyncApi.class)
.put(QuotaClassApi.class, QuotaClassAsyncApi.class)
.put(VolumeApi.class, VolumeAsyncApi.class)
.put(VolumeAttachmentApi.class, VolumeAttachmentAsyncApi.class)
.put(VolumeTypeApi.class, VolumeTypeAsyncApi.class)
.build();
@SuppressWarnings("unchecked")
public NovaRestClientModule() {
super(TypeToken.class.cast(typeToken(NovaApi.class)), TypeToken.class.cast(typeToken(NovaAsyncApi.class)), DELEGATE_MAP);
@ -134,7 +131,7 @@ public class NovaRestClientModule<S extends NovaApi, A extends NovaAsyncApi> ext
bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
super.configure();
}
@Provides
@Singleton
public Multimap<URI, URI> aliases() {
@ -163,8 +160,6 @@ public class NovaRestClientModule<S extends NovaApi, A extends NovaAsyncApi> ext
URI.create("http://docs.openstack.org/compute/ext/flavor_extra_specs/api/v1.1"))
.put(URI.create(ExtensionNamespaces.QUOTAS),
URI.create("http://docs.openstack.org/compute/ext/quotas-sets/api/v1.1"))
.put(URI.create(ExtensionNamespaces.QUOTA_CLASSES),
URI.create("http://docs.openstack.org/compute/ext/quota-classes-sets/api/v1.1"))
.put(URI.create(ExtensionNamespaces.VOLUME_TYPES),
URI.create("http://docs.openstack.org/compute/ext/volume_types/api/v1.1"))
.build();

View File

@ -1,62 +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.openstack.nova.v2_0.domain;
import java.beans.ConstructorProperties;
/**
* Represents the set of limits (quota class) returned by the Quota Class Extension
*
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi
*/
public class QuotaClass extends Quota {
public static Builder<?> builder() {
return new ConcreteBuilder();
}
public Builder<?> toBuilder() {
return new ConcreteBuilder().fromQuotaClass(this);
}
public abstract static class Builder<T extends Builder<T>> extends Quota.Builder<T> {
public QuotaClass build() {
return new QuotaClass(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
}
public T fromQuotaClass(QuotaClass in) {
return super.fromQuotas(in);
}
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
protected ConcreteBuilder self() {
return this;
}
}
@ConstructorProperties({
"id", "metadata_items", "injected_file_content_bytes", "volumes", "gigabytes", "ram", "floating_ips", "instances", "injected_files", "cores", "security_groups", "security_group_rules", "key_pairs"
})
protected QuotaClass(String id, int metadataItems, int injectedFileContentBytes, int volumes, int gigabytes, int ram, int floatingIps, int instances, int injectedFiles, int cores, int securityGroups, int securityGroupRules, int keyPairs) {
super(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
}
}

View File

@ -93,11 +93,6 @@ public interface ExtensionNamespaces {
*/
public static final String EXTENDED_STATUS = "http://docs.openstack.org/compute/ext/extended_status/api/v1.1";
/**
* Quota Classes extension
*/
public static final String QUOTA_CLASSES = "http://docs.openstack.org/ext/quota-classes-sets/api/v1.1";
/**
* Disk Config extension
*/

View File

@ -1,51 +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.openstack.nova.v2_0.extensions;
import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.openstack.v2_0.services.Extension;
import com.google.common.annotations.Beta;
/**
* Provides synchronous access to Quota Classes via the REST API.
* <p/>
* To use this extension, you need to have administrative rights to the tenants upon which you are placing quotas.
*
* @author Adam Lowe
* @see QuotaClassAsyncApi
* @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.quota_classes.html"/>
* @see <a href="http://wiki.openstack.org/QuotaClass"/>
*/
@Beta
@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTA_CLASSES)
public interface QuotaClassApi {
/**
* @return the quota settings for the tenant
*/
QuotaClass get(String id);
/**
* Update the quotas for a given tenant
*
* @return true if successful
*/
boolean update(String id, QuotaClass quotas);
}

View File

@ -1,78 +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.openstack.nova.v2_0.extensions;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.openstack.v2_0.services.Extension;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to Quota Classes via the REST API.
*
* @author Adam Lowe
* @see QuotaClassApi
* @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.quota_classes.html"/>
* @see <a href="http://wiki.openstack.org/QuotaClass"/>
*/
@Beta
@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTA_CLASSES)
@RequestFilters(AuthenticateRequest.class)
@Path("/os-quota-class-sets")
public interface QuotaClassAsyncApi {
/**
* @see QuotaClassApi#get
*/
@Named("quotaclass:get")
@GET
@SelectJson("quota_class_set")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{id}")
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends QuotaClass> get(@PathParam("id") String id);
/**
* @see QuotaClassApi#update
*/
@Named("quotaclass:update")
@PUT
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@MapBinder(BindToJsonPayload.class)
ListenableFuture<Boolean> update(@PathParam("id") String id, @PayloadParam("quota_class_set") QuotaClass quotas);
}

View File

@ -1,105 +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.openstack.nova.v2_0.extensions;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
import org.jclouds.rest.ResourceNotFoundException;
import org.testng.annotations.Test;
/**
* Tests HostAdministrationApi guice wiring and parsing
*
* @author Adam Lowe
*/
@Test(groups = "unit", testName = "QuotaClassApiExpectTest")
public class QuotaClassApiExpectTest extends BaseNovaApiExpectTest {
public void testGetQuotas() throws Exception {
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas");
QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quota_class.json")).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
assertEquals(api.get("jcloudstestquotas"), getTestQuotas());
}
public void testGetQuotasFailsTenantNotFound() throws Exception {
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas");
QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(404).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
assertNull(api.get("jcloudstestquotas"));
}
public void testUpdateQuotas() throws Exception {
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/myclass");
QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
HttpRequest.builder().endpoint(endpoint).method("PUT")
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromResourceWithContentType("/quota_class.json", MediaType.APPLICATION_JSON))
.build(),
HttpResponse.builder().statusCode(200).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
assertTrue(api.update("myclass", getTestQuotas()));
}
@Test(expectedExceptions = ResourceNotFoundException.class)
public void testUpdateQuotasFailsNotFound() throws Exception {
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas");
QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
HttpRequest.builder().endpoint(endpoint).method("PUT")
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromResourceWithContentType("/quota_class.json", MediaType.APPLICATION_JSON))
.build(),
HttpResponse.builder().statusCode(404).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
api.update("jcloudstestquotas", getTestQuotas());
}
public static QuotaClass getTestQuotas() {
return QuotaClass.builder()
.metadataItems(128)
.injectedFileContentBytes(10240)
.injectedFiles(5)
.gigabytes(1000)
.ram(4096)
.floatingIps(10)
.securityGroups(10)
.securityGroupRules(20)
.instances(5)
.keyPairs(100)
.volumes(5)
.cores(10)
.id("jcloudstestquotas").build();
}
}

View File

@ -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.openstack.nova.v2_0.extensions;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Optional;
import com.google.common.collect.Iterables;
/**
* Tests behavior of QuotaApi
*
* @author Adam Lowe
*/
@Test(groups = "live", testName = "QuotaClassApiLiveTest", singleThreaded = true)
public class QuotaClassApiLiveTest extends BaseNovaApiLiveTest {
private Optional<? extends QuotaClassApi> apiOption;
private String zone;
@BeforeClass(groups = {"integration", "live"})
@Override
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
apiOption = api.getQuotaClassExtensionForZone(zone);
}
public void testUpdateAndGetQuotaClass() {
if (apiOption.isPresent()) {
QuotaClassApi api = apiOption.get();
QuotaClass firstVersion =
QuotaClassApiExpectTest.getTestQuotas().toBuilder()
.id("jcloudstestquotas")
.cores(10)
.instances(5)
.ram(4096)
.volumes(5)
.build();
assertTrue(api.update(firstVersion.getId(), firstVersion));
assertEquals(api.get(firstVersion.getId()), firstVersion);
// Change it again (since we may have run this test before and we can't delete the QuotaClass)
QuotaClass secondVersion = firstVersion.toBuilder().ram(8192).build();
assertTrue(api.update(secondVersion.getId(), secondVersion));
assertEquals(api.get(secondVersion.getId()), secondVersion);
}
}
}

View File

@ -191,14 +191,6 @@
"alias": "os-server-start-stop",
"description": "Start/Stop instance compute API support"
},
{
"updated": "2012-03-12T00:00:00+00:00",
"name": "QuotaClasses",
"links": [],
"namespace": "http://docs.openstack.org/compute/ext/quota-classes-sets/api/v1.1",
"alias": "os-quota-class-sets",
"description": "Quota classes management support"
},
{
"updated": "2012-01-19T00:00:00+00:00",
"name": "Certificates",
@ -278,4 +270,4 @@
"namespace": "http://docs.openstack.org/compute/ext/floating_ips/api/v1.1",
"alias": "os-floating-ips",
"description": "Floating IPs support"}
]}
]}

View File

@ -1,15 +0,0 @@
{"quota_class_set": {
"metadata_items": 128,
"injected_file_content_bytes": 10240,
"injected_files": 5,
"gigabytes": 1000,
"ram": 4096,
"floating_ips": 10,
"security_group_rules": 20,
"instances": 5,
"key_pairs": 100,
"volumes": 5,
"cores": 10,
"id": "jcloudstestquotas",
"security_groups": 10
}}