Merge branch 'master' of git://github.com/jclouds/jclouds

This commit is contained in:
Jason King 2011-09-29 09:30:35 +01:00
commit 7d7b7df48c
7 changed files with 42 additions and 6 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()

View File

@ -109,7 +109,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>10.0-rc3</version>
<version>10.0</version>
</dependency>
</dependencies>

View File

@ -35,7 +35,7 @@
<properties>
<test.openhosting-east1.endpoint>https://api.east1.openhosting.com</test.openhosting-east1.endpoint>
<test.openhosting-east1.apiversion>1.0</test.openhosting-east1.apiversion>
<test.openhosting-east1.apiversion>2.0</test.openhosting-east1.apiversion>
<test.openhosting-east1.identity>FIXME_IDENTITY</test.openhosting-east1.identity>
<test.openhosting-east1.credential>FIXME_CREDENTIAL</test.openhosting-east1.credential>
</properties>

View File

@ -37,7 +37,7 @@ public class OpenHostingEast1PropertiesBuilder extends ElasticStackPropertiesBui
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA");
properties.setProperty(PROPERTY_ENDPOINT, "https://api.east1.openhosting.com");
properties.setProperty(PROPERTY_API_VERSION, "1.0");
properties.setProperty(PROPERTY_API_VERSION, "2.0");
return properties;
}

View File

@ -62,7 +62,9 @@ public class Utils {
}
}
private static final Pattern pattern = Pattern.compile("\\{(.+?)\\}");
/** matches any expression inside curly braces (where the expression does not including an open curly brace) */
private static final Pattern pattern = Pattern.compile("\\{([^\\{]+?)\\}");
/**
* replaces tokens that are expressed as <code>{token}</code>

View File

@ -23,6 +23,7 @@ import static org.testng.Assert.assertEquals;
import java.io.UnsupportedEncodingException;
import org.jclouds.scriptbuilder.domain.OsFamily;
import org.jclouds.scriptbuilder.domain.ShellToken;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
@ -80,4 +81,9 @@ public class UtilsTest {
"set HOST=\r\nset PORT=\r\n");
}
public void testSingleCurlyBraceDoesntBreakLfTokenReplacement() {
assertEquals(Utils.replaceTokens("{{lf}", ShellToken.tokenValueMap(OsFamily.UNIX)),
"{\n");
}
}