mirror of https://github.com/apache/jclouds.git
incorporated lastest location changes into byon
This commit is contained in:
parent
30ed6fd848
commit
e56697170a
|
@ -32,7 +32,9 @@ import org.jclouds.byon.suppliers.NodesParsedFromSupplier;
|
|||
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
|
||||
import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
|
||||
import org.jclouds.concurrent.SingleThreaded;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -62,6 +64,8 @@ public class BYONComputeServiceContextModule extends
|
|||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(new TypeLiteral<Supplier<Location>>() {
|
||||
}).to(OnlyLocationOrFirstZone.class);
|
||||
bind(new TypeLiteral<Supplier<Map<String, Node>>>() {
|
||||
}).to(NodesParsedFromSupplier.class);
|
||||
bind(new TypeLiteral<Supplier<InputStream>>() {
|
||||
|
|
|
@ -73,12 +73,12 @@ public class BYONComputeServiceTest {
|
|||
assertEquals(supplier.get(), ImmutableMap.<String, Node> of(NodesFromYamlTest.TEST1.id,
|
||||
NodesFromYamlTest.TEST1));
|
||||
|
||||
assertEquals(context.getComputeService().listNodes(), ImmutableSet.of(NodeToNodeMetadataTest.TEST1));
|
||||
assertEquals(context.getComputeService().listNodes(), ImmutableSet.of(NodeToNodeMetadataTest
|
||||
.expectedNodeMetadataFromResource(endpoint)));
|
||||
|
||||
} finally {
|
||||
if (context != null)
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,24 +46,30 @@ import com.google.common.collect.Maps;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class NodeToNodeMetadataTest {
|
||||
public static final Location location = new LocationBuilder().scope(LocationScope.PROVIDER).id("byon").description(
|
||||
"byon").build();
|
||||
public static Location expectedLocationFromResource(String resource) {
|
||||
return new LocationBuilder().scope(LocationScope.PROVIDER).id("byon").description(resource).build();
|
||||
}
|
||||
|
||||
public static final NodeMetadata TEST1 = new NodeMetadataBuilder().ids("cluster-1").tag("hadoop").name("cluster-1")
|
||||
.location(location).state(NodeState.RUNNING).operatingSystem(
|
||||
new OperatingSystemBuilder().description("redhat").family(OsFamily.RHEL).arch("x86")
|
||||
.version("5.3").build()).publicAddresses(ImmutableSet.of("cluster-1.mydomain.com"))
|
||||
.credentials(new Credentials("myUser", NodesFromYamlTest.key)).adminPassword("happy bear").build();
|
||||
public static NodeMetadata expectedNodeMetadataFromResource(String resource) {
|
||||
Location location = expectedLocationFromResource(resource);
|
||||
|
||||
return new NodeMetadataBuilder().ids("cluster-1").tag("hadoop").name("cluster-1").location(location).state(
|
||||
NodeState.RUNNING).operatingSystem(
|
||||
new OperatingSystemBuilder().description("redhat").family(OsFamily.RHEL).arch("x86").version("5.3")
|
||||
.build()).publicAddresses(ImmutableSet.of("cluster-1.mydomain.com")).credentials(
|
||||
new Credentials("myUser", NodesFromYamlTest.key)).adminPassword("happy bear").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodesParse() throws Exception {
|
||||
|
||||
Map<String, Credentials> credentialStore = Maps.newLinkedHashMap();
|
||||
|
||||
NodeToNodeMetadata parser = new NodeToNodeMetadata(Suppliers.ofInstance(location),
|
||||
NodeToNodeMetadata parser = new NodeToNodeMetadata(
|
||||
Suppliers.ofInstance(expectedLocationFromResource("location")),
|
||||
new SupplyFromProviderURIOrNodesProperty(URI.create("test")), credentialStore);
|
||||
|
||||
assertEquals(parser.apply(NodesFromYamlTest.TEST1), TEST1);
|
||||
assertEquals(parser.apply(NodesFromYamlTest.TEST1), expectedNodeMetadataFromResource("location"));
|
||||
assertEquals(credentialStore, ImmutableMap.of("node#cluster-1", new Credentials("myUser", NodesFromYamlTest.key)));
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue