Fix location assignment in SoftLayer VirtualGuestToNodeMetadata

This commit is contained in:
Ignasi Barrera 2015-02-04 17:18:27 +01:00 committed by Andrea Turli
parent acd06b3024
commit fa8b9e2332
2 changed files with 4 additions and 2 deletions

View File

@ -73,7 +73,7 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
builder.hostname(from.getHostname() + from.getDomain());
if (from.getDatacenter() != null) {
builder.location(from(locations.get()).firstMatch(
LocationPredicates.idEquals(from.getDatacenter().getId() + "")).orNull());
LocationPredicates.idEquals(from.getDatacenter().getName())).orNull());
}
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getHostname()));
builder.hardware(virtualGuestToHardware.apply(from));

View File

@ -51,7 +51,7 @@ public class VirtualGuestToNodeMetadataTest {
VirtualGuestToHardware virtualGuestToHardware = Guice.createInjector().getInstance(VirtualGuestToHardware.class);
GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
Location location = new LocationBuilder().id("123456789")
Location location = new LocationBuilder().id("test")
.description("example")
.scope(LocationScope.ZONE)
.build();
@ -65,6 +65,8 @@ public class VirtualGuestToNodeMetadataTest {
virtualGuestToImage, virtualGuestToHardware).apply(virtualGuest);
assertNotNull(nodeMetadata);
assertEquals(nodeMetadata.getName(), virtualGuest.getHostname());
assertNotNull(nodeMetadata.getLocation());
assertEquals(nodeMetadata.getLocation().getId(), location.getId());
assertEquals(nodeMetadata.getHostname(), virtualGuest.getHostname() + virtualGuest.getDomain());
assertEquals(nodeMetadata.getHardware().getRam(), virtualGuest.getMaxMemory());
assertTrue(nodeMetadata.getHardware().getProcessors().size() == 1);