mirror of
				https://gitee.com/BDWare/ypk-deploy-tool
				synced 2025-11-04 06:32:15 +00:00 
			
		
		
		
	add simple-ypk-packer
This commit is contained in:
		
							parent
							
								
									e1e8a393c5
								
							
						
					
					
						commit
						9eb1102a66
					
				@ -7,7 +7,7 @@
 | 
			
		||||
        mavenCentral()
 | 
			
		||||
    }
 | 
			
		||||
    dependencies {
 | 
			
		||||
        classpath "org.bdware.bdcontract:ypk-deploy-tool:0.4.0"
 | 
			
		||||
        classpath "org.bdware.bdcontract:ypk-deploy-tool:0.5.0"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
//....
 | 
			
		||||
@ -20,9 +20,7 @@ task deploy(dependsOn: ["xxx"]) {
 | 
			
		||||
2) 配置`./xxx/deployconfig.json`文件。
 | 
			
		||||
参数说明:
 | 
			
		||||
 | 
			
		||||
`host`为运行了bdagent的服务端的ip
 | 
			
		||||
 | 
			
		||||
`agentPort`为端口。
 | 
			
		||||
`agentAddress`为运行了bdagent的服务端的ip:port
 | 
			
		||||
 | 
			
		||||
`privateKey/publicKey`为有部署权限的一组SM2KeyPair
 | 
			
		||||
 | 
			
		||||
@ -31,8 +29,7 @@ task deploy(dependsOn: ["xxx"]) {
 | 
			
		||||
`deployconfig.json`配置示例:
 | 
			
		||||
```json
 | 
			
		||||
{
 | 
			
		||||
  "host": "192.168.x.x",
 | 
			
		||||
  "agentPort": 18000,
 | 
			
		||||
  "agentAddress": "192.168.x.x:18000",
 | 
			
		||||
  "privateKey": "5895c18430dd...",
 | 
			
		||||
  "publicKey": "04d1924329f72ced14...",
 | 
			
		||||
  "ypkPath":  "/path/to/todeploy.ypk",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										24
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								build.gradle
									
									
									
									
									
								
							@ -4,10 +4,9 @@ plugins {
 | 
			
		||||
    id 'maven-publish'
 | 
			
		||||
    id 'signing'
 | 
			
		||||
}
 | 
			
		||||
group 'org.bdware.bdcontract'
 | 
			
		||||
version '0.4.0'
 | 
			
		||||
group "org.bdware.bdcontract"
 | 
			
		||||
version "0.5.2"
 | 
			
		||||
sourceCompatibility = 1.8
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    mavenCentral()
 | 
			
		||||
    mavenLocal()
 | 
			
		||||
@ -24,6 +23,25 @@ dependencies {
 | 
			
		||||
    testImplementation 'junit:junit:4.13.2'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
task copyLibs(type: Copy, dependsOn: [':ypk-deploy-tool:jar']) {
 | 
			
		||||
    from configurations.runtimeClasspath
 | 
			
		||||
    into "./build/output/libs/"
 | 
			
		||||
}
 | 
			
		||||
task copyScript(type: Copy) {
 | 
			
		||||
    from "./docker/javarun.sh"
 | 
			
		||||
    from "./docker/docker-compose/deployentry.json"
 | 
			
		||||
    into "./build/output/"
 | 
			
		||||
}
 | 
			
		||||
task copyJar(type: Copy, dependsOn: [":ypk-deploy-tool:copyLibs",":ypk-deploy-tool:copyScript"]) {
 | 
			
		||||
    from "./build/libs/$project.name-${project.version}.jar"
 | 
			
		||||
    into "./build/output"
 | 
			
		||||
    rename { String fileName -> "${project.name}.jar" }
 | 
			
		||||
    doFirst {
 | 
			
		||||
        println "copyJar start"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
task classJar(type: Jar, dependsOn: classes) {
 | 
			
		||||
    classifier = "jar"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								docker/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								docker/Dockerfile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
FROM openjdk:8
 | 
			
		||||
 | 
			
		||||
ARG GOPRIVATE=bdware.org/*
 | 
			
		||||
ARG GOPROXY=https://goproxy.cn
 | 
			
		||||
 | 
			
		||||
LABEL maintainer="caihuaqian@internetapi.cn"
 | 
			
		||||
LABEL org.bdware.version="0.5.2"
 | 
			
		||||
LABEL org.bdware.version.isproduction="true"
 | 
			
		||||
LABEL org.bdware.release-date="2022-05-25"
 | 
			
		||||
 | 
			
		||||
COPY ./output /ypk-deploy-tool
 | 
			
		||||
WORKDIR /ypk-deploy-tool
 | 
			
		||||
VOLUME /ypk-deploy-tool/input
 | 
			
		||||
ENTRYPOINT ["java"]
 | 
			
		||||
CMD ["-Dfile.encoding=UTF-8", "-cp", "./libs/*:ypk-deploy-tool.jar", "org.bdware.ypkdeploy.Entry"]
 | 
			
		||||
							
								
								
									
										25
									
								
								docker/buildDocker.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								docker/buildDocker.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
if [ $# -gt 2 ]; then
 | 
			
		||||
  echo "too many arguments,\nusage: \$version [-,push,save] \$saveDir"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
version=$(awk '/version "[0-9]/ { sub(/[^"]*"/,"") ; sub(/".*$/,""); print $0 } ' build.gradle)
 | 
			
		||||
cp ./docker/Dockerfile ./build/Dockerfile
 | 
			
		||||
cd ./build
 | 
			
		||||
DOCKER_CLI_EXPERIMENTAL=enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if [ "$1" == "push" ]; then
 | 
			
		||||
  echo "push to docker hub"
 | 
			
		||||
  docker buildx build --platform linux/arm64/v8,linux/amd64 -t bdware/ypk-deploy-tool:$version ./ --push
 | 
			
		||||
elif [ "$1" == "save" ]; then
 | 
			
		||||
  echo "save to $2"
 | 
			
		||||
  docker buildx build --platform linux/arm64/v8 -t bdware/ypk-deploy-tool:arm_$version ./ --load
 | 
			
		||||
  docker save -o $2/ypk-deploy-tool-arm_$version.tar bdware/ypk-deploy-tool:arm_$version
 | 
			
		||||
  docker buildx build --platform linux/amd64 -t bdware/ypk-deploy-tool:amd64_$version ./ --load
 | 
			
		||||
  docker save -o $2/ypk-deploy-tool-amd64_$version.tar bdware/ypk-deploy-tool:amd64_$version
 | 
			
		||||
else
 | 
			
		||||
  echo "create at local"
 | 
			
		||||
  docker build -t bdware/ypk-deploy-tool:$version ./
 | 
			
		||||
  docker tag bdware/ypk-deploy-tool:$version bdware/ypk-deploy-tool:latest
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										14
									
								
								docker/docker-compose/deployentry.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								docker/docker-compose/deployentry.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
{
 | 
			
		||||
  "generateTasks": [
 | 
			
		||||
    {
 | 
			
		||||
      "isBatch": true,
 | 
			
		||||
      "dir": "./input/deploy",
 | 
			
		||||
      "template": "example.json.template",
 | 
			
		||||
      "commvar": "commonvar.json",
 | 
			
		||||
      "files": "examplefiles.json"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "deployTasks": [
 | 
			
		||||
    "./input/deploy/controlproxy/"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								docker/docker-compose/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								docker/docker-compose/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
version: "3"
 | 
			
		||||
 | 
			
		||||
services:
 | 
			
		||||
  ypk-deploy-tool:
 | 
			
		||||
    image: bdware/ypk-deploy-tool:0.5.2
 | 
			
		||||
    command: "-Dfile.encoding=UTF-8 -cp ./libs/*:ypk-deploy-tool.jar org.bdware.ypkdeploy.Entry ./deployentry.json"
 | 
			
		||||
    volumes:
 | 
			
		||||
      - ./input:/ypk-deploy-tool/input
 | 
			
		||||
      - ./deployentry.json:/ypk-deploy-tool/deployentry.json
 | 
			
		||||
							
								
								
									
										2
									
								
								docker/docker-compose/dockerun.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docker/docker-compose/dockerun.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
#! /bin/bash
 | 
			
		||||
docker run  -v `pwd`/deployentry.json:/ypk-deploy-tool/deployentry.json bdware/ypk-deploy-tool:0.5.2
 | 
			
		||||
							
								
								
									
										6
									
								
								docker/docker-compose/input/commonvar.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								docker/docker-compose/input/commonvar.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "_YPK_": "./input/ypk/Example-1.0.6.ypk",
 | 
			
		||||
  "___山西___": "",
 | 
			
		||||
  "_IP0_": "39.104.201.40",
 | 
			
		||||
  "_IP1_": "39.104.208.148"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								docker/docker-compose/input/example.json.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								docker/docker-compose/input/example.json.template
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
{
 | 
			
		||||
  "agentAddress": "_HOST_:18010",
 | 
			
		||||
  "privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
  "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
  "ypkPath": "_AUDIT_PROXY_YPK_",
 | 
			
		||||
  "killBeforeStart": "AutoAudit",
 | 
			
		||||
  "createParam": {
 | 
			
		||||
    "privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
    "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
    "repoName": "AuditProxy",
 | 
			
		||||
    "auditURI": "tcp://_HOST_:18051",
 | 
			
		||||
    "grafanaUrl": "jdbc:postgresql://iodlog.demo.internetapi.cn:5432/iodlog?useServerPrepStmts=true",
 | 
			
		||||
    "grafanaUserName": "iodlog",
 | 
			
		||||
    "grafanaPassword": "iodlog1107",
 | 
			
		||||
    "grafanaServicePort": 18055,
 | 
			
		||||
    "aceiServicePort": 18053
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								docker/docker-compose/input/examplefiles.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								docker/docker-compose/input/examplefiles.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
			
		||||
[
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_shanxi.json",
 | 
			
		||||
    "_HOST_": "_IP0_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_ty.json",
 | 
			
		||||
    "_HOST_": "_IP1_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_dt.json",
 | 
			
		||||
    "_HOST_": "_IP2_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_ty_xd.json",
 | 
			
		||||
    "_HOST_": "_IP3_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_ty_yz.json",
 | 
			
		||||
    "_HOST_": "_IP4_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_dt_yg.json",
 | 
			
		||||
    "_HOST_": "_IP5_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_dt_yz.json",
 | 
			
		||||
    "_HOST_": "_IP6_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_njust.json",
 | 
			
		||||
    "_HOST_": "_IP7_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_bit.json",
 | 
			
		||||
    "_HOST_": "_IP8_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_mpi.json",
 | 
			
		||||
    "_HOST_": "_IP9_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_weixing.json",
 | 
			
		||||
    "_HOST_": "_IP12_"
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										2
									
								
								docker/javarun.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docker/javarun.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
#! /bin/bash
 | 
			
		||||
java -Dfile.encoding=UTF-8 -cp ./libs/*:ypk-deploy-tool.jar org.bdware.ypkdeploy.Entry ./deployentry.json
 | 
			
		||||
							
								
								
									
										15
									
								
								docker/prepareVersion.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								docker/prepareVersion.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
version=$(awk '/version "[0-9]/ { sub(/[^"]*"/,"") ; sub(/".*$/,""); print $0 } ' build.gradle)
 | 
			
		||||
echo version extract from build.gradle '-->' $version
 | 
			
		||||
if [ $# -gt 0 ]; then
 | 
			
		||||
  time=$1
 | 
			
		||||
else
 | 
			
		||||
  time=$(date "+%Y-%m-%d")
 | 
			
		||||
fi
 | 
			
		||||
echo time is $time
 | 
			
		||||
 | 
			
		||||
cd ./docker/
 | 
			
		||||
awk ' {gsub(/version=\".*\"/,"version=\"'$version'\""); print $0;  } ' Dockerfile >Dockerfile.2
 | 
			
		||||
awk ' {gsub(/release-date=\".*\"/,"release-date=\"'$time'\""); print $0;  } ' Dockerfile.2 >Dockerfile
 | 
			
		||||
rm Dockerfile.2
 | 
			
		||||
							
								
								
									
										74
									
								
								src/main/java/org/bdware/ypkdeploy/DeployConfGenerator.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								src/main/java/org/bdware/ypkdeploy/DeployConfGenerator.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,74 @@
 | 
			
		||||
package org.bdware.ypkdeploy;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.JsonArray;
 | 
			
		||||
import com.google.gson.JsonElement;
 | 
			
		||||
import com.google.gson.JsonObject;
 | 
			
		||||
import com.google.gson.JsonParser;
 | 
			
		||||
 | 
			
		||||
import java.io.*;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
 | 
			
		||||
public class DeployConfGenerator {
 | 
			
		||||
    final static String TAG = "[DeployConfGenerator] ";
 | 
			
		||||
 | 
			
		||||
    public static String getFileContent(String path) {
 | 
			
		||||
        try {
 | 
			
		||||
            File file = new File(path);
 | 
			
		||||
            long fileLen = file.length();
 | 
			
		||||
            byte[] fileContent = new byte[(int) fileLen];
 | 
			
		||||
            FileInputStream in = new FileInputStream(file);
 | 
			
		||||
            in.read(fileContent);
 | 
			
		||||
            in.close();
 | 
			
		||||
            return new String(fileContent, StandardCharsets.UTF_8);
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void generateDeployConf(String dir, String template, String commonvar, String fileName) {
 | 
			
		||||
        String templateStr = getFileContent(dir + template);
 | 
			
		||||
        try {
 | 
			
		||||
            JsonObject commVar = JsonParser.parseReader(new FileReader(new File(dir, commonvar))).getAsJsonObject();
 | 
			
		||||
            String content = templateStr;
 | 
			
		||||
            File output = new File(dir, fileName);
 | 
			
		||||
            if (!output.getParentFile().exists())
 | 
			
		||||
                output.getParentFile().mkdirs();
 | 
			
		||||
            FileOutputStream fout = new FileOutputStream(output);
 | 
			
		||||
            for (String key : commVar.keySet()) {
 | 
			
		||||
                content = content.replaceAll(key, commVar.get(key).getAsString());
 | 
			
		||||
            }
 | 
			
		||||
            fout.write(content.getBytes(StandardCharsets.UTF_8));
 | 
			
		||||
            fout.close();
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void batchGenerateDeployConf(String dir, String template, String commonvar, String filesStr) {
 | 
			
		||||
        String templateStr = getFileContent(new File(dir, template).getAbsolutePath());
 | 
			
		||||
        try {
 | 
			
		||||
            JsonObject commVar = JsonParser.parseReader(new FileReader(new File(dir, commonvar))).getAsJsonObject();
 | 
			
		||||
            JsonArray files = JsonParser.parseReader(new FileReader(new File(dir, filesStr))).getAsJsonArray();
 | 
			
		||||
            for (JsonElement je : files) {
 | 
			
		||||
                JsonObject file = je.getAsJsonObject();
 | 
			
		||||
                File output = new File(dir, file.get("fileName").getAsString());
 | 
			
		||||
                if (!output.getParentFile().exists())
 | 
			
		||||
                    output.getParentFile().mkdirs();
 | 
			
		||||
                FileOutputStream fout = new FileOutputStream(output);
 | 
			
		||||
                String content = templateStr;
 | 
			
		||||
                for (String key : file.keySet()) {
 | 
			
		||||
                    if (!key.startsWith("_")) continue;
 | 
			
		||||
                    content = content.replaceAll(key, file.get(key).getAsString());
 | 
			
		||||
                }
 | 
			
		||||
                for (String key : commVar.keySet()) {
 | 
			
		||||
                    if (file.has(key)) continue;
 | 
			
		||||
                    content = content.replaceAll(key, commVar.get(key).getAsString());
 | 
			
		||||
                }
 | 
			
		||||
                fout.write(content.getBytes(StandardCharsets.UTF_8));
 | 
			
		||||
                fout.close();
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								src/main/java/org/bdware/ypkdeploy/Entry.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/main/java/org/bdware/ypkdeploy/Entry.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,57 @@
 | 
			
		||||
package org.bdware.ypkdeploy;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.Gson;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class Entry {
 | 
			
		||||
    static class DeployEntry {
 | 
			
		||||
        List<GenerateTask> generateTasks;
 | 
			
		||||
        List<String> deployTasks;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static class GenerateTask {
 | 
			
		||||
        public String dir;
 | 
			
		||||
        public String template;
 | 
			
		||||
        public String commvar;
 | 
			
		||||
        public String files;
 | 
			
		||||
        public boolean isBatch;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void goByStr(String str) {
 | 
			
		||||
        DeployEntry entry = new Gson().fromJson(str, DeployEntry.class);
 | 
			
		||||
        generateJson(entry.generateTasks);
 | 
			
		||||
        deployYpk(entry.deployTasks);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void deployYpk(List<String> deployTasks) {
 | 
			
		||||
        if (deployTasks == null) return;
 | 
			
		||||
        for (String deployTask : deployTasks) {
 | 
			
		||||
            HTTPTool.deploy(deployTask);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void generateJson(List<GenerateTask> generateTaskList) {
 | 
			
		||||
        if (generateTaskList == null) return;
 | 
			
		||||
        for (GenerateTask task : generateTaskList) {
 | 
			
		||||
            if (task.isBatch) {
 | 
			
		||||
                DeployConfGenerator.batchGenerateDeployConf(task.dir, task.template, task.commvar, task.files);
 | 
			
		||||
            } else
 | 
			
		||||
                DeployConfGenerator.generateDeployConf(task.dir, task.template, task.commvar, task.files);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void goByPath(String path) {
 | 
			
		||||
        String conf = DeployConfGenerator.getFileContent(path);
 | 
			
		||||
        goByStr(conf);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        System.out.println("Usage: set deployentry.json or ");
 | 
			
		||||
        if (args.length > 0)
 | 
			
		||||
            goByPath(args[0]);
 | 
			
		||||
        else
 | 
			
		||||
            goByPath("./deployentry.json");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -1,8 +1,6 @@
 | 
			
		||||
package org.bdware.ypkdeploy;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.Gson;
 | 
			
		||||
import com.google.gson.JsonElement;
 | 
			
		||||
import com.google.gson.JsonObject;
 | 
			
		||||
import com.google.gson.*;
 | 
			
		||||
import org.apache.http.HttpEntity;
 | 
			
		||||
import org.apache.http.client.methods.CloseableHttpResponse;
 | 
			
		||||
import org.apache.http.client.methods.HttpPost;
 | 
			
		||||
@ -11,6 +9,7 @@ import org.apache.http.entity.mime.MultipartEntityBuilder;
 | 
			
		||||
import org.apache.http.impl.client.CloseableHttpClient;
 | 
			
		||||
import org.apache.http.impl.client.HttpClients;
 | 
			
		||||
import org.bdware.client.ResultCallback;
 | 
			
		||||
import org.bdware.client.ws.Action;
 | 
			
		||||
import org.bouncycastle.crypto.CryptoException;
 | 
			
		||||
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
 | 
			
		||||
import org.zz.gmhelper.SM2KeyPair;
 | 
			
		||||
@ -18,45 +17,70 @@ import org.zz.gmhelper.SM2Util;
 | 
			
		||||
 | 
			
		||||
import java.io.*;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		||||
 | 
			
		||||
public class HTTPTool {
 | 
			
		||||
    final static String TAG = "[HTTPTool] ";
 | 
			
		||||
 | 
			
		||||
    static class DeployConfig {
 | 
			
		||||
        String agentAddress;
 | 
			
		||||
        //common config
 | 
			
		||||
        String host;
 | 
			
		||||
        String ypkPath;
 | 
			
		||||
        JsonElement createParam;
 | 
			
		||||
        String killBeforeStart;
 | 
			
		||||
        String privateKey;
 | 
			
		||||
        String publicKey;
 | 
			
		||||
        String killBeforeStart;
 | 
			
		||||
        JsonElement createParam;
 | 
			
		||||
        //config for http deploy
 | 
			
		||||
        int agentPort;
 | 
			
		||||
        String ypkPath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static void batchRun(String path, boolean restart) {
 | 
			
		||||
    public static void deployWithYpk(String deployConfigPath, String ypkPath) {
 | 
			
		||||
        DeployConfig config = null;
 | 
			
		||||
        try {
 | 
			
		||||
            config = new Gson().fromJson(new FileReader(path), DeployConfig.class);
 | 
			
		||||
            config = new Gson().fromJson(new FileReader(deployConfigPath), DeployConfig.class);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            System.out.println(TAG + " parse config failed!");
 | 
			
		||||
        }
 | 
			
		||||
        config.ypkPath = ypkPath;
 | 
			
		||||
        deployUseHttp(config);
 | 
			
		||||
        restart(config);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void deploy(String path) {
 | 
			
		||||
        DeployConfig config = null;
 | 
			
		||||
        File f = new File(path);
 | 
			
		||||
        try {
 | 
			
		||||
            if (f.isDirectory()) {
 | 
			
		||||
                File[] files = f.listFiles((f2) -> f2.getName().endsWith(".json"));
 | 
			
		||||
                if (files != null)
 | 
			
		||||
                    for (File file : files)
 | 
			
		||||
                        deploy(file.getAbsolutePath());
 | 
			
		||||
                return;
 | 
			
		||||
            } else {
 | 
			
		||||
                config = new Gson().fromJson(new FileReader(path), DeployConfig.class);
 | 
			
		||||
                deployUseHttp(config);
 | 
			
		||||
                restart(config);
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            System.out.println(TAG + " parse config failed!");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void restart(DeployConfig config) {
 | 
			
		||||
        SM2KeyPair keyPair = SM2KeyPair.fromJson(new Gson().toJson(config));
 | 
			
		||||
        SmartContractClientExt ext = new SmartContractClientExt(String.format("ws://%s:%d/SCIDE/SCExecutor", config.host, config.agentPort), keyPair);
 | 
			
		||||
        SmartContractClientExt ext = new SmartContractClientExt(String.format("ws://%s/SCIDE/SCExecutor", config.agentAddress), keyPair);
 | 
			
		||||
        ext.waitForConnect();
 | 
			
		||||
        ext.login();
 | 
			
		||||
        for (; !ext.isLoggedIn; )
 | 
			
		||||
            Thread.yield();
 | 
			
		||||
        AtomicInteger counter = new AtomicInteger(0);
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
 | 
			
		||||
            if (config.killBeforeStart != null)
 | 
			
		||||
                ext.kill(config.killBeforeStart, new ResultCallback() {
 | 
			
		||||
            if (config.killBeforeStart != null) ext.kill(config.killBeforeStart, new ResultCallback() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onResult(JsonObject r) {
 | 
			
		||||
                    System.out.println(TAG + r);
 | 
			
		||||
@ -71,23 +95,49 @@ public class HTTPTool {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
        File f = new File(config.ypkPath);
 | 
			
		||||
        ext.startContract(f.getName()
 | 
			
		||||
                .replaceAll(".zip", "")
 | 
			
		||||
                .replaceAll(".ypk", ""), config.createParam, new ResultCallback() {
 | 
			
		||||
        List<String> fileNames = new ArrayList<>();
 | 
			
		||||
        String contractName = f.getName().replaceAll(".zip", "").replaceAll(".ypk", "");
 | 
			
		||||
        ext.listProjects(true, new ResultCallback() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onResult(JsonObject r) {
 | 
			
		||||
                JsonArray array = JsonParser.parseString(r.get("data").getAsString()).getAsJsonArray();
 | 
			
		||||
                for (JsonElement je : array) {
 | 
			
		||||
                    String fileName = je.getAsString();
 | 
			
		||||
                    if (fileName.startsWith(contractName)) fileNames.add(fileName);
 | 
			
		||||
                }
 | 
			
		||||
                counter.incrementAndGet();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        for (; counter.get() == 1; )
 | 
			
		||||
            Thread.yield();
 | 
			
		||||
        Collections.sort(fileNames, new Comparator<String>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public int compare(String o1, String o2) {
 | 
			
		||||
                return getCount(o2, contractName) - getCount(o1, contractName);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        System.out.println(TAG + "startContract:" + fileNames.get(0));
 | 
			
		||||
        ext.startContract(fileNames.get(0), config.createParam, new ResultCallback() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onResult(JsonObject r) {
 | 
			
		||||
                System.out.println(TAG + r);
 | 
			
		||||
                counter.incrementAndGet();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        for (; counter.get() == 1; )
 | 
			
		||||
        for (; counter.get() == 2; )
 | 
			
		||||
            Thread.yield();
 | 
			
		||||
        ;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getCount(String dirName, String contractName) {
 | 
			
		||||
        String sub = dirName.substring(contractName.length());
 | 
			
		||||
        if (sub.startsWith("_")) {
 | 
			
		||||
            return Integer.valueOf(sub.substring(1));
 | 
			
		||||
        } else return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void deployUseHttp(DeployConfig config) {
 | 
			
		||||
        String url = "http://%s:%d/Upload?%s&sign=%s";
 | 
			
		||||
        String url = "http://%s/Upload?%s&sign=%s";
 | 
			
		||||
        File file = new File(config.ypkPath);
 | 
			
		||||
        String path = config.ypkPath;
 | 
			
		||||
        String argWithoutSig = "path=%s&fileName=%s&isPrivate=true&order=%d&count=%d&pubKey=%s";
 | 
			
		||||
@ -103,19 +153,15 @@ public class HTTPTool {
 | 
			
		||||
                CloseableHttpClient client = HttpClients.createDefault();
 | 
			
		||||
                String arg = String.format(argWithoutSig, "./", file.getName(), order, count, pubKey);
 | 
			
		||||
                String sign = ByteUtils.toHexString(SM2Util.sign(keyPair.getPrivateKeyParameter(), arg.getBytes(StandardCharsets.UTF_8)));
 | 
			
		||||
                String urlStr = String.format(url, config.host, config.agentPort, arg, sign);
 | 
			
		||||
                String urlStr = String.format(url, config.agentAddress, arg, sign);
 | 
			
		||||
                HttpPost httpPost = new HttpPost(urlStr);
 | 
			
		||||
                MultipartEntityBuilder builder = MultipartEntityBuilder.create();
 | 
			
		||||
                if (len == trunc)
 | 
			
		||||
                    builder.addBinaryBody(
 | 
			
		||||
                            "file", buff,
 | 
			
		||||
                            ContentType.APPLICATION_OCTET_STREAM, file.getName());
 | 
			
		||||
                    builder.addBinaryBody("file", buff, ContentType.APPLICATION_OCTET_STREAM, file.getName());
 | 
			
		||||
                else {
 | 
			
		||||
                    byte[] bu = new byte[len];
 | 
			
		||||
                    System.arraycopy(buff, 0, bu, 0, len);
 | 
			
		||||
                    builder.addBinaryBody(
 | 
			
		||||
                            "file", bu,
 | 
			
		||||
                            ContentType.APPLICATION_OCTET_STREAM, file.getName());
 | 
			
		||||
                    builder.addBinaryBody("file", bu, ContentType.APPLICATION_OCTET_STREAM, file.getName());
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                HttpEntity multipart = builder.build();
 | 
			
		||||
@ -123,15 +169,11 @@ public class HTTPTool {
 | 
			
		||||
                CloseableHttpResponse response = client.execute(httpPost);
 | 
			
		||||
                ByteArrayOutputStream bo = new ByteArrayOutputStream();
 | 
			
		||||
                response.getEntity().writeTo(bo);
 | 
			
		||||
                System.out.println("[YpkDeployTool] " + order
 | 
			
		||||
                        + " " + count + " " + bo);
 | 
			
		||||
                System.out.println(TAG + +order + " " + count + " " + bo);
 | 
			
		||||
            }
 | 
			
		||||
        } catch (IOException | CryptoException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        batchRun("./deployconfig.json", true);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -263,6 +263,23 @@ public class SmartContractClientExt extends SmartContractClient {
 | 
			
		||||
        if (cb != null) cb.onResult(jo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void listProjects(boolean isPrivate, ResultCallback resultCallback) {
 | 
			
		||||
        JsonObject request = new JsonObject();
 | 
			
		||||
        request.addProperty("action", "listProjects");
 | 
			
		||||
        request.addProperty("isPrivate", isPrivate);
 | 
			
		||||
        String requestID = System.currentTimeMillis() + "";
 | 
			
		||||
        request.addProperty("requestID", requestID);
 | 
			
		||||
        cbs.put(requestID, resultCallback);
 | 
			
		||||
        sendMsg(request.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Action
 | 
			
		||||
    public void onListProjects(JsonObject jo) {
 | 
			
		||||
        String responseID = jo.get("responseID").getAsString();
 | 
			
		||||
        ResultCallback cb = cbs.get(responseID);
 | 
			
		||||
        if (cb != null) cb.onResult(jo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Action
 | 
			
		||||
    public void onKillContractProcess(JsonObject jo) {
 | 
			
		||||
        if (!jo.has("responseID")) {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										30
									
								
								src/test/java/EntryTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/test/java/EntryTest.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
import org.bdware.ypkdeploy.Entry;
 | 
			
		||||
import org.bdware.ypkdeploy.HTTPTool;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
public class EntryTest {
 | 
			
		||||
    @Test
 | 
			
		||||
    public void generateAllConf() {
 | 
			
		||||
        Entry.main(new String[]{"./testinput/generateAllConf.json"});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void deployrouter() {
 | 
			
		||||
        Entry.main(new String[]{"./testinput/deployrouter.json"});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void deployap() {
 | 
			
		||||
        Entry.main(new String[]{"./testinput/deployrouter.json"});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void deploycp() {
 | 
			
		||||
        Entry.main(new String[]{"./testinput/deployrouter.json"});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void deployBDTest() {
 | 
			
		||||
        HTTPTool.deploy("./testinput/deploy/router/GlobalRouter-023.json");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								testinput/deploy/auditproxy.json.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								testinput/deploy/auditproxy.json.template
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
{
 | 
			
		||||
  "agentAddress": "_HOST_:18010",
 | 
			
		||||
  "privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
  "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
  "ypkPath": "_AUDIT_PROXY_YPK_",
 | 
			
		||||
  "killBeforeStart": "AutoAudit",
 | 
			
		||||
  "createParam": {
 | 
			
		||||
    "privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
    "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
    "repoName": "AuditProxy",
 | 
			
		||||
    "auditURI": "tcp://_HOST_:18051",
 | 
			
		||||
    "grafanaUrl": "jdbc:postgresql://iodlog.demo.internetapi.cn:5432/iodlog?useServerPrepStmts=true",
 | 
			
		||||
    "grafanaUserName": "iodlog",
 | 
			
		||||
    "grafanaPassword": "iodlog1107",
 | 
			
		||||
    "grafanaServicePort": 18055,
 | 
			
		||||
    "aceiServicePort": 18053
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								testinput/deploy/auditproxyfiles.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								testinput/deploy/auditproxyfiles.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
			
		||||
[
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_shanxi.json",
 | 
			
		||||
    "_HOST_": "_IP0_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_ty.json",
 | 
			
		||||
    "_HOST_": "_IP1_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_dt.json",
 | 
			
		||||
    "_HOST_": "_IP2_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_ty_xd.json",
 | 
			
		||||
    "_HOST_": "_IP3_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_ty_yz.json",
 | 
			
		||||
    "_HOST_": "_IP4_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_dt_yg.json",
 | 
			
		||||
    "_HOST_": "_IP5_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_sx_dt_yz.json",
 | 
			
		||||
    "_HOST_": "_IP6_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_njust.json",
 | 
			
		||||
    "_HOST_": "_IP7_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_bit.json",
 | 
			
		||||
    "_HOST_": "_IP8_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_mpi.json",
 | 
			
		||||
    "_HOST_": "_IP9_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./auditproxy/AuditProxy_weixing.json",
 | 
			
		||||
    "_HOST_": "_IP12_"
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										25
									
								
								testinput/deploy/commonvar.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								testinput/deploy/commonvar.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
{
 | 
			
		||||
  "_CONTROL_PROXY_YPK_": "/Users/huaqiancai/BDWare/datanet/ControlProxy/backend/build/ControlProxy-1.2.0.ypk",
 | 
			
		||||
  "_AUDIT_PROXY_YPK_": "./datanet-pack/ypk/AuditProxy-1.0.6.ypk",
 | 
			
		||||
  "_RRouter_YPK_": "/Users/huaqiancai/BDWare/datanet/datanet-router-bunndle/datanet-router-backend/build/Router-1.6.0.ypk",
 | 
			
		||||
  "_GRouter_YPK_": "/Users/huaqiancai/BDWare/datanet/datanet-router-bunndle/datanet-router-backend/build/GlobalRouter-1.6.0.ypk",
 | 
			
		||||
  "_CTROUTER_": "Router",
 | 
			
		||||
  "___山西___": "",
 | 
			
		||||
  "_IP0_": "39.104.201.40",
 | 
			
		||||
  "_IP1_": "39.104.208.148",
 | 
			
		||||
  "_IP2_": "39.104.201.243",
 | 
			
		||||
  "_IP3_": "39.104.208.223",
 | 
			
		||||
  "_IP4_": "39.104.200.95",
 | 
			
		||||
  "_IP5_": "39.104.202.247",
 | 
			
		||||
  "_IP6_": "39.104.209.178",
 | 
			
		||||
  "___工业___": "",
 | 
			
		||||
  "_IP7_": "39.104.209.15",
 | 
			
		||||
  "_IP8_": "39.104.207.76",
 | 
			
		||||
  "___药监___": "",
 | 
			
		||||
  "_IP9_": "39.104.204.44",
 | 
			
		||||
  "_IP10_": "39.104.209.158",
 | 
			
		||||
  "_IP11_": "39.104.208.114",
 | 
			
		||||
  "___卫星___": "",
 | 
			
		||||
  "_IP12_": "39.104.205.122",
 | 
			
		||||
  "_IP13_": "39.104.200.8"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								testinput/deploy/controlproxy.json.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								testinput/deploy/controlproxy.json.template
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
{
 | 
			
		||||
  "host": "_HOST_",
 | 
			
		||||
  "privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
  "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
  "ypkPath": "_CONTROL_PROXY_YPK_",
 | 
			
		||||
  "killBeforeStart": "ControlProxy",
 | 
			
		||||
  "createParam": {
 | 
			
		||||
    "privateKey": "4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b",
 | 
			
		||||
    "publicKey": "04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98",
 | 
			
		||||
    "prefix": "_PREFIX_",
 | 
			
		||||
    "router": "_CTROUTER_",
 | 
			
		||||
    "routerURI": "tcp://_HOST_:18041",
 | 
			
		||||
    "auditType": "OnlyHash"
 | 
			
		||||
  },
 | 
			
		||||
  "agentPort": 18010
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										38
									
								
								testinput/deploy/controlproxyfiles.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								testinput/deploy/controlproxyfiles.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,38 @@
 | 
			
		||||
[
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./controlproxy/CP_shanxi.json",
 | 
			
		||||
    "_HOST_": "_IP0_",
 | 
			
		||||
    "_PREFIX_": "shanxi",
 | 
			
		||||
    "_CTROUTER_": "GlobalRouter"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./controlproxy/CP_sx_ty.json",
 | 
			
		||||
    "_HOST_": "_IP1_",
 | 
			
		||||
    "_PREFIX_": "shanxi.taiyuan"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./controlproxy/CP_sx_dt.json",
 | 
			
		||||
    "_HOST_": "_IP2_",
 | 
			
		||||
    "_PREFIX_": "shanxi.datong"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./controlproxy/CP_sx_ty_xd.json",
 | 
			
		||||
    "_HOST_": "_IP3_",
 | 
			
		||||
    "_PREFIX_": "shanxi.taiyuan.xiaodian"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./controlproxy/CP_sx_ty_yj.json",
 | 
			
		||||
    "_HOST_": "_IP4_",
 | 
			
		||||
    "_PREFIX_": "shanxi.taiyuan.yingze"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./controlproxy/CP_sx_dt_yg.json",
 | 
			
		||||
    "_HOST_": "_IP5_",
 | 
			
		||||
    "_PREFIX_": "shanxi.datong.yungang"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./controlproxy/CP_sx_dt_yz.json",
 | 
			
		||||
    "_HOST_": "_IP6_",
 | 
			
		||||
    "_PREFIX_": "shanxi.datong.yunzhou"
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										19
									
								
								testinput/deploy/router.json.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								testinput/deploy/router.json.template
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
{
 | 
			
		||||
  "agentAddress": "_HOST_:18010",
 | 
			
		||||
  "privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
  "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
  "ypkPath": "_RRouter_YPK_",
 | 
			
		||||
  "killBeforeStart": "_CTROUTER_",
 | 
			
		||||
  "createParam": {
 | 
			
		||||
    "auditProxyAddress": "tcp://_HOST_:18051",
 | 
			
		||||
    "controlProxyAddress": "ws://_HOST_:18010",
 | 
			
		||||
    "repositoryAddress": "tcp://_HOST_:18031",
 | 
			
		||||
    "name": "_ROUTERNAME_",
 | 
			
		||||
    "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
    "privateKey":"d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
    "doId": "_PREFIX_",
 | 
			
		||||
    "routerAddress": "tcp://_HOST_:18041",
 | 
			
		||||
    "upperRouterAddress": "tcp://_HOST2_:18041",
 | 
			
		||||
    "scheme":"irp"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								testinput/deploy/router/GlobalRouter-023.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								testinput/deploy/router/GlobalRouter-023.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
{
 | 
			
		||||
  "agentAddress": "023.node.internetapi.cn:21130",
 | 
			
		||||
  "privateKey": "e85ce2f4d8882ff343d32ce42adde91d09e29c321452dd4ef9f07ebe76d1c6a5",
 | 
			
		||||
  "publicKey": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926",
 | 
			
		||||
  "ypkPath": "/Users/huaqiancai/BDWare/datanet/datanet-router-bunndle/datanet-router-backend/build/GlobalRouter-1.6.0.ypk",
 | 
			
		||||
  "killBeforeStart": "GlobalRouter",
 | 
			
		||||
  "createParam": {
 | 
			
		||||
    "auditProxyAddress": "tcp://39.104.204.44:18051",
 | 
			
		||||
    "controlProxyAddress": "ws://39.104.209.15:21130",
 | 
			
		||||
    "repositoryAddress": "tcp://39.104.204.44:18031",
 | 
			
		||||
    "name": "数瑞测试网",
 | 
			
		||||
    "publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
 | 
			
		||||
    "privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
 | 
			
		||||
    "doId": "bdtest",
 | 
			
		||||
    "routerAddress": "tcp://39.104.209.15:21162",
 | 
			
		||||
    "upperRouterAddress": "tcp://_HOST2_:18041",
 | 
			
		||||
    "scheme": "irp"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										76
									
								
								testinput/deploy/routerfiles.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								testinput/deploy/routerfiles.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,76 @@
 | 
			
		||||
[
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/GlobalRouter-sx.json",
 | 
			
		||||
    "_HOST_": "_IP0_",
 | 
			
		||||
    "_PREFIX_": "shanxi",
 | 
			
		||||
    "_CTROUTER_": "GlobalRouter",
 | 
			
		||||
    "_ROUTERNAME_": "山西能源数联网",
 | 
			
		||||
    "_RRouter_YPK_": "_GRouter_YPK_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/Router_ty.json",
 | 
			
		||||
    "_HOST_": "_IP1_",
 | 
			
		||||
    "_HOST2_": "_IP0_",
 | 
			
		||||
    "_PREFIX_": "shanxi.taiyuan",
 | 
			
		||||
    "_ROUTERNAME_": "山西太原节点"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/Router_dt.json",
 | 
			
		||||
    "_HOST_": "_IP2_",
 | 
			
		||||
    "_HOST2_": "_IP0_",
 | 
			
		||||
    "_PREFIX_": "shanxi.datong",
 | 
			
		||||
    "_ROUTERNAME_": "山西大同节点"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/Router_ty_xd.json",
 | 
			
		||||
    "_HOST_": "_IP3_",
 | 
			
		||||
    "_HOST2_": "_IP1_",
 | 
			
		||||
    "_PREFIX_": "shanxi.taiyuan.xiaodian",
 | 
			
		||||
    "_ROUTERNAME_": "太原小店区节点"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/Router_ty_yz.json",
 | 
			
		||||
    "_HOST_": "_IP4_",
 | 
			
		||||
    "_HOST2_": "_IP1_",
 | 
			
		||||
    "_PREFIX_": "shanxi.taiyuan.yingze",
 | 
			
		||||
    "_ROUTERNAME_": "太原迎泽区节点"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/Router_dt_yg.json",
 | 
			
		||||
    "_HOST_": "_IP5_",
 | 
			
		||||
    "_HOST2_": "_IP2_",
 | 
			
		||||
    "_PREFIX_": "shanxi.datong.yungang",
 | 
			
		||||
    "_ROUTERNAME_": "大同云岗区节点"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/Router_dt_yz.json",
 | 
			
		||||
    "_HOST_": "_IP6_",
 | 
			
		||||
    "_HOST2_": "_IP2_",
 | 
			
		||||
    "_PREFIX_": "shanxi.datong.yunzhou",
 | 
			
		||||
    "_ROUTERNAME_": "大同云州区节点"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/GlobalRouter-njust.json",
 | 
			
		||||
    "_HOST_": "_IP7_",
 | 
			
		||||
    "_PREFIX_": "njust",
 | 
			
		||||
    "_CTROUTER_": "GlobalRouter",
 | 
			
		||||
    "_ROUTERNAME_": "5G工业数联网",
 | 
			
		||||
    "_RRouter_YPK_": "_GRouter_YPK_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/GlobalRouter-mpi.json",
 | 
			
		||||
    "_HOST_": "_IP9_",
 | 
			
		||||
    "_PREFIX_": "mpi",
 | 
			
		||||
    "_CTROUTER_": "GlobalRouter",
 | 
			
		||||
    "_ROUTERNAME_": "药监数联网",
 | 
			
		||||
    "_RRouter_YPK_": "_GRouter_YPK_"
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fileName": "./router/GlobalRouter-wx.json",
 | 
			
		||||
    "_HOST_": "_IP12_",
 | 
			
		||||
    "_PREFIX_": "wx",
 | 
			
		||||
    "_CTROUTER_": "GlobalRouter",
 | 
			
		||||
    "_ROUTERNAME_": "卫星数联网",
 | 
			
		||||
    "_RRouter_YPK_": "_GRouter_YPK_"
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								testinput/deployentry.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								testinput/deployentry.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
{
 | 
			
		||||
  "generateTasks": [
 | 
			
		||||
    {
 | 
			
		||||
      "isBatch": true,
 | 
			
		||||
      "dir": "./testinput/deploy",
 | 
			
		||||
      "template": "controlproxy.json.template",
 | 
			
		||||
      "commvar": "commonvar.json",
 | 
			
		||||
      "files": "controlproxyfiles.json"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "isBatch": true,
 | 
			
		||||
      "dir": "./testinput/deploy",
 | 
			
		||||
      "template": "router.json.template",
 | 
			
		||||
      "commvar": "commonvar.json",
 | 
			
		||||
      "files": "routerfiles.json"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "isBatch": true,
 | 
			
		||||
      "dir": "./testinput/deploy",
 | 
			
		||||
      "template": "auditproxy.json.template",
 | 
			
		||||
      "commvar": "commonvar.json",
 | 
			
		||||
      "files": "auditproxyfiles.json"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "deployTasks": [
 | 
			
		||||
    "./testinput/deploy/controlproxy2/"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								testinput/deployrouter.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								testinput/deployrouter.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "generateTasks": [
 | 
			
		||||
  ],
 | 
			
		||||
  "deployTasks": [
 | 
			
		||||
    "./testinput/deploy/router/GlobalRouter-wx.json"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								testinput/generateAllConf.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								testinput/generateAllConf.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
{
 | 
			
		||||
  "generateTasks": [
 | 
			
		||||
    {
 | 
			
		||||
      "isBatch": true,
 | 
			
		||||
      "dir": "./testinput/deploy",
 | 
			
		||||
      "template": "controlproxy.json.template",
 | 
			
		||||
      "commvar": "commonvar.json",
 | 
			
		||||
      "files": "controlproxyfiles.json"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "isBatch": true,
 | 
			
		||||
      "dir": "./testinput/deploy",
 | 
			
		||||
      "template": "router.json.template",
 | 
			
		||||
      "commvar": "commonvar.json",
 | 
			
		||||
      "files": "routerfiles.json"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "isBatch": true,
 | 
			
		||||
      "dir": "./testinput/deploy",
 | 
			
		||||
      "template": "auditproxy.json.template",
 | 
			
		||||
      "commvar": "commonvar.json",
 | 
			
		||||
      "files": "auditproxyfiles.json"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "deployTasks": [
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user