Skip to content

Commit

Permalink
Merge pull request #104 from ow2-proactive/azure-integration
Browse files Browse the repository at this point in the history
Azure integration
  • Loading branch information
mbenguig authored Oct 29, 2024
2 parents b6ba1b3 + 71e28f7 commit f959c0f
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ public class Credential implements Serializable {

@JsonProperty("domain")
private String domain = null;

@JsonProperty("subscriptionId")
private String subscriptionId = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public class Credentials implements Serializable {
@Column(name = "DOMAIN")
private String domain;

@Column(name = "SUBSCRIPTION_ID")
private String subscriptionId;
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ private Hardware createHardware(JSONObject nodeCandidateJSON, PACloud paCloud) {
hardware.setName(hardwareJSON.optString("type"));
hardware.setProviderId(hardwareJSON.optString("type"));
hardware.setCores(Math.round(Float.parseFloat(hardwareJSON.optString("minCores"))));
hardware.setRam(Long.valueOf(hardwareJSON.optString("minRam")));
String minRam = hardwareJSON.optString("minRam");
if (minRam.endsWith(".0")) {
minRam = minRam.replace(".0", "");
}
hardware.setRam(Long.valueOf(minRam));
hardware.setFpga(hardwareJSON.optString("type"));

if ("aws-ec2".equals(nodeCandidateJSON.optString("cloud"))) {
Expand Down Expand Up @@ -376,6 +380,9 @@ public void saveNodeCandidates(List<String> newCloudIds) {
case "openstack":
imageReq = os;
break;
case "azure":
imageReq = os;
break;
default:
throw new IllegalArgumentException("The infrastructure " + paCloud.getCloudProviderName() +
" is not handled yet.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public Integer addClouds(String sessionId, List<CloudDefinition> clouds) throws
credentials.setUserName(cloud.getCredentials().getUser());
credentials.setPrivateKey(cloud.getCredentials().getSecret());
credentials.setDomain(cloud.getCredentials().getDomain());
credentials.setSubscriptionId(cloud.getCredentials().getSubscriptionId());
repositoryService.saveCredentials(credentials);
newCloud.setCredentials(credentials);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ private void defineNSWithDeploymentInfo(String nodeSourceName, PACloud cloud, De
variables.put("os_region", deployment.getNode().getNodeCandidate().getLocation().getName());
variables.put("os_networkId", cloud.getDefaultNetwork());
break;
case "azure":
filename = File.separator + "Define_NS_Azure.xml";
variables.put("azure_username", cloud.getCredentials().getUserName());
variables.put("azure_secret", cloud.getCredentials().getPrivateKey());
variables.put("azure_domain", cloud.getCredentials().getDomain());
variables.put("azure_subscription_id", cloud.getCredentials().getSubscriptionId());
break;
default:
throw new IllegalArgumentException("Unhandled cloud provider: " + cloud.getCloudProviderName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ public void defineInfrastructure(String infrastructureName, PACloud cloud, Strin
cloud.getCredentials().getPrivateKey() + "\", \"domain\": \"" +
cloud.getCredentials().getDomain() + "\"}, \"region\": \"" + region + "\"}";
break;
case "azure":
jsonOutputString = "{\"id\": \"" + infrastructureName + "\"," + "\"type\": \"" +
cloud.getCloudProviderName() + "\"," + "\"credentials\": {\"username\": \"" +
cloud.getCredentials().getUserName() + "\", \"password\": \"" +
cloud.getCredentials().getPrivateKey() + "\", \"domain\": \"" +
cloud.getCredentials().getDomain() + "\", \"subscriptionId\": \"" +
cloud.getCredentials().getSubscriptionId() + "\"}}";
break;
default:
throw new IllegalArgumentException("The infrastructure " + infrastructureName + " is not handled yet.");
}
Expand Down
124 changes: 124 additions & 0 deletions sal-service/src/main/resources/Define_NS_Azure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<job
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:proactive:jobdescriptor:3.13" xsi:schemaLocation="urn:proactive:jobdescriptor:3.13 http://www.activeeon.com/public_content/schemas/proactive/jobdescriptor/3.13/schedulerjob.xsd" name="Define_NS_Azure" projectName="NebulOuS" priority="normal" onTaskError="continueJobExecution" maxNumberOfExecution="2" >
<variables>
<variable name="NS_name" value="" />
<variable name="NS_nVMs" value="0" model="PA:Integer" />
<variable name="azure_username" value="" model="PA:HIDDEN" />
<variable name="azure_secret" value="" model="PA:HIDDEN" />
<variable name="security_group" value="" />
<variable name="sshUsername" value="" />
<variable name="sshKeyPairName" value="" />
<variable name="sshPrivateKey" value="" model="PA:HIDDEN" />
<variable name="subnet" value="" />
<variable name="image" value="" />
<variable name="rm_host_name" value="" />
<variable name="pa_port" value="" />
</variables>
<description>
<![CDATA[ A workflow that executes Groovy in JVM. ]]>
</description>
<taskFlow>
<task name="defineAzureNodeSource"




fork="true">
<description>
<![CDATA[ Define an Azure NodeSource ]]>
</description>
<scriptExecutable>
<script>
<code language="groovy">
<![CDATA[
// Connecting to the Scheduler
def retCode = 0;
def nodeSourceName = variables.get("NS_name")
def protocol = (variables.get("pa_port") == "443" || variables.get("pa_port") == "8443" ) ? "https" : "http"
println "[+] Preparation of NodeSoure " + nodeSourceName
print "(1/4) Connecting to the RM ..."
rmapi.connect()
println " ... OK !"
// Getting NS configuration settings
def infrastructureType = "org.ow2.proactive.resourcemanager.nodesource.infrastructure.AzureInfrastructure"
def infrastructureParameters = [variables.get("azure_username"), //username
variables.get("azure_secret"), //secret
variables.get("NS_nVMs"), //N of VMs
"1", //N VMs per node
variables.get("image"), //image
variables.get("sshUsername"), //sshUsername
variables.get("sshKeyPairName"), //sshKeyPair
"", //ram
"", //Ncore
"", //VmType
variables.get("security_group"), //sg
variables.get("subnet"), //subnet
variables.get("rm_host_name"), //host
protocol + "://" + variables.get("rm_host_name") + ":"+ variables.get("pa_port") + "/connector-iaas", //connector-iaas url
protocol + "://" + variables.get("rm_host_name") + ":"+ variables.get("pa_port") + "/rest/node.jar", //node jar url
"-Dproactive.useIPaddress=true", //additionalProperties"
"300000", //timeout
"mkdir -p /tmp/node && cd /tmp/node; if ! type -p jre/bin/java; then wget -nv -N https://s3.amazonaws.com/ci-materials/Latest_jre/jre-8u312b07-linux-x64.tar.gz; tar -xf jre-8u312b07-linux-x64.tar.gz; mv jre1.8.0_312b07/ jre; fi; wget -nv --no-check-certificate %nodeJarUrl% ; nohup jre/bin/java -Xmx600m -jar node.jar -Dproactive.communication.protocol=%protocol% -Dpython.path=%jythonPath% -Dproactive.pamr.router.address=%rmHostname% -D%instanceIdNodeProperty%=%instanceId% -r %rmUrl% -s %nodeSourceName% %nodeNamingOption% -v %credentials% -w %numberOfNodesPerInstance% %additionalProperties% &",
""]
def infrastructureFileParameters = [variables.get("sshPrivateKey")]
def policyType = "org.ow2.proactive.resourcemanager.nodesource.policy.EmptyPolicy"
def poliyParameters = ["ALL","ME"]
def policyFileParameters = []
def nodesRecoverable = "true"
// Enforcing ....
try {
print "(2/4) Creating NodeSource ..."
rmapi.defineNodeSource(nodeSourceName,infrastructureType,(String[]) infrastructureParameters.toArray(),(String[]) infrastructureFileParameters.toArray(), policyType, (String[]) poliyParameters.toArray(), (String[]) policyFileParameters.toArray(),nodesRecoverable)
println " ... OK !"
print "(3/4) Deploying the NodeSource ..."
rmapi.deployNodeSource(nodeSourceName)
println " ... OK !"
} catch (Exception e) {
println " ... Error: " + e.getMessage();
retCode = 1;
} finally {
print "(4/4) Logging out ..."
rmapi.disconnect();
println " ... OK !"
}
return retCode;
]]>
</code>
</script>
</scriptExecutable>
<metadata>
<positionTop>
142.125
</positionTop>
<positionLeft>
351.5
</positionLeft>
</metadata>
</task>
</taskFlow>
<metadata>
<visualization>
<![CDATA[ <html>
<head>
<link rel="stylesheet" href="/studio/styles/studio-standalone.css">
<style>
#workflow-designer {
left:0 !important;
top:0 !important;
width:2864px;
height:3536px;
}
</style>
</head>
<body>
<div id="workflow-visualization-view"><div id="workflow-visualization" style="position:relative;top:-137.1171875px;left:-346.5px"><div class="task _jsPlumb_endpoint_anchor_ ui-draggable" id="jsPlumb_1_1" style="top: 142.125px; left: 351.5px;"><a class="task-name" data-toggle="tooltip" data-placement="right" title="Define an Azure NodeSource"><img src="/studio/images/Groovy.png" width="20px">&nbsp;<span class="name">defineAzureNodeSource</span></a></div><div class="_jsPlumb_endpoint source-endpoint dependency-source-endpoint connected _jsPlumb_endpoint_anchor_ ui-draggable ui-droppable" style="position: absolute; height: 20px; width: 20px; left: 412px; top: 172px;"><svg style="position:absolute;left:0px;top:0px" width="20" height="20" pointer-events="all" position="absolute" version="1.1" xmlns="http://www.w3.org/1999/xhtml"><circle cx="10" cy="10" r="10" version="1.1" xmlns="http://www.w3.org/1999/xhtml" fill="#666" stroke="none" style=""></circle></svg></div></div></div>
</body>
</html>
]]>
</visualization>
</metadata>
</job>
Loading

0 comments on commit f959c0f

Please sign in to comment.