|
2 | 2 |
|
3 | 3 | import java.util.ArrayList;
|
4 | 4 | import java.util.List;
|
| 5 | +import java.util.NoSuchElementException; |
5 | 6 | import java.util.Set;
|
6 | 7 | import org.jclouds.compute.ComputeService;
|
7 |
| -import org.jclouds.compute.RunNodesException; |
| 8 | +import org.jclouds.compute.domain.Hardware; |
8 | 9 | import org.jclouds.compute.domain.NodeMetadata;
|
9 | 10 | import org.jclouds.compute.options.TemplateOptions;
|
10 | 11 | import org.jclouds.scriptbuilder.domain.Statement;
|
@@ -60,6 +61,7 @@ public LaunchNodeThread(ComputeService compute, Configuration config, String ins
|
60 | 61 | // Create initScript
|
61 | 62 | _initScript = new ArrayList<Statement>();
|
62 | 63 | _initScript.add(exec("echo \"" + daemons.toString() + "\" > ~/daemons"));
|
| 64 | + _initScript.add(exec("echo \"" + instanceType.toString() + "\" > ~/.instance-type")); |
63 | 65 | if (zkMyId != null)
|
64 | 66 | _initScript.addAll(Zookeeper.writeZKMyIds(_username, zkMyId));
|
65 | 67 |
|
@@ -88,7 +90,18 @@ public void run() {
|
88 | 90 | .runScript(new StatementList(_initScript))
|
89 | 91 | .overrideLoginCredentials(Tools.getPrivateKeyCredentials(_username))
|
90 | 92 | .authorizePublicKey(Tools.getPublicKey())).build());
|
91 |
| - } catch (RunNodesException ex) { |
| 93 | + } catch (NoSuchElementException ex) { |
| 94 | + // happens often when hardwareId is not found. List all possible hardware types |
| 95 | + if (ex.getMessage().toLowerCase().contains("hardwareid") && ex.getMessage().toLowerCase().contains("not found")) { |
| 96 | + log.error("You have specified unknown hardware profile. Here follows a list of supported profiles: "); |
| 97 | + Set<? extends Hardware> availableHardware = _compute.listHardwareProfiles(); |
| 98 | + for (Hardware h : availableHardware) { |
| 99 | + log.info(h.toString()); |
| 100 | + } |
| 101 | + } else { |
| 102 | + log.error("Problem: ", ex); |
| 103 | + } |
| 104 | + } catch (Exception ex) { |
92 | 105 | log.error("Problem launching instance", ex);
|
93 | 106 | }
|
94 | 107 | }
|
|
0 commit comments