Skip to content

Commit

Permalink
Azure integration (#115)
Browse files Browse the repository at this point in the history
* Fix missing OS family and arch with Azure

* Add constants in NodeCandidateUtils.java

* Add constants in NodeCandidateUtils.java

* Azure integration

* Fix issue when retrieving Azure images

* Azure integration (support ssh pub key auth)

* AddCloud documentation for Azure
  • Loading branch information
mbenguig authored Dec 12, 2024
1 parent e0cd9af commit fc6d417
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
18 changes: 10 additions & 8 deletions endpoints/2-cloud-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Note that cloud credentials are validated only during async process.
]
```


* For AWS cloud:

```json
Expand Down Expand Up @@ -88,10 +87,11 @@ Note that cloud credentials are validated only during async process.
"cloudProviderName": "azure",
"cloudType": "PUBLIC",
"subnet": null,
"securityGroup": "{{azure-securityGroup}}",
"securityGroup": null,
"sshCredentials": {
"username": "{{azure-username}}",
"username": "ubuntu",
"keyPairName": null,
"publicKey": "{{azure-publickey}}",
"privateKey": "{{azure-password}}"
},
"endpoint": null,
Expand All @@ -105,7 +105,7 @@ Note that cloud credentials are validated only during async process.
"user": "{{azure-user}}",
"secret": "{{azure-secret}}",
"domain": "{{azure-domain}}",
"subscriptionId": "{{azure-subscription}}"
"subscriptionId": "{{azure-subscription_id}}"
},
"blacklist": null
}
Expand Down Expand Up @@ -134,7 +134,8 @@ Contains SSH access information for the cloud. For Open Stack and AWS should be

- `username` (string): The SSH username.
- `keyPairName` (string): The name of the key pair used for SSH access.
- `privateKey` (string or `null`): The private key in RSA format, with line breaks represented by `\n` for JSON compatibility. If not required, use `null`.
- `publicKey` (string or `null`): The public key in RSA format. If not required, use `null`.
- `privateKey` (string or `null`): The private key in RSA format, with line breaks represented by `\n` for JSON compatibility. If not required, use `null`. For Azure, set it to the VM ssh password.

- `endpoint` (string or `null`):
The authentication endpoint for the cloud provider. For OpenStack, use your specific authentication URL. AWS and Azure does not require this field, so it can be `null`.
Expand All @@ -155,10 +156,11 @@ Contains authentication details for accessing the cloud. The fields are:

- `user` (string): The cloud username or access key.
- `secret` (string): The cloud password or secret access key.
- `domain` (string or `null`): The domain for the cloud account, required by OpenStack and Azure. For AWS, set this to `null`.
- `subscriptionId` (string or `null`): This field is used only for the Azure cloud, For Open Stack and AWS, set this to `null`.
- `domain` (string or `null`): The domain for the cloud account, required by OpenStack. For AWS, set this to `null`.
- `subscriptionId` (string or `null`): The subscription id for the cloud account, required by Azure. For AWS and OpenStack, set this to `null`.

- `blacklist` (string or `null`): Allows you to specify any blacklisted regions (e.g. locations). Use `null` if not applicable.
- `blacklist` (string or `null`):
Allows you to specify any blacklisted regions (e.g. locations). Use `null` if not applicable.

#### 2.2- GetAllClouds endpoint:

Expand Down
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 fc6d417

Please sign in to comment.