Examples of ItemBase


Examples of org.platformlayer.core.model.ItemBase

  @Handler
  public void handler() throws OpsException {
    if (OpsContext.isConfigure()) {
      for (OwnedItem<?> childServer : parentController.getChildren(OwnedItem.class)) {
        ItemBase server = childServer.getItem();
        if (server == null) {
          // TODO: It's _possible_ that the child is ready instantly.
          // Right now, we have to go through a retry cycle
          throw new OpsException("Child server not ready");
        }
        List<EndpointInfo> endpoints = EndpointInfo.findEndpoints(server.getTags(), port);
        if (endpoints.isEmpty()) {
          // TODO: Cope in future e.g. if we only need one of two in a cluster
          throw new OpsException("Child server not ready");
        }
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

    }
  }

  @Override
  public Map<String, String> buildLinkTargetConfiguration(LinkConsumer consumer) throws OpsException {
    ItemBase serverItem = platformLayer.getItem(model.server);
    DatabaseServer databaseServer = providers.toInterface(serverItem, DatabaseServer.class);

    InetAddressChooser inetAddressChooser = consumer.getInetAddressChooser();

    return databaseServer.buildTargetConfiguration(model.username, model.password, model.databaseName,
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

  public Secret getIpsecSecret() throws OpsException {
    Secret secret = null;

    for (ProviderOf<HasIpsecPolicy> ipsecPolicyProvider : providerHelper.listItemsProviding(HasIpsecPolicy.class)) {
      ItemBase item = ipsecPolicyProvider.getItem();

      if (item.getState() != ManagedItemState.ACTIVE) {
        continue;
      }

      HasIpsecPolicy ipsec = ipsecPolicyProvider.get();
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

  }

  private List<BackendModel> resolveBackends(List<NginxBackend> backends) throws OpsException {
    List<BackendModel> resolved = Lists.newArrayList();
    for (NginxBackend backend : backends) {
      ItemBase backendItem = platformLayer.getItem(backend.backend);

      Machine backendMachine = instances.getMachine(backendItem);

      int port = 0;
      if (port == 0) {
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

        entry.ruleKey = uniqueId;
      } else if (sourceItemKey != null) {
        LateBound<IptablesFilterEntry> entry = new LateBound<IptablesFilterEntry>() {
          @Override
          public IptablesFilterEntry get() throws OpsException {
            ItemBase sourceItem = platformLayerHelpers.getItem(sourceItemKey);

            NetworkPoint targetNetworkPoint = NetworkPoint.forTargetInContext();

            boolean required = !OpsContext.isDelete();
            Machine sourceMachine = instanceHelpers.getMachine(sourceItem, required);
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

    boolean failed = false;

    OpsContext ops = OpsContext.get();

    List<ItemBase> dataItems = Lists.newArrayList();
    ItemBase contextDataItem = ops.getInstance(dataItemClass);
    if (contextDataItem != null) {
      dataItems.add(contextDataItem);
    } else {
      for (ItemBase dataItem : platformLayer.listItems(dataItemClass)) {
        dataItems.add(dataItem);
      }
    }

    Object contextMachine = ops.getInstance(machineItemClass);
    if (contextMachine != null) {
      // We are presumably building the machine item
      PlatformLayerKey targetItemKey = ops.getJobRecord().getTargetItemKey();
      ItemBase machineItem = (ItemBase) contextMachine;

      if (!Objects.equal(targetItemKey, machineItem.getKey())) {
        throw new OpsException("Expected to find same model");
      }

      Machine machine = instances.findMachine(machineItem);
      if (machine == null) {
        log.warn("Server instance not found: " + contextMachine);
        failed = true;
      } else {
        OpsTarget target = machine.getTarget(sshKey);
        failed |= processDataItems(controller, dataItems, machineItem, machine, target);
      }
    } else {
      // We are building a data item
      for (ItemBase machineItem : platformLayer.listItems(machineItemClass)) {
        if (machineItem.getState() != ManagedItemState.ACTIVE) {
          log.warn("Machine not yet active: " + machineItem);
          failed = true;
          continue;
        }
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

    return client.getItem(key, itemClass);
  }

  public void cleanup() throws IOException, OpsException {
    while (!ownedItems.isEmpty()) {
      ItemBase item = ownedItems.remove(ownedItems.size() - 1);
      JobData deleteJob = deleteItem(item);
      System.out.println("Deleted " + item.getKey() + " jobId=" + deleteJob.getJobId());
      waitForDeleted(item);
    }
  }
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

  @Inject
  InstanceHelpers instances;

  @Handler
  public void doOperation() throws OpsException, IOException {
    ItemBase item = ops.getInstance(ItemBase.class);

    Tag parentTag = Tag.buildParentTag(item.getKey());

    PersistentInstance persistentInstanceTemplate = buildPersistentInstanceTemplate();

    persistentInstanceTemplate.getTags().add(parentTag);

    // Set during doOperation
    Machine machine = null;
    PersistentInstance persistentInstance = null;
    InstanceBase instance = null;
    OpsTarget target = null;

    persistentInstance = getOrCreate(parentTag, persistentInstanceTemplate);

    if (persistentInstance != null) {
      // We have to connect to the underlying machine not-via-DNS for Dns service => use instance id
      // TODO: Should we always use the instance id??

      instance = instances.findInstance(persistentInstance);
      if (instance == null && !OpsContext.isDelete()) {
        // A machine has not (yet) been assigned
        throw new OpsException("Machine is not yet built").setRetry(TimeSpan.ONE_MINUTE);
      }
    }

    if (instance != null) {
      machine = cloudHelpers.toMachine(instance);
    }

    if (addTagToManaged && !OpsContext.isDelete()) {
      // Add tag with instance id to persistent instance (very helpful for
      // DNS service!)
      PlatformLayerKey machineKey = machine.getKey();
      platformLayer.addTag(item.getKey(), Tag.INSTANCE_KEY.build(machineKey));
    }

    SshKey sshKey = service.getSshKey();
    if (machine != null) {
      if (OpsContext.isDelete()) {
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

    addChild(DnsResolver.class);

    String hostname = dnsName;
    if (Strings.isNullOrEmpty(hostname)) {
      // We always want to set a valid hostname
      ItemBase item = ops.getInstance(ItemBase.class);
      hostname = item.getId();
    }

    if (hostname != null) {
      addChild(ConfigureHostname.build(hostname));
    }
View Full Code Here

Examples of org.platformlayer.core.model.ItemBase

  public PlatformLayerKey getOwner() throws OpsException {
    if (owner != null) {
      return owner;
    }
    ItemBase itemBase = OpsContext.get().getInstance(ItemBase.class);
    if (itemBase == null) {
      throw new OpsException("No owner in scope");
    }
    return itemBase.getKey();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.