
org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jclouds-shaded Show documentation
Show all versions of jclouds-shaded Show documentation
Provides a shaded jclouds with relocated guava and guice
The newest version!
/*
* 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.cloudstack.compute.config;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.cloudstack.config.CloudStackProperties.AUTO_GENERATE_KEYPAIRS;
import static org.jclouds.util.Predicates2.retry;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.cloudstack.CloudStackApi;
import org.jclouds.cloudstack.compute.extensions.CloudStackImageExtension;
import org.jclouds.cloudstack.compute.extensions.CloudStackSecurityGroupExtension;
import org.jclouds.cloudstack.compute.functions.CloudStackSecurityGroupToSecurityGroup;
import org.jclouds.cloudstack.compute.functions.IngressRuleToIpPermission;
import org.jclouds.cloudstack.compute.functions.OrphanedGroupsByZoneId;
import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware;
import org.jclouds.cloudstack.compute.functions.TemplateToImage;
import org.jclouds.cloudstack.compute.functions.TemplateToOperatingSystem;
import org.jclouds.cloudstack.compute.functions.VirtualMachineToNodeMetadata;
import org.jclouds.cloudstack.compute.functions.ZoneToLocation;
import org.jclouds.cloudstack.compute.loaders.CreateUniqueKeyPair;
import org.jclouds.cloudstack.compute.loaders.FindSecurityGroupOrCreate;
import org.jclouds.cloudstack.compute.options.CloudStackTemplateOptions;
import org.jclouds.cloudstack.compute.strategy.AdvancedNetworkOptionsConverter;
import org.jclouds.cloudstack.compute.strategy.BasicNetworkOptionsConverter;
import org.jclouds.cloudstack.compute.strategy.CloudStackComputeServiceAdapter;
import org.jclouds.cloudstack.compute.strategy.OptionsConverter;
import org.jclouds.cloudstack.domain.FirewallRule;
import org.jclouds.cloudstack.domain.IPForwardingRule;
import org.jclouds.cloudstack.domain.IngressRule;
import org.jclouds.cloudstack.domain.Network;
import org.jclouds.cloudstack.domain.NetworkType;
import org.jclouds.cloudstack.domain.OSType;
import org.jclouds.cloudstack.domain.Project;
import org.jclouds.cloudstack.domain.SecurityGroup;
import org.jclouds.cloudstack.domain.ServiceOffering;
import org.jclouds.cloudstack.domain.SshKeyPair;
import org.jclouds.cloudstack.domain.Template;
import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.Zone;
import org.jclouds.cloudstack.domain.ZoneAndName;
import org.jclouds.cloudstack.domain.ZoneSecurityGroupNamePortsCidrs;
import org.jclouds.cloudstack.features.GuestOSApi;
import org.jclouds.cloudstack.functions.CreateSecurityGroupIfNeeded;
import org.jclouds.cloudstack.functions.GetFirewallRulesByVirtualMachine;
import org.jclouds.cloudstack.functions.GetIPForwardingRulesByVirtualMachine;
import org.jclouds.cloudstack.functions.StaticNATVirtualMachineInNetwork;
import org.jclouds.cloudstack.functions.ZoneIdToZone;
import org.jclouds.cloudstack.predicates.JobComplete;
import org.jclouds.cloudstack.suppliers.GetCurrentUser;
import org.jclouds.cloudstack.suppliers.NetworksForCurrentUser;
import org.jclouds.cloudstack.suppliers.ProjectsForCurrentUser;
import org.jclouds.cloudstack.suppliers.ZoneIdToZoneSupplier;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.extensions.ImageExtension;
import org.jclouds.compute.extensions.SecurityGroupExtension;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.Location;
import org.jclouds.net.domain.IpPermission;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import shaded.com.google.common.base.Function;
import shaded.com.google.common.base.MoreObjects;
import shaded.com.google.common.base.Predicate;
import shaded.com.google.common.base.Supplier;
import shaded.com.google.common.cache.CacheBuilder;
import shaded.com.google.common.cache.CacheLoader;
import shaded.com.google.common.cache.LoadingCache;
import shaded.com.google.common.collect.ImmutableMap;
import shaded.com.google.common.collect.Maps;
import shaded.com.google.common.collect.Multimap;
import shaded.com.google.inject.Injector;
import shaded.com.google.inject.Key;
import shaded.com.google.inject.Provides;
import shaded.com.google.inject.TypeLiteral;
import shaded.com.google.inject.assistedinject.FactoryModuleBuilder;
import shaded.com.google.inject.name.Names;
public class CloudStackComputeServiceContextModule extends
ComputeServiceAdapterContextModule {
@Override
protected void configure() {
super.configure();
bind(new TypeLiteral>() {
}).to(CloudStackComputeServiceAdapter.class);
bind(new TypeLiteral>() {
}).to(VirtualMachineToNodeMetadata.class);
bind(new TypeLiteral>() {
}).to(CloudStackSecurityGroupToSecurityGroup.class);
bind(new TypeLiteral>() {
}).to(IngressRuleToIpPermission.class);
bind(new TypeLiteral>() {
}).to(TemplateToImage.class);
bind(new TypeLiteral>() {
}).to(ServiceOfferingToHardware.class);
bind(new TypeLiteral>() {
}).to(ZoneToLocation.class);
bind(TemplateOptions.class).to(CloudStackTemplateOptions.class);
bind(new TypeLiteral>() {
}).to(TemplateToOperatingSystem.class);
install(new FactoryModuleBuilder().build(StaticNATVirtualMachineInNetwork.Factory.class));
bind(new TypeLiteral>>() {
}).to(GetIPForwardingRulesByVirtualMachine.class);
bind(new TypeLiteral>>() {
}).to(GetFirewallRulesByVirtualMachine.class);
bind(new TypeLiteral>() {
}).to(ZoneIdToZone.class);
bind(new TypeLiteral>() {
}).to(CreateUniqueKeyPair.class);
bind(new TypeLiteral>>() {
}).to(ZoneIdToZoneSupplier.class);
bind(new TypeLiteral>() {
}).to(CreateSecurityGroupIfNeeded.class);
bind(new TypeLiteral>() {
}).to(FindSecurityGroupOrCreate.class);
bind(new TypeLiteral, Multimap>>() {
}).to(OrphanedGroupsByZoneId.class);
bind(new TypeLiteral() {
}).to(CloudStackImageExtension.class);
bind(new TypeLiteral() {
}).to(CloudStackSecurityGroupExtension.class);
// to have the compute service adapter override default locations
install(new LocationsFromComputeServiceAdapterModule() {
});
}
@Override
protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
return options.as(CloudStackTemplateOptions.class)
.generateKeyPair(injector.getInstance(
Key.get(boolean.class, Names.named(AUTO_GENERATE_KEYPAIRS))));
}
@Provides
@Singleton
@Memoized
public final Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy