Package org.platformlayer.ops

Examples of org.platformlayer.ops.Machine


        log.warn("Item not yet active: " + machineItem);
        failed = true;
        continue;
      }

      Machine machine = instances.findMachine(machineItem);
      if (machine == null) {
        log.warn("Server instance not found: " + machineItem);
        failed = true;
        continue;
      }

      OpsTarget target = machine.getTarget(sshKey);

      try {
        // Execute the children in a scope with the paired item and machine
        BindingScope scope = BindingScope.push(machine, target, machineItem);
        try {
View Full Code Here


  }

  @Override
  public List<InetAddress> findAddresses(NetworkPoint from) throws OpsException {
    Machine machine = instances.getMachine(model);
    if (machine == null) {
      return Collections.emptyList();
    }

    List<InetAddress> addresses = machine.getNetworkPoint().findAddresses(from);
    return addresses;
  }
View Full Code Here

    if (gitService.getState() != ManagedItemState.ACTIVE) {
      throw new OpsException("Server not yet active: " + gitService);
    }

    Machine machine = instances.findMachine(gitService);
    if (machine == null) {
      throw new OpsException("Server machine not found:" + gitService);
    }

    SshKey sshKey = service.getSshKey();
    OpsTarget target = machine.getTarget(sshKey);

    getRecursionState().pushChildScope(OpsTarget.class, target);
  }
View Full Code Here

    request.securityGroups.add(securityGroup);

    // We don't need a lot of memory to build a disk image (I think!)
    request.minimumMemoryMB = 256;

    Machine machine = cloud.createInstance(request, image.getKey());

    opsContext.takeOwnership(machine);

    machine = waitForAddress(machine);
    OpsTarget target = machine.getTarget(sshKey);
    waitForTarget(target);

    File tempDir = target.createTempDir();

    apt.update(target, true);
View Full Code Here

      }

      return TimeoutPoll.poll(TimeSpan.FIVE_MINUTES, TimeSpan.TEN_SECONDS, new PollFunction<Machine>() {
        @Override
        public Machine call() throws Exception {
          Machine refreshed = cloud.refreshMachine(machine);

          List<InetAddress> addresses = refreshed.getNetworkPoint().findAddresses(myNetworkPoint);
          if (!addresses.isEmpty()) {
            return refreshed;
          }
          return null;
        }
View Full Code Here

    Filter parentFilter = TagFilter.byTag(Tag.buildParentTag(model.getKey()));

    List<Machine> machines = Lists.newArrayList();

    for (SolrServer server : platformLayer.listItems(SolrServer.class, parentFilter)) {
      Machine machine = instances.getMachine(server, required);
      if (machine != null) {
        machines.add(machine);
      }
    }
View Full Code Here

    instance.addChild(injected(PostgresqlServerBackup.class));
  }

  @Override
  public String getJdbcUrl(String databaseName, InetAddressChooser chooser) throws OpsException {
    Machine itemMachine = instanceHelpers.getMachine(model);

    InetAddress address = itemMachine.getNetworkPoint().getBestAddress(NetworkPoint.forTargetInContext(), chooser);
    String host = address.getHostAddress();
    if (InetAddressUtils.isIpv6(address)) {
      host = "[" + host + "]";
    }
    return "jdbc:postgresql://" + host + ":5432/" + databaseName;
View Full Code Here

    // return glanceImageStore;
    // } else

    if (url.getScheme().equals("ssh")) {
      String myAddress = url.getHost();
      Machine machine = new OpaqueMachine(NetworkPoint.forPublicHostname(myAddress));
      // This is nasty; we're in the context of another service here...
      SshKey sshKey = sshKeys.findOtherServiceKey(new ServiceType("imagestore"));
      OpsTarget target = machine.getTarget("imagestore", sshKey.getKeyPair());

      DirectImageStore directImageStore = OpsContext.get().getInjector().getInstance(DirectImageStore.class);
      directImageStore.connect(target);
      return directImageStore;
    } else {
View Full Code Here

  @Inject
  PlatformLayerCloudHelpers cloud;

  @Override
  public OpenstackBackupContext build(ItemBase item) throws OpsException {
    Machine machine = instances.findMachine(item);
    if (machine == null) {
      throw new OpsException("Cannot determine machine for: " + item);
    }
    StorageConfiguration storageConfiguration = cloud.getStorageConfiguration(machine);
    return build(storageConfiguration);
View Full Code Here

    if (assignedInstanceIds.isEmpty() && !OpsContext.isDelete()) {
      throw new OpsException("Instance not yet assigned");
    }

    Machine machine = null;
    OpsTarget target = null;

    if (!assignedInstanceIds.isEmpty()) {
      if (assignedInstanceIds.size() != 1) {
        log.warn("Multiple instance ids found: " + assignedInstanceIds);
      }

      // We just take the first instance id
      String assignedInstanceId = Iterables.getFirst(assignedInstanceIds, null);

      Server server = openstack.findServerById(cloud, assignedInstanceId);

      if (server == null) {
        if (OpsContext.isConfigure()) {
          throw new OpsException("Unable to find assigned server: " + assignedInstanceId);
        }
      } else {
        server = openstack.ensureHasPublicIp(cloud, server);

        AsyncServerOperation powerOnOperation = openstack.ensurePoweredOn(cloud, server);
        if (powerOnOperation != null) {
          waitOperation(powerOnOperation);
        }

        machine = new OpenstackComputeMachine(openstack, cloud, server);

        SshKey sshKey = service.getSshKey();
        target = machine.getTarget(sshKey);
      }
    }

    if (!assignedInstanceIds.isEmpty() && OpsContext.isDelete()) {
      CloudBehaviours cloudBehaviours = new CloudBehaviours(cloud);
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.Machine

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.