Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for API publish to bintray and github . Also versioning API changes #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 88 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ apply plugin: 'org.sonarqube'
apply plugin: 'nebula.rpm'
apply plugin: 'nebula.deb'
apply plugin: "com.github.hierynomus.license"
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'com.jfrog.bintray'
//apply plugin: 'nebula.lint'

// rpm/deb package variables
Expand All @@ -17,21 +19,42 @@ def _arch = 'x86_64'
def _os = 'LINUX'
def _release = 1
def _sourcePaths=[]
def apiVersion = ''

def getCurrentTimestamp(){
new Date().format("MM-dd-yyyy_hh-mm")
}

def updateVersionProperties() {
def buildInfoFile = file('src/main/resources/buildInfo.properties')
String buildInfoProp = buildInfoFile.getText('UTF-8')
println "updating version to '${version}' in ${buildInfoFile}"
buildInfoProp = buildInfoProp.replaceAll(/buildInfo\.version=.*/, "buildInfo.version=${version}")
buildInfoFile.write(buildInfoProp, 'UTF-8')
println "updating docker tag to '${dockerTag}' in ${buildInfoFile}"
buildInfoProp = buildInfoProp.replaceAll(/buildInfo\.tag=.*/, "buildInfo.tag=${dockerTag}")
buildInfoFile.write(buildInfoProp, 'UTF-8')
println "updating build date to '${getCurrentTimestamp()}' in ${buildInfoFile}"
buildInfoProp = buildInfoProp.replaceAll(/buildInfo\.date=.*/, "buildInfo.date=${getCurrentTimestamp()}")
buildInfoFile.write(buildInfoProp, 'UTF-8')
}

sourceCompatibility = 1.8
version = "${version}"
dockerTag = "${dockerTag}"
group = 'com.dell.isg.smi'
apiVersion = 'api-'+"${version}"

buildscript {
ext {
springVersion = '4.3.6.RELEASE'
springBootVersion = '1.5.1.RELEASE'
springCloudVersion = 'Camden.SR5'
generatedAsciidoc = file("${buildDir}/docs/apidocs/asciidoc/generated")
}
repositories {
mavenLocal()
maven {url "${artifactory_contextUrl}/libs-release"}
mavenCentral()
maven {url "https://plugins.gradle.org/m2/"}
}
dependencies {
Expand All @@ -41,6 +64,9 @@ buildscript {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.1"
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.13.1"
//classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.15'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}

Expand Down Expand Up @@ -75,33 +101,38 @@ jar {
baseName = 'service-powerthermal-monitoring'
}

allprojects {
updateVersionProperties()
}

repositories {
mavenLocal()
maven {
url "${artifactory_contextUrl}/libs-release"
}
mavenCentral()
}


dependencies {
compile 'com.dell.isg.smi:adapter-server:1.0.55'
compile 'com.dell.isg.smi:commons-elm:1.0.76'
compile 'com.dell.isg.smi:commons-utilities:1.0.32'
compile 'com.dell.isg.smi:commons-model:1.0.89'
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile 'org.springframework.cloud:spring-cloud-starter-consul-all'
compile "org.springframework.boot:spring-boot-starter-actuator"
compile 'org.springframework.cloud:spring-cloud-starter-consul-all'
compile "org.springframework:spring-web"
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'
compile group: "io.springfox", name: "springfox-swagger2", version: "2.6.1"
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.6.1'
compile group: 'org.samba.jcifs', name: 'jcifs', version: '1.3.15'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.5.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.5.0'
testCompile group: 'io.springfox', name:'springfox-staticdocs', version: '2.5.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}

testCompile('org.springframework.boot:spring-boot-starter-test')
test {
systemProperties 'property': 'value'
systemProperty 'staticdocs.outputDir', generatedAsciidoc
}

license {
Expand Down Expand Up @@ -229,3 +260,49 @@ task dependencySourcesZip(type: Zip, dependsOn: 'buildSourcePathsArray' ) {

from _sourcePaths
}

asciidoctor {
dependsOn test
sources {
include 'api-*.adoc'
}
backends = ['pdf']
attributes = [
doctype: 'book',
toc: 'left',
toclevels: '2',
numbered: '',
sectlinks: '',
sectanchors: '',
hardbreaks: '',
generated: generatedAsciidoc
]
}

bintrayUpload.dependsOn asciidoctor

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
filesSpec {
from file(asciidoctor.outputDir.path + '/pdf')
into '.'
}
dryRun = false
publish = true
override = false
pkg {
repo = "${bintrayRepo}"
name = apiVersion
userOrg = "${bintrayUserOrg}"
desc = 'Swagger API for Power Thermal Monitoring Service.'
licenses = ['Apache-2.0']
vcsUrl = "${bintrayVcsUrl}"
publicDownloadNumbers = true
version {
name = apiVersion
desc = 'apidoc'
vcsTag = 'master'
}
}
}
13 changes: 10 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
version=1.0.0
version=1.0
dockerTag=devel
artifactory_contextUrl=https://gtie-artifactory.us.dell.com/artifactory
buildInfo.licenseControl.runChecks=true
buildInfo.licenseControl.autoDiscover=true
buildInfo.build.name=com.dell.isg.aps:service-powerthermal-monitoring
buildInfo.build.name=com.dell.isg.aps:service-powerthermal-monitoring
systemProp.sonar.host.url=https://sonarqube.com
systemProp.sonar.organization=rackhd-smi
systemProp.sonar.login=##sonarqubeLogin-placeholder##
bintrayRepo=docs
bintrayUserOrg=rackhd
bintrayVcsUrl=https://bintray.com/rackhd/docs/apidoc
bintrayUser=##bintray-user-placeholder##
bintrayApiKey=##bintray-api-key-placeholder##
5 changes: 5 additions & 0 deletions src/docs/asciidoc/api-powerthremal-monitor-v1.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include::{generated}/overview.adoc[]
include::readme.adoc[]
include::{generated}/paths.adoc[]
include::{generated}/definitions.adoc[]
include::misc.adoc[]
10 changes: 10 additions & 0 deletions src/docs/asciidoc/misc.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Licensing
---------

This docker microservice is available under the
http://www.apache.org/licenses/LICENSE-2.0.txt[Apache 2.0 License].

Support
--------

Slack Channel: codecommunity.slack.com
72 changes: 72 additions & 0 deletions src/docs/asciidoc/readme.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Purpose
~~~~~~~

Power and Thermal Microservice collect power monitoring and consumption on compute node using industry standard WS-Management - WSMAN Protocol.

Power and Thermal monitoring for hardware resources in a datacenter environment is one of the major challenges for hardware administrator in converged and hyper converged environment. Administrators want to manage the power consumption by nodes or by rack.
Setting power capping on an individual node or set of nodes will ensure the power consumption is under control and monitored.
This Dell Server Power and Thermal Microservice will enable an administrator to monitor and manage power and thermal consumption by node or set of nodes within their racks.

The microservice is available at dockerhub as a docker image to download and run.

How to Use
~~~~~~~~~~

A docker container for this service is available at: https://hub.docker.com/r/rackhd/dell-powerthermal-monitoring/

....
sudo docker run -p 0.0.0.0:46019:46019 --name dell-powerthermal-monitoring -d rackhd/dell-powerthermal-monitoring:latest
....

The service can also start up to bootstrap its configuration from consul. More information about registration with and using advanced configuration settings provided by a Consul K/V store can be found in the online help.

Example Post
++++++++++++

POST - /api/1.0/server/powerthermal
....
{
"password": "string",
"serverAddress": "string",
"userName": "string"
}
....

PUT - /api/1.0/server/powerthermal
....

{
"enableCapping": true,
"password": "string",
"powerCap": 0,
"serverAddress": "string",
"userName": "string"
}
....

POST - /api/1.0/server/powerthermal/all
....
[
{
"password": "string",
"serverAddress": "string",
"userName": "string"
}
]
....

PUT - /api/1.0/server/powerthermal/all
....

{
"enableCapping": true,
"powerCap": 0,
"servers": [
{
"password": "string",
"serverAddress": "string",
"userName": "string"
}
]
}
....
78 changes: 78 additions & 0 deletions src/main/java/com/dell/isg/aps/powerthermal/BuildInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Copyright � 2017 DELL Inc. or its subsidiaries. All Rights Reserved.
*/
package com.dell.isg.aps.powerthermal;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;


@ConfigurationProperties(prefix = "buildInfo")
@PropertySource({
"classpath:buildInfo.properties"
})
@Component
public class BuildInfo {

public BuildInfo() {
super();
}

private String apiVersion = "1.0";

private String version;

private String tag;

private String date;

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getTag() {
return tag;
}

public void setTag(String tag) {
this.tag = tag;
}

public String getDate() {
return date;
}

public void setDate(String date) {
this.date = date;
}

public String getApiVersion() {
return apiVersion;
}

public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}

@Override
public String toString() {
StringBuffer versionStr = new StringBuffer();
versionStr.append("API Version :" +apiVersion+"\r\n");
versionStr.append("Release Version :" +version+"\r\n");
versionStr.append("Release Tag :" +tag+"\r\n");
versionStr.append("Release Date :" +date+"\r\n");

return versionStr.toString();
}






}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
*/
package com.dell.isg.aps.powerthermal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;

import com.dell.isg.aps.powerthermal.common.UriConstants;
import com.google.common.base.Predicates;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
Expand All @@ -33,14 +28,12 @@ public static void main(String[] args) {
SpringApplication.run(ServicePowerThermalMonitoringApplication.class, args);
}

@Autowired
private BuildInfo buildInfo;

@Bean
public Docket anewsApipi() {
return new Docket(DocumentationType.SWAGGER_2).groupName("powerthermal").apiInfo(apiInfo()).select().paths(regex("/api.*")).build();
}


private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("SMI Microservice : Power and Thermal ").description("Power and Thermal Microservice collect power monitoring and consumption on compute node using industry standard WS-Management - WSMAN Protocol").termsOfServiceUrl("http://www.dell.com/smi/powermonitoring").license("Dell SMI License Version 1.0").licenseUrl("www.dell.com/smi").version("1.0 dev").build();
return new Docket(DocumentationType.SWAGGER_2).groupName("powerthermal").apiInfo(new ApiInfoBuilder().title("SMI Microservice : Power and Thermal ").version(buildInfo.toString()).build()).select().paths(regex("/api.*")).build();
}

}
Loading