use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class ImageFactory method getOrCreateImage.
public DiskImage getOrCreateImage(DiskImage template) throws OpsException {
DiskImage best = null;
try {
for (DiskImage candidate : platformLayer.listItems(DiskImage.class)) {
if (isMatch(candidate, template)) {
best = candidate;
break;
}
}
if (best == null) {
// We should be owned by the recipe
PlatformLayerKey recipeKey = template.getRecipeId();
if (recipeKey != null) {
template.getTags().add(Tag.buildParentTag(recipeKey));
}
best = platformLayer.putItem(template);
}
} catch (PlatformLayerClientException e) {
throw new OpsException("Error fetching or building image", e);
}
return best;
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class PlatformLayerCloudContext method refreshMachine.
@Override
public Machine refreshMachine(Machine machine) throws OpsException {
PlatformLayerKey key = machine.getKey();
InstanceBase refreshed = findInstanceByInstanceKey(key);
return cloudHelpers.toMachine(refreshed);
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class PlatformLayerCloudHelpers method getStorageConfiguration.
public StorageConfiguration getStorageConfiguration(Machine machine) throws OpsException {
InstanceBase instance = toInstance(machine);
PlatformLayerKey cloudKey = instance.cloud;
MachineProvider cloud = getCloud(cloudKey);
return getStorageConfiguration(cloud);
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class ZookeeperInstanceModel method getClusterServers.
public List<ZookeeperServer> getClusterServers() throws OpsException {
PlatformLayerKey parent = getClusterKey();
if (parent == null) {
log.warn("Parent tag not set on Zookeeper server; assuming standalone server");
return Lists.newArrayList(model);
}
List<ZookeeperServer> servers = platformLayer.listItems(ZookeeperServer.class, TagFilter.byTag(Tag.PARENT.build(parent)));
return servers;
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class PlatformLayerTestContext method getItem.
public <T extends ItemBase> T getItem(String id, Class<T> itemClass) throws OpsException, IOException {
TypedPlatformLayerClient client = getTypedClient();
JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(itemClass, new Class[] {});
PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, new ManagedItemId(id), itemClass, client.listServices(true));
return client.getItem(key, itemClass);
}
Aggregations