Search in sources :

Example 1 with Tag

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

the class DirectPlatformLayerClient method listChildrenTyped.

@Override
public List<ItemBase> listChildrenTyped(PlatformLayerKey parentKey, boolean includeDeleted) throws OpsException {
    parentKey = resolveKey(parentKey);
    Tag parentTag = Tag.buildParentTag(parentKey);
    Filter filter = TagFilter.byTag(parentTag);
    if (!includeDeleted) {
        filter = StateFilter.excludeDeleted(filter);
    }
    List<ItemBase> items = itemService.listAll(auth, filter);
    return items;
}
Also used : StateFilter(org.platformlayer.StateFilter) TagFilter(org.platformlayer.TagFilter) Filter(org.platformlayer.Filter) ItemBase(org.platformlayer.core.model.ItemBase) Tag(org.platformlayer.core.model.Tag)

Example 2 with Tag

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

the class OwnedEndpoint method buildItemTemplate.

@Override
protected PublicEndpointBase buildItemTemplate() throws OpsException {
    InstanceBase instance = OpsContext.get().getInstance(InstanceBase.class);
    PlatformLayerKey instanceKey = instance.getKey();
    PublicEndpointBase publicEndpoint = platformLayerCloudHelpers.createPublicEndpoint(instance, parentItem);
    // publicEndpoint.network = network;
    publicEndpoint.publicPort = publicPort;
    publicEndpoint.publicPortCluster = publicPortCluster;
    publicEndpoint.backendPort = backendPort;
    publicEndpoint.instance = instanceKey;
    publicEndpoint.key = PlatformLayerKey.fromId(instance.getId() + "_" + publicPort);
    if (transport != null) {
        publicEndpoint.transport = transport.toString();
    }
    // publicEndpoint.getTags().add(OpsSystem.get().createParentTag(instance));
    Tag uniqueTag = UniqueTag.build(instance, String.valueOf(publicPort));
    publicEndpoint.getTags().add(uniqueTag);
    return publicEndpoint;
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) UniqueTag(org.platformlayer.ops.UniqueTag) Tag(org.platformlayer.core.model.Tag) PublicEndpointBase(org.platformlayer.core.model.PublicEndpointBase) InstanceBase(org.platformlayer.core.model.InstanceBase)

Example 3 with Tag

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

the class PropertiesFileStore method findFirst.

public String findFirst(List<Tag> tags) throws OpsException {
    List<String> keys = getKeys();
    for (String key : keys) {
        Properties properties = readProperties(key);
        boolean valid = true;
        for (Tag tag : tags) {
            // String tagKey = PropertiesFileStore.PROPERTY_PREFIX_TAG + tag.key;
            String tagKey = tag.key;
            String tagValue = properties.getProperty(tagKey);
            if (!Objects.equal(tagValue, tag.getValue())) {
                valid = false;
                break;
            }
        }
        if (valid) {
            return key;
        }
    }
    return null;
}
Also used : Tag(org.platformlayer.core.model.Tag) Properties(java.util.Properties)

Example 4 with Tag

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

the class PropertiesFileStore method find.

public List<String> find(List<Tag> tags) throws OpsException {
    List<String> matches = Lists.newArrayList();
    List<String> keys = getKeys();
    for (String key : keys) {
        Properties properties = readProperties(key);
        boolean valid = true;
        for (Tag tag : tags) {
            // String tagKey = PropertiesFileStore.PROPERTY_PREFIX_TAG + tag.key;
            String tagKey = tag.key;
            String tagValue = properties.getProperty(tagKey);
            if (!Comparisons.equalsIgnoreCase(tagValue, tag.getValue())) {
                valid = false;
                break;
            }
        }
        if (valid) {
            matches.add(key);
        }
    }
    return matches;
}
Also used : Tag(org.platformlayer.core.model.Tag) Properties(java.util.Properties)

Example 5 with Tag

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

the class PlatformLayerHelpers method getOrCreateUuid.

public UUID getOrCreateUuid(ItemBase model) throws PlatformLayerClientException {
    Tags tags = model.getTags();
    UUID uuid = Tag.UUID.findUnique(tags);
    if (uuid != null) {
        return uuid;
    }
    uuid = UUID.randomUUID();
    Tag uuidTag = Tag.UUID.build(uuid);
    tags.add(uuidTag);
    this.addTag(model.getKey(), uuidTag);
    return uuid;
}
Also used : Tag(org.platformlayer.core.model.Tag) UUID(java.util.UUID) Tags(org.platformlayer.core.model.Tags)

Aggregations

Tag (org.platformlayer.core.model.Tag)41 OpsException (org.platformlayer.ops.OpsException)16 ItemBase (org.platformlayer.core.model.ItemBase)8 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)8 Tags (org.platformlayer.core.model.Tags)8 Handler (org.platformlayer.ops.Handler)8 TagChanges (org.platformlayer.core.model.TagChanges)6 JSONObject (org.json.JSONObject)4 OpenstackException (org.openstack.client.OpenstackException)4 RepositoryException (org.platformlayer.RepositoryException)4 Machine (org.platformlayer.ops.Machine)4 JdbcTransaction (com.fathomdb.jdbc.JdbcTransaction)3 SQLException (java.sql.SQLException)3 OpenstackImageClient (org.openstack.client.common.OpenstackImageClient)3 Filter (org.platformlayer.Filter)3 PlatformLayerClient (org.platformlayer.PlatformLayerClient)3 StateFilter (org.platformlayer.StateFilter)3 OpsTarget (org.platformlayer.ops.OpsTarget)3 UniqueTag (org.platformlayer.ops.UniqueTag)3 SshKey (org.platformlayer.ops.helpers.SshKey)3