1 /**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. 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,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
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 import com.google.common.util.concurrent.ListenableFuture;
30
31 /**
32 * Separates out how one implements the ability to run a script on a node.
33 *
34 * @author Adrian Cole
35 */
36 @Beta
37 public interface RunScriptOnNode extends Callable<ExecResponse> {
38
39 public interface Factory {
40
41 RunScriptOnNode create(NodeMetadata node, Statement script, RunScriptOptions options);
42
43 ListenableFuture<ExecResponse> submit(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 * @return statement that will be executed
54 */
55 Statement getStatement();
56
57 /**
58 * verifies that the command can execute on the node. For example, if this is ssh, it may attempt
59 * to find a reachable socket. If this is using an API, it may attempt to validate that
60 * connection.
61 */
62 RunScriptOnNode init();
63
64 /**
65 * the node this command is being executed on.
66 */
67 NodeMetadata getNode();
68
69 }