Commit febd17a1 authored by Ali Fahs's avatar Ali Fahs
Browse files

Merge branch 'OpenStack-nc' into 'proactive-dev'

OpenStack retrieve Linux NC

See merge request !169
parents fc7b5d0a 0a0a695d
Pipeline #16751 passed with stages
in 2 minutes and 47 seconds
...@@ -53,6 +53,7 @@ build:amq-message-java-library: ...@@ -53,6 +53,7 @@ build:amq-message-java-library:
only: only:
- master - master
- morphemic-rc1.5 - morphemic-rc1.5
- openstack-nc
script: script:
- $AMQ_MESSAGE_JAVA_LIBRARY_CLI clean install - $AMQ_MESSAGE_JAVA_LIBRARY_CLI clean install
artifacts: artifacts:
...@@ -138,6 +139,7 @@ deploy:scheduling-abstraction-layer: ...@@ -138,6 +139,7 @@ deploy:scheduling-abstraction-layer:
- master - master
- morphemic-rc1.5 - morphemic-rc1.5
- proactive-dev - proactive-dev
- OpenStack-nc
dependencies: dependencies:
- build:scheduling-abstraction-layer - build:scheduling-abstraction-layer
script: script:
......
...@@ -10,10 +10,8 @@ import org.json.JSONObject; ...@@ -10,10 +10,8 @@ import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
...@@ -257,26 +255,47 @@ public class NodeCandidateUtils { ...@@ -257,26 +255,47 @@ public class NodeCandidateUtils {
//TODO: (Optimization) An images per region map structure <region,[image1,image2]> could be the best here. //TODO: (Optimization) An images per region map structure <region,[image1,image2]> could be the best here.
// It can reduce the getNodeCandidates calls to PA. // It can reduce the getNodeCandidates calls to PA.
List<String> entries = new LinkedList<>();
List<String> openstackOsList = Arrays.asList("Ubuntu","Fedora","Centos","Debian");
consolidatedImages.forEach(image -> { consolidatedImages.forEach(image -> {
String region = image.optString("location"); String region = image.optString("location");
String imageReq; String imageReq;
String os = (String) ((JSONObject) image.get("operatingSystem")).get("family");
os = os.substring(0, 1).toUpperCase() + os.substring(1);
String pair =os+":"+region;
switch (paCloud.getCloudProviderName()) { switch (paCloud.getCloudProviderName()) {
case "aws-ec2": case "aws-ec2":
imageReq = "Linux"; imageReq = "Linux";
break; break;
case "openstack": case "openstack":
imageReq = "linux"; imageReq = os;
break; break;
default: default:
throw new IllegalArgumentException("The infrastructure " + paCloud.getCloudProviderName() + " is not handled yet."); throw new IllegalArgumentException("The infrastructure " + paCloud.getCloudProviderName() + " is not handled yet.");
} }
JSONArray nodeCandidates = connectorIaasGateway.getNodeCandidates(paCloud.getDummyInfrastructureName(),
region, imageReq); if (paCloud.getCloudProviderName().equals("openstack")){
nodeCandidates.forEach(nc -> { if((!entries.contains(pair)) && openstackOsList.contains(os)) {
JSONObject nodeCandidate = (JSONObject) nc; entries.add(pair);
EntityManagerHelper.persist(createLocation(nodeCandidate, paCloud)); JSONArray nodeCandidates = connectorIaasGateway.getNodeCandidates(paCloud.getDummyInfrastructureName(),
EntityManagerHelper.persist(createNodeCandidate(nodeCandidate, image, paCloud)); region, imageReq);
}); nodeCandidates.forEach(nc -> {
JSONObject nodeCandidate = (JSONObject) nc;
EntityManagerHelper.persist(createLocation(nodeCandidate, paCloud));
EntityManagerHelper.persist(createNodeCandidate(nodeCandidate, image, paCloud));
});
}
}
else {
JSONArray nodeCandidates = connectorIaasGateway.getNodeCandidates(paCloud.getDummyInfrastructureName(),
region, imageReq);
nodeCandidates.forEach(nc -> {
JSONObject nodeCandidate = (JSONObject) nc;
EntityManagerHelper.persist(createLocation(nodeCandidate, paCloud));
EntityManagerHelper.persist(createNodeCandidate(nodeCandidate, image, paCloud));
});
}
}); });
}); });
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment