use of org.platformlayer.core.model.Tags in project platformlayer by platformlayer.
the class Tagger method handler.
@Handler
public void handler() throws OpsException {
if (OpsContext.isDelete() || OpsContext.isConfigure()) {
TagChanges tagChanges = tagChangesProvider.get();
if (tagChanges != null) {
log.info("Setting tags on " + platformLayerKey);
if (OpsContext.isDelete()) {
// Swap the tags for a removal
Tags x = tagChanges.addTags;
tagChanges.addTags = tagChanges.removeTags;
tagChanges.removeTags = x;
}
platformLayer.changeTags(platformLayerKey, tagChanges, null);
}
}
}
use of org.platformlayer.core.model.Tags 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;
}
use of org.platformlayer.core.model.Tags in project platformlayer by platformlayer.
the class SshAddressFinder method visit.
public void visit(UntypedItem item) throws PlatformLayerClientException {
UntypedItemXml untypedItem = (UntypedItemXml) item;
ElementInfo rootElementInfo = untypedItem.getRootElementInfo();
boolean consider = true;
switch(untypedItem.getState()) {
case DELETED:
case DELETE_REQUESTED:
consider = false;
break;
}
Set<String> instanceTypes = Sets.newHashSet();
instanceTypes.add("directInstance");
instanceTypes.add("googleCloudInstance");
if (!instanceTypes.contains(rootElementInfo.elementName)) {
consider = false;
}
if (consider) {
Tags itemTags = untypedItem.getTags();
for (InetAddress address : Tag.NETWORK_ADDRESS.find(itemTags)) {
found.add(address);
}
}
boolean includeDeleted = false;
for (UntypedItem child : client.listChildren(untypedItem.getKey(), includeDeleted).getItems()) {
visit(child);
}
}
use of org.platformlayer.core.model.Tags in project platformlayer by platformlayer.
the class UntypedItemFormatter method visit.
@Override
public void visit(CliContext contextGeneric, UntypedItem o, OutputSink sink) throws IOException {
PlatformLayerCliContext context = (PlatformLayerCliContext) contextGeneric;
LinkedHashMap<String, Object> values = Maps.newLinkedHashMap();
UntypedItemXml item = (UntypedItemXml) o;
Element dataElement = item.getDataElement();
// String xml = o.getModelData();
//
// Element documentElement;
//
// try {
// Document dom = XmlHelper.parseXmlDocument(xml, false);
// documentElement = dom.getDocumentElement();
// } catch (Exception e) {
// throw new IllegalArgumentException("Error parsing XML", e);
// }
values.put("key", Utils.formatUrl(context, item.getKey()));
values.put("state", item.getState());
Tags tags = item.getTags();
values.put("tags", tagsToString(context, tags));
NodeList childNodes = dataElement.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
String nodeName = node.getNodeName();
String localName = node.getLocalName();
String namespace = node.getNamespaceURI();
if (namespace.equals("http://platformlayer.org/core/v1.0")) {
if (localName.equals("tags")) {
continue;
}
if (localName.equals("key")) {
continue;
}
if (localName.equals("version")) {
continue;
}
if (localName.equals("state")) {
continue;
}
}
String text = formatCell(node);
text = Utils.reformatText(context, text);
values.put(nodeName, text);
}
sink.outputRow(values);
}
use of org.platformlayer.core.model.Tags in project platformlayer by platformlayer.
the class DirectImageStore method findImages.
@Override
public List<CloudImage> findImages(List<Tag> tags) throws OpsException {
List<CloudImage> images = Lists.newArrayList();
for (String imageId : fileStore.find(tags)) {
Properties properties = fileStore.readProperties(imageId);
Tags imageTags = fileStore.asTags(properties);
images.add(new DirectCloudImage(this, imageId, imageTags));
}
return images;
}
Aggregations