Package org.platformlayer.core.model

Examples of org.platformlayer.core.model.TagChanges


  public JobData deleteItem(PlatformLayerKey key) throws PlatformLayerClientException {
    return platformLayerClient.deleteItem(key);
  }

  public Tags addTags(PlatformLayerKey key, List<Tag> tags) throws PlatformLayerClientException {
    TagChanges changeTags = new TagChanges();

    changeTags.addTags.addAll(tags);

    return changeTags(key, changeTags);
  }
View Full Code Here


          if (publicAddress == null) {
            throw new OpsException("Cannot find address for instance: " + model.instance);
          }

          TagChanges tagChanges = new TagChanges();
          EndpointInfo endpoint = new EndpointInfo(publicAddress, model.publicPort);
          tagChanges.addTags.add(endpoint.toTag());

          return tagChanges;
        }
View Full Code Here

              }
            }

            List<EndpointInfo> endpointInfos = EndpointInfo.findEndpoints(item.getTags(), publicPort);
            if (!endpointInfos.isEmpty()) {
              TagChanges tagChanges = new TagChanges();
              for (EndpointInfo endpointInfo : endpointInfos) {
                tagChanges.addTags.add(endpointInfo.toTag());
              }

              return tagChanges;
View Full Code Here

            }

            throw new OpsException("No machine in scope");
          }

          TagChanges changeTags = new TagChanges();
          changeTags.addTags.add(Tag.INSTANCE_KEY.build(machine.getKey()));
          platformLayer.changeTags(model.getKey(), changeTags, null);
          return changeTags;
        }
      };
View Full Code Here

  }

  public void setUniqueTags(PlatformLayerKey key, Iterable<Tag> uniqueTags) throws OpsException {
    Tags tags = getItemTags(key);

    TagChanges tagChanges = new TagChanges();
    for (Tag setTag : uniqueTags) {
      String tagKey = setTag.getKey();

      List<String> existing = tags.findAll(tagKey);
      if (existing == null || existing.isEmpty()) {
        tagChanges.addTags.add(setTag);
      } else if (existing.size() == 1) {
        String existingValue = existing.get(0);
        if (!Objects.equal(existingValue, setTag.value)) {
          tagChanges.addTags.add(setTag);
          tagChanges.removeTags.add(Tag.build(tagKey, existingValue));
        }
      } else {
        // We probably should replace existing tags...
        throw new OpsException("Found duplicate tag for: " + setTag.key);
      }
    }

    if (!tagChanges.isEmpty()) {
      changeTags(key, tagChanges);
    }
  }
View Full Code Here

      throws OpsException {
    Set<String> newTagValuesSet = Sets.newHashSet(newTagValues);

    Tags existingTags = getItemTags(key);

    TagChanges tagChanges = new TagChanges();

    Set<String> foundValues = Sets.newHashSet();

    for (Tag existingTag : existingTags) {
      String existingTagKey = existingTag.getKey();

      if (!tagKey.equals(existingTagKey)) {
        continue;
      }

      String existingTagValue = existingTag.getValue();
      if (!newTagValuesSet.contains(existingTagValue)) {
        tagChanges.removeTags.add(existingTag);
      } else {
        foundValues.add(existingTagValue);
      }
    }

    for (String newTagValue : newTagValues) {
      if (foundValues.contains(newTagValue)) {
        continue;
      }

      tagChanges.addTags.add(Tag.build(tagKey, newTagValue));
    }

    if (!tagChanges.isEmpty()) {
      changeTags(key, tagChanges);
    }
  }
View Full Code Here

    {
      OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {
        @Override
        public TagChanges get() {
          TagChanges tagChanges = new TagChanges();
          String address = ingress.getPublicAddress();
          if (Strings.isNullOrEmpty(address)) {
            throw new IllegalStateException();
          }
View Full Code Here

      OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {
        @Override
        public TagChanges get() {
          GoogleComputeMachine machine = OpsContext.get().getInstance(GoogleComputeMachine.class);

          TagChanges tagChanges = new TagChanges();
          tagChanges.addTags.add(Tag.INSTANCE_KEY.build(model.getKey()));
          tagChanges.addTags.addAll(machine.buildAddressTags());

          return tagChanges;
        }
View Full Code Here

  PlatformLayerClient platformLayer;

  @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()) {
View Full Code Here

          missing.add(publicKeySig);
        }
      }

      if (!missing.isEmpty()) {
        TagChanges tagChanges = new TagChanges();
        for (String add : missing) {
          tagChanges.addTags.add(Tag.PUBLIC_KEY_SIG.build(add));
        }
        platformlayer.changeTags(tagWithPublicKeys.getKey(), tagChanges);
      }
View Full Code Here

TOP

Related Classes of org.platformlayer.core.model.TagChanges

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.