Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
New Release v1.2.1 for OCI Service Broker
Browse files Browse the repository at this point in the history
- Minor Update to use unified API for ATP/ADW service. Internal change with no customer impact

Co-authored-by: Ashokkumar Kannan ashokkumar.kannan@oracle.com
Co-authored-by: Jayasheelan Kumar jayasheelan.kumar@oracle.com
Co-authored-by: Naman Mehta naman.mehta@oracle.com
  • Loading branch information
jayasheelankumar authored Jun 28, 2019
1 parent 097a944 commit d5e0040
Show file tree
Hide file tree
Showing 16 changed files with 364 additions and 673 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

[1.2.1]

- Minor Update to use unified API for ATP/ADW service. Internal change with no customer impact

[1.2.0]

- Adding Support to Bind Existing Service Instance for all supported services
- Adding Diagnostic Tool to help identify the common issues during installation
- Minor Document Fixes

[1.1.1]

- Adding support for Seoul (ICN) region
- Minor Document Fixes
- Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion charts/oci-service-broker/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
apiVersion: v1
description: A Helm chart for installing OCI Service Broker into a Kubernetes cluster
name: oci-service-broker
version: 1.2.0
version: 1.2.1
2 changes: 1 addition & 1 deletion charts/oci-service-broker/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ brew update && brew install kubernetes-service-catalog-client
The OCI Service Broker is packaged as Helm chart for making it easy to install in Kubernetes. The chart is available at [charts/oci-service-broker](../) directory.

```plain
https://github.com/oracle/oci-service-broker/releases/download/v1.2.0/oci-service-broker-1.2.0.tgz
https://github.com/oracle/oci-service-broker/releases/download/v1.2.0/oci-service-broker-1.2.1.tgz
```

### OCI credentials
Expand Down
2 changes: 1 addition & 1 deletion charts/oci-service-broker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ image:
repository: iad.ocir.io/oracle/oci-service-broker

# Tag of the image
tag: 1.2.0
tag: 1.2.1

# The image pull policy
pullPolicy: Always
Expand Down
2 changes: 1 addition & 1 deletion oci-service-broker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ apply plugin: 'maven-publish'
archivesBaseName = 'oci-service-broker'

// Sometimes, the version has to be overridden from command line
version = project.hasProperty('version_num') ? project.getProperty('version_num') : '1.2.0'
version = project.hasProperty('version_num') ? project.getProperty('version_num') : '1.2.1'
ext.dockerGroup = 'iad.ocir.io/oci-cnp-dev'
mainClassName = 'com.oracle.oci.osb.Broker'

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public class AutonomousDatabaseInstance {
private String id;
private TYPE type;
private AutonomousDatabaseAdapter.DBWorkloadType dbWorkloadType;
private String displayName;
private int cpuCoreCount;
private int storageSizeInGBs;
Expand All @@ -30,10 +30,10 @@ public enum TYPE {
}


public AutonomousDatabaseInstance(String id, TYPE type, String displayName, int cpuCoreCount, int
public AutonomousDatabaseInstance(String id, AutonomousDatabaseAdapter.DBWorkloadType dbWorkloadType, String displayName, int cpuCoreCount, int
storageSizeInGBs, String dbName, AutonomousDatabaseAdapter.LicenseModel licenseModel, Map<String, String> freeformTags, LifecycleState lifecycleState) {
this.id = id;
this.type = type;
this.dbWorkloadType = dbWorkloadType;
this.displayName = displayName;
this.cpuCoreCount = cpuCoreCount;
this.storageSizeInGBs = storageSizeInGBs;
Expand All @@ -56,8 +56,8 @@ public String getId() {
return id;
}

public TYPE getType() {
return type;
public AutonomousDatabaseAdapter.DBWorkloadType getDbWorkloadType() {
return dbWorkloadType;
}

public String getDbName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,283 @@

package com.oracle.oci.osb.adapters.adb;

import com.oracle.bmc.Region;
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
import com.oracle.bmc.database.DatabaseClient;
import com.oracle.bmc.database.model.*;
import com.oracle.bmc.database.requests.*;
import com.oracle.bmc.database.responses.*;
import com.oracle.oci.osb.util.Constants;
import com.oracle.oci.osb.util.RequestUtil;
import com.oracle.oci.osb.util.Utils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.oracle.oci.osb.util.Utils.debugLog;
import static com.oracle.oci.osb.util.Utils.getLogger;

public class AutonomousDatabaseOCIClient implements AutoCloseable{

private static final Logger LOGGER = getLogger(AutonomousDatabaseOCIClient.class);

private DatabaseClient ociDBClient;

private String compartmentId;

AutonomousDatabaseOCIClient(AuthenticationDetailsProvider authProvider, String compartmentId) {
this(authProvider, compartmentId, Region.fromRegionId(System.getProperty(Constants.REGION_ID)));
}

private AutonomousDatabaseOCIClient(AuthenticationDetailsProvider authProvider, String compartmentId, Region regionId) {
this.compartmentId = compartmentId;
ociDBClient = new DatabaseClient(authProvider);
ociDBClient.setRegion(regionId);
}

/**
* Create an AD instance. The instance will be provisioned asynchronously
*
* @param displayName display name(mostly for console)
* @param dbName name of the database.
* @param type DBWorkload Type of the Database. OLTP or DW.
* @param cpuCount number of cpu cores required.
* @param StorageSize required storage size for DB in Terabytes.
* @param tags freeform tags.
* @param password password to be set for the DB admin user.
* @return AutonomousDatabase
*/
public AutonomousDatabaseInstance create(String displayName, String dbName, CreateAutonomousDatabaseBase.DbWorkload type,
int cpuCount, int StorageSize, Map<String, String> tags,
Map<String, Map<String, Object>> definedTags, String password,
boolean licenseIncluded) {
CreateAutonomousDatabaseDetails request = CreateAutonomousDatabaseDetails.builder()
.adminPassword(password)
.compartmentId(compartmentId)
.cpuCoreCount(cpuCount)
.dbWorkload(type)
.dataStorageSizeInTBs(StorageSize)
.dbName(dbName)
.displayName(displayName)
.freeformTags(tags)
.definedTags(definedTags)
.licenseModel(licenseIncluded ? CreateAutonomousDatabaseDetails
.LicenseModel.LicenseIncluded : CreateAutonomousDatabaseDetails.LicenseModel
.BringYourOwnLicense)
.build();
CreateAutonomousDatabaseResponse response = ociDBClient.createAutonomousDatabase
(CreateAutonomousDatabaseRequest.builder().createAutonomousDatabaseDetails(request).build());

return buildADInstance(response.getAutonomousDatabase());
}

/**
* Update an AD Instance. Update will be done asynchronously. If the param
* values are empty or if they already match the existing value then update
* is skipped for those values. If none of the params have any change then
* this simply returns without doing any update.
*
* @param adOCID OCID of the AD instance to be updated.
* @param displayName new display name.
* @param cpuCount new number of CPU core.
* @param StorageSize new DB storage size in Terabytes.
* @param tags new freeform tags.
* @return AutonomousDatabase
*/
public AutonomousDatabaseInstance update(String adOCID, String displayName, int cpuCount, int StorageSize,
Map<String, String> tags, Map<String, Map<String, Object>> definedTags) {
AutonomousDatabase ad = getADInstance(adOCID);
UpdateAutonomousDatabaseDetails.Builder reqBuilder = UpdateAutonomousDatabaseDetails.builder();

//Check if update required
boolean updateRequired = false;
if (!Utils.isNullOrEmptyString(displayName) && !ad.getDisplayName().equals(displayName)) {
reqBuilder = reqBuilder.displayName(displayName);
debugLog(LOGGER, "DisplayName to be updated.from:%s;to:%s", Level.FINE, ad.getDisplayName(), displayName);
updateRequired = true;
}
if (cpuCount > 0 && ad.getCpuCoreCount() != cpuCount) {
reqBuilder = reqBuilder.cpuCoreCount(cpuCount);
debugLog(LOGGER, "CpuCoreCount to be updated.from:%s;to:%s", Level.FINE, ad.getCpuCoreCount()
.toString(), Integer.toString(cpuCount));
updateRequired = true;
}
if (StorageSize > 0 && ad.getDataStorageSizeInTBs() != StorageSize) {
reqBuilder = reqBuilder.dataStorageSizeInTBs(StorageSize);
debugLog(LOGGER, "StorageSize to be updated.from:%s;to:%s", Level.FINE, ad.getDataStorageSizeInTBs()
.toString(), Integer.toString(StorageSize));
updateRequired = true;
}
if (tags != null && tags.entrySet().size() > 0 && !tags.equals(ad.getFreeformTags())) {
reqBuilder = reqBuilder.freeformTags(tags);
debugLog(LOGGER, "tags to be updated.from:%s;to:%s", Level.FINE, ad.getFreeformTags(), tags);
updateRequired = true;
}
if (definedTags != null && definedTags.entrySet().size() > 0 && !definedTags.equals(ad.getDefinedTags())) {
reqBuilder = reqBuilder.definedTags(definedTags);
debugLog(LOGGER, "Defined tags to be updated.from:%s;to:%s", Level.FINE, ad.getDefinedTags(), definedTags);
updateRequired = true;
}
if (!updateRequired) {
throw new AutonomousDatabaseAdapter.UpdateNotRequiredException();
}

UpdateAutonomousDatabaseDetails request = reqBuilder.build();
UpdateAutonomousDatabaseResponse response = ociDBClient.updateAutonomousDatabase
(UpdateAutonomousDatabaseRequest.builder().autonomousDatabaseId(adOCID)
.updateAutonomousDatabaseDetails(request).build());
return buildADInstance(response.getAutonomousDatabase());
}

/**
* Get details of an AD instance.
* @param adOCID OCID of the AD instance to be updated.
* @return AutonomousDatabase
*/
public AutonomousDatabaseInstance get(String adOCID) {
return buildADInstance(getADInstance(adOCID));
}

/**
* Delete an AD instance. The operation will be asynchronously.
*
* @param adOCID OCID of the AD instance to be deleted.
*/
public void delete(String adOCID) {
DeleteAutonomousDatabaseRequest request = DeleteAutonomousDatabaseRequest.builder().autonomousDatabaseId
(adOCID).build();
ociDBClient.deleteAutonomousDatabase(request);
}

/**
* Update DB ADMIN password.
*
* @param password new DB ADMIN password.
* @return AutonomousDatabase
*/
public AutonomousDatabaseInstance changePassword(String password) {
UpdateAutonomousDatabaseDetails request = UpdateAutonomousDatabaseDetails.builder().adminPassword(password)
.build();
UpdateAutonomousDatabaseResponse response = ociDBClient.updateAutonomousDatabase
(UpdateAutonomousDatabaseRequest.builder().updateAutonomousDatabaseDetails(request).build());
return buildADInstance(response.getAutonomousDatabase());
}

/**
* Download the credential/configuration files for connecting to an AD
* instance. The files are base64 encoded and converted as strings.
*
* @param adID OCID of the AD instance.
* @param dbName name of the database.
* @param wPassword password to set for the Oracle wallet that is
* created for this request.
* @return Map with filename/attribute name as keys and filename/attribute
* base64 encoded contents as values.
* @throws IOException if downloading credential zip file fails.
*/
public Map<String, String> getCredentials(String adID, String dbName, String wPassword) throws IOException {
GenerateAutonomousDatabaseWalletDetails adbWalletDetails = GenerateAutonomousDatabaseWalletDetails.builder()
.password(wPassword).build();
GenerateAutonomousDatabaseWalletResponse adbWalletResponse = ociDBClient.generateAutonomousDatabaseWallet(
GenerateAutonomousDatabaseWalletRequest.builder()
.generateAutonomousDatabaseWalletDetails(adbWalletDetails)
.autonomousDatabaseId(adID)
.build());
return ADBUtils.generateCredentialsMap(dbName, adbWalletResponse.getInputStream());
}

/**
* Fetch the list of all AD with a specific display name in a given OCI
* compartment.
*
* @param compartmentId OCID of the Compartment.
* @param displayName display name to filter the AD instances.
* @return List of ADB instance details.
*/
public List<AutonomousDatabaseInstance> listInstances(String compartmentId, String displayName) {
ListAutonomousDatabasesRequest.Builder reqBuilder = ListAutonomousDatabasesRequest.builder().compartmentId
(compartmentId);
if (displayName != null && !displayName.isEmpty()) {
reqBuilder.displayName(displayName);
}
ListAutonomousDatabasesRequest request = reqBuilder.build();
ListAutonomousDatabasesResponse response = ociDBClient.listAutonomousDatabases(request);
List<AutonomousDatabaseInstance> autonomousDatabaseInstanceList = new ArrayList<>();
response.getItems().forEach((adwSummary) -> autonomousDatabaseInstanceList.add(buildADInstance(adwSummary)));

return autonomousDatabaseInstanceList;
}

public interface AutonomousDatabaseOCIClient extends AutoCloseable {
AutonomousDatabaseInstance create(String displayName, String dbName, int cpuCount, int StorageSize, Map<String,
String> tags, Map<String, Map<String, Object>> definedTags, String password, boolean licenseIncluded);
public void close() {
ociDBClient.close();
}

AutonomousDatabaseInstance update(String instanceOCID, String displayName, int cpuCount, int StorageSize,
Map<String, String> tags, Map<String, Map<String, Object>> definedTags);
private AutonomousDatabase getADInstance(String adOCID) {
GetAutonomousDatabaseRequest request = GetAutonomousDatabaseRequest.builder().autonomousDatabaseId(adOCID)
.build();
GetAutonomousDatabaseResponse response = ociDBClient.getAutonomousDatabase(request);
return response.getAutonomousDatabase();
}

AutonomousDatabaseInstance get(String instanceOCID);
private AutonomousDatabaseInstance buildADInstance(AutonomousDatabaseSummary summary) {
if (summary == null) {
return null;
} else {
return new AutonomousDatabaseInstance(summary.getId(),
getDBWorkloadType(summary.getDbWorkload().getValue()),
summary.getDisplayName(),
summary.getCpuCoreCount(),
summary.getDataStorageSizeInTBs(),
summary.getDbName(),
getADBLicenseType(summary.getLicenseModel()),
summary.getFreeformTags(),
AutonomousDatabaseInstance.lifecycleState(summary.getLifecycleState().getValue()));
}
}

void delete(String instanceOCID);
private AutonomousDatabaseInstance buildADInstance(AutonomousDatabase adbInstance) {
if (adbInstance == null) {
return null;
} else {
return new AutonomousDatabaseInstance(adbInstance.getId(),
getDBWorkloadType(adbInstance.getDbWorkload().getValue()),
adbInstance.getDisplayName(),
adbInstance.getCpuCoreCount(),
adbInstance.getDataStorageSizeInTBs(),
adbInstance.getDbName(),
getADBLicenseType(adbInstance.getLicenseModel()),
adbInstance.getFreeformTags(),
AutonomousDatabaseInstance.lifecycleState(adbInstance.getLifecycleState().getValue()));
}
}

void close();
private AutonomousDatabaseAdapter.DBWorkloadType getDBWorkloadType (String dbWorkloadType) {
if (dbWorkloadType.equalsIgnoreCase(AutonomousDatabase.DbWorkload.Oltp.getValue())) {
return AutonomousDatabaseAdapter.DBWorkloadType.ATP;
} else {
return AutonomousDatabaseAdapter.DBWorkloadType.ADW;
}
}

Map<String, String> getCredentials(String atpId, String dbName, String wPassword) throws IOException;
private AutonomousDatabaseAdapter.LicenseModel getADBLicenseType(AutonomousDatabaseSummary.LicenseModel
sdkLicenseModel){
switch (sdkLicenseModel) {
case BringYourOwnLicense: return AutonomousDatabaseAdapter.LicenseModel.BYOL;
case LicenseIncluded: return AutonomousDatabaseAdapter.LicenseModel.NEW;
default: return AutonomousDatabaseAdapter.LicenseModel.UNKNOWN;
}
}

List<AutonomousDatabaseInstance> listInstances(String compartmentId, String displayName);
private AutonomousDatabaseAdapter.LicenseModel getADBLicenseType(AutonomousDatabase.LicenseModel
adwLicenseModel){
switch (adwLicenseModel) {
case BringYourOwnLicense: return AutonomousDatabaseAdapter.LicenseModel.BYOL;
case LicenseIncluded: return AutonomousDatabaseAdapter.LicenseModel.NEW;
default: return AutonomousDatabaseAdapter.LicenseModel.UNKNOWN;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@
*/
public class ADWServiceAdapter extends AutonomousDatabaseAdapter {

@Override
protected AutonomousDatabaseOCIClient getOCIClient(AuthenticationDetailsProvider authProvider, String
compartmentId) {
return new ADWServiceOCIClient(authProvider, compartmentId);
}

@Override
protected String getInstanceTypeString() {
return AutonomousDatabaseInstance.TYPE.ADW.name();
return AutonomousDatabaseAdapter.DBWorkloadType.ADW.name();
}

@Override
Expand Down
Loading

0 comments on commit d5e0040

Please sign in to comment.