Skip to content

Commit

Permalink
feat(oraclebmcs): Add Oracle BMCS Storage Service provider (#230)
Browse files Browse the repository at this point in the history
Note that we manually download our SDK and add to classpath in our gradle build script. We did this in clouddriver too. This will be fixed once
our SDK is available on Maven central - soon(ish).

Also note that due to the Front50 classpath containing Jersey 1 (brought in by kork IIRC?) we've had to not use our SDK's Jersey 2 based storage
client and instead create a minimal Jersey 1 implementation. Hopefully this can be improved upon in the future either by bumping kork to use
Jersey 2?
  • Loading branch information
simonlord authored and lwander committed May 12, 2017
1 parent b617135 commit fb3e0d1
Show file tree
Hide file tree
Showing 8 changed files with 448 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ out/
vendor/
.bundle/
*.iml
.idea
.idea

front50-oracle-bmcs/bmcs-sdk
58 changes: 58 additions & 0 deletions front50-oracle-bmcs/front50-oracle-bmcs.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
class DownloadTask extends DefaultTask {
@Input
String sourceUrl

@OutputFile
File target

@TaskAction
void download() {
ant.get(src: sourceUrl, dest: target)
}
}

final File sdkDownloadLocation = project.file('build/sdkdownload')
final File sdkLocation = project.file('build/bmcs-sdk')

// Oracle BMCS SDK isn't published to any maven repo (yet!), so we manually download, unpack and add to compile deps
task fetchSdk(type: DownloadTask) {
sourceUrl = 'https://github.com/oracle/bmcs-java-sdk/releases/download/v1.2.5/oracle-bmcs-java-sdk.zip'
target = sdkDownloadLocation
}

task unpackSdk(type: Sync) {
dependsOn('fetchSdk')
from zipTree(tasks.fetchSdk.target)
into sdkLocation
include "**/*.jar"
exclude "**/*-sources.jar"
exclude "**/*-javadoc.jar"
exclude "apidocs/**"
exclude "examples/**"
exclude "**/*jackson*.jar"
exclude "**/*jersey*.jar"
exclude "**/hk2*.jar"
exclude "**/*guava*.jar"
exclude "**/commons*.jar"
exclude "**/aopalliance*.jar"
exclude "**/javassist*.jar"
exclude "**/slf*.jar"
exclude "**/osgi*.jar"
exclude "**/validation*.jar"
exclude "**/jsr305*.jar"
}

task cleanSdk(type: Delete) {
delete sdkLocation, sdkDownloadLocation
}

tasks.clean.dependsOn('cleanSdk')
tasks.compileJava.dependsOn('unpackSdk')

dependencies {
compile project(":front50-core")

compile fileTree(sdkLocation)

testCompile project(":front50-test")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2017 Oracle America, Inc.
*
* The contents of this file are subject to the Apache License Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* If a copy of the Apache License Version 2.0 was not distributed with this file,
* You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.html
*/
package com.netflix.spinnaker.front50.config;

import com.netflix.spinnaker.front50.model.OracleBMCSStorageService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;

@Configuration
@ConditionalOnExpression("${spinnaker.oraclebmcs.enabled:false}")
@EnableConfigurationProperties(OracleBMCSProperties.class)
public class OracleBMCSConfig extends CommonStorageServiceDAOConfig {

@Bean
public OracleBMCSStorageService oracleBMCSStorageService(OracleBMCSProperties oracleBMCSProperties) throws IOException {
OracleBMCSStorageService oracleBMCSStorageService = new OracleBMCSStorageService(oracleBMCSProperties);
oracleBMCSStorageService.ensureBucketExists();
return oracleBMCSStorageService;
}

@Bean
@ConditionalOnMissingBean(RestTemplate.class)
public RestTemplate restTemplate() {
return new RestTemplate();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2017 Oracle America, Inc.
*
* The contents of this file are subject to the Apache License Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* If a copy of the Apache License Version 2.0 was not distributed with this file,
* You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.html
*/
package com.netflix.spinnaker.front50.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("spinnaker.oraclebmcs")
public class OracleBMCSProperties {

private String bucketName = "_spinnaker_front50_data";
private String namespace;
private String compartmentId;
private String region = "us-phoenix-1";
private String userId;
private String fingerprint;
private String sshPrivateKeyFilePath;
private String tenancyId;


public String getBucketName() {
return bucketName;
}

public void setBucketName(String bucketName) {
this.bucketName = bucketName;
}

public String getNamespace() {
return namespace;
}

public void setNamespace(String namespace) {
this.namespace = namespace;
}

public String getCompartmentId() {
return compartmentId;
}

public void setCompartmentId(String compartmentId) {
this.compartmentId = compartmentId;
}

public String getRegion() {
return region;
}

public void setRegion(String region) {
this.region = region;
}

public String getUserId() {
return userId;
}

public void setUserId(String userId) {
this.userId = userId;
}

public String getFingerprint() {
return fingerprint;
}

public void setFingerprint(String fingerprint) {
this.fingerprint = fingerprint;
}

public String getSshPrivateKeyFilePath() {
return sshPrivateKeyFilePath;
}

public void setSshPrivateKeyFilePath(String sshPrivateKeyFilePath) {
this.sshPrivateKeyFilePath = sshPrivateKeyFilePath;
}

public String getTenancyId() {
return tenancyId;
}

public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2017 Oracle America, Inc.
*
* The contents of this file are subject to the Apache License Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* If a copy of the Apache License Version 2.0 was not distributed with this file,
* You can obtain one at https://www.apache.org/licenses/LICENSE-2.0.html
*/

package com.netflix.spinnaker.front50.model;


public class LastModified {
private Long lastModified = System.currentTimeMillis();

public Long getLastModified() {
return lastModified;
}

public void setLastModified(Long lastModified) {
this.lastModified = lastModified;
}
}
Loading

0 comments on commit fb3e0d1

Please sign in to comment.