refactoring due to org.jclouds.io.Payload and org.jclouds.scriptbuilder.domain.Statements changes

This commit is contained in:
andrea 2010-09-28 16:17:35 +02:00
parent b0e2085659
commit b24b0aa87c
5 changed files with 11 additions and 11 deletions

View File

@ -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");
}

View File

@ -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, Payload> {
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
.<String, List<String>> of("run_list", runList), RUN_LIST_TYPE)));
Statement runChef = exec("chef-client -j " + chefBootFile);

View File

@ -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<Byte> md5 = Bytes.asList(content.getContentMD5());
List<Byte> md5 = Bytes.asList(content.getContentMetadata().getContentMD5());
// request an upload site for this file
UploadSandbox site = getAdminConnection().getUploadSandboxForChecksums(ImmutableSet.of(md5));

View File

@ -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)));

View File

@ -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