mirror of https://github.com/apache/jclouds.git
cleanup and example of overriding nova api version
This commit is contained in:
parent
41e4a369e7
commit
b77a3bf0c8
|
@ -252,7 +252,7 @@ public class Endpoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper(this)
|
return Objects.toStringHelper(this).omitNullValues()
|
||||||
.add("versionId", versionId).add("region", region).add("publicURL", publicURL).add("internalURL", internalURL)
|
.add("versionId", versionId).add("region", region).add("publicURL", publicURL).add("internalURL", internalURL)
|
||||||
.add("adminURL", adminURL).add("versionInfo", versionInfo).add("versionList", versionList).add("tenantId", tenantId);
|
.add("adminURL", adminURL).add("versionInfo", versionInfo).add("versionList", versionList).add("tenantId", tenantId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
|
||||||
|
import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.config.NovaRestClientModule;
|
import org.jclouds.openstack.nova.v2_0.config.NovaRestClientModule;
|
||||||
import org.jclouds.openstack.v2_0.ServiceType;
|
import org.jclouds.openstack.v2_0.ServiceType;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
@ -101,6 +102,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(KeystoneAuthenticationModule.class)
|
.add(KeystoneAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(ZoneModule.class)
|
||||||
|
.add(NovaParserModule.class)
|
||||||
.add(NovaRestClientModule.class)
|
.add(NovaRestClientModule.class)
|
||||||
.add(NovaComputeServiceContextModule.class).build());
|
.add(NovaComputeServiceContextModule.class).build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,6 @@ public class NovaRestClientModule<S extends NovaApi, A extends NovaAsyncApi> ext
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new NovaParserModule());
|
|
||||||
bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
|
bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
|
||||||
super.configure();
|
super.configure();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.openstack.nova.v2_0;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "OverrideApiVersionExpectTest")
|
||||||
|
public class OverrideApiVersionExpectTest extends BaseNovaApiExpectTest {
|
||||||
|
|
||||||
|
public OverrideApiVersionExpectTest() {
|
||||||
|
this.identity = "demo:demo";
|
||||||
|
this.credential = "password";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Properties setupProperties() {
|
||||||
|
Properties overrides = super.setupProperties();
|
||||||
|
overrides.setProperty(Constants.PROPERTY_ENDPOINT, "http://10.10.10.10:5000/v2.0/");
|
||||||
|
overrides.setProperty(provider + ".api-version", "bb3ce9ccdc5045909882688b90cc3ff0");
|
||||||
|
return overrides;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVersionMatchOnConfiguredZonesWhenResponseIs2xx() {
|
||||||
|
|
||||||
|
HttpRequest authenticate = HttpRequest.builder().method("POST")
|
||||||
|
.endpoint("http://10.10.10.10:5000/v2.0/tokens")
|
||||||
|
.addHeader("Accept", "application/json")
|
||||||
|
.payload(payloadFromStringWithContentType(
|
||||||
|
"{\"auth\":{\"passwordCredentials\":{\"username\":\"demo\",\"password\":\"password\"},\"tenantName\":\"demo\"}}"
|
||||||
|
, "application/json")).build();
|
||||||
|
|
||||||
|
|
||||||
|
HttpResponse authenticationResponse = HttpResponse.builder().statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/access_version_uids.json", "application/json")).build();
|
||||||
|
|
||||||
|
NovaApi whenNovaRegionExists = requestSendsResponse(authenticate, authenticationResponse);
|
||||||
|
|
||||||
|
assertEquals(whenNovaRegionExists.getConfiguredZones(), ImmutableSet.of("RegionOne"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{"access": {"token": {"expires": "2012-09-29T19:53:45Z", "id": "b267e2e240624b108b1ed5bba6e5882e", "tenant": {"enabled": true, "description": null, "name": "demo", "id": "82d8d2f865484776a1daf1e2245d3317"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://10.10.10.10:8774/v2/82d8d2f865484776a1daf1e2245d3317", "region": "RegionOne", "internalURL": "http://10.10.10.10:8774/v2/82d8d2f865484776a1daf1e2245d3317", "id": "bb3ce9ccdc5045909882688b90cc3ff0", "publicURL": "http://10.10.10.10:8774/v2/82d8d2f865484776a1daf1e2245d3317"}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "http://10.10.10.10:3333", "region": "RegionOne", "internalURL": "http://10.10.10.10:3333", "id": "9646263f31ea4f499732c5e1370ecf5e", "publicURL": "http://10.10.10.10:3333"}], "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": "http://10.10.10.10:9292", "region": "RegionOne", "internalURL": "http://10.10.10.10:9292", "id": "aa5d0b2574824ba097dc07faacf3be65", "publicURL": "http://10.10.10.10:9292"}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "http://10.10.10.10:8776/v1/82d8d2f865484776a1daf1e2245d3317", "region": "RegionOne", "internalURL": "http://10.10.10.10:8776/v1/82d8d2f865484776a1daf1e2245d3317", "id": "7679065b1405447eb5f1a38a6b99ccc0", "publicURL": "http://10.10.10.10:8776/v1/82d8d2f865484776a1daf1e2245d3317"}], "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": [{"adminURL": "http://10.10.10.10:8773/services/Admin", "region": "RegionOne", "internalURL": "http://10.10.10.10:8773/services/Cloud", "id": "22b007f023fb4c42be094916eb2bf18b", "publicURL": "http://10.10.10.10:8773/services/Cloud"}], "endpoints_links": [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://10.10.10.10:35357/v2.0", "region": "RegionOne", "internalURL": "http://10.10.10.10:5000/v2.0", "id": "57ee5fb4f9a840f3b965909681d0fc53", "publicURL": "http://10.10.10.10:5000/v2.0"}], "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": "demo", "roles_links": [], "id": "ca248caf55844c14a4876c22112bbbb9", "roles": [{"name": "Member"}], "name": "demo"}, "metadata": {"is_admin": 0, "roles": ["1f697d8e3ace4f5a80f7701e554ee5d9"]}}}
|
Loading…
Reference in New Issue