Search in sources :

Example 71 with PlatformLayerKey

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;
}
Also used : PlatformLayerClientException(org.platformlayer.PlatformLayerClientException) OpsException(org.platformlayer.ops.OpsException) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) DiskImage(org.platformlayer.images.model.DiskImage)

Example 72 with PlatformLayerKey

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);
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) InstanceBase(org.platformlayer.core.model.InstanceBase)

Example 73 with PlatformLayerKey

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);
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) InstanceBase(org.platformlayer.core.model.InstanceBase)

Example 74 with PlatformLayerKey

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;
}
Also used : ZookeeperServer(org.platformlayer.service.zookeeper.model.ZookeeperServer) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 75 with PlatformLayerKey

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);
}
Also used : TypedPlatformLayerClient(org.platformlayer.TypedPlatformLayerClient) JaxbHelper(org.platformlayer.xml.JaxbHelper) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId)

Aggregations

PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)86 PlatformLayerClient (org.platformlayer.PlatformLayerClient)21 OpsException (org.platformlayer.ops.OpsException)16 ItemBase (org.platformlayer.core.model.ItemBase)14 ManagedItemId (org.platformlayer.ids.ManagedItemId)13 UntypedItem (org.platformlayer.common.UntypedItem)10 ProjectId (org.platformlayer.ids.ProjectId)10 Tag (org.platformlayer.core.model.Tag)8 RepositoryException (org.platformlayer.RepositoryException)7 ServiceType (org.platformlayer.ids.ServiceType)7 JobData (org.platformlayer.jobs.model.JobData)7 InstanceBase (org.platformlayer.core.model.InstanceBase)6 ItemType (org.platformlayer.ids.ItemType)6 OpsTarget (org.platformlayer.ops.OpsTarget)6 JaxbHelper (org.platformlayer.xml.JaxbHelper)6 Handler (org.platformlayer.ops.Handler)5 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)4 UntypedItemXml (org.platformlayer.UntypedItemXml)4 FederationKey (org.platformlayer.ids.FederationKey)4 Machine (org.platformlayer.ops.Machine)4