org.jclouds.vcloud.compute.config.CommonVCloudComputeServiceContextModule Maven / Gradle / Ivy
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC.
*
* ====================================================================
* Licensed 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.vcloud.compute.config;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.compute.LoadBalancerService;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
import org.jclouds.domain.Location;
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.compute.suppliers.StaticHardwareSupplier;
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier;
import org.jclouds.vcloud.domain.Status;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.util.Providers;
/**
* Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
* bound.
*
* @author Adrian Cole
*/
public abstract class CommonVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
@VisibleForTesting
static final Map vAppStatusToNodeState = ImmutableMap. builder().put(
Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING)
.put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Status.DEPLOYED,
NodeState.PENDING).put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN,
NodeState.UNRECOGNIZED).put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT,
NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED,
NodeState.PENDING).build();
@Singleton
@Provides
Map provideVAppStatusToNodeState() {
return vAppStatusToNodeState;
}
@Override
protected void configure() {
install(new ComputeServiceTimeoutsModule());
bind(RunNodesAndAddToSetStrategy.class).to(EncodeTagIntoNameRunNodesAndAddToSetStrategy.class);
bindLoadBalancer();
}
protected void bindLoadBalancer() {
bind(LoadBalancerService.class).toProvider(Providers. of(null));
}
@Override
protected Supplier> getSourceSizeSupplier(Injector injector) {
return injector.getInstance(StaticHardwareSupplier.class);
}
@Override
protected Supplier> getSourceLocationSupplier(Injector injector) {
return injector.getInstance(OrgAndVDCToLocationSupplier.class);
}
@Override
protected Supplier> getSourceImageSupplier(Injector injector) {
return injector.getInstance(VCloudImageSupplier.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy