Commit f40747a4 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Fix image and hardware provider IDs

parent f429b3d2
......@@ -2,6 +2,7 @@ package org.activeeon.morphemic.service;
import org.activeeon.morphemic.infrastructure.deployment.PAConnectorIaasGateway;
import org.activeeon.morphemic.model.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import org.json.JSONArray;
......@@ -118,7 +119,7 @@ public class NodeCandidateUtils {
hardware = new Hardware();
hardware.setId(hardwareId);
hardware.setName(hardwareJSON.optString("type"));
hardware.setProviderId(paCloud.getCloudID());
hardware.setProviderId(hardwareJSON.optString("type"));
hardware.setCores(Math.round(Float.parseFloat(hardwareJSON.optString("minCores"))));
hardware.setRam(Long.valueOf(hardwareJSON.optString("minRam")));
if ("aws-ec2".equals(nodeCandidateJSON.optString("cloud"))) {
......@@ -133,7 +134,7 @@ public class NodeCandidateUtils {
}
private Location createLocation(JSONObject nodeCandidateJSON, PACloud paCloud) {
LOGGER.info("Creating location ...");
LOGGER.debug("Creating location ...");
String locationId = paCloud.getCloudID() + "/" + nodeCandidateJSON.optString("region");
Location location = em.find(Location.class, locationId);
if (location == null) {
......@@ -145,7 +146,7 @@ public class NodeCandidateUtils {
location.setIsAssignable(true);
location.setGeoLocation(createGeoLocation(paCloud.getCloudProviderName(), location.getName()));
}
LOGGER.info("Location created: " + location.toString());
LOGGER.debug("Location created: " + location.toString());
return location;
}
......@@ -171,7 +172,7 @@ public class NodeCandidateUtils {
image = new Image();
image.setId(imageId);
image.setName(imageJSON.optString("name"));
image.setProviderId(paCloud.getCloudID());
image.setProviderId(StringUtils.substringAfterLast(imageJSON.optString("id"), "/"));
OperatingSystem os = new OperatingSystem();
JSONObject osJSON = imageJSON.optJSONObject("operatingSystem");
os.setOperatingSystemFamily(OperatingSystemFamily.fromValue(osJSON.optString("family")));
......@@ -208,7 +209,7 @@ public class NodeCandidateUtils {
}
public NodeCandidate createNodeCandidate(JSONObject nodeCandidateJSON, JSONObject imageJSON, PACloud paCloud) {
LOGGER.info("Creating node candidate ...");
LOGGER.debug("Creating node candidate ...");
NodeCandidate nodeCandidate = new NodeCandidate();
nodeCandidate.setNodeCandidateType(NodeCandidate.NodeCandidateTypeEnum.IAAS);
nodeCandidate.setPrice(nodeCandidateJSON.optDouble("price"));
......@@ -221,7 +222,7 @@ public class NodeCandidateUtils {
nodeCandidate.setPricePerInvocation((double) 0);
nodeCandidate.setMemoryPrice((double) 0);
nodeCandidate.setEnvironment(new Environment());
LOGGER.info("Node candidate created: " + nodeCandidate.toString());
LOGGER.debug("Node candidate created: " + nodeCandidate.toString());
return nodeCandidate;
}
......
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