use of org.platformlayer.ops.databases.DatabaseTarget in project platformlayer by platformlayer.
the class PostgresqlServerController method buildDatabaseTarget.
@Override
public DatabaseTarget buildDatabaseTarget(String username, Secret password, String databaseName) throws OpsException {
OpsTarget target = instanceHelpers.getTarget(model);
// Machine machine = instanceHelpers.getMachine(pgServer);
//
// String address = machine.getBestAddress(NetworkPoint.forTargetInContext(), POSTGRES_PORT);
// PostgresTarget mysql = new TunneledPostgresTarget(address, username, password);
DatabaseTarget db = new TunneledDatabaseTarget(target, username, password, databaseName);
return db;
}
use of org.platformlayer.ops.databases.DatabaseTarget in project platformlayer by platformlayer.
the class DatabaseConnection method doRecurseOperation.
@Override
public void doRecurseOperation() throws OpsException {
ItemBase server = platformLayer.getItem(serverKey);
DatabaseServer database = providers.toInterface(server, DatabaseServer.class);
String username = this.username;
if (username == null) {
username = database.getRootUsername();
}
if (username.equals("postgres") && password == null) {
password = database.getRootPassword();
}
DatabaseTarget dbTarget = database.buildDatabaseTarget(username, password, databaseName);
BindingScope scope = BindingScope.push(dbTarget);
try {
OpsContext opsContext = OpsContext.get();
OperationRecursor.doRecurseChildren(opsContext, this);
} finally {
scope.pop();
}
}
Aggregations