use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class CloudProvider method getResourceDescription.
public CloudMethodResourceDescription getResourceDescription(String instanceTypeName, String imageName) {
CloudMethodResourceDescription result = null;
CloudInstanceTypeDescription type = typeManager.getType(instanceTypeName);
if (type != null) {
CloudImageDescription image = imgManager.getImage(imageName);
if (image != null) {
result = new CloudMethodResourceDescription(type, image);
result.setValue(cost.getMachineCostPerHour(result));
} else {
LOGGER.warn(WARN_NO_VALID_IMAGE);
}
} else {
LOGGER.warn(WARN_NO_VALID_INSTANCE);
}
return result;
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class CloudMethodWorker method getMonitoringData.
@Override
public String getMonitoringData(String prefix) {
StringBuilder sb = new StringBuilder();
sb.append(prefix).append(super.getMonitoringData(prefix));
String providerName = provider.getName();
if (providerName == null) {
providerName = "";
}
sb.append(prefix).append("<Provider>").append(providerName).append("</Provider>").append("\n");
CloudImageDescription image = ((CloudMethodResourceDescription) description).getImage();
String imageName = "";
if (image != null) {
imageName = image.getImageName();
}
sb.append(prefix).append("<Image>").append(imageName).append("</Image>").append("\n");
return sb.toString();
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class CloudImageManager method getCompatibleImages.
/**
* Finds all the images provided by the Cloud Provider which fulfill the resource description.
*
* @param requested
* description of the features that the image must provide
* @return The best image provided by the Cloud Provider which fulfills the resource description
*/
public List<CloudImageDescription> getCompatibleImages(MethodResourceDescription requested) {
// logger.debug("REQUESTED: " + requested.toString());
List<CloudImageDescription> compatiblesList = new LinkedList<>();
for (CloudImageDescription cid : images.values()) {
// logger.debug("CID: " + cid.toString());
// OS CHECK
String imageOSType = cid.getOperatingSystemType();
String reqOSType = requested.getOperatingSystemType();
if (!imageOSType.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !reqOSType.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !imageOSType.equals(reqOSType)) {
continue;
}
String imageOSDistr = cid.getOperatingSystemDistribution();
String reqOSDistr = requested.getOperatingSystemDistribution();
if (!imageOSDistr.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !reqOSDistr.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !imageOSDistr.equals(reqOSDistr)) {
continue;
}
String imageOSVersion = cid.getOperatingSystemVersion();
String reqOSVersion = requested.getOperatingSystemVersion();
if (!imageOSVersion.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !reqOSVersion.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !imageOSVersion.equals(reqOSVersion)) {
continue;
}
// SOFTWARE CHECK
if (!cid.getAppSoftware().containsAll(requested.getAppSoftware())) {
continue;
}
// CHECK QUEUES
List<String> req_queues = requested.getHostQueues();
List<String> image_queues = cid.getQueues();
// Disjoint = true if the two specified collections have no elements in common.
if (!req_queues.isEmpty() && Collections.disjoint(req_queues, image_queues)) {
continue;
}
compatiblesList.add(cid);
}
return compatiblesList;
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class CloudManagerTest method createProvider.
private static CloudProvider createProvider(CloudManager cm) {
String providerName = "Provider" + (int) (Math.random() * 10000);
Map<String, String> properties = new HashMap<>();
CloudProvider cp = null;
try {
cp = cm.registerCloudProvider(providerName, 0, RUNTIME_CONNECTOR, null, null, properties);
} catch (Exception e) {
fail("Could not create the Cloud Provider");
}
String imageName = "IMAGE" + (int) (Math.random() * 10000);
CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
cp.addCloudImage(cid);
String typeName = "TYPE" + (int) (Math.random() * 10000);
float type1Memory = (float) Math.random() * 5;
MethodResourceDescription mrd1 = new MethodResourceDescription();
mrd1.setMemorySize(type1Memory);
CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
cp.addInstanceType(citd);
return cp;
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class ResourceManagerTest method addProvider.
private static CloudProvider addProvider() {
String providerName = "Provider" + (int) (Math.random() * 10000);
Map<String, String> properties = new HashMap<>();
CloudProvider cp = null;
try {
cp = ResourceManager.registerCloudProvider(providerName, 0, RUNTIME_CONNECTOR, null, null, properties);
} catch (Exception e) {
fail("Could not create the Cloud Provider");
}
String imageName = "IMAGE" + (int) (Math.random() * 10000);
CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
cp.addCloudImage(cid);
String typeName = "TYPE" + (int) (Math.random() * 10000);
float type1Memory = (float) Math.random() * 5;
MethodResourceDescription mrd1 = new MethodResourceDescription();
mrd1.setMemorySize(type1Memory);
CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
cp.addInstanceType(citd);
return cp;
}
Aggregations