Search in sources :

Example 1 with DatabaseTarget

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;
}
Also used : OpsTarget(org.platformlayer.ops.OpsTarget) TunneledDatabaseTarget(org.platformlayer.ops.databases.TunneledDatabaseTarget) DatabaseTarget(org.platformlayer.ops.databases.DatabaseTarget) TunneledDatabaseTarget(org.platformlayer.ops.databases.TunneledDatabaseTarget)

Example 2 with DatabaseTarget

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();
    }
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) DatabaseServer(org.platformlayer.ops.databases.DatabaseServer) DatabaseTarget(org.platformlayer.ops.databases.DatabaseTarget) OpsContext(org.platformlayer.ops.OpsContext) BindingScope(org.platformlayer.ops.BindingScope)

Aggregations

DatabaseTarget (org.platformlayer.ops.databases.DatabaseTarget)2 ItemBase (org.platformlayer.core.model.ItemBase)1 BindingScope (org.platformlayer.ops.BindingScope)1 OpsContext (org.platformlayer.ops.OpsContext)1 OpsTarget (org.platformlayer.ops.OpsTarget)1 DatabaseServer (org.platformlayer.ops.databases.DatabaseServer)1 TunneledDatabaseTarget (org.platformlayer.ops.databases.TunneledDatabaseTarget)1