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