Issue 669: ensure elasticstack doesn't pass nic mac address when setting server config

This commit is contained in:
Adrian Cole 2011-09-28 13:28:16 -07:00
parent 1a46eb82ca
commit 34bca807d5
2 changed files with 30 additions and 2 deletions

View File

@ -23,23 +23,27 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.elasticstack.domain.Device;
import org.jclouds.elasticstack.domain.NIC;
import org.jclouds.elasticstack.domain.Server;
import org.jclouds.logging.Logger;
import org.jclouds.rest.annotations.ApiVersion;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import org.jclouds.rest.annotations.ApiVersion;
/**
* @author Adrian Cole
*/
@Singleton
public class ServerToMap implements Function<Server, Map<String, String>> {
@Resource
protected Logger logger = Logger.NULL;
@ApiVersion
private final String apiVersion;
@ -75,7 +79,7 @@ public class ServerToMap implements Function<Server, Map<String, String>> {
if (nic.getVlan() != null)
builder.put("nic:" + nicId + ":vlan", nic.getVlan());
if (nic.getMac() != null)
builder.put("nic:" + nicId + ":mac", nic.getMac());
logger.trace("setting mac on network interfaces not supported: %s", nic);
nicId++;
}

View File

@ -63,6 +63,30 @@ public class ServerToMapTest {
"vnc:password", "XXXXXXXX")).build());
}
public void testWeDontSetMac() {
assertEquals(
SERVER_TO_MAP.apply(new Server.Builder()
.name("TestServer")
.cpu(2000)
.mem(1024)
.devices(
ImmutableMap.of("ide:0:0",
new IDEDevice.Builder(0, 0).uuid("08c92dd5-70a0-4f51-83d2-835919d254df").build()))
.bootDeviceIds(ImmutableSet.of("ide:0:0"))
.nics(ImmutableSet.of(new NIC.Builder().mac("foo").model(Model.E1000).
build())).vnc(new VNC(null, "XXXXXXXX", false)).build()),
ImmutableMap
.builder()
.putAll(ImmutableMap.of("name", "TestServer", "cpu", "2000", "smp", "auto", "mem", "1024"))
.putAll(
ImmutableMap.of("persistent", "false", "boot", "ide:0:0", "ide:0:0",
"08c92dd5-70a0-4f51-83d2-835919d254df"))
.putAll(
ImmutableMap.of("ide:0:0:media", "disk", "nic:0:model", "e1000", "vnc:ip", "auto",
"vnc:password", "XXXXXXXX")).build());
}
public void testBasicsV2() {
assertEquals(
SERVER_TO_MAP_V2.apply(new Server.Builder()