mirror of https://github.com/apache/jclouds.git
fixed ibmdev to compile again
This commit is contained in:
parent
5b27c07eaf
commit
a8c24236ab
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.ibmdev.compute.config;
|
||||
|
||||
import org.jclouds.compute.config.BindComputeStrategiesByClass;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.compute.strategy.ResumeNodeStrategy;
|
||||
import org.jclouds.compute.strategy.SuspendNodeStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudAddNodeWithTagStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudDestroyNodeStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudGetNodeMetadataStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudLifeCycleStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudListNodesStrategy;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IBMDeveloperCloudBindComputeStrategiesByClass extends BindComputeStrategiesByClass {
|
||||
|
||||
@Override
|
||||
protected Class<? extends AddNodeWithTagStrategy> defineAddNodeWithTagStrategy() {
|
||||
return IBMDeveloperCloudAddNodeWithTagStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends DestroyNodeStrategy> defineDestroyNodeStrategy() {
|
||||
return IBMDeveloperCloudDestroyNodeStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends GetNodeMetadataStrategy> defineGetNodeMetadataStrategy() {
|
||||
return IBMDeveloperCloudGetNodeMetadataStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ListNodesStrategy> defineListNodesStrategy() {
|
||||
return IBMDeveloperCloudListNodesStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends RebootNodeStrategy> defineRebootNodeStrategy() {
|
||||
return IBMDeveloperCloudLifeCycleStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ResumeNodeStrategy> defineStartNodeStrategy() {
|
||||
return IBMDeveloperCloudLifeCycleStrategy.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends SuspendNodeStrategy> defineStopNodeStrategy() {
|
||||
return IBMDeveloperCloudLifeCycleStrategy.class;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.ibmdev.compute.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.config.BindComputeSuppliersByClass;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.ibmdev.compute.suppliers.IBMDeveloperCloudHardwareSupplier;
|
||||
import org.jclouds.ibmdev.compute.suppliers.IBMDeveloperCloudImageSupplier;
|
||||
import org.jclouds.ibmdev.compute.suppliers.IBMDeveloperCloudLocationSupplier;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IBMDeveloperCloudBindComputeSuppliersByClass extends BindComputeSuppliersByClass {
|
||||
@Override
|
||||
protected Class<? extends Supplier<Set<? extends Hardware>>> defineHardwareSupplier() {
|
||||
return IBMDeveloperCloudHardwareSupplier.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends Supplier<Set<? extends Image>>> defineImageSupplier() {
|
||||
return IBMDeveloperCloudImageSupplier.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends Supplier<Set<? extends Location>>> defineLocationSupplier() {
|
||||
return IBMDeveloperCloudLocationSupplier.class;
|
||||
}
|
||||
}
|
|
@ -21,76 +21,26 @@ package org.jclouds.ibmdev.compute.config;
|
|||
|
||||
import static org.jclouds.compute.domain.OsFamily.SUSE;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.LoadBalancerService;
|
||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.domain.Size;
|
||||
import org.jclouds.compute.domain.TemplateBuilder;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudAsyncClient;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
import org.jclouds.ibmdev.compute.functions.InstanceToNodeMetadata;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudAddNodeWithTagStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudDestroyNodeStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudGetNodeMetadataStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudListNodesStrategy;
|
||||
import org.jclouds.ibmdev.compute.strategy.IBMDeveloperCloudRebootNodeStrategy;
|
||||
import org.jclouds.ibmdev.compute.suppliers.IBMDeveloperCloudImageSupplier;
|
||||
import org.jclouds.ibmdev.compute.suppliers.IBMDeveloperCloudLocationSupplier;
|
||||
import org.jclouds.ibmdev.compute.suppliers.IBMDeveloperCloudSizeSupplier;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.compute.internal.BaseComputeService;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
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.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
/**
|
||||
* Configures the {@link IBMDeveloperCloudComputeServiceContext}; requires
|
||||
* {@link BaseComputeService} bound.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IBMDeveloperCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
install(new ComputeServiceTimeoutsModule());
|
||||
bind(new TypeLiteral<Function<Instance, NodeMetadata>>() {
|
||||
}).to(InstanceToNodeMetadata.class);
|
||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||
}).to(new TypeLiteral<ComputeServiceContextImpl<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(new TypeLiteral<RestContext<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient>>() {
|
||||
}).to(new TypeLiteral<RestContextImpl<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(AddNodeWithTagStrategy.class).to(IBMDeveloperCloudAddNodeWithTagStrategy.class);
|
||||
bind(ListNodesStrategy.class).to(IBMDeveloperCloudListNodesStrategy.class);
|
||||
bind(GetNodeMetadataStrategy.class).to(IBMDeveloperCloudGetNodeMetadataStrategy.class);
|
||||
bind(RebootNodeStrategy.class).to(IBMDeveloperCloudRebootNodeStrategy.class);
|
||||
bind(DestroyNodeStrategy.class).to(IBMDeveloperCloudDestroyNodeStrategy.class);
|
||||
bind(LoadBalancerService.class).toProvider(Providers.<LoadBalancerService> of(null));
|
||||
install(new IBMDeveloperCloudComputeServiceDependenciesModule());
|
||||
install(new IBMDeveloperCloudBindComputeStrategiesByClass());
|
||||
install(new IBMDeveloperCloudBindComputeSuppliersByClass());
|
||||
super.configure();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,48 +50,4 @@ public class IBMDeveloperCloudComputeServiceContextModule extends BaseComputeSer
|
|||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||
return template.osFamily(SUSE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("CREDENTIALS")
|
||||
Map<String, String> credentialsMap() {
|
||||
return new ConcurrentHashMap<String, String>();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static final Map<Instance.Status, NodeState> instanceStatusToNodeState = ImmutableMap
|
||||
.<Instance.Status, NodeState> builder().put(Instance.Status.ACTIVE, NodeState.RUNNING)//
|
||||
.put(Instance.Status.STOPPED, NodeState.SUSPENDED)//
|
||||
.put(Instance.Status.REMOVED, NodeState.TERMINATED)//
|
||||
.put(Instance.Status.DEPROVISIONING, NodeState.PENDING)//
|
||||
.put(Instance.Status.FAILED, NodeState.ERROR)//
|
||||
.put(Instance.Status.NEW, NodeState.PENDING)//
|
||||
.put(Instance.Status.PROVISIONING, NodeState.PENDING)//
|
||||
.put(Instance.Status.REJECTED, NodeState.ERROR)//
|
||||
.put(Instance.Status.RESTARTING, NodeState.PENDING)//
|
||||
.put(Instance.Status.STARTING, NodeState.PENDING)//
|
||||
.put(Instance.Status.STOPPING, NodeState.PENDING)//
|
||||
.put(Instance.Status.DEPROVISION_PENDING, NodeState.PENDING)//
|
||||
.put(Instance.Status.UNKNOWN, NodeState.UNKNOWN).build();
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
Map<Instance.Status, NodeState> provideServerToNodeState() {
|
||||
return instanceStatusToNodeState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Image>> getSourceImageSupplier(Injector injector) {
|
||||
return injector.getInstance(IBMDeveloperCloudImageSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Size>> getSourceSizeSupplier(Injector injector) {
|
||||
return injector.getInstance(IBMDeveloperCloudSizeSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<Set<? extends Location>> getSourceLocationSupplier(Injector injector) {
|
||||
return injector.getInstance(IBMDeveloperCloudLocationSupplier.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.ibmdev.compute.config;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudAsyncClient;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
import org.jclouds.ibmdev.compute.functions.InstanceToNodeMetadata;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IBMDeveloperCloudComputeServiceDependenciesModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(new TypeLiteral<Function<Instance, NodeMetadata>>() {
|
||||
}).to(InstanceToNodeMetadata.class);
|
||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||
}).to(new TypeLiteral<ComputeServiceContextImpl<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(new TypeLiteral<RestContext<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient>>() {
|
||||
}).to(new TypeLiteral<RestContextImpl<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("CREDENTIALS")
|
||||
Map<String, String> credentialsMap() {
|
||||
return new ConcurrentHashMap<String, String>();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static final Map<Instance.Status, NodeState> instanceStatusToNodeState = ImmutableMap
|
||||
.<Instance.Status, NodeState> builder().put(Instance.Status.ACTIVE, NodeState.RUNNING)//
|
||||
.put(Instance.Status.STOPPED, NodeState.SUSPENDED)//
|
||||
.put(Instance.Status.REMOVED, NodeState.TERMINATED)//
|
||||
.put(Instance.Status.DEPROVISIONING, NodeState.PENDING)//
|
||||
.put(Instance.Status.FAILED, NodeState.ERROR)//
|
||||
.put(Instance.Status.NEW, NodeState.PENDING)//
|
||||
.put(Instance.Status.PROVISIONING, NodeState.PENDING)//
|
||||
.put(Instance.Status.REJECTED, NodeState.ERROR)//
|
||||
.put(Instance.Status.RESTARTING, NodeState.PENDING)//
|
||||
.put(Instance.Status.STARTING, NodeState.PENDING)//
|
||||
.put(Instance.Status.STOPPING, NodeState.PENDING)//
|
||||
.put(Instance.Status.DEPROVISION_PENDING, NodeState.PENDING)//
|
||||
.put(Instance.Status.UNKNOWN, NodeState.UNRECOGNIZED).build();
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
Map<Instance.Status, NodeState> provideServerToNodeState() {
|
||||
return instanceStatusToNodeState;
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.ibmdev.compute.domain;
|
||||
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.Location;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IBMImage extends ImageImpl {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -8520373150950058296L;
|
||||
|
||||
private final org.jclouds.ibmdev.domain.Image rawImage;
|
||||
|
||||
public IBMImage(org.jclouds.ibmdev.domain.Image in, Location location) {
|
||||
// TODO parse correct OS
|
||||
// TODO manifest fails to parse due to encoding issues in the path
|
||||
// TODO get correct default credentials
|
||||
// http://www-180.ibm.com/cloud/enterprise/beta/ram/community/_rlvid.jsp.faces?_rap=pc_DiscussionForum.doDiscussionTopic&_rvip=/community/discussionForum.jsp&guid={DA689AEE-783C-6FE7-6F9F-DFEE9763F806}&v=1&submission=false&fid=1068&tid=1527
|
||||
super(in.getId(), in.getName(), in.getId(), location, null, ImmutableMap.<String, String> of(),
|
||||
new OperatingSystem((in.getPlatform().indexOf("Red Hat") != -1) ? OsFamily.RHEL : OsFamily.SUSE, null,
|
||||
null, null, in.getPlatform(), (in.getPlatform().indexOf("32") == -1)), in.getDescription(), in
|
||||
.getCreatedTime().getTime()
|
||||
+ "", new Credentials("idcuser", null));
|
||||
|
||||
this.rawImage = in;
|
||||
}
|
||||
|
||||
public org.jclouds.ibmdev.domain.Image getRawImage() {
|
||||
return rawImage;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.ibmdev.compute.domain;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||
import org.jclouds.ibmdev.domain.InstanceType;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IBMSize extends SizeImpl {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -8520373150950058296L;
|
||||
|
||||
private final IBMImage image;
|
||||
|
||||
private final InstanceType instanceType;
|
||||
|
||||
// until we can lookup cores by id, we are multiplying price *100 to get a positive integer we
|
||||
// can compare against.
|
||||
public IBMSize(IBMImage in, InstanceType instanceType) {
|
||||
super(instanceType.getId(), instanceType.getLabel(), in.getId() + "/" + instanceType.getId(), in.getLocation(),
|
||||
in.getRawImage().getManifest(), ImmutableMap.<String, String> of(), (int) (instanceType.getPrice()
|
||||
.getRate() * 100), (int) (instanceType.getPrice().getRate() * 1024d), (int) (instanceType
|
||||
.getPrice().getRate() * 100d), null);
|
||||
this.image = in;
|
||||
this.instanceType = instanceType;
|
||||
}
|
||||
|
||||
public IBMImage getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType() {
|
||||
return instanceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsImage(Image input) {
|
||||
return image.getId().equals(input.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", name=" + getName() + ", cores=" + getCores()
|
||||
+ ", ram=" + getRam() + ", disk=" + getDisk() + ", supportsImage=" + image.getId() + ", rate="
|
||||
+ instanceType.getPrice().getRate() + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -32,16 +32,16 @@ import javax.inject.Singleton;
|
|||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
|
@ -51,6 +51,21 @@ import com.google.common.collect.ImmutableSet;
|
|||
@Singleton
|
||||
public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata> {
|
||||
|
||||
@VisibleForTesting
|
||||
public static final Map<Instance.Status, NodeState> instanceStatusToNodeState = ImmutableMap
|
||||
.<Instance.Status, NodeState> builder().put(Instance.Status.ACTIVE, NodeState.RUNNING)//
|
||||
.put(Instance.Status.STOPPED, NodeState.SUSPENDED)//
|
||||
.put(Instance.Status.REMOVED, NodeState.TERMINATED)//
|
||||
.put(Instance.Status.DEPROVISIONING, NodeState.PENDING)//
|
||||
.put(Instance.Status.FAILED, NodeState.ERROR)//
|
||||
.put(Instance.Status.NEW, NodeState.PENDING)//
|
||||
.put(Instance.Status.PROVISIONING, NodeState.PENDING)//
|
||||
.put(Instance.Status.REJECTED, NodeState.ERROR)//
|
||||
.put(Instance.Status.RESTARTING, NodeState.PENDING)//
|
||||
.put(Instance.Status.STARTING, NodeState.PENDING)//
|
||||
.put(Instance.Status.STOPPING, NodeState.PENDING)//
|
||||
.put(Instance.Status.DEPROVISION_PENDING, NodeState.PENDING)//
|
||||
.put(Instance.Status.UNKNOWN, NodeState.UNRECOGNIZED).build();
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
private final Map<Instance.Status, NodeState> instanceStateToNodeState;
|
||||
|
@ -60,8 +75,8 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
|
|||
|
||||
@Inject
|
||||
InstanceToNodeMetadata(Map<Instance.Status, NodeState> instanceStateToNodeState,
|
||||
Supplier<Map<String, ? extends Image>> images, @Named("CREDENTIALS") Map<String, String> credentialsMap,
|
||||
Supplier<Map<String, ? extends Location>> locations) {
|
||||
Supplier<Map<String, ? extends Image>> images, @Named("CREDENTIALS") Map<String, String> credentialsMap,
|
||||
Supplier<Map<String, ? extends Location>> locations) {
|
||||
this.instanceStateToNodeState = checkNotNull(instanceStateToNodeState, "instanceStateToNodeState");
|
||||
this.images = checkNotNull(images, "images");
|
||||
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
||||
|
@ -70,14 +85,15 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
|
|||
|
||||
@Override
|
||||
public NodeMetadata apply(Instance from) {
|
||||
//TODO hardware
|
||||
String tag = parseTagFromName(from.getName());
|
||||
Set<String> ipSet = from.getIp() != null ? ImmutableSet.of(from.getIp()) : ImmutableSet.<String> of();
|
||||
NodeState state = instanceStateToNodeState.get(from.getStatus());
|
||||
Image image = images.get().get(from.getImageId());
|
||||
String key = tag != null ? credentialsMap.get(tag) : null;
|
||||
return new NodeMetadataImpl(from.getId() + "", from.getName(), from.getId() + "", locations.get().get(
|
||||
image.getLocation()), null, ImmutableMap.<String, String> of(), tag, from.getImageId(),
|
||||
image != null ? image.getOperatingSystem() : null, state, ipSet, ImmutableList.<String> of(),
|
||||
ImmutableMap.<String, String> of(), new Credentials(image.getDefaultCredentials().identity, key));
|
||||
return new NodeMetadataBuilder().ids(from.getId() + "").name(from.getName())
|
||||
.location(locations.get().get(image.getLocation())).tag(tag).imageId(from.getImageId())
|
||||
.state(instanceStateToNodeState.get(from.getStatus()))
|
||||
.operatingSystem(image != null ? image.getOperatingSystem() : null).publicAddresses(ipSet)
|
||||
.credentials(new Credentials(image.getDefaultCredentials().identity, key)).build();
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ package org.jclouds.ibmdev.compute.strategy;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -39,8 +38,6 @@ import org.jclouds.compute.strategy.ListNodesStrategy;
|
|||
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.util.ComputeUtils;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.util.Utils;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -52,9 +49,9 @@ public class CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet extends EncodeTag
|
|||
|
||||
@Inject
|
||||
protected CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet(AddNodeWithTagStrategy addNodeWithTagStrategy,
|
||||
ListNodesStrategy listNodesStrategy, @Named("NAMING_CONVENTION") String nodeNamingConvention,
|
||||
ComputeUtils utils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||
IBMDeveloperCloudClient client, @Named("CREDENTIALS") Map<String, String> credentialsMap) {
|
||||
ListNodesStrategy listNodesStrategy, @Named("NAMING_CONVENTION") String nodeNamingConvention,
|
||||
ComputeUtils utils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||
IBMDeveloperCloudClient client, @Named("CREDENTIALS") Map<String, String> credentialsMap) {
|
||||
super(addNodeWithTagStrategy, listNodesStrategy, nodeNamingConvention, utils, executor);
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
||||
|
@ -62,15 +59,9 @@ public class CreateKeyPairEncodeTagIntoNameRunNodesAndAddToSet extends EncodeTag
|
|||
|
||||
@Override
|
||||
public Map<?, Future<Void>> execute(String tag, int count, Template template, Set<NodeMetadata> nodes,
|
||||
Map<NodeMetadata, Exception> badNodes) {
|
||||
Payload key = template.getOptions().getPublicKey();
|
||||
if (key != null) {
|
||||
String keyAsText;
|
||||
try {
|
||||
keyAsText = Utils.toStringAndClose(key.getInput());
|
||||
} catch (IOException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
Map<NodeMetadata, Exception> badNodes) {
|
||||
String keyAsText = template.getOptions().getPublicKey();
|
||||
if (keyAsText != null) {
|
||||
template.getOptions().dontAuthorizePublicKey();
|
||||
try {
|
||||
client.addPublicKey(tag, keyAsText);
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.jclouds.compute.domain.NodeMetadata;
|
|||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
import org.jclouds.ibmdev.compute.domain.IBMImage;
|
||||
import org.jclouds.ibmdev.compute.domain.IBMSize;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -46,16 +44,15 @@ public class IBMDeveloperCloudAddNodeWithTagStrategy implements AddNodeWithTagSt
|
|||
|
||||
@Inject
|
||||
protected IBMDeveloperCloudAddNodeWithTagStrategy(IBMDeveloperCloudClient client,
|
||||
Function<Instance, NodeMetadata> instanceToNodeMetadata) {
|
||||
Function<Instance, NodeMetadata> instanceToNodeMetadata) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.instanceToNodeMetadata = checkNotNull(instanceToNodeMetadata, "instanceToNodeMetadata");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String tag, String name, Template template) {
|
||||
Instance instance = client.createInstanceInLocation(template.getLocation().getId(), name, IBMImage.class.cast(
|
||||
template.getImage()).getRawImage().getId(), IBMSize.class.cast(template.getSize()).getInstanceType()
|
||||
.getId(), authorizePublicKey(tag));
|
||||
public NodeMetadata addNodeWithTag(String tag, String name, Template template) {
|
||||
Instance instance = client.createInstanceInLocation(template.getLocation().getId(), name, template.getImage()
|
||||
.getProviderId(), template.getHardware().getProviderId(), authorizePublicKey(tag));
|
||||
return instanceToNodeMetadata.apply(client.getInstance(instance.getId()));
|
||||
}
|
||||
}
|
|
@ -44,8 +44,8 @@ public class IBMDeveloperCloudDestroyNodeStrategy implements DestroyNodeStrategy
|
|||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String id) {
|
||||
public NodeMetadata destroyNode(String id) {
|
||||
client.deleteInstance(id);
|
||||
return getNode.execute(id);
|
||||
return getNode.getNode(id);
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ public class IBMDeveloperCloudGetNodeMetadataStrategy implements GetNodeMetadata
|
|||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String id) {
|
||||
public NodeMetadata getNode(String id) {
|
||||
Instance instance = client.getInstance(checkNotNull(id, "id"));
|
||||
return instance == null ? null : instanceToNodeMetadata.apply(instance);
|
||||
}
|
||||
|
|
|
@ -27,26 +27,38 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.compute.strategy.ResumeNodeStrategy;
|
||||
import org.jclouds.compute.strategy.SuspendNodeStrategy;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class IBMDeveloperCloudRebootNodeStrategy implements RebootNodeStrategy {
|
||||
public class IBMDeveloperCloudLifeCycleStrategy implements RebootNodeStrategy, SuspendNodeStrategy, ResumeNodeStrategy {
|
||||
|
||||
private final IBMDeveloperCloudClient client;
|
||||
private final GetNodeMetadataStrategy getNode;
|
||||
|
||||
@Inject
|
||||
protected IBMDeveloperCloudRebootNodeStrategy(IBMDeveloperCloudClient client, GetNodeMetadataStrategy getNode) {
|
||||
protected IBMDeveloperCloudLifeCycleStrategy(IBMDeveloperCloudClient client, GetNodeMetadataStrategy getNode) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.getNode = checkNotNull(getNode, "getNode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String id) {
|
||||
public NodeMetadata rebootNode(String id) {
|
||||
client.restartInstance(id);
|
||||
return getNode.execute(id);
|
||||
return getNode.getNode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata suspendNode(String id) {
|
||||
throw new UnsupportedOperationException("suspend not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata resumeNode(String id) {
|
||||
throw new UnsupportedOperationException("resume not supported");
|
||||
}
|
||||
}
|
|
@ -43,13 +43,13 @@ public class IBMDeveloperCloudListNodesStrategy implements ListNodesStrategy {
|
|||
|
||||
@Inject
|
||||
protected IBMDeveloperCloudListNodesStrategy(IBMDeveloperCloudClient client,
|
||||
Function<Instance, NodeMetadata> instanceToNodeMetadata) {
|
||||
Function<Instance, NodeMetadata> instanceToNodeMetadata) {
|
||||
this.client = client;
|
||||
this.instanceToNodeMetadata = instanceToNodeMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends ComputeMetadata> list() {
|
||||
public Iterable<? extends ComputeMetadata> listNodes() {
|
||||
return listDetailsOnNodesMatching(NodePredicates.all());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.ibmdev.compute.suppliers;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.HardwareBuilder;
|
||||
import org.jclouds.compute.domain.Processor;
|
||||
import org.jclouds.compute.domain.Volume;
|
||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
import org.jclouds.ibmdev.domain.InstanceType;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class IBMDeveloperCloudHardwareSupplier implements Supplier<Set<? extends Hardware>> {
|
||||
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
private final IBMDeveloperCloudClient sync;
|
||||
private final Supplier<Map<String, ? extends Location>> locations;
|
||||
|
||||
@Inject
|
||||
IBMDeveloperCloudHardwareSupplier(IBMDeveloperCloudClient sync, Supplier<Map<String, ? extends Location>> locations) {
|
||||
this.sync = sync;
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends Hardware> get() {
|
||||
final Set<Hardware> hardware = Sets.newHashSet();
|
||||
logger.debug(">> providing hardware");
|
||||
for (org.jclouds.ibmdev.domain.Image image : sync.listImages()) {
|
||||
for (InstanceType instanceType : image.getSupportedInstanceTypes()) {
|
||||
hardware.add(new HardwareBuilder()
|
||||
.id(image.getId() + "/" + instanceType.getId())
|
||||
.providerId(image.getId())
|
||||
.name(instanceType.getLabel())
|
||||
.location(locations.get().get(image.getLocation()))
|
||||
.uri(image.getManifest())
|
||||
.processors(ImmutableList.of(new Processor((instanceType.getPrice().getRate() * 100), 1.0)))
|
||||
.ram((int) instanceType.getPrice().getRate() * 1024)
|
||||
.volumes(
|
||||
ImmutableList.<Volume> of(new VolumeImpl((float) (instanceType.getPrice().getRate() * 100d),
|
||||
true, true))).build());
|
||||
|
||||
}
|
||||
}
|
||||
logger.debug("<< hardware(%d)", hardware.size());
|
||||
return hardware;
|
||||
}
|
||||
}
|
|
@ -28,10 +28,13 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.ImageBuilder;
|
||||
import org.jclouds.compute.domain.OperatingSystemBuilder;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
import org.jclouds.ibmdev.compute.domain.IBMImage;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -51,7 +54,7 @@ public class IBMDeveloperCloudImageSupplier implements Supplier<Set<? extends Im
|
|||
|
||||
@Inject
|
||||
IBMDeveloperCloudImageSupplier(final IBMDeveloperCloudClient sync,
|
||||
Supplier<Map<String, ? extends Location>> locations) {
|
||||
Supplier<Map<String, ? extends Location>> locations) {
|
||||
this.sync = sync;
|
||||
this.locations = locations;
|
||||
}
|
||||
|
@ -61,11 +64,24 @@ public class IBMDeveloperCloudImageSupplier implements Supplier<Set<? extends Im
|
|||
final Set<Image> images = Sets.newHashSet();
|
||||
logger.debug(">> providing images");
|
||||
|
||||
for (org.jclouds.ibmdev.domain.Image image : sync.listImages())
|
||||
images.add(new IBMImage(image, locations.get().get(image.getLocation())));
|
||||
for (org.jclouds.ibmdev.domain.Image image : sync.listImages()) {
|
||||
// TODO parse correct OS
|
||||
// TODO manifest fails to parse due to encoding issues in the path
|
||||
// TODO get correct default credentials
|
||||
// http://www-180.ibm.com/cloud/enterprise/beta/ram/community/_rlvid.jsp.faces?_rap=pc_DiscussionForum.doDiscussionTopic&_rvip=/community/discussionForum.jsp&guid={DA689AEE-783C-6FE7-6F9F-DFEE9763F806}&v=1&submission=false&fid=1068&tid=1527
|
||||
images.add(new ImageBuilder()
|
||||
.ids(image.getId())
|
||||
.name(image.getName())
|
||||
.location(locations.get().get(image.getLocation()))
|
||||
.operatingSystem(
|
||||
new OperatingSystemBuilder()
|
||||
.family((image.getPlatform().indexOf("Red Hat") != -1) ? OsFamily.RHEL : OsFamily.SUSE)
|
||||
.arch(image.getPlatform()).is64Bit(image.getPlatform().indexOf("32") == -1).build())
|
||||
.description(image.getDescription()).version(image.getCreatedTime().getTime() + "")
|
||||
.defaultCredentials(new Credentials("idcuser", null)).build());
|
||||
}
|
||||
|
||||
logger.debug("<< images(%d)", images.size());
|
||||
return images;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.ibmdev.compute.suppliers;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.Size;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.ibmdev.compute.domain.IBMImage;
|
||||
import org.jclouds.ibmdev.compute.domain.IBMSize;
|
||||
import org.jclouds.ibmdev.domain.InstanceType;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class IBMDeveloperCloudSizeSupplier implements Supplier<Set<? extends Size>> {
|
||||
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
private final Supplier<Set<? extends Image>> images;
|
||||
|
||||
@Inject
|
||||
IBMDeveloperCloudSizeSupplier(Supplier<Set<? extends Image>> images) {
|
||||
this.images = images;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends Size> get() {
|
||||
final Set<Size> sizes = Sets.newHashSet();
|
||||
logger.debug(">> providing sizes");
|
||||
for (Image in : images.get()) {
|
||||
IBMImage image = IBMImage.class.cast(in);
|
||||
for (InstanceType instanceType : image.getRawImage().getSupportedInstanceTypes())
|
||||
sizes.add(new IBMSize(image, instanceType));
|
||||
}
|
||||
logger.debug("<< sizes(%d)", sizes.size());
|
||||
return sizes;
|
||||
}
|
||||
}
|
|
@ -56,8 +56,7 @@ public class IBMDeveloperCloudErrorHandler implements HttpErrorHandler {
|
|||
response.getStatusLine());
|
||||
switch (response.getStatusCode()) {
|
||||
case 401:
|
||||
exception = new AuthorizationException(command.getRequest(), message != null ? message : response
|
||||
.getStatusLine());
|
||||
exception = new AuthorizationException(exception.getMessage(), exception);
|
||||
break;
|
||||
case 402:
|
||||
case 403:
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.jclouds.ibmdev.xml.LocationHandler;
|
|||
import org.jclouds.ibmdev.xml.LocationsHandler;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextFactory.ContextSpec;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
@ -660,7 +660,7 @@ public class IBMDeveloperCloudAsyncClientTest extends RestClientTest<IBMDevelope
|
|||
}
|
||||
|
||||
@Override
|
||||
public ContextSpec<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient> createContextSpec() {
|
||||
public RestContextSpec<IBMDeveloperCloudClient, IBMDeveloperCloudAsyncClient> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec("ibmdev", "identity", "credential", new Properties());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,14 +41,14 @@ import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
|||
import org.jclouds.ibmdev.domain.Address;
|
||||
import org.jclouds.ibmdev.domain.Image;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.ibmdev.domain.Instance.Software;
|
||||
import org.jclouds.ibmdev.domain.InstanceType;
|
||||
import org.jclouds.ibmdev.domain.Key;
|
||||
import org.jclouds.ibmdev.domain.Location;
|
||||
import org.jclouds.ibmdev.domain.Offering;
|
||||
import org.jclouds.ibmdev.domain.StorageOffering;
|
||||
import org.jclouds.ibmdev.domain.Volume;
|
||||
import org.jclouds.ibmdev.domain.Instance.Software;
|
||||
import org.jclouds.ibmdev.domain.StorageOffering.Format;
|
||||
import org.jclouds.ibmdev.domain.Volume;
|
||||
import org.jclouds.ibmdev.predicates.AddressFree;
|
||||
import org.jclouds.ibmdev.predicates.InstanceActive;
|
||||
import org.jclouds.ibmdev.predicates.InstanceActiveOrFailed;
|
||||
|
@ -56,6 +56,7 @@ import org.jclouds.ibmdev.predicates.InstanceRemovedOrNotFound;
|
|||
import org.jclouds.ibmdev.predicates.VolumeUnmounted;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
|
@ -63,7 +64,6 @@ import org.jclouds.ssh.ExecResponse;
|
|||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.SshException;
|
||||
import org.jclouds.ssh.jsch.JschSshClient;
|
||||
import org.jclouds.ssh.jsch.predicates.InetSocketAddressConnect;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jclouds.ibmdev.compute;
|
||||
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||
|
@ -52,7 +53,7 @@ public class IBMDeveloperCloudComputeServiceLiveTestDisabled extends BaseCompute
|
|||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.SUSE);
|
||||
assertEquals(defaultTemplate.getLocation().getId(), "1");
|
||||
assertEquals(defaultTemplate.getSize().getCores(), 2.0d);
|
||||
assertEquals(getCores(defaultTemplate.getHardware()), 2.0d);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package org.jclouds.ibmdev.compute;
|
||||
|
||||
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
|
||||
import org.jclouds.compute.OsFamilyVersion64Bit;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "ibmdev.IBMDeveloperCloudTemplateBuilderLiveTest")
|
||||
public class IBMDeveloperCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||
|
||||
public IBMDeveloperCloudTemplateBuilderLiveTest() {
|
||||
provider = "ibmdev";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
|
||||
return new Predicate<OsFamilyVersion64Bit>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(OsFamilyVersion64Bit input) {
|
||||
return input.family != OsFamily.RHEL && //
|
||||
input.family != OsFamily.SUSE && //
|
||||
input.family != OsFamily.WINDOWS;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
|
@ -25,13 +25,13 @@ import org.testng.annotations.Test;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ibmdev.IBMDeveloperCloudComputeServiceContextModuleTest")
|
||||
public class IBMDeveloperCloudComputeServiceContextModuleTest {
|
||||
@Test(groups = "unit", testName = "ibmdev.IBMDeveloperCloudComputeServiceDependenciesModuleTest")
|
||||
public class IBMDeveloperCloudComputeServiceDependenciesModuleTest {
|
||||
|
||||
public void testAllStatusCovered() {
|
||||
|
||||
for (Instance.Status state : Instance.Status.values()) {
|
||||
assert IBMDeveloperCloudComputeServiceContextModule.instanceStatusToNodeState.containsKey(state) : state;
|
||||
assert IBMDeveloperCloudComputeServiceDependenciesModule.instanceStatusToNodeState.containsKey(state) : state;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue