diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/OperatingSystemFamily.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/OperatingSystemFamily.java index d36b611..0a6f200 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/OperatingSystemFamily.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/OperatingSystemFamily.java @@ -68,7 +68,9 @@ public enum OperatingSystemFamily { CLOUD_LINUX("CLOUD_LINUX"), - WINDOWS("WINDOWS"); + WINDOWS("WINDOWS"), + + LINUX("LINUX"); private String value; diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java index be89fc6..bc2e6e6 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java @@ -38,6 +38,14 @@ @Component public class NodeCandidateUtils { + public static final String AWS_EC2 = "aws-ec2"; + + public static final String AZURE = "azure"; + + public static final String GCE = "gce"; + + public static final String OPENSTACK = "openstack"; + @Autowired private PAConnectorIaasGateway connectorIaasGateway; @@ -224,7 +232,7 @@ private Hardware createHardware(JSONObject nodeCandidateJSON, PACloud paCloud) { hardware.setRam(Long.valueOf(minRam)); hardware.setFpga(hardwareJSON.optString("type")); - if ("aws-ec2".equals(nodeCandidateJSON.optString("cloud"))) { + if (AWS_EC2.equals(nodeCandidateJSON.optString("cloud"))) { hardware.setDisk((double) 8); } else { hardware.setDisk((double) 0); @@ -256,13 +264,13 @@ private Location createLocation(JSONObject nodeCandidateJSON, PACloud paCloud) { private GeoLocation createGeoLocation(String cloud, String region) { switch (cloud) { - case "aws-ec2": + case AWS_EC2: return new GeoLocation(geoLocationUtils.findGeoLocation("AWS", region)); - case "azure": + case AZURE: return new GeoLocation(geoLocationUtils.findGeoLocation("Azure", region)); - case "gce": + case GCE: return new GeoLocation(geoLocationUtils.findGeoLocation("GCE", region)); - case "openstack": + case OPENSTACK: return new GeoLocation(geoLocationUtils.findGeoLocation("OVH", region)); } LOGGER.warn("Cloud provider name no handled for Geo Location."); @@ -279,15 +287,17 @@ private Image createImage(JSONObject nodeCandidateJSON, JSONObject imageJSON, PA image.setProviderId(StringUtils.substringAfterLast(imageJSON.optString("id"), "/")); OperatingSystem os = new OperatingSystem(); JSONObject osJSON = imageJSON.optJSONObject("operatingSystem"); - os.setOperatingSystemFamily(OperatingSystemFamily.fromValue(osJSON.optString("family"))); + os.setOperatingSystemFamily(OperatingSystemFamily.fromValue(osJSON.optString("family").toUpperCase())); String arch = ""; - if ("aws-ec2".equals(nodeCandidateJSON.optString("cloud"))) { + if (AWS_EC2.equals(nodeCandidateJSON.optString("cloud"))) { if (nodeCandidateJSON.optJSONObject("hw").optString("type").startsWith("a")) { arch = osJSON.optBoolean("is64Bit") ? "ARM64" : "ARM"; } else { arch = osJSON.optBoolean("is64Bit") ? "AMD64" : "i386"; } + } else if (AZURE.equals(nodeCandidateJSON.optString("cloud"))) { + arch = osJSON.optString("arch"); } os.setOperatingSystemArchitecture(OperatingSystemArchitecture.fromValue(arch)); os.setOperatingSystemVersion(osJSON.optBigDecimal("version", BigDecimal.valueOf(0))); @@ -374,13 +384,13 @@ public void saveNodeCandidates(List newCloudIds) { os = os.substring(0, 1).toUpperCase() + os.substring(1); String pair = os + ":" + region; switch (paCloud.getCloudProviderName()) { - case "aws-ec2": + case AWS_EC2: imageReq = "Linux"; break; - case "openstack": + case OPENSTACK: imageReq = os; break; - case "azure": + case AZURE: imageReq = os; break; default: @@ -388,7 +398,7 @@ public void saveNodeCandidates(List newCloudIds) { " is not handled yet."); } - if (paCloud.getCloudProviderName().equals("openstack")) { + if (paCloud.getCloudProviderName().equals(OPENSTACK)) { entries.add(pair); } populateNodeCandidatesFromCache(paCloud, region, imageReq, image);