use of org.platformlayer.ops.Machine in project platformlayer by platformlayer.
the class PostgresqlServerController method getJdbcUrl.
@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;
}
use of org.platformlayer.ops.Machine in project platformlayer by platformlayer.
the class RecurseOverAll method doRecursion.
public void doRecursion(Object controller, SshKey sshKey, Class<? extends ItemBase> machineItemClass) throws OpsException {
boolean failed = false;
for (ItemBase machineItem : platformLayer.listItems(machineItemClass)) {
switch(machineItem.getState()) {
case ACTIVE:
break;
case DELETED:
log.warn("Ignoring deleted server: " + machineItem);
continue;
default:
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 {
OpsContext opsContext = OpsContext.get();
OperationRecursor.doRecurseChildren(opsContext, controller);
} finally {
scope.pop();
}
} catch (OpsException e) {
failed = true;
log.warn("Error updating machine: " + machine, e);
}
}
if (failed) {
throw new OpsException("Could not update all servers").setRetry(TimeSpan.ONE_MINUTE);
}
}
Aggregations