Skip to content

Commit

Permalink
Azure integration (support ssh pub key auth)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbenguig committed Dec 12, 2024
1 parent 9df0bac commit c025533
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public class SSHCredentials implements Serializable {
@JsonProperty("keyPairName")
private String keyPairName = null;

@Lob
@Column(name = "PUBLIC_KEY")
@JsonProperty("publicKey")
private String publicKey = null;

@Lob
@Column(name = "PRIVATE_KEY")
@JsonProperty("privateKey")
Expand All @@ -49,11 +54,12 @@ public boolean equals(Object o) {
SSHCredentials sshCredentials = (SSHCredentials) o;
return Objects.equals(this.username, sshCredentials.username) &&
Objects.equals(this.keyPairName, sshCredentials.keyPairName) &&
Objects.equals(this.publicKey, sshCredentials.publicKey) &&
Objects.equals(this.privateKey, sshCredentials.privateKey);
}

@Override
public int hashCode() {
return Objects.hash(username, keyPairName, privateKey);
return Objects.hash(username, keyPairName, publicKey, privateKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,15 @@ private Credentials hideCredentials(Credentials creds) {
private SSHCredentials hideSshCredentials(SSHCredentials creds) {
SSHCredentials newCreds = new SSHCredentials();
if (creds != null) {
newCreds.setKeyPairName(creds.getKeyPairName());
newCreds.setUsername(creds.getUsername());
if (creds.getUsername() != null) {
newCreds.setUsername(creds.getUsername());
}
if (creds.getKeyPairName() != null) {
newCreds.setKeyPairName(creds.getKeyPairName());
}
if (creds.getPublicKey() != null) {
newCreds.setPublicKey(creds.getPublicKey());
}
if (creds.getPrivateKey() != null) {
newCreds.setPrivateKey(hideString(creds.getPrivateKey(), 3));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ private void defineNSWithDeploymentInfo(String nodeSourceName, PACloud cloud, De
variables.put("vmSizeType", deployment.getNode().getNodeCandidate().getHardware().getProviderId());
variables.put("vmUsername", cloud.getSshCredentials().getUsername());
variables.put("vmPassword", cloud.getSshCredentials().getPrivateKey());
variables.put("vmPublicKey", cloud.getSshCredentials().getPublicKey());
variables.put("region", deployment.getNode().getNodeCandidate().getLocation().getName());
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion sal-service/src/main/resources/Define_NS_Azure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<variable name="imageOSType" value="" />
<variable name="vmSizeType" value="" />
<variable name="vmUsername" value="" />
<variable name="vmPassword" value="" />
<variable name="vmPassword" value="" model="PA:HIDDEN" />
<variable name="vmPublicKey" value="" />
<variable name="resourceGroup" value="" />
<variable name="region" value="" />
Expand Down

0 comments on commit c025533

Please sign in to comment.