Search in sources :

Example 1 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class FederatedPlatformLayerClient method mapToChildForCreate.

private MappedPlatformLayerKey mapToChildForCreate(PlatformLayerKey plk) {
    if (plk.getItemId() != null) {
        throw new IllegalArgumentException();
    }
    FederationMapping childKey = federationMap.getClientForCreate(plk);
    ManagedItemId childItemId;
    ChildClient childClient = getClient(childKey);
    childItemId = null;
    MappedPlatformLayerKey mapped = new MappedPlatformLayerKey();
    mapped.child = childClient;
    mapped.key = new PlatformLayerKey(childKey.host, childKey.project, plk.getServiceType(), plk.getItemType(), childItemId);
    return mapped;
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId)

Example 2 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class FederatedPlatformLayerClient method listItems.

@Override
public <T> List<T> listItems(final Class<T> clazz) throws PlatformLayerClientException {
    JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(clazz, ManagedItemCollection.class);
    PlatformLayerKey path = PlatformLayerClientBase.toKey(jaxbHelper, null, listServices(true));
    return doListConcatenationTyped(getChildClients(path), AddHostTyped.wrap(new ListItemsTyped<T>(clazz)));
}
Also used : JaxbHelper(org.platformlayer.xml.JaxbHelper) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 3 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class TypedPlatformLayerClient method toKey.

public <T> PlatformLayerKey toKey(Class<T> itemClass, String id) throws PlatformLayerClientException {
    JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(itemClass, new Class[0]);
    ManagedItemId itemId = new ManagedItemId(id);
    PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, itemId, itemClass, platformLayerClient.listServices(true));
    return key;
}
Also used : JaxbHelper(org.platformlayer.xml.JaxbHelper) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId)

Example 4 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class ImageFactory method getOrCreateImageId.

public CloudImage getOrCreateImageId(MachineProvider targetCloud, List<ImageFormat> formats, PlatformLayerKey recipeKey) throws OpsException {
    if (recipeKey == null) {
        log.debug("Looking for bootstrap image");
        for (ImageFormat format : formats) {
            CloudImage bootstrapImage = findBootstrapImage(format, cloud.getImageStore(targetCloud));
            if (bootstrapImage != null) {
                return bootstrapImage;
            // Tags tags = bootstrapImage.getTags();
            // String compression = tags.findUnique("org.openstack.sync__1__expand");
            // return new ImageInfo(bootstrapImage.getId(), format, compression);
            }
        }
        throw new OpsException("Cannot find bootstrap image for format " + Joiner.on(",").join(formats));
    }
    DiskImage imageTemplate = new DiskImage();
    imageTemplate.setFormat(formats.get(0).name());
    imageTemplate.setRecipeId(recipeKey);
    String id = "image-" + recipeKey.getItemId().getKey();
    imageTemplate.setKey(PlatformLayerKey.fromId(id));
    PlatformLayerKey cloudKey = targetCloud.getModel().getKey();
    imageTemplate.setCloud(cloudKey);
    DiskImage image = getOrCreateImage(imageTemplate);
    return getImageInfo(image);
}
Also used : OpsException(org.platformlayer.ops.OpsException) CloudImage(org.platformlayer.ops.images.CloudImage) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) DiskImage(org.platformlayer.images.model.DiskImage) ImageFormat(org.platformlayer.ops.images.ImageFormat)

Example 5 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class ImageFactory method getOrCreateImageId.

public CloudImage getOrCreateImageId(MachineProvider targetCloud, List<ImageFormat> formats, DiskImageRecipe recipeTemplate) throws OpsException {
    DiskImageRecipe recipeItem = getOrCreateRecipe(recipeTemplate);
    PlatformLayerKey recipeKey = recipeItem.getKey();
    return getOrCreateImageId(targetCloud, formats, recipeKey);
}
Also used : DiskImageRecipe(org.platformlayer.images.model.DiskImageRecipe) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

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