mirror of https://github.com/apache/jclouds.git
Adding AdminURL supplier for keystone 2.0
This commit is contained in:
parent
e3fb2543e9
commit
d6ac7be31d
|
@ -46,6 +46,8 @@ import org.jclouds.openstack.keystone.v2_0.domain.Access;
|
||||||
import org.jclouds.openstack.keystone.v2_0.functions.AuthenticateApiAccessKeyCredentials;
|
import org.jclouds.openstack.keystone.v2_0.functions.AuthenticateApiAccessKeyCredentials;
|
||||||
import org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials;
|
import org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials;
|
||||||
import org.jclouds.openstack.keystone.v2_0.handlers.RetryOnRenew;
|
import org.jclouds.openstack.keystone.v2_0.handlers.RetryOnRenew;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersionSupplier;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier;
|
||||||
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToURIFromAccessForTypeAndVersionSupplier;
|
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToURIFromAccessForTypeAndVersionSupplier;
|
||||||
import org.jclouds.openstack.keystone.v2_0.suppliers.ZoneIdToURIFromAccessForTypeAndVersionSupplier;
|
import org.jclouds.openstack.keystone.v2_0.suppliers.ZoneIdToURIFromAccessForTypeAndVersionSupplier;
|
||||||
import org.jclouds.rest.annotations.ApiVersion;
|
import org.jclouds.rest.annotations.ApiVersion;
|
||||||
|
@ -85,6 +87,8 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class,
|
install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class,
|
||||||
RegionIdToURIFromAccessForTypeAndVersionSupplier.class).build(RegionIdToURISupplier.Factory.class));
|
RegionIdToURIFromAccessForTypeAndVersionSupplier.class).build(RegionIdToURISupplier.Factory.class));
|
||||||
|
install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class,
|
||||||
|
RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.class).build(RegionIdToAdminURISupplier.Factory.class));
|
||||||
// dynamically build the region list as opposed to from properties
|
// dynamically build the region list as opposed to from properties
|
||||||
bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class);
|
bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +102,16 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
||||||
RegionIdToURISupplier.Factory factory) {
|
RegionIdToURISupplier.Factory factory) {
|
||||||
return factory.createForApiTypeAndVersion(serviceType, apiVersion);
|
return factory.createForApiTypeAndVersion(serviceType, apiVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// supply the region to id to AdminURL map from keystone, based on the servicetype and api version in
|
||||||
|
// config
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected RegionIdToAdminURISupplier provideRegionIdToAdminURISupplierForApiVersion(
|
||||||
|
@Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion,
|
||||||
|
RegionIdToAdminURISupplier.Factory factory) {
|
||||||
|
return factory.createForApiTypeAndVersion(serviceType, apiVersion);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* 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.keystone.v2_0.functions;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class AdminURL implements EndpointToSupplierAdminURI {
|
||||||
|
// TODO: check accessibility and prioritize private first
|
||||||
|
@Override
|
||||||
|
public Supplier<URI> apply(Endpoint input) {
|
||||||
|
return Suppliers.ofInstance(input.getAdminURL());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "supplyAdminURL()";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* 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.keystone.v2_0.functions;
|
||||||
|
|
||||||
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@ImplementedBy(AdminURL.class)
|
||||||
|
public interface EndpointToSupplierAdminURI extends EndpointToSupplierURI {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.jclouds.openstack.keystone.v2_0.functions;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.location.functions.RegionToEndpoint;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
public class RegionToAdminEndpointURI extends RegionToEndpoint {
|
||||||
|
@Inject
|
||||||
|
public RegionToAdminEndpointURI(RegionIdToAdminURISupplier regionToEndpointSupplier) {
|
||||||
|
super(regionToEndpointSupplier);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
* 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.keystone.v2_0.suppliers;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.domain.Access;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.functions.EndpointToRegion;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.functions.EndpointToSupplierAdminURI;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class RegionIdToAdminURIFromAccessForTypeAndVersionSupplier extends
|
||||||
|
LocationIdToURIFromAccessForTypeAndVersionSupplier implements RegionIdToAdminURISupplier {
|
||||||
|
@Inject
|
||||||
|
public RegionIdToAdminURIFromAccessForTypeAndVersionSupplier(Supplier<Access> access,
|
||||||
|
EndpointToSupplierAdminURI endpointToSupplierURI, EndpointToRegion endpointToRegion,
|
||||||
|
@Assisted("apiType") String apiType, @Assisted("apiVersion") String apiVersion) {
|
||||||
|
super(access, endpointToSupplierURI, endpointToRegion, apiType, apiVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "regionIdToAdminURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.jclouds.openstack.keystone.v2_0.suppliers;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.inject.ImplementedBy;
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@ImplementedBy(RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.class)
|
||||||
|
public interface RegionIdToAdminURISupplier extends Supplier<Map<String, Supplier<URI>>> {
|
||||||
|
static interface Factory {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param apiType
|
||||||
|
* type of the api, according to the provider. ex. {@code compute} {@code
|
||||||
|
* object-store}
|
||||||
|
* @param apiVersion
|
||||||
|
* version of the api
|
||||||
|
* @return regions mapped to default uri
|
||||||
|
*/
|
||||||
|
RegionIdToAdminURISupplier createForApiTypeAndVersion(@Assisted("apiType") String apiType,
|
||||||
|
@Assisted("apiVersion") String apiVersion);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue