Search in sources :

Example 1 with DiskEncryptionConfiguration

use of com.google.api.services.sqladmin.model.DiskEncryptionConfiguration in project cloudbreak by hortonworks.

the class GcpDatabaseServerLaunchService method getDatabaseInstance.

private DatabaseInstance getDatabaseInstance(DatabaseStack stack, String deploymentName, Compute compute, String projectId) throws java.io.IOException {
    DatabaseServer databaseServer = stack.getDatabaseServer();
    GcpDatabaseServerView databaseServerView = new GcpDatabaseServerView(databaseServer);
    GcpDatabaseNetworkView databaseNetworkView = new GcpDatabaseNetworkView(stack.getNetwork());
    Subnetwork subnetworkForRedbeams;
    if (Strings.isNullOrEmpty(databaseNetworkView.getSharedProjectId())) {
        subnetworkForRedbeams = compute.subnetworks().get(projectId, databaseServerView.getLocation(), databaseNetworkView.getSubnetId()).execute();
    } else {
        subnetworkForRedbeams = compute.subnetworks().get(databaseNetworkView.getSharedProjectId(), databaseServerView.getLocation(), databaseNetworkView.getSubnetId()).execute();
    }
    DatabaseInstance databaseInstance = new DatabaseInstance();
    databaseInstance.setCurrentDiskSize(databaseServerView.getAllocatedStorageInMb());
    databaseInstance.setName(deploymentName);
    databaseInstance.setInstanceType("CLOUD_SQL_INSTANCE");
    databaseInstance.setBackendType("SECOND_GEN");
    databaseInstance.setRegion(databaseServerView.getLocation());
    databaseInstance.setRootPassword(databaseServerView.getAdminPassword());
    databaseInstance.setConnectionName(databaseServerView.getAdminLoginName());
    databaseInstance.setGceZone(databaseNetworkView.getAvailabilityZone());
    databaseInstance.setDatabaseVersion(databaseServerView.getDatabaseVersion());
    databaseInstance.setSettings(getSettings(stack, databaseServerView, subnetworkForRedbeams));
    String keyName = databaseServer.getStringParameter(VOLUME_ENCRYPTION_KEY_ID);
    if (keyName != null && !keyName.isEmpty()) {
        DiskEncryptionConfiguration diskEncryptionConfiguration = new DiskEncryptionConfiguration();
        diskEncryptionConfiguration.setKmsKeyName(keyName);
        databaseInstance.setDiskEncryptionConfiguration(diskEncryptionConfiguration);
    }
    return databaseInstance;
}
Also used : GcpDatabaseServerView(com.sequenceiq.cloudbreak.cloud.gcp.view.GcpDatabaseServerView) Subnetwork(com.google.api.services.compute.model.Subnetwork) DatabaseServer(com.sequenceiq.cloudbreak.cloud.model.DatabaseServer) DiskEncryptionConfiguration(com.google.api.services.sqladmin.model.DiskEncryptionConfiguration) GcpDatabaseNetworkView(com.sequenceiq.cloudbreak.cloud.gcp.view.GcpDatabaseNetworkView) DatabaseInstance(com.google.api.services.sqladmin.model.DatabaseInstance)

Aggregations

Subnetwork (com.google.api.services.compute.model.Subnetwork)1 DatabaseInstance (com.google.api.services.sqladmin.model.DatabaseInstance)1 DiskEncryptionConfiguration (com.google.api.services.sqladmin.model.DiskEncryptionConfiguration)1 GcpDatabaseNetworkView (com.sequenceiq.cloudbreak.cloud.gcp.view.GcpDatabaseNetworkView)1 GcpDatabaseServerView (com.sequenceiq.cloudbreak.cloud.gcp.view.GcpDatabaseServerView)1 DatabaseServer (com.sequenceiq.cloudbreak.cloud.model.DatabaseServer)1