protected Location getLocation(@Nullable Collection<? extends Location> locations) { if (locations==null || locations.isEmpty()) locations = entity().getLocations(); if (locations.isEmpty()) { MachineProvisioningLocation<?> provisioner = entity().getAttribute(SoftwareProcess.PROVISIONING_LOCATION); if (provisioner!=null) locations = Arrays.<Location>asList(provisioner); } locations = Locations.getLocationsCheckingAncestors(locations, entity()); Maybe<MachineLocation> ml = Locations.findUniqueMachineLocation(locations); if (ml.isPresent()) return ml.get(); if (locations.isEmpty()) throw new IllegalArgumentException("No locations specified when starting "+entity()); if (locations.size() != 1 || Iterables.getOnlyElement(locations)==null) throw new IllegalArgumentException("Ambiguous locations detected when starting "+entity()+": "+locations); return Iterables.getOnlyElement(locations); }
MachineProvisioningLocation<MachineLocation> provisioner = entity().getAttribute(SoftwareProcess.PROVISIONING_LOCATION); if (Iterables.isEmpty(entity().getLocations())) { log.debug("No machine decommissioning necessary for " + entity() + " - no locations"); return new StopMachineDetails<>("No machine suspend necessary - no locations", 0);
for (Location location : entity.getLocations()) { builder.locations.add(location.getId());
return wrapAsTemplateModel( driver.getLocation() ); if (entity!=null) return wrapAsTemplateModel( Iterables.getOnlyElement( entity.getLocations() ) );
@Override public MachineDetails call(ConfigBag parameters) { Maybe<MachineLocation> machine = Machines.findUniqueMachineLocation(entity().getLocations()); try { machine.get().getMachineDetails(); throw new IllegalStateException("Expected failure in ssh"); } catch (RuntimeException e) { return null; } }}) .build();
Maybe<MachineLocation> machine = Machines.findUniqueMachineLocation(entity.getLocations()); ProvisioningTaskState provisioningState = entity.sensors().get(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE); if (machine.isAbsent() && provisioningState == ProvisioningTaskState.RUNNING) {
MachineProvisioningLocation<MachineLocation> provisioner = entity().getAttribute(SoftwareProcess.PROVISIONING_LOCATION); if (Iterables.isEmpty(entity().getLocations())) { log.debug("No machine decommissioning necessary for "+entity()+" - no locations"); return new StopMachineDetails<Integer>("No machine decommissioning necessary - no locations", 0);
@Override public void run() { log.info("Starting {} on machine {}", entity(), machine); Collection<Location> oldLocs = entity().getLocations(); if (!oldLocs.isEmpty()) { List<MachineLocation> oldSshLocs = ImmutableList.copyOf(Iterables.filter(oldLocs, MachineLocation.class));
protected void doStop(ConfigBag parameters, Callable<StopMachineDetails<Integer>> stopTask) { preStopConfirmCustom(); log.info("Stopping {} in {}", entity(), entity().getLocations()); Maybe<MachineLocation> machine = Machines.findUniqueMachineLocation(entity().getLocations()); ProvisioningTaskState provisioningState = entity().sensors().get(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
@SuppressWarnings({ "unchecked", "deprecation" }) protected void startWithChefSoloAsync() { String baseDir = MachineLifecycleEffectorTasks.resolveOnBoxDir(entity(), Machines.findUniqueMachineLocation(entity().getLocations(), SshMachineLocation.class).get()); String installDir = Urls.mergePaths(baseDir, "installs/chef");
@SuppressWarnings({ "unchecked", "deprecation" }) protected void startWithChefSoloAsync() { String baseDir = MachineLifecycleEffectorTasks.resolveOnBoxDir(entity(), Machines.findUniqueMachineLocation(entity().getLocations(), SshMachineLocation.class).get()); String installDir = Urls.mergePaths(baseDir, "installs/chef");