forked from jenkinsci/ec2-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applied patches of pull request jenkinsci#990: Test/implement windows…
… ssh
- Loading branch information
Showing
13 changed files
with
862 additions
and
1,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package hudson.plugins.ec2; | ||
|
||
import jenkins.model.Jenkins; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
public abstract class SSHData extends AMITypeData { | ||
protected final String rootCommandPrefix; | ||
protected final String slaveCommandPrefix; | ||
protected final String slaveCommandSuffix; | ||
protected final String sshPort; | ||
protected final String bootDelay; | ||
|
||
protected SSHData(String rootCommandPrefix, String slaveCommandPrefix, String slaveCommandSuffix, String sshPort, String bootDelay) { | ||
this.rootCommandPrefix = rootCommandPrefix; | ||
this.slaveCommandPrefix = slaveCommandPrefix; | ||
this.slaveCommandSuffix = slaveCommandSuffix; | ||
this.sshPort = sshPort; | ||
this.bootDelay = bootDelay; | ||
|
||
this.readResolve(); | ||
} | ||
|
||
protected Object readResolve() { | ||
Jenkins j = Jenkins.getInstanceOrNull(); | ||
if (j != null) { | ||
j.checkPermission(Jenkins.ADMINISTER); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isWindowsSSH() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isWindows() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isUnix() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isMac() { | ||
return false; | ||
} | ||
|
||
public String getRootCommandPrefix() { | ||
return rootCommandPrefix; | ||
} | ||
|
||
public String getSlaveCommandPrefix() { | ||
return slaveCommandPrefix; | ||
} | ||
|
||
public String getSlaveCommandSuffix() { | ||
return slaveCommandSuffix; | ||
} | ||
|
||
public String getSshPort() { | ||
return sshPort == null || sshPort.isEmpty() ? "22" : sshPort; | ||
} | ||
|
||
public String getBootDelay() { | ||
return bootDelay; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((rootCommandPrefix == null) ? 0 : rootCommandPrefix.hashCode()); | ||
result = prime * result + ((slaveCommandPrefix == null) ? 0 : slaveCommandPrefix.hashCode()); | ||
result = prime * result + ((slaveCommandSuffix == null) ? 0 : slaveCommandSuffix.hashCode()); | ||
result = prime * result + ((sshPort == null) ? 0 : sshPort.hashCode()); | ||
result = prime * result + ((bootDelay == null) ? 0 : bootDelay.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (this.getClass() != obj.getClass()) | ||
return false; | ||
final SSHData other = (SSHData) obj; | ||
if (StringUtils.isEmpty(rootCommandPrefix)) { | ||
if (!StringUtils.isEmpty(other.rootCommandPrefix)) | ||
return false; | ||
} else if (!rootCommandPrefix.equals(other.rootCommandPrefix)) | ||
return false; | ||
if (StringUtils.isEmpty(slaveCommandPrefix)) { | ||
if (!StringUtils.isEmpty(other.slaveCommandPrefix)) | ||
return false; | ||
} else if (!slaveCommandPrefix.equals(other.slaveCommandPrefix)) | ||
return false; | ||
if (StringUtils.isEmpty(slaveCommandSuffix)) { | ||
if (!StringUtils.isEmpty(other.slaveCommandSuffix)) | ||
return false; | ||
} else if (!slaveCommandSuffix.equals(other.slaveCommandSuffix)) | ||
return false; | ||
if (StringUtils.isEmpty(sshPort)) { | ||
if (!StringUtils.isEmpty(other.sshPort)) | ||
return false; | ||
} else if (!sshPort.equals(other.sshPort)) | ||
return false; | ||
if (bootDelay == null) { | ||
if (other.bootDelay != null) | ||
return false; | ||
} else if (!bootDelay.equals(other.bootDelay)) | ||
return false; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,28 @@ | ||
package hudson.plugins.ec2; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Extension; | ||
import hudson.model.Descriptor; | ||
import jenkins.model.Jenkins; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
public class UnixData extends AMITypeData { | ||
private final String rootCommandPrefix; | ||
private final String slaveCommandPrefix; | ||
private final String slaveCommandSuffix; | ||
private final String sshPort; | ||
private final String bootDelay; | ||
public class UnixData extends SSHData { | ||
|
||
@DataBoundConstructor | ||
public UnixData(String rootCommandPrefix, String slaveCommandPrefix, String slaveCommandSuffix, String sshPort, String bootDelay) { | ||
this.rootCommandPrefix = rootCommandPrefix; | ||
this.slaveCommandPrefix = slaveCommandPrefix; | ||
this.slaveCommandSuffix = slaveCommandSuffix; | ||
this.sshPort = sshPort; | ||
this.bootDelay = bootDelay; | ||
|
||
this.readResolve(); | ||
} | ||
|
||
protected Object readResolve() { | ||
Jenkins j = Jenkins.getInstanceOrNull(); | ||
if (j != null) { | ||
j.checkPermission(Jenkins.ADMINISTER); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isWindows() { | ||
return false; | ||
super(rootCommandPrefix, slaveCommandPrefix, slaveCommandSuffix, sshPort, bootDelay); | ||
} | ||
|
||
@Override | ||
public boolean isUnix() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isMac() { | ||
return false; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<AMITypeData> { | ||
@Override | ||
@NonNull | ||
public String getDisplayName() { | ||
return "unix"; | ||
} | ||
} | ||
|
||
public String getRootCommandPrefix() { | ||
return rootCommandPrefix; | ||
} | ||
|
||
public String getSlaveCommandPrefix() { | ||
return slaveCommandPrefix; | ||
} | ||
|
||
public String getSlaveCommandSuffix() { | ||
return slaveCommandSuffix; | ||
} | ||
|
||
public String getSshPort() { | ||
return sshPort == null || sshPort.isEmpty() ? "22" : sshPort; | ||
} | ||
|
||
public String getBootDelay() { | ||
return bootDelay; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((rootCommandPrefix == null) ? 0 : rootCommandPrefix.hashCode()); | ||
result = prime * result + ((slaveCommandPrefix == null) ? 0 : slaveCommandPrefix.hashCode()); | ||
result = prime * result + ((slaveCommandSuffix == null) ? 0 : slaveCommandSuffix.hashCode()); | ||
result = prime * result + ((sshPort == null) ? 0 : sshPort.hashCode()); | ||
result = prime * result + ((bootDelay == null) ? 0 : bootDelay.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (this.getClass() != obj.getClass()) | ||
return false; | ||
final UnixData other = (UnixData) obj; | ||
if (StringUtils.isEmpty(rootCommandPrefix)) { | ||
if (!StringUtils.isEmpty(other.rootCommandPrefix)) | ||
return false; | ||
} else if (!rootCommandPrefix.equals(other.rootCommandPrefix)) | ||
return false; | ||
if (StringUtils.isEmpty(slaveCommandPrefix)) { | ||
if (!StringUtils.isEmpty(other.slaveCommandPrefix)) | ||
return false; | ||
} else if (!slaveCommandPrefix.equals(other.slaveCommandPrefix)) | ||
return false; | ||
if (StringUtils.isEmpty(slaveCommandSuffix)) { | ||
if (!StringUtils.isEmpty(other.slaveCommandSuffix)) | ||
return false; | ||
} else if (!slaveCommandSuffix.equals(other.slaveCommandSuffix)) | ||
return false; | ||
if (StringUtils.isEmpty(sshPort)) { | ||
if (!StringUtils.isEmpty(other.sshPort)) | ||
return false; | ||
} else if (!sshPort.equals(other.sshPort)) | ||
return false; | ||
if (bootDelay == null) { | ||
if (other.bootDelay != null) | ||
return false; | ||
} else if (!bootDelay.equals(other.bootDelay)) | ||
return false; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package hudson.plugins.ec2; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Extension; | ||
import hudson.model.Descriptor; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
|
||
public class WindowsSSHData extends SSHData { | ||
|
||
@DataBoundConstructor | ||
public WindowsSSHData(String rootCommandPrefix, String slaveCommandPrefix, String slaveCommandSuffix, String sshPort, String bootDelay) { | ||
super(rootCommandPrefix, slaveCommandPrefix, slaveCommandSuffix, sshPort, bootDelay); | ||
} | ||
|
||
@Override | ||
public boolean isWindowsSSH() { | ||
return true; | ||
} | ||
|
||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<AMITypeData> { | ||
@Override | ||
@NonNull | ||
public String getDisplayName() { | ||
return "windows-ssh"; | ||
} | ||
} | ||
} |
Oops, something went wrong.