1 /**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19 package org.jclouds.compute.callables;
20
21 import java.util.concurrent.Callable;
22
23 import org.jclouds.compute.domain.ExecResponse;
24 import org.jclouds.compute.domain.NodeMetadata;
25 import org.jclouds.compute.options.RunScriptOptions;
26 import org.jclouds.scriptbuilder.domain.Statement;
27
28 import com.google.common.annotations.Beta;
29
30 /**
31 * Separates out how one implements the ability to run a script on a node.
32 *
33 * @author Adrian Cole
34 */
35 @Beta
36 public interface RunScriptOnNode extends Callable<ExecResponse> {
37
38 public interface Factory {
39 RunScriptOnNode create(NodeMetadata node, String script);
40
41 RunScriptOnNode create(NodeMetadata node, Statement script);
42
43 RunScriptOnNode create(NodeMetadata node, Statement script, RunScriptOptions options);
44 }
45
46 /**
47 * Note that {@link #init} must be called first.
48 */
49 @Override
50 ExecResponse call();
51
52 /**
53 * verifies that the command can execute on the node. For example, if this is ssh, it may attempt
54 * to find a reachable socket. If this is using an API, it may attempt to validate that
55 * connection.
56 */
57 RunScriptOnNode init();
58
59 /**
60 * the node this command is being executed on.
61 */
62 NodeMetadata getNode();
63
64 }