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; |
20 | |
21 | import static org.jclouds.compute.util.ComputeServiceUtils.createExecutionErrorMessage; |
22 | import static org.jclouds.compute.util.ComputeServiceUtils.createNodeErrorMessage; |
23 | |
24 | import java.util.Map; |
25 | |
26 | import org.jclouds.javax.annotation.Nullable; |
27 | |
28 | import org.jclouds.compute.domain.ExecResponse; |
29 | import org.jclouds.compute.domain.NodeMetadata; |
30 | import org.jclouds.compute.options.RunScriptOptions; |
31 | import org.jclouds.scriptbuilder.domain.Statement; |
32 | |
33 | /** |
34 | * |
35 | * @author Adrian Cole |
36 | */ |
37 | public class RunScriptOnNodesException extends Exception { |
38 | |
39 | /** The serialVersionUID */ |
40 | private static final long serialVersionUID = -2272965726680821281L; |
41 | private final Statement runScript; |
42 | private final RunScriptOptions options; |
43 | private final Map<NodeMetadata, ExecResponse> successfulNodes; |
44 | private final Map<? extends NodeMetadata, ? extends Throwable> failedNodes; |
45 | private final Map<?, Exception> executionExceptions; |
46 | |
47 | public RunScriptOnNodesException(Statement runScript, @Nullable RunScriptOptions options, |
48 | Map<NodeMetadata, ExecResponse> successfulNodes, Map<?, Exception> executionExceptions, |
49 | Map<? extends NodeMetadata, ? extends Throwable> failedNodes) { |
50 | super(String.format("error runScript on filtered nodes options(%s)%n%s%n%s", options, |
51 | createExecutionErrorMessage(executionExceptions), createNodeErrorMessage(failedNodes))); |
52 | this.runScript = runScript; |
53 | this.options = options; |
54 | this.successfulNodes = successfulNodes; |
55 | this.failedNodes = failedNodes; |
56 | this.executionExceptions = executionExceptions; |
57 | } |
58 | |
59 | /** |
60 | * @return Nodes that performed ssh without error |
61 | */ |
62 | public Map<NodeMetadata, ExecResponse> getSuccessfulNodes() { |
63 | return successfulNodes; |
64 | } |
65 | |
66 | /** |
67 | * |
68 | * @return Nodes that performed startup without error, but incurred problems applying options |
69 | */ |
70 | public Map<?, ? extends Throwable> getExecutionErrors() { |
71 | return executionExceptions; |
72 | } |
73 | |
74 | /** |
75 | * |
76 | * @return Nodes that performed startup without error, but incurred problems applying options |
77 | */ |
78 | public Map<? extends NodeMetadata, ? extends Throwable> getNodeErrors() { |
79 | return failedNodes; |
80 | } |
81 | |
82 | public Statement getRunScript() { |
83 | return runScript; |
84 | } |
85 | |
86 | public RunScriptOptions getOptions() { |
87 | return options; |
88 | } |
89 | |
90 | } |