diff --git a/apis/chef/src/main/java/org/jclouds/chef/domain/Resource.java b/apis/chef/src/main/java/org/jclouds/chef/domain/Resource.java index 62bce310e0..8804c95cb4 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/domain/Resource.java +++ b/apis/chef/src/main/java/org/jclouds/chef/domain/Resource.java @@ -40,7 +40,7 @@ public class Resource { private String specificity; public Resource(FilePayload payload) { - this(payload.getRawContent().getName(), null, payload.getContentMD5(), payload + this(payload.getRawContent().getName(), null, payload.getContentMetadata().getContentMD5(), payload .getRawContent().getPath(), "default"); } diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/TagToBootScript.java b/apis/chef/src/main/java/org/jclouds/chef/functions/TagToBootScript.java index b4b2e3f574..c2cd1e0f82 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/functions/TagToBootScript.java +++ b/apis/chef/src/main/java/org/jclouds/chef/functions/TagToBootScript.java @@ -22,7 +22,7 @@ package org.jclouds.chef.functions; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static org.jclouds.io.Payloads.newStringPayload; -import static org.jclouds.scriptbuilder.domain.Statements.createFile; +import static org.jclouds.scriptbuilder.domain.Statements.appendFile; import static org.jclouds.scriptbuilder.domain.Statements.exec; import static org.jclouds.scriptbuilder.domain.Statements.newStatementList; @@ -92,18 +92,18 @@ public class TagToBootScript implements Function { String chefConfigDir = "{root}etc{fs}chef"; Statement createChefConfigDir = exec("{md} " + chefConfigDir); - Statement createClientRb = createFile(chefConfigDir + "{fs}client.rb", ImmutableList.of("require 'rubygems'", + Statement createClientRb = appendFile(chefConfigDir + "{fs}client.rb", ImmutableList.of("require 'rubygems'", "require 'ohai'", "o = Ohai::System.new", "o.all_plugins", String.format( "node_name \"%s-\" + o[:ipaddress]", tag), "log_level :info", "log_location STDOUT", String .format("validation_client_name \"%s\"", client.getClientname()), String.format( "chef_server_url \"%s\"", endpoint))); - Statement createValidationPem = createFile(chefConfigDir + "{fs}validation.pem", Splitter.on('\n').split( + Statement createValidationPem = appendFile(chefConfigDir + "{fs}validation.pem", Splitter.on('\n').split( Pems.pem(client.getPrivateKey()))); String chefBootFile = chefConfigDir + "{fs}first-boot.json"; - Statement createFirstBoot = createFile(chefBootFile, Collections.singleton(json.toJson(ImmutableMap + Statement createFirstBoot = appendFile(chefBootFile, Collections.singleton(json.toJson(ImmutableMap .> of("run_list", runList), RUN_LIST_TYPE))); Statement runChef = exec("chef-client -j " + chefBootFile); diff --git a/apis/chef/src/test/java/org/jclouds/chef/BaseChefClientLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/BaseChefClientLiveTest.java index e97da0ec2f..db46574313 100644 --- a/apis/chef/src/test/java/org/jclouds/chef/BaseChefClientLiveTest.java +++ b/apis/chef/src/test/java/org/jclouds/chef/BaseChefClientLiveTest.java @@ -95,7 +95,7 @@ public abstract class BaseChefClientLiveTest { // define the file you want in the cookbook FilePayload content = Payloads.newFilePayload(new File(System.getProperty("user.dir"), "pom.xml")); - content.setContentType("application/x-binary"); + content.getContentMetadata().setContentType("application/x-binary"); // get an md5 so that you can see if the server already has it or not Payloads.calculateMD5(content); @@ -103,7 +103,7 @@ public abstract class BaseChefClientLiveTest { // Note that java collections cannot effectively do equals or hashcodes on // byte arrays, // so let's convert to a list of bytes. - List md5 = Bytes.asList(content.getContentMD5()); + List md5 = Bytes.asList(content.getContentMetadata().getContentMD5()); // request an upload site for this file UploadSandbox site = getAdminConnection().getUploadSandboxForChecksums(ImmutableSet.of(md5)); diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/TagToBootScriptTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/TagToBootScriptTest.java index 238943089f..17b12ec113 100644 --- a/apis/chef/src/test/java/org/jclouds/chef/functions/TagToBootScriptTest.java +++ b/apis/chef/src/test/java/org/jclouds/chef/functions/TagToBootScriptTest.java @@ -94,7 +94,7 @@ public class TagToBootScriptTest { replay(client); replay(privateKey); - + assertEquals(fn.apply("foo").getRawContent(), CharStreams.toString(Resources.newReaderSupplier(Resources .getResource("one-recipe.sh"), Charsets.UTF_8))); diff --git a/apis/chef/src/test/resources/one-recipe.sh b/apis/chef/src/test/resources/one-recipe.sh index 5209003828..5e53346a67 100755 --- a/apis/chef/src/test/resources/one-recipe.sh +++ b/apis/chef/src/test/resources/one-recipe.sh @@ -14,7 +14,7 @@ if [ ! -f /usr/bin/chef-client ]; then gem install chef ohai --no-rdoc --no-ri --verbose fi mkdir -p /etc/chef -cat > /etc/chef/client.rb <<'END_OF_FILE' +cat >> /etc/chef/client.rb <<'END_OF_FILE' require 'rubygems' require 'ohai' o = Ohai::System.new @@ -25,7 +25,7 @@ log_location STDOUT validation_client_name "fooclient" chef_server_url "http://localhost:4000" END_OF_FILE -cat > /etc/chef/validation.pem <<'END_OF_FILE' +cat >> /etc/chef/validation.pem <<'END_OF_FILE' -----BEGIN PRIVATE KEY----- LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVB eWIyWkpKcUdtMEtLUis4bmZRSk5zU2QrRjl0WE5NVjdDZk9jVzZqc3FzOEVaZ2lW @@ -64,7 +64,7 @@ SU4wUnl2ZApPNFpwV0RXWW5DTzAyMUpUT1VVT0o0Si95MDQxNkJ2a3cwejU5eTdz Tlg3d0RCQkhIYksvWENjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= -----END PRIVATE KEY----- END_OF_FILE -cat > /etc/chef/first-boot.json <<'END_OF_FILE' +cat >> /etc/chef/first-boot.json <<'END_OF_FILE' {"run_list":["recipe[apache2]"]} END_OF_FILE chef-client -j /etc/chef/first-boot.json