Skip to content

Commit

Permalink
Add config drive flag. Fixes JENKINS-23454
Browse files Browse the repository at this point in the history
  • Loading branch information
felfert committed Nov 13, 2016
1 parent c888392 commit 4ad8d81
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Expand Up @@ -130,6 +130,7 @@ public class JCloudsSlaveTemplate implements Describable<JCloudsSlaveTemplate>,
public final String networks;
public final String securityGroups;
public final Mode mode;
public final boolean useConfigDrive;
private String credentialsId;
private String adminCredentialsId;

Expand Down Expand Up @@ -161,7 +162,7 @@ public JCloudsSlaveTemplate(final String name, final String imageId, final Strin
final String fsRoot, final boolean allowSudo, final boolean installPrivateKey, final Integer overrideRetentionTime, final int spoolDelayMs,
final boolean assignFloatingIp, final boolean waitPhoneHome, final int waitPhoneHomeTimeout, final String keyPairName,
final boolean assignPublicIp, final String networks, final String securityGroups, final String credentialsId,
final String adminCredentialsId, final String mode) {
final String adminCredentialsId, final String mode, final boolean useConfigDrive) {

this.name = Util.fixEmptyAndTrim(name);
this.imageId = Util.fixEmptyAndTrim(imageId);
Expand Down Expand Up @@ -196,6 +197,7 @@ public JCloudsSlaveTemplate(final String name, final String imageId, final Strin
this.credentialsId = Util.fixEmptyAndTrim(credentialsId);
this.adminCredentialsId = Util.fixEmptyAndTrim(adminCredentialsId);
this.mode = Mode.valueOf(Util.fixNull(mode));
this.useConfigDrive = useConfigDrive;
readResolve();
this.vmPassword = null; // Not used anymore, but retained for backward compatibility.
this.vmUser = null; // Not used anymore, but retained for backward compatibility.
Expand Down Expand Up @@ -380,6 +382,10 @@ public NodeMetadata get() {
options.as(NovaTemplateOptions.class).shouldAutoAssignFloatingIp());
}

if (useConfigDrive && options instanceof NovaTemplateOptions) {
options.as(NovaTemplateOptions.class).configDrive(true);
}

if (!isNullOrEmpty(keyPairName)) {
if (options instanceof NovaTemplateOptions) {
LOGGER.info("Setting OpenStack keyPairName to: " + keyPairName);
Expand Down
Expand Up @@ -157,6 +157,9 @@
<f:entry title="${%Assign Floating IP}" field="assignFloatingIp">
<f:checkbox />
</f:entry>
<f:entry title="${%Use config drive}" field="useConfigDrive">
<f:checkbox />
</f:entry>
</f:section>

<f:section title="${%CloudStack Options}">
Expand Down
Expand Up @@ -25,7 +25,7 @@ public void testConfigRoundtrip() throws Exception {
true /* assignFloatingIp */, false /* waitPhoneHome */, 0 /* waitPhoneHomeTimeout */,
null /* keyPairName */, true /* assignPublicIp */, "network1_id,network2_id",
"security_group1,security_group2", null /* credentialsId */,
null /* adminCredentialsId */, "NORMAL" /* mode */);
null /* adminCredentialsId */, "NORMAL" /* mode */, true /* useConfigDrive */);

final List<JCloudsSlaveTemplate> templates = new ArrayList<>();
templates.add(beforeTemplate);
Expand All @@ -43,7 +43,7 @@ public void testConfigRoundtrip() throws Exception {
j.assertEqualBeans(beforeCloud, afterCloud,
"profile,providerName,endPointUrl,trustAll");
j.assertEqualBeans(beforeTemplate, afterTemplate,
"name,cores,ram,osFamily,osVersion,labelString,description,initScript,numExecutors,stopOnTerminate,mode");
"name,cores,ram,osFamily,osVersion,labelString,description,initScript,numExecutors,stopOnTerminate,mode,useConfigDrive");
}

}

0 comments on commit 4ad8d81

Please sign in to comment.