Skip to content

Commit

Permalink
Merge pull request #1154 from WeBankPartners/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Roy Wu(伍健君) authored Oct 30, 2020
2 parents eae337a + 598baab commit 10f14c2
Show file tree
Hide file tree
Showing 25 changed files with 914 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target/
cmdb-core/data/
# Ignore the generated front-end resource
**/resources/static/
# Ignore the generated index.html
Expand Down
6 changes: 0 additions & 6 deletions cmdb-core/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,3 @@ cmdb:

#Effective ONLY when security-enabled set as true
whitelist-ip-address: 127.0.0.1
logging:
level:
root: INFO
com:
webank:
cmdb: INFO
2 changes: 1 addition & 1 deletion cmdb-core/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">

<property name="logPath" value="${CMDB_LOG_PATH:-./data/wecmdb/log}"/>
<property name="logPath" value="${CMDB_LOG_PATH:-/data/wecmdb/log}"/>
<property name="logFile" value="cmdb-core"/>

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
Expand Down
18 changes: 9 additions & 9 deletions cmdb-core/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ cmdb:
enabled: false
whitelist-ip-address: 127.0.0.1

logging:
level:
root: WARN
com:
webank:
cmdb: INFO
org:
hibernate:
SQL: INFO
#logging:
# level:
# root: WARN
# com:
# webank:
# cmdb: INFO
# org:
# hibernate:
# SQL: INFO
44 changes: 44 additions & 0 deletions cmdb-core/src/test/resources/logback-test-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">

<property name="logPath" value="${CMDB_LOG_PATH:-./target/data/wecmdb/log}"/>
<property name="logFile" value="cmdb-core"/>

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>

<jmxConfigurator/>

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %-48logger{48} - %msg%n</pattern>
</encoder>
</appender>

<appender name="rollingFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">

<File>${logPath}/${logFile}.log</File>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logPath}/${logFile}-%d{yyyyMMdd}.log
</FileNamePattern>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
<MaxHistory>30</MaxHistory>
</rollingPolicy>

<encoder>
<Pattern><![CDATA[%d{yyyy-MM-dd HH:mm:ss} %thread %-5level %-48logger{48} %msg%n]]>
</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>

<root level="info">
<!--
<appender-ref ref="console"/>
-->
<appender-ref ref="rollingFile"/>
</root>
</configuration>
162 changes: 90 additions & 72 deletions cmdb-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,81 +1,99 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.webank.cmdb</groupId>
<artifactId>cmdb</artifactId>
<version>${cmdb.version}</version>
</parent>
<parent>
<groupId>com.webank.cmdb</groupId>
<artifactId>cmdb</artifactId>
<version>${cmdb.version}</version>
</parent>

<artifactId>wecube-plugins-wecmdb</artifactId>
<packaging>jar</packaging>
<artifactId>wecube-plugins-wecmdb</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.webank.cmdb</groupId>
<artifactId>cmdb-core</artifactId>
<version>${cmdb.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependencies>
<dependency>
<groupId>com.webank.cmdb</groupId>
<artifactId>cmdb-core</artifactId>
<version>${cmdb.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>1.63</version>
</dependency>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx2048m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>

<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx2048m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
17 changes: 16 additions & 1 deletion cmdb-plugin/register.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<!-- 6.运行资源 - 描述部署运行本插件包需要的基础资源(如主机、虚拟机、容器、数据库等) -->
<resourceDependencies>
<docker imageName="{{REPOSITORY}}:{{VERSION}}" containerName="{{REPOSITORY}}-{{VERSION}}" portBindings="{{ALLOCATE_PORT}}:8081,{{MONITOR_PORT}}:18081" volumeBindings="{{BASE_MOUNT_PATH}}/wecmdb/log:/data/wecmdb/log,/etc/localtime:/etc/localtime" envVariables="DB_HOST={{DB_HOST}},DB_PORT={{DB_PORT}},DB_SCHEMA={{DB_SCHEMA}},DB_USER={{DB_USER}},DB_PWD={{DB_PWD}},JWT_SIGNING_KEY={{JWT_SIGNING_KEY}}"/>
<docker imageName="{{REPOSITORY}}:{{VERSION}}" containerName="{{REPOSITORY}}-{{VERSION}}" portBindings="{{ALLOCATE_PORT}}:8081,{{MONITOR_PORT}}:18081" volumeBindings="{{BASE_MOUNT_PATH}}/wecmdb/log:/data/wecmdb/log,/etc/localtime:/etc/localtime,{{BASE_MOUNT_PATH}}/certs:/data/certs" envVariables="DB_HOST={{DB_HOST}},DB_PORT={{DB_PORT}},DB_SCHEMA={{DB_SCHEMA}},DB_USER={{DB_USER}},DB_PWD={{DB_PWD}},JWT_SIGNING_KEY={{JWT_SIGNING_KEY}}"/>
<mysql schema="wecmdb_embedded" initFileName="init.sql" upgradeFileName="upgrade.sql"/>
</resourceDependencies>

Expand Down Expand Up @@ -142,5 +142,20 @@
</outputParameters>
</interface>
</plugin>
<plugin name="ci-data-attribute-update" targetPackage="" targetEntity="" registerName="" targetEntityFilterRule="">
<interface action="attribute-update" path="/wecmdb/data/update" filterRule="">
<inputParameters>
<parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">entityName</parameter>
<parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">guid</parameter>
<parameter datatype="string" required="Y" sensitiveData="N" mappingType="constant">attrName</parameter>
<parameter datatype="string" required="N" sensitiveData="N" mappingType="constant">attrVal</parameter>
</inputParameters>
<outputParameters>
<parameter datatype="string" sensitiveData="N" mappingType="context">guid</parameter>
<parameter datatype="string" sensitiveData="N" mappingType="context">errorCode</parameter>
<parameter datatype="string" sensitiveData="N" mappingType="context">errorMessage</parameter>
</outputParameters>
</interface>
</plugin>
</plugins>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import com.webank.cmdb.config.ApplicationProperties;
import com.webank.cmdb.config.DatabaseConfig;
import com.webank.cmdb.config.SpringAppConfig;
import com.webank.cmdb.config.SpringWebConfig;
import com.webank.plugins.wecmdb.config.PluginApplicationProperties;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
@ComponentScan({ "com.webank.plugins.wecmdb.service", "com.webank.plugins.wecmdb.controller", "com.webank.plugins.wecmdb.mvc", "com.webank.cmdb.config", "com.webank.cmdb.repository" })
@EnableConfigurationProperties({PluginApplicationProperties.class,ApplicationProperties.class})
@EnableEncryptableProperties
@ComponentScan({ "com.webank.plugins.wecmdb.propenc", "com.webank.plugins.wecmdb.service", "com.webank.plugins.wecmdb.controller", "com.webank.plugins.wecmdb.mvc", "com.webank.cmdb.config", "com.webank.cmdb.repository" })
@Import({ DatabaseConfig.class })
public class Application extends AbstractAnnotationConfigDispatcherServletInitializer {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.webank.plugins.wecmdb.config;

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

@ConfigurationProperties(prefix = "plugins")
public class PluginApplicationProperties {
private String propertyEncryptKeyPath;

public String getPropertyEncryptKeyPath() {
return propertyEncryptKeyPath;
}

public void setPropertyEncryptKeyPath(String propertyEncryptKeyPath) {
this.propertyEncryptKeyPath = propertyEncryptKeyPath;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ public OperateCiJsonResponse confirmBatchCiData(@RequestBody OperateCiDtoInputs
}
return response;
}

@PostMapping("/data/update")
@ResponseBody
public OperateCiJsonResponse updateCiData(@RequestBody OperateCiDataUpdateDtoInputs inputs) {
List<OperateCiDataUpdateDto> operateCiDataUpdateDtos = inputs.getInputs();
OperateCiJsonResponse response = new OperateCiJsonResponse();
List<ExceptionHolder> exceptionHolders = new ArrayList<ExceptionHolder>();
List<Map<String, Object>> results = wecubeAdapterService.updateCiDataByGuid(operateCiDataUpdateDtos, exceptionHolders);

if (exceptionHolders.size() > 0) {
response = OperateCiJsonResponse.errorWithData(String.format("Fail to update [%s] CIs, detail error in the data block", inputs), results);
} else {
response = OperateCiJsonResponse.okayWithData(results);
}
return response;
}

@PostMapping("/data/refresh")
@ResponseBody
Expand Down
Loading

0 comments on commit 10f14c2

Please sign in to comment.