mirror of https://github.com/apache/jclouds.git
Cleaned up ChefApi and ChefService interfaces
Cleaned up and renamed some methods to have a more consistent naming, and improved the javadocs.
This commit is contained in:
parent
da047831f1
commit
47e4508fc6
File diff suppressed because it is too large
Load Diff
|
@ -44,6 +44,11 @@ import com.google.inject.Module;
|
|||
* @author Ignasi Barrera
|
||||
*/
|
||||
public class ChefApiMetadata extends BaseHttpApiMetadata<ChefApi> {
|
||||
|
||||
/**
|
||||
* The default Chef Server API version to use.
|
||||
*/
|
||||
public static final String DEFAULT_VERSION = "0.10.8";
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
|
@ -83,7 +88,7 @@ public class ChefApiMetadata extends BaseHttpApiMetadata<ChefApi> {
|
|||
.name("OpsCode Chef Api")
|
||||
.identityName("User")
|
||||
.credentialName("Certificate")
|
||||
.version(ChefApi.VERSION)
|
||||
.version(DEFAULT_VERSION)
|
||||
.documentation(URI.create("http://wiki.opscode.com/display/chef/Server+API"))
|
||||
.defaultEndpoint("http://localhost:4000")
|
||||
.defaultProperties(ChefApiMetadata.defaultProperties())
|
||||
|
|
|
@ -20,116 +20,84 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.chef.config.ChefProperties;
|
||||
import org.jclouds.chef.domain.BootstrapConfig;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
import org.jclouds.chef.domain.Environment;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.chef.internal.BaseChefService;
|
||||
import org.jclouds.chef.util.ChefUtils;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.ohai.config.OhaiModule;
|
||||
import org.jclouds.rest.annotations.SinceApiVersion;
|
||||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* Provides high level chef operations
|
||||
* Provides high level Chef operations.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ImplementedBy(BaseChefService.class)
|
||||
public interface ChefService {
|
||||
|
||||
/**
|
||||
* @return a reference to the context that created this.
|
||||
* Get the context that created this service.
|
||||
*
|
||||
* @return The context that created the service.
|
||||
*/
|
||||
ChefContext getContext();
|
||||
|
||||
// Crypto
|
||||
|
||||
/**
|
||||
* Encrypt the given input stream.
|
||||
*
|
||||
* @param supplier The input stream to encrypt.
|
||||
* @return The encrypted bytes for the given input stream.
|
||||
* @throws IOException If there is an error reading from the input stream.
|
||||
*/
|
||||
byte[] encrypt(InputSupplier<? extends InputStream> supplier) throws IOException;
|
||||
|
||||
/**
|
||||
* Decrypt the given input stream.
|
||||
*
|
||||
* @param supplier The input stream to decrypt.
|
||||
* @return The decrypted bytes for the given input stream.
|
||||
* @throws IOException If there is an error reading from the input stream.
|
||||
*/
|
||||
byte[] decrypt(InputSupplier<? extends InputStream> supplier) throws IOException;
|
||||
|
||||
void cleanupStaleNodesAndClients(String prefix, int secondsStale);
|
||||
// Bootstrap
|
||||
|
||||
/**
|
||||
* Creates all steps necessary to bootstrap the node.
|
||||
*
|
||||
* @param nodeName
|
||||
* @param runList
|
||||
* @return node sent to the server containing the automatic attributes
|
||||
*/
|
||||
Node createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList);
|
||||
|
||||
/**
|
||||
* Creates all steps necessary to bootstrap and run the chef api.
|
||||
*
|
||||
* @param group
|
||||
* corresponds to a configured
|
||||
* {@link org.jclouds.chef.config.ChefProperties#CHEF_BOOTSTRAP_DATABAG
|
||||
* databag} where run_list and other information are stored
|
||||
* @return boot script
|
||||
* @see #updateRunListForTag
|
||||
* @param group corresponds to a configured
|
||||
* {@link ChefProperties#CHEF_BOOTSTRAP_DATABAG} data bag where
|
||||
* run_list and other information are stored.
|
||||
* @return The script used to bootstrap the node.
|
||||
*/
|
||||
Statement createBootstrapScriptForGroup(String group);
|
||||
|
||||
/**
|
||||
* Configures how the nodes of a certain group will be bootstrapped
|
||||
*
|
||||
* @param group
|
||||
* The group where the given bootstrap configuration will be
|
||||
* applied.
|
||||
* @param bootstrapConfig
|
||||
* The configuration to be applied to the nodes in the group.
|
||||
* @param group The group where the given bootstrap configuration will be
|
||||
* applied.
|
||||
* @param bootstrapConfig The configuration to be applied to the nodes in the
|
||||
* group.
|
||||
*/
|
||||
void updateBootstrapConfigForGroup(String group, BootstrapConfig bootstrapConfig);
|
||||
|
||||
/**
|
||||
* assigns a run list to all nodes bootstrapped with a certain group
|
||||
* Get the run list for the given group.
|
||||
*
|
||||
* @param runList
|
||||
* list of recipes or roles to assign. syntax is
|
||||
* {@code recipe[name]} and {@code role[name]}
|
||||
*
|
||||
* @param group
|
||||
* corresponds to a configured
|
||||
* {@link org.jclouds.chef.config.ChefProperties#CHEF_BOOTSTRAP_DATABAG
|
||||
* databag} where run_list and other information are stored
|
||||
* @deprecated Use {link
|
||||
* {@link #updateBootstrapConfigForGroup(String, BootstrapConfig)}
|
||||
*/
|
||||
@Deprecated
|
||||
void updateBootstrapConfigForGroup(Iterable<String> runList, String group);
|
||||
|
||||
/**
|
||||
* assigns a run list to all nodes bootstrapped with a certain group, and
|
||||
* configures the chef run to use the given json attributes.
|
||||
*
|
||||
* @param runList
|
||||
* list of recipes or roles to assign. syntax is
|
||||
* {@code recipe[name]} and {@code role[name]}
|
||||
*
|
||||
* @param jsonAttributes
|
||||
* A json string with the attributes to be populated. Since each
|
||||
* cookbook may define its own attribute structure, a simple Map or
|
||||
* Properties object may not be convenient.
|
||||
*
|
||||
* @param group
|
||||
* corresponds to a configured
|
||||
* {@link org.jclouds.chef.config.ChefProperties#CHEF_BOOTSTRAP_DATABAG
|
||||
* databag} where run_list and other information are stored
|
||||
* @deprecated Use {link
|
||||
* {@link #updateBootstrapConfigForGroup(String, BootstrapConfig)}
|
||||
*/
|
||||
@Deprecated
|
||||
void updateBootstrapConfigForGroup(Iterable<String> runList, JsonBall jsonAttributes, String group);
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* corresponds to a configured
|
||||
* {@link org.jclouds.chef.config.ChefProperties#CHEF_BOOTSTRAP_DATABAG
|
||||
* databag} where run_list and other information are stored
|
||||
* @param The group to get the configured run list for.
|
||||
* @return run list for all nodes bootstrapped with a certain group
|
||||
* @see #updateRunListForTag
|
||||
*/
|
||||
List<String> getRunListForGroup(String group);
|
||||
|
||||
|
@ -139,45 +107,91 @@ public interface ChefService {
|
|||
* The bootstrap configuration is a Json object containing the run list and
|
||||
* the configured attributes.
|
||||
*
|
||||
* @param group
|
||||
* The name of the group.
|
||||
* @param group The name of the group.
|
||||
* @return The bootstrap configuration for the given group.
|
||||
*/
|
||||
public JsonBall getBootstrapConfigForGroup(String group);
|
||||
|
||||
void deleteAllNodesInList(Iterable<String> names);
|
||||
// Nodes
|
||||
|
||||
Iterable<? extends Node> listNodes();
|
||||
|
||||
Iterable<? extends Node> listNodesMatching(Predicate<String> nodeNameSelector);
|
||||
|
||||
Iterable<? extends Node> listNodesNamed(Iterable<String> names);
|
||||
|
||||
void deleteAllClientsInList(Iterable<String> names);
|
||||
|
||||
Iterable<? extends Client> listClientsDetails();
|
||||
|
||||
Iterable<? extends Client> listClientsDetailsMatching(Predicate<String> clientNameSelector);
|
||||
|
||||
Iterable<? extends Client> listClientsNamed(Iterable<String> names);
|
||||
|
||||
Iterable<? extends CookbookVersion> listCookbookVersions();
|
||||
|
||||
Iterable<? extends CookbookVersion> listCookbookVersionsMatching(Predicate<String> cookbookNameSelector);
|
||||
|
||||
Iterable<? extends CookbookVersion> listCookbookVersionsNamed(Iterable<String> cookbookNames);
|
||||
/**
|
||||
* Creates a new node and populates the automatic attributes.
|
||||
*
|
||||
* @param nodeName The name of the node to create.
|
||||
* @param runList The run list for the created node.
|
||||
* @return The created node with the automatic attributes populated.
|
||||
* @see OhaiModule
|
||||
* @see ChefUtils#ohaiAutomaticAttributeBinder(com.google.inject.Binder)
|
||||
*/
|
||||
Node createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList);
|
||||
|
||||
/**
|
||||
* Update and populate the automatic attributes of the given node.
|
||||
*
|
||||
* @param nodeName The node to update.
|
||||
*/
|
||||
void updateAutomaticAttributesOnNode(String nodeName);
|
||||
|
||||
/**
|
||||
* Remove the nodes and clients that have been inactive for a given amount of
|
||||
* time.
|
||||
*
|
||||
* @param prefix The prefix for the nodes and clients to delete.
|
||||
* @param secondsStale The seconds of inactivity to consider a node and
|
||||
* client obsolete.
|
||||
*/
|
||||
void cleanupStaleNodesAndClients(String prefix, int secondsStale);
|
||||
|
||||
/**
|
||||
* Delete the given nodes.
|
||||
*
|
||||
* @param names The names of the nodes to delete.
|
||||
*/
|
||||
void deleteAllNodesInList(Iterable<String> names);
|
||||
|
||||
/**
|
||||
* Delete the given clients.
|
||||
*
|
||||
* @param names The names of the client to delete.
|
||||
*/
|
||||
void deleteAllClientsInList(Iterable<String> names);
|
||||
|
||||
/**
|
||||
* List the details of all existing nodes.
|
||||
*
|
||||
* @return The details of all existing nodes.
|
||||
*/
|
||||
Iterable<? extends Node> listNodes();
|
||||
|
||||
/**
|
||||
* List the details of all existing nodes in the given environment.
|
||||
*
|
||||
* @param environmentName The name fo the environment.
|
||||
* @return The details of all existing nodes in the given environment.
|
||||
*/
|
||||
@SinceApiVersion("0.10.0")
|
||||
Iterable<? extends Node> listNodesInEnvironment(String environmentName);
|
||||
|
||||
/**
|
||||
* List the details of all existing clients.
|
||||
*
|
||||
* @return The details of all existing clients.
|
||||
*/
|
||||
Iterable<? extends Client> listClients();
|
||||
|
||||
/**
|
||||
* List the details of all existing cookbooks.
|
||||
*
|
||||
* @return The details of all existing cookbooks.
|
||||
*/
|
||||
Iterable<? extends CookbookVersion> listCookbookVersions();
|
||||
|
||||
/**
|
||||
* List the details of all existing environments.
|
||||
*
|
||||
* @return The details of all existing environments.
|
||||
*/
|
||||
@SinceApiVersion("0.10.0")
|
||||
Iterable<? extends Environment> listEnvironments();
|
||||
|
||||
@SinceApiVersion("0.10.0")
|
||||
Iterable<? extends Environment> listEnvironmentsMatching(Predicate<String> environmentNameSelector);
|
||||
|
||||
@SinceApiVersion("0.10.0")
|
||||
Iterable<? extends Environment> listEnvironmentsNamed(Iterable<String> names);
|
||||
|
||||
@SinceApiVersion("0.10.0")
|
||||
Iterable<? extends Node> listEnvironmentNodes(String environmentName);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static com.google.common.base.Charsets.UTF_8;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.hash.Hashing.sha1;
|
||||
import static com.google.common.io.BaseEncoding.base64;
|
||||
import static com.google.common.io.ByteStreams.asByteSource;
|
||||
import static com.google.common.io.ByteStreams.toByteArray;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -58,6 +57,7 @@ import com.google.common.base.Throwables;
|
|||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.io.ByteSource;
|
||||
|
||||
/**
|
||||
* Ported from mixlib-authentication in order to sign Chef requests.
|
||||
|
@ -135,7 +135,7 @@ public class SignedHeaderAuth implements HttpRequestFilter {
|
|||
@VisibleForTesting
|
||||
String hashPath(String path) {
|
||||
try {
|
||||
return base64().encode(asByteSource(canonicalPath(path).getBytes(UTF_8)).hash(sha1()).asBytes());
|
||||
return base64().encode(ByteSource.wrap(canonicalPath(path).getBytes(UTF_8)).hash(sha1()).asBytes());
|
||||
} catch (Exception e) {
|
||||
Throwables.propagateIfPossible(e);
|
||||
throw new HttpException("error creating sigature for path: " + path, e);
|
||||
|
|
|
@ -49,21 +49,19 @@ import org.jclouds.chef.strategy.DeleteAllClientsInList;
|
|||
import org.jclouds.chef.strategy.DeleteAllNodesInList;
|
||||
import org.jclouds.chef.strategy.ListClients;
|
||||
import org.jclouds.chef.strategy.ListCookbookVersions;
|
||||
import org.jclouds.chef.strategy.ListEnvironments;
|
||||
import org.jclouds.chef.strategy.ListEnvironmentNodes;
|
||||
import org.jclouds.chef.strategy.ListEnvironments;
|
||||
import org.jclouds.chef.strategy.ListNodes;
|
||||
import org.jclouds.chef.strategy.UpdateAutomaticAttributesOnNode;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.io.payloads.RSADecryptingPayload;
|
||||
import org.jclouds.io.payloads.RSAEncryptingPayload;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.json.Json;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
@ -129,81 +127,43 @@ public class BaseChefService implements ChefService {
|
|||
this.json = checkNotNull(json, "json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupStaleNodesAndClients(String prefix, int secondsStale) {
|
||||
cleanupStaleNodesAndClients.execute(prefix, secondsStale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList) {
|
||||
return createNodeAndPopulateAutomaticAttributes.execute(nodeName, runList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllNodesInList(Iterable<String> names) {
|
||||
deleteAllNodesInList.execute(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> listNodes() {
|
||||
return listNodes.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> listNodesMatching(Predicate<String> nodeNameSelector) {
|
||||
return listNodes.execute(nodeNameSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> listNodesNamed(Iterable<String> names) {
|
||||
return listNodes.execute(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllClientsInList(Iterable<String> names) {
|
||||
deleteAllClientsInList.execute(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Client> listClientsDetails() {
|
||||
return listClients.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Client> listClientsDetailsMatching(Predicate<String> clientNameSelector) {
|
||||
return listClients.execute(clientNameSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Client> listClientsNamed(Iterable<String> names) {
|
||||
return listClients.execute(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends CookbookVersion> listCookbookVersions() {
|
||||
return listCookbookVersions.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends CookbookVersion> listCookbookVersionsMatching(Predicate<String> cookbookNameSelector) {
|
||||
return listCookbookVersions.execute(cookbookNameSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends CookbookVersion> listCookbookVersionsNamed(Iterable<String> names) {
|
||||
return listCookbookVersions.execute(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAutomaticAttributesOnNode(String nodeName) {
|
||||
updateAutomaticAttributesOnNode.execute(nodeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChefContext getContext() {
|
||||
return chefContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
|
||||
return ByteStreams.toByteArray(new RSAEncryptingPayload(Payloads.newPayload(supplier.getInput()), privateKey
|
||||
.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] decrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
|
||||
return ByteStreams.toByteArray(new RSADecryptingPayload(Payloads.newPayload(supplier.getInput()), privateKey
|
||||
.get()));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
String buildBootstrapConfiguration(BootstrapConfig bootstrapConfig) {
|
||||
checkNotNull(bootstrapConfig, "bootstrapConfig must not be null");
|
||||
|
||||
Map<String, Object> configMap = Maps.newHashMap();
|
||||
configMap.put("run_list", bootstrapConfig.getRunList());
|
||||
|
||||
if (bootstrapConfig.getEnvironment().isPresent()) {
|
||||
configMap.put("environment", bootstrapConfig.getEnvironment().get());
|
||||
}
|
||||
|
||||
if (bootstrapConfig.getAttribtues().isPresent()) {
|
||||
Map<String, Object> attributes = json.fromJson(bootstrapConfig.getAttribtues().get().toString(),
|
||||
BootstrapConfigForGroup.BOOTSTRAP_CONFIG_TYPE);
|
||||
configMap.putAll(attributes);
|
||||
}
|
||||
|
||||
return json.toJson(configMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement createBootstrapScriptForGroup(String group) {
|
||||
return groupToBootScript.apply(group);
|
||||
|
@ -227,19 +187,6 @@ public class BaseChefService implements ChefService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void updateBootstrapConfigForGroup(Iterable<String> runList, String group) {
|
||||
updateBootstrapConfigForGroup(runList, null, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void updateBootstrapConfigForGroup(Iterable<String> runList, @Nullable JsonBall jsonAttributes, String group) {
|
||||
updateBootstrapConfigForGroup(group, BootstrapConfig.builder().runList(runList).attributes(jsonAttributes)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRunListForGroup(String group) {
|
||||
return runListForGroup.apply(group);
|
||||
|
@ -251,35 +198,43 @@ public class BaseChefService implements ChefService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte[] decrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
|
||||
return ByteStreams.toByteArray(new RSADecryptingPayload(Payloads.newPayload(supplier.getInput()), privateKey
|
||||
.get()));
|
||||
public void cleanupStaleNodesAndClients(String prefix, int secondsStale) {
|
||||
cleanupStaleNodesAndClients.execute(prefix, secondsStale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
|
||||
return ByteStreams.toByteArray(new RSAEncryptingPayload(Payloads.newPayload(supplier.getInput()), privateKey
|
||||
.get()));
|
||||
public Node createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList) {
|
||||
return createNodeAndPopulateAutomaticAttributes.execute(nodeName, runList);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
String buildBootstrapConfiguration(BootstrapConfig bootstrapConfig) {
|
||||
checkNotNull(bootstrapConfig, "bootstrapConfig must not be null");
|
||||
@Override
|
||||
public void updateAutomaticAttributesOnNode(String nodeName) {
|
||||
updateAutomaticAttributesOnNode.execute(nodeName);
|
||||
}
|
||||
|
||||
Map<String, Object> configMap = Maps.newHashMap();
|
||||
configMap.put("run_list", bootstrapConfig.getRunList());
|
||||
@Override
|
||||
public void deleteAllNodesInList(Iterable<String> names) {
|
||||
deleteAllNodesInList.execute(names);
|
||||
}
|
||||
|
||||
if (bootstrapConfig.getEnvironment().isPresent()) {
|
||||
configMap.put("environment", bootstrapConfig.getEnvironment().get());
|
||||
}
|
||||
@Override
|
||||
public void deleteAllClientsInList(Iterable<String> names) {
|
||||
deleteAllClientsInList.execute(names);
|
||||
}
|
||||
|
||||
if (bootstrapConfig.getAttribtues().isPresent()) {
|
||||
Map<String, Object> attributes = json.fromJson(bootstrapConfig.getAttribtues().get().toString(),
|
||||
BootstrapConfigForGroup.BOOTSTRAP_CONFIG_TYPE);
|
||||
configMap.putAll(attributes);
|
||||
}
|
||||
@Override
|
||||
public Iterable<? extends Node> listNodes() {
|
||||
return listNodes.execute();
|
||||
}
|
||||
|
||||
return json.toJson(configMap);
|
||||
@Override
|
||||
public Iterable<? extends Client> listClients() {
|
||||
return listClients.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends CookbookVersion> listCookbookVersions() {
|
||||
return listCookbookVersions.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -288,17 +243,7 @@ public class BaseChefService implements ChefService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Environment> listEnvironmentsMatching(Predicate<String> environmentNameSelector) {
|
||||
return listEnvironments.execute(environmentNameSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Environment> listEnvironmentsNamed(Iterable<String> names) {
|
||||
return listEnvironments.execute(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> listEnvironmentNodes(String environmentName) {
|
||||
public Iterable<? extends Node> listNodesInEnvironment(String environmentName) {
|
||||
return listEnvironmentNodes.execute(environmentName);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
|||
@Override
|
||||
public Iterable<? extends CookbookVersion> apply(final String cookbook) {
|
||||
// TODO getting each version could also go parallel
|
||||
Set<String> cookbookVersions = api.getVersionsOfCookbook(cookbook);
|
||||
Set<String> cookbookVersions = api.listVersionsOfCookbook(cookbook);
|
||||
ListenableFuture<List<CookbookVersion>> futures = allAsList(transform(cookbookVersions,
|
||||
new Function<String, ListenableFuture<CookbookVersion>>() {
|
||||
@Override
|
||||
|
|
|
@ -80,12 +80,12 @@ public class ListEnvironmentNodesImpl implements ListEnvironmentNodes {
|
|||
|
||||
@Override
|
||||
public Iterable<? extends Node> execute(ListeningExecutorService executor, String environmentName) {
|
||||
return execute(executor, environmentName, api.listEnvironmentNodes(environmentName));
|
||||
return execute(executor, environmentName, api.listNodesInEnvironment(environmentName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> execute(ListeningExecutorService executor, String environmentName, Predicate<String> nodeNameSelector) {
|
||||
return execute(executor, environmentName, filter(api.listEnvironmentNodes(environmentName), nodeNameSelector));
|
||||
return execute(executor, environmentName, filter(api.listNodesInEnvironment(environmentName), nodeNameSelector));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -203,12 +203,12 @@ public class TransientChefApi implements ChefApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UploadSandbox getUploadSandboxForChecksums(Set<List<Byte>> md5s) {
|
||||
public UploadSandbox createUploadSandboxForChecksums(Set<List<Byte>> md5s) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getVersionsOfCookbook(String cookbookName) {
|
||||
public Set<String> listVersionsOfCookbook(String cookbookName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -258,12 +258,12 @@ public class TransientChefApi implements ChefApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SearchResult<? extends DatabagItem> searchDatabag(String databagName) {
|
||||
public SearchResult<? extends DatabagItem> searchDatabagItems(String databagName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResult<? extends DatabagItem> searchDatabag(String databagName, SearchOptions options) {
|
||||
public SearchResult<? extends DatabagItem> searchDatabagItems(String databagName, SearchOptions options) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -343,22 +343,22 @@ public class TransientChefApi implements ChefApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<CookbookDefinition> listEnvironmentCookbooks(String environmentname) {
|
||||
public Set<CookbookDefinition> listCookbooksInEnvironment(String environmentname) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<CookbookDefinition> listEnvironmentCookbooks(String environmentname, String numversions) {
|
||||
public Set<CookbookDefinition> listCookbooksInEnvironment(String environmentname, String numversions) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CookbookDefinition getEnvironmentCookbook(String environmentname, String cookbookname) {
|
||||
public CookbookDefinition getCookbookInEnvironment(String environmentname, String cookbookname) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CookbookDefinition getEnvironmentCookbook(String environmentname, String cookbookname, String numversions) {
|
||||
public CookbookDefinition getCookbookInEnvironment(String environmentname, String cookbookname, String numversions) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -373,12 +373,12 @@ public class TransientChefApi implements ChefApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<String> listEnvironmentRecipes(String environmentname) {
|
||||
public Set<String> listRecipesInEnvironment(String environmentname) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> listEnvironmentNodes(String environmentname) {
|
||||
public Set<String> listNodesInEnvironment(String environmentname) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,8 @@ import java.util.Set;
|
|||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.chef.BaseChefApiExpectTest;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.chef.config.ChefHttpApiModule;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
@ -51,12 +49,12 @@ public class ChefApiExpectTest extends BaseChefApiExpectTest<ChefApi> {
|
|||
signed(HttpRequest.builder() //
|
||||
.method("GET") //
|
||||
.endpoint("http://localhost:4000/environments/dev/recipes") //
|
||||
.addHeader("X-Chef-Version", ChefApi.VERSION) //
|
||||
.addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_VERSION) //
|
||||
.addHeader("Accept", MediaType.APPLICATION_JSON).build()), //
|
||||
HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/environment_recipes.json", MediaType.APPLICATION_JSON)) //
|
||||
.build());
|
||||
Set<String> recipes = api.listEnvironmentRecipes("dev");
|
||||
Set<String> recipes = api.listRecipesInEnvironment("dev");
|
||||
assertEquals(recipes.size(), 3);
|
||||
assertTrue(recipes.contains("apache2"));
|
||||
}
|
||||
|
@ -66,12 +64,12 @@ public class ChefApiExpectTest extends BaseChefApiExpectTest<ChefApi> {
|
|||
signed(HttpRequest.builder() //
|
||||
.method("GET") //
|
||||
.endpoint("http://localhost:4000/environments/dev/recipes") //
|
||||
.addHeader("X-Chef-Version", ChefApi.VERSION) //
|
||||
.addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_VERSION) //
|
||||
.addHeader("Accept", MediaType.APPLICATION_JSON).build()), //
|
||||
HttpResponse.builder().statusCode(404)
|
||||
.build());
|
||||
|
||||
assertTrue(api.listEnvironmentRecipes("dev").isEmpty());
|
||||
assertTrue(api.listRecipesInEnvironment("dev").isEmpty());
|
||||
}
|
||||
|
||||
public void testListEnvironmentNodesReturns2xx() {
|
||||
|
@ -79,12 +77,12 @@ public class ChefApiExpectTest extends BaseChefApiExpectTest<ChefApi> {
|
|||
signed(HttpRequest.builder() //
|
||||
.method("GET") //
|
||||
.endpoint("http://localhost:4000/environments/dev/nodes") //
|
||||
.addHeader("X-Chef-Version", ChefApi.VERSION) //
|
||||
.addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_VERSION) //
|
||||
.addHeader("Accept", MediaType.APPLICATION_JSON).build()), //
|
||||
HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/environment_nodes.json", MediaType.APPLICATION_JSON)) //
|
||||
.build());
|
||||
Set<String> nodes = api.listEnvironmentNodes("dev");
|
||||
Set<String> nodes = api.listNodesInEnvironment("dev");
|
||||
assertEquals(nodes.size(), 3);
|
||||
assertTrue(nodes.contains("blah"));
|
||||
}
|
||||
|
@ -94,12 +92,12 @@ public class ChefApiExpectTest extends BaseChefApiExpectTest<ChefApi> {
|
|||
signed(HttpRequest.builder() //
|
||||
.method("GET") //
|
||||
.endpoint("http://localhost:4000/environments/dev/nodes") //
|
||||
.addHeader("X-Chef-Version", ChefApi.VERSION) //
|
||||
.addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_VERSION) //
|
||||
.addHeader("Accept", MediaType.APPLICATION_JSON).build()), //
|
||||
HttpResponse.builder().statusCode(404)
|
||||
.build());
|
||||
|
||||
assertTrue(api.listEnvironmentNodes("dev").isEmpty());
|
||||
assertTrue(api.listNodesInEnvironment("dev").isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("0189e76ccc476701d6b374e5a1a27347", true)));
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"PUT http://localhost:4000/sandboxes/0189e76ccc476701d6b374e5a1a27347 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"is_completed\":true}", "application/json", false);
|
||||
|
||||
|
@ -95,14 +95,14 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
|
||||
}
|
||||
|
||||
public void testGetUploadSandboxForChecksums() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "getUploadSandboxForChecksums", Set.class);
|
||||
public void testCreateUploadSandboxForChecksums() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "createUploadSandboxForChecksums", Set.class);
|
||||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList
|
||||
.<Object> of(ImmutableSet.of(asList(base16().lowerCase().decode("0189e76ccc476701d6b374e5a1a27347")),
|
||||
asList(base16().lowerCase().decode("0c5ecd7788cf4f6c7de2a57193897a6c")), asList(base16().lowerCase()
|
||||
.decode("1dda05ed139664f1f89b9dec482b77c0"))))));
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/sandboxes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest,
|
||||
"{\"checksums\":{\"0189e76ccc476701d6b374e5a1a27347\":null,\"0c5ecd7788cf4f6c7de2a57193897a6c\":null,"
|
||||
|
@ -120,7 +120,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
|
||||
ImmutableList.<Object> of(URI.create("http://foo/bar"), new StringPayload("{\"foo\": \"bar\"}"))));
|
||||
assertRequestLineEquals(httpRequest, "PUT http://foo/bar HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"foo\": \"bar\"}", "application/x-binary", false);
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
|
||||
ImmutableList.<Object> of("cookbook", "1.0.0")));
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/cookbooks/cookbook/1.0.0 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
|
||||
ImmutableList.<Object> of("cookbook", "1.0.0")));
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/cookbooks/cookbook/1.0.0 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -173,7 +173,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("cookbook", "1.0.1", CookbookVersion.builder("cookbook", "1.0.1").build())));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/cookbooks/cookbook/1.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest,
|
||||
"{\"name\":\"cookbook-1.0.1\",\"definitions\":[],\"attributes\":[],\"files\":[],"
|
||||
|
@ -197,7 +197,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/cookbooks HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -209,13 +209,13 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
|
||||
}
|
||||
|
||||
public void testGetVersionsOfCookbook() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "getVersionsOfCookbook", String.class);
|
||||
public void testListVersionsOfCookbook() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "listVersionsOfCookbook", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor
|
||||
.apply(Invocation.create(method, ImmutableList.<Object> of("apache2")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/cookbooks/apache2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -232,7 +232,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor
|
||||
.apply(Invocation.create(method, ImmutableList.<Object> of("client")));
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/clients/client HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -249,7 +249,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of("api")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/clients HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"api\"}", "application/json", false);
|
||||
|
||||
|
@ -267,7 +267,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("api", CreateClientOptions.Builder.admin())));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/clients HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"api\",\"admin\":true}", "application/json", false);
|
||||
|
||||
|
@ -284,7 +284,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/clients HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -301,7 +301,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor
|
||||
.apply(Invocation.create(method, ImmutableList.<Object> of("client")));
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/clients/client HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"client\", \"private_key\": true}", "application/json", false);
|
||||
|
||||
|
@ -317,7 +317,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
Invokable<?, ?> method = method(ChefApi.class, "deleteNode", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of("node")));
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/nodes/node HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -337,7 +337,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
.environment("_default").build())));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/nodes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest,
|
||||
"{\"name\":\"testnode\",\"normal\":{},\"override\":{},\"default\":{},\"automatic\":{},"
|
||||
|
@ -360,7 +360,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
.environment("_default").build())));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/nodes/testnode HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest,
|
||||
"{\"name\":\"testnode\",\"normal\":{},\"override\":{},\"default\":{},\"automatic\":{},"
|
||||
|
@ -380,7 +380,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/nodes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -396,7 +396,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
Invokable<?, ?> method = method(ChefApi.class, "deleteRole", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of("role")));
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/roles/role HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -414,7 +414,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of(Role.builder().name("testrole").runListElement("recipe[java]").build())));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/roles HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"testrole\",\"override_attributes\":{},\"default_attributes\":{},"
|
||||
+ "\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"}",
|
||||
|
@ -434,7 +434,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of(Role.builder().name("testrole").runListElement("recipe[java]").build())));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/roles/testrole HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"testrole\",\"override_attributes\":{},\"default_attributes\":{},"
|
||||
+ "\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"}",
|
||||
|
@ -453,7 +453,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/roles HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -470,7 +470,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor
|
||||
.apply(Invocation.create(method, ImmutableList.<Object> of("databag")));
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/data/databag HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -487,7 +487,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of("name")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"name\"}", "application/json", false);
|
||||
|
||||
|
@ -504,7 +504,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/data HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -520,7 +520,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
Invokable<?, ?> method = method(ChefApi.class, "deleteDatabagItem", String.class, String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
|
||||
ImmutableList.<Object> of("name", "databagItem")));
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -540,7 +540,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("name", new DatabagItem("id", "100"))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
|
@ -564,7 +564,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("name", new DatabagItem("id", "{\"id\": \"item1\",\"my_key\": \"my_data\"}"))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
|
@ -586,7 +586,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("name", new DatabagItem("id", "{\"id\": \"id\",\"my_key\": \"my_data\"}"))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"id\": \"id\",\"my_key\": \"my_data\"}", "application/json", false);
|
||||
|
||||
|
@ -604,7 +604,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("name", new DatabagItem("id", "{\"my_key\": \"my_data\"}"))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"id\":\"id\",\"my_key\": \"my_data\"}", "application/json", false);
|
||||
|
||||
|
@ -622,7 +622,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of("name", new DatabagItem("id", "{\"my_key\": \"my_data\"}"))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/data/name/id HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
|
||||
assertPayloadEquals(httpRequest, "{\"id\":\"id\",\"my_key\": \"my_data\"}", "application/json", false);
|
||||
|
@ -640,7 +640,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of("name")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -657,7 +657,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -674,7 +674,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/role HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -692,7 +692,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of(SearchOptions.Builder.query("text"))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/role?q=text HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -709,7 +709,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/client HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -727,7 +727,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of(SearchOptions.Builder.query("text").rows(5))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/client?q=text&rows=5 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -744,7 +744,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/node HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -762,7 +762,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of(SearchOptions.Builder.query("foo:foo").start(3))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/node?q=foo%3Afoo&start=3 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -774,12 +774,12 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
|
||||
}
|
||||
|
||||
public void testSearchDatabag() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "searchDatabag", String.class);
|
||||
public void testSearchDatabagItems() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "searchDatabagItems", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of("foo")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/foo HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -791,13 +791,13 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
|
||||
}
|
||||
|
||||
public void testSearchDatabagWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "searchDatabag", String.class, SearchOptions.class);
|
||||
public void testSearchDatabagItemsWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Invokable<?, ?> method = method(ChefApi.class, "searchDatabagItems", String.class, SearchOptions.class);
|
||||
GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
|
||||
ImmutableList.<Object> of("foo", SearchOptions.Builder.query("bar").sort("name DESC"))));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/foo?q=bar&sort=name%20DESC HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -815,7 +815,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
ImmutableList.<Object> of(Resource.builder().name("test").url(URI.create("http://foo/bar")).build())));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://foo/bar HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_VERSION
|
||||
+ "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -841,7 +841,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
|
|||
@Override
|
||||
protected Properties setupProperties() {
|
||||
Properties props = super.setupProperties();
|
||||
props.put(Constants.PROPERTY_API_VERSION, ChefApi.VERSION + "-test");
|
||||
props.put(Constants.PROPERTY_API_VERSION, ChefApiMetadata.DEFAULT_VERSION + "-test");
|
||||
return props;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.io.File;
|
|||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
|
@ -45,7 +45,7 @@ public class BindHexEncodedMD5sToJsonPayloadTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.security.PrivateKey;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefBootstrapModule;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
|
@ -71,7 +71,7 @@ public class GroupToBootScriptTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
bind(String.class).annotatedWith(Names.named(CHEF_UPDATE_GEM_SYSTEM)).toInstance("true");
|
||||
bind(String.class).annotatedWith(Names.named(CHEF_UPDATE_GEMS)).toInstance("true");
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.security.cert.CertificateException;
|
|||
import java.security.cert.X509Certificate;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
|
@ -66,7 +66,7 @@ public class ParseClientFromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
|
@ -48,7 +48,7 @@ public class ParseCookbookDefinitionFromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.CookbookDefinition;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -45,7 +45,7 @@ public class ParseCookbookDefinitionFromJsonv10Test {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.CookbookDefinition;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -46,7 +46,7 @@ public class ParseCookbookDefinitionListFromJsonv10Test {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
import org.jclouds.chef.domain.Metadata;
|
||||
|
@ -59,7 +59,7 @@ public class ParseCookbookVersionFromJsonTest {
|
|||
injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
|
@ -48,7 +48,7 @@ public class ParseCookbookVersionsV09FromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
|
@ -48,7 +48,7 @@ public class ParseCookbookVersionsV10FromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -50,7 +50,7 @@ public class ParseDataBagItemFromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
|
@ -48,7 +48,7 @@ public class ParseKeySetFromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
|
@ -52,7 +52,7 @@ public class ParseNodeFromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Sandbox;
|
||||
import org.jclouds.date.DateService;
|
||||
|
@ -53,7 +53,7 @@ public class ParseSandboxFromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
import org.jclouds.chef.domain.SearchResult;
|
||||
|
@ -46,7 +46,7 @@ public class ParseSearchDataBagItemFromJsonTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.ChecksumStatus;
|
||||
import org.jclouds.chef.domain.UploadSandbox;
|
||||
|
@ -56,7 +56,7 @@ public class ParseUploadSandboxFromJsonTest {
|
|||
injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
|
@ -48,7 +49,7 @@ public class RunListForGroupTest {
|
|||
private Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
|
||||
// It may take a bit until the search index is populated
|
||||
protected int maxWaitForIndexInMs = 60000;
|
||||
|
||||
|
||||
// The id of the data bag item used in search tests
|
||||
private String databagitemId;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
List<Byte> md5 = Bytes.asList(content.getContentMetadata().getContentMD5());
|
||||
|
||||
// Request an upload site for this file
|
||||
UploadSandbox site = api.getUploadSandboxForChecksums(ImmutableSet.of(md5));
|
||||
UploadSandbox site = api.createUploadSandboxForChecksums(ImmutableSet.of(md5));
|
||||
assertTrue(site.getChecksums().containsKey(md5), md5 + " not in " + site.getChecksums());
|
||||
|
||||
try {
|
||||
|
@ -135,10 +135,10 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
assertFalse(cookbookNames.isEmpty(), "No cookbooks were found");
|
||||
|
||||
for (String cookbookName : cookbookNames) {
|
||||
Set<String> versions = api.getVersionsOfCookbook(cookbookName);
|
||||
Set<String> versions = api.listVersionsOfCookbook(cookbookName);
|
||||
assertFalse(versions.isEmpty(), "There are no versions of the cookbook: " + cookbookName);
|
||||
|
||||
for (String version : api.getVersionsOfCookbook(cookbookName)) {
|
||||
for (String version : api.listVersionsOfCookbook(cookbookName)) {
|
||||
CookbookVersion cookbook = api.getCookbook(cookbookName, version);
|
||||
assertNotNull(cookbook, "Could not get cookbook: " + cookbookName);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
|
||||
@Test(dependsOnMethods = { "testListSearchIndexes", "testCreateDatabagItem" })
|
||||
public void testSearchDatabag() throws Exception {
|
||||
SearchResult<? extends DatabagItem> results = api.searchDatabag(PREFIX);
|
||||
SearchResult<? extends DatabagItem> results = api.searchDatabagItems(PREFIX);
|
||||
assertNotNull(results, "Data bag item result list should not be null");
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
|
||||
@Override
|
||||
public boolean apply(SearchOptions input) {
|
||||
SearchResult<? extends DatabagItem> results = api.searchDatabag(PREFIX, input);
|
||||
SearchResult<? extends DatabagItem> results = api.searchDatabagItems(PREFIX, input);
|
||||
assertNotNull(results);
|
||||
if (results.size() > 0) {
|
||||
assertEquals(results.size(), 1);
|
||||
|
@ -418,7 +418,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, dependsOnMethods = "testListSearchIndexes")
|
||||
public void testSearchDatabagNotFound() throws Exception {
|
||||
SearchResult<? extends DatabagItem> results = api.searchDatabag("whoopie");
|
||||
SearchResult<? extends DatabagItem> results = api.searchDatabagItems("whoopie");
|
||||
assertNotNull(results, "Data bag item result list should not be null");
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
|
||||
@Test(dependsOnMethods = "testCreateEnvironment")
|
||||
public void testListEnvironmentRecipes() {
|
||||
Set<String> recipeList = api.listEnvironmentRecipes(PREFIX);
|
||||
Set<String> recipeList = api.listRecipesInEnvironment(PREFIX);
|
||||
assertTrue(!recipeList.isEmpty());
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
|
|||
api.createNode(Node.builder().name(ENV_NODE).runListElement("role[" + PREFIX + "]").environment(PREFIX).build());
|
||||
Node node = api.getNode(ENV_NODE);
|
||||
assertNotNull(node, "Created node should not be null");
|
||||
Set<String> nodeList = api.listEnvironmentNodes(PREFIX);
|
||||
Set<String> nodeList = api.listNodesInEnvironment(PREFIX);
|
||||
assertTrue(!nodeList.isEmpty());
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import org.jclouds.apis.ApiMetadata;
|
|||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefBootstrapModule;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.config.ChefHttpApiModule;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.ohai.AutomaticSupplier;
|
||||
import org.jclouds.ohai.config.ConfiguresOhai;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.json.Json;
|
||||
|
@ -60,7 +60,7 @@ public class JMXTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule(), new JMXOhaiModule() {
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Properties;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.json.Json;
|
||||
|
@ -63,7 +63,7 @@ public class OhaiModuleTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule(), new OhaiModule() {
|
||||
@Override
|
||||
|
@ -97,7 +97,7 @@ public class OhaiModuleTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule(), new OhaiModule() {
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.json.Json;
|
||||
|
@ -52,7 +52,7 @@ public class NestSlashKeysTest {
|
|||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApi.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
converter = injector.getInstance(NestSlashKeys.class);
|
||||
|
|
Loading…
Reference in New Issue