[Agent] [Octopus] - caqa fix bugs
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -35,3 +35,4 @@ build/
|
|||||||
/agent-go/agent-go
|
/agent-go/agent-go
|
||||||
/cmii_operator/log/
|
/cmii_operator/log/
|
||||||
/cmii_operator/vendor/
|
/cmii_operator/vendor/
|
||||||
|
/cmii_operator/cqga/
|
||||||
|
|||||||
@@ -1946,9 +1946,12 @@ func (op *AgentOsOperator) installChronyByDockerExec(funcArgs []string) (bool, [
|
|||||||
"--name=chrony",
|
"--name=chrony",
|
||||||
"--restart=always",
|
"--restart=always",
|
||||||
"--detach",
|
"--detach",
|
||||||
|
"--cap-add=SYS_TIME",
|
||||||
"--publish=123:123/udp",
|
"--publish=123:123/udp",
|
||||||
"--env=NTP_SERVERS=\"ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com\"",
|
"--env=NTP_SERVERS=\"ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com\"",
|
||||||
"--env=LOG_LEVEL=0",
|
"--env=LOG_LEVEL=0",
|
||||||
|
"--env=TZ=Asia/Shanghai",
|
||||||
|
"--env=ENABLE_SYSCLK=true",
|
||||||
funcArgs[0] + ":8033/cmii/chronyd:0.4.3",
|
funcArgs[0] + ":8033/cmii/chronyd:0.4.3",
|
||||||
})
|
})
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ func (hOp *HarborOperator) SyncProjectExec(funcArgs []string) (bool, []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo cqga failed
|
||||||
octopusSourceRegistry := &model.Registry{
|
octopusSourceRegistry := &model.Registry{
|
||||||
Credential: &model.RegistryCredential{
|
Credential: &model.RegistryCredential{
|
||||||
AccessKey: "admin",
|
AccessKey: "admin",
|
||||||
@@ -264,24 +265,23 @@ func (hOp *HarborOperator) SyncProjectExec(funcArgs []string) (bool, []string) {
|
|||||||
Type: "basic",
|
Type: "basic",
|
||||||
},
|
},
|
||||||
Insecure: true,
|
Insecure: true,
|
||||||
ID: 7,
|
|
||||||
Name: OctopusSourceHarborName, // 源 Harbor 实例的注册表 ID,通常为 0
|
Name: OctopusSourceHarborName, // 源 Harbor 实例的注册表 ID,通常为 0
|
||||||
Type: "harbor",
|
Type: "harbor",
|
||||||
URL: strings.Split(hOp.SourceHarborHost, "/api")[0],
|
URL: strings.Split(hOp.SourceHarborHost, "/api")[0],
|
||||||
}
|
}
|
||||||
err := targetClient.NewRegistry(ctx, octopusSourceRegistry)
|
err := targetClient.NewRegistry(ctx, octopusSourceRegistry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, []string{
|
sprintf := fmt.Sprintf("[SyncProjectExec] - source endpoints create failed ! => %s", err.Error())
|
||||||
"[Harbor Sync Project ] - source endpoints create failed !",
|
log.Error(sprintf)
|
||||||
}
|
return false, []string{sprintf}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the real one for it's ID
|
// get the real one for it's ID
|
||||||
realOctopusSourceRegistry, err := targetClient.GetRegistryByName(ctx, OctopusSourceHarborName)
|
realOctopusSourceRegistry, err := targetClient.GetRegistryByName(ctx, OctopusSourceHarborName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, []string{
|
sprintf := fmt.Sprintf("[SyncProjectExec] - get target registry id failed ! => %s", err.Error())
|
||||||
"[Harbor Sync Project ] - source endpoints get failed !",
|
log.Error(sprintf)
|
||||||
}
|
return false, []string{sprintf}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建复制策略
|
// 创建复制策略
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"wdd.io/agent-go/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NetworkMetric struct {
|
type NetworkMetric struct {
|
||||||
@@ -165,6 +166,18 @@ func GetNetworkInfo() ([]NetworkInfo, error) {
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetLocalHostIP() string {
|
||||||
|
interfaceStatList, err := net.Interfaces()
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF("[GetLocalHostIP] -- error %s", err.Error())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.BeautifulPrint(interfaceStatList)
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func GetNetworkConnectionALl() []net.ConnectionStat {
|
func GetNetworkConnectionALl() []net.ConnectionStat {
|
||||||
|
|
||||||
connections, err := net.Connections("all")
|
connections, err := net.Connections("all")
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import (
|
|||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/klauspost/pgzip"
|
"github.com/klauspost/pgzip"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -137,6 +139,7 @@ func ImageTagFromSourceToTarget(sourceImageName, targetImageName string) bool {
|
|||||||
log.ErrorF("[ImageTagFromSourceToTarget] - from %s to %s error %s", sourceImageName, targetImageName, err.Error())
|
log.ErrorF("[ImageTagFromSourceToTarget] - from %s to %s error %s", sourceImageName, targetImageName, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.InfoF("[ImageTagFromSourceToTarget] - from %s to %s success!", sourceImageName, targetImageName)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +164,45 @@ func ImagePushToOctopusKindHarbor(targetImageName string) (pushResult io.ReadClo
|
|||||||
return pushResult
|
return pushResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ImageTagFromListAndPushToCHarbor(referenceImageList []string, targetHarborHost string) (errorPushImageNameList []string) {
|
||||||
|
|
||||||
|
for _, imageName := range referenceImageList {
|
||||||
|
// check image
|
||||||
|
cmiiImageFullName := imageName
|
||||||
|
if strings.HasPrefix(imageName, "cmii") {
|
||||||
|
cmiiImageFullName = CmiiHarborPrefix + imageName
|
||||||
|
}
|
||||||
|
|
||||||
|
targetProject := "cmii"
|
||||||
|
if strings.HasPrefix(imageName, "rancher") {
|
||||||
|
targetProject = "rancher"
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(imageName, "/") {
|
||||||
|
imageName = strings.Split(imageName, "/")[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
targetImageName := targetHarborHost + ":8033/" + targetProject + "/" + imageName
|
||||||
|
|
||||||
|
if ImageTagFromSourceToTarget(cmiiImageFullName, targetImageName) {
|
||||||
|
pushResult := ImagePushToOctopusKindHarbor(targetImageName)
|
||||||
|
if pushResult == nil {
|
||||||
|
errorPushImageNameList = append(errorPushImageNameList, cmiiImageFullName)
|
||||||
|
}
|
||||||
|
scanner := bufio.NewScanner(pushResult)
|
||||||
|
for scanner.Scan() {
|
||||||
|
|
||||||
|
}
|
||||||
|
log.InfoF("[ImageTagFromListAndPushToCHarbor] - push of %s success!", targetImageName)
|
||||||
|
} else {
|
||||||
|
errorPushImageNameList = append(errorPushImageNameList, cmiiImageFullName)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorPushImageNameList
|
||||||
|
}
|
||||||
|
|
||||||
func ImagePullFromCmiiHarbor(imageName string) (pullResult io.ReadCloser) {
|
func ImagePullFromCmiiHarbor(imageName string) (pullResult io.ReadCloser) {
|
||||||
pullResult, err := apiClient.ImagePull(context.TODO(), imageName, types.ImagePullOptions{
|
pullResult, err := apiClient.ImagePull(context.TODO(), imageName, types.ImagePullOptions{
|
||||||
All: false,
|
All: false,
|
||||||
@@ -185,18 +227,18 @@ func ImagePullFromCmiiHarborByMap(imageVersionMap map[string]string, silentMode
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImagePullFromFileJson(filePathName string) {
|
func ImagePullCMiiFromFileJson(filePathName string) {
|
||||||
|
|
||||||
readFile, err := os.ReadFile(filePathName)
|
readFile, err := os.ReadFile(filePathName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorF("[ImagePullFromFileJson] - file %s read error ! %s", filePathName, err.Error())
|
log.ErrorF("[ImagePullCMiiFromFileJson] - file %s read error ! %s", filePathName, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var resultMap map[string]string
|
var resultMap map[string]string
|
||||||
err = json.Unmarshal(readFile, &readFile)
|
err = json.Unmarshal(readFile, &readFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorF("[ImagePullFromFileJson] - file %s un marshal error ! %s", filePathName, err.Error())
|
log.ErrorF("[ImagePullCMiiFromFileJson] - file %s un marshal error ! %s", filePathName, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +309,53 @@ func ImagePullFromListAndCompressSplit(fullImageNameList []string, gzipFolder st
|
|||||||
return errorPullImageList, errorGzipImageList
|
return errorPullImageList, errorGzipImageList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ImageLoadFromFile(gzipFullPath string) bool {
|
||||||
|
openFile, err := os.OpenFile(gzipFullPath, 0, fs.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF("[ImageLoadFromFile] - failed to open file %s, error is %s", gzipFullPath, err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
loadResponse, err := apiClient.ImageLoad(context.TODO(), openFile, true)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF("[ImageLoadFromFile] - load error %s, error is %s", gzipFullPath, err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfoF("[ImageLoadFromFile] - load of %s, result is %s", gzipFullPath, strconv.FormatBool(loadResponse.JSON))
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(loadResponse.Body)
|
||||||
|
for scanner.Scan() {
|
||||||
|
line := scanner.Text()
|
||||||
|
fmt.Println(line)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func ImageLoadFromFolderPath(folderPath string) (errorLoadImageNameList []string) {
|
||||||
|
if !strings.HasSuffix(folderPath, "/") {
|
||||||
|
folderPath += "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
dirEntries, err := os.ReadDir(folderPath)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF("[ImageLoadFromFolderPath] - error read folder %s error is %s", folderPath, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// load gzip file
|
||||||
|
for _, dirEntry := range dirEntries {
|
||||||
|
if strings.HasSuffix(dirEntry.Name(), ".tar.gz") {
|
||||||
|
if !ImageLoadFromFile(folderPath + dirEntry.Name()) {
|
||||||
|
errorLoadImageNameList = append(errorLoadImageNameList, folderPath+dirEntry.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorLoadImageNameList
|
||||||
|
}
|
||||||
|
|
||||||
func ImageSaveToTarGZ(targetImageName, folderPathPrefix string) bool {
|
func ImageSaveToTarGZ(targetImageName, folderPathPrefix string) bool {
|
||||||
|
|
||||||
imageGetByName := ImageGetByName(targetImageName)
|
imageGetByName := ImageGetByName(targetImageName)
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ func TestImagePushToOctopusKindHarbor(t *testing.T) {
|
|||||||
fmt.Println("image push success!")
|
fmt.Println("image push success!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestImageLoadFromFile(t *testing.T) {
|
||||||
|
loadFromFile := ImageLoadFromFile("/root/octopus_image/cqga/cqga/cmlc=cmii=cmii-uav-user=5.2.0.tar.gz")
|
||||||
|
|
||||||
|
assert.Equal(t, loadFromFile, true, "image load error !")
|
||||||
|
}
|
||||||
|
|
||||||
func TestImageSaveToTarGZ(t *testing.T) {
|
func TestImageSaveToTarGZ(t *testing.T) {
|
||||||
image := "harbor.cdcyy.com.cn/cmii/cmii-uav-gateway:4.1.6-beta"
|
image := "harbor.cdcyy.com.cn/cmii/cmii-uav-gateway:4.1.6-beta"
|
||||||
|
|
||||||
@@ -147,3 +153,20 @@ func TestImagePruneAllCmiiImages(t *testing.T) {
|
|||||||
|
|
||||||
utils.BeautifulPrintListWithTitle(errorRemoveImageNameList, "CMII Image Prune Error")
|
utils.BeautifulPrintListWithTitle(errorRemoveImageNameList, "CMII Image Prune Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestImageTagFromSourceToTarget(t *testing.T) {
|
||||||
|
|
||||||
|
sourceImageName := "ossrs/srs:v5.0.195"
|
||||||
|
targetImageName := "harbor.wdd.io:8033/cmii/srs:v5.0.195"
|
||||||
|
|
||||||
|
if ImageTagFromSourceToTarget(sourceImageName, targetImageName) {
|
||||||
|
pushResult := ImagePushToOctopusKindHarbor(targetImageName)
|
||||||
|
defer pushResult.Close()
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(pushResult)
|
||||||
|
for scanner.Scan() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const OfflineImageGzipFolderPrefix = "/root/octopus_image/"
|
const OfflineImageGzipFolderPrefix = "/root/octopus_image/"
|
||||||
|
const OfflineDeployHarborHost = "harbor.wdd.io"
|
||||||
|
|
||||||
func FetchDemoImages(projectName string, gzipSplit bool) (errorPullImageList, errorGzipImageList []string) {
|
func FetchDemoImages(projectName string, gzipSplit bool) (errorPullImageList, errorGzipImageList []string) {
|
||||||
|
|
||||||
@@ -83,3 +84,34 @@ func FetchDependencyRepos(gzipSplit bool) (errorPullImageList, errorGzipImageLis
|
|||||||
return append(errorPullImageList, pull...), append(errorGzipImageList, gzipImageList...)
|
return append(errorPullImageList, pull...), append(errorGzipImageList, gzipImageList...)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadSplitGzipImageToTargetHarbor(projectName, targetHarborHost string) (errorLoadImageNameList, errorPushImageNameList []string) {
|
||||||
|
|
||||||
|
// list folder
|
||||||
|
projectGzipFolder := OfflineImageGzipFolderPrefix + projectName
|
||||||
|
errorLoadImageNameList = append(errorLoadImageNameList, ImageLoadFromFolderPath(projectGzipFolder)...)
|
||||||
|
// read from json
|
||||||
|
errorPushImageNameList = append(errorPushImageNameList, ImageTagFromListAndPushToCHarbor(Cmii520DemoImageList, targetHarborHost)...)
|
||||||
|
|
||||||
|
// re-tag
|
||||||
|
// push
|
||||||
|
|
||||||
|
// todo clean host and harbor
|
||||||
|
// check harbor exits
|
||||||
|
|
||||||
|
return errorLoadImageNameList, errorPushImageNameList
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadSplitDepGzipImageToTargetHarbor(targetHarborHost string) (errorLoadImageNameList []string, errorPushImageNameList []string) {
|
||||||
|
|
||||||
|
middle := OfflineImageGzipFolderPrefix + "middle/"
|
||||||
|
rke := OfflineImageGzipFolderPrefix + "rke/"
|
||||||
|
errorLoadImageNameList = append(errorLoadImageNameList, ImageLoadFromFolderPath(middle)...)
|
||||||
|
errorLoadImageNameList = append(errorLoadImageNameList, ImageLoadFromFolderPath(rke)...)
|
||||||
|
|
||||||
|
errorPushImageNameList = append(errorPushImageNameList, ImageTagFromListAndPushToCHarbor(MiddlewareAmd64, targetHarborHost)...)
|
||||||
|
errorPushImageNameList = append(errorPushImageNameList, ImageTagFromListAndPushToCHarbor(Rancher1204Amd64, targetHarborHost)...)
|
||||||
|
|
||||||
|
return errorLoadImageNameList, errorPushImageNameList
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,3 +22,17 @@ func TestFetchDependencyRepos(t *testing.T) {
|
|||||||
utils.BeautifulPrintListWithTitle(errorGzipImageList, "dep errorGzipImageList")
|
utils.BeautifulPrintListWithTitle(errorGzipImageList, "dep errorGzipImageList")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadSplitGzipImageToTargetHarbor(t *testing.T) {
|
||||||
|
errorLoadImageNameList, errorPushImageNameList := LoadSplitGzipImageToTargetHarbor("cqga", OfflineDeployHarborHost)
|
||||||
|
|
||||||
|
utils.BeautifulPrintListWithTitle(errorLoadImageNameList, "errorLoadImageNameList")
|
||||||
|
utils.BeautifulPrintListWithTitle(errorPushImageNameList, "errorPushImageNameList")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadSplitDepGzipImageToTargetHarbor(t *testing.T) {
|
||||||
|
errorLoadImageNameList, errorPushImageNameList := LoadSplitDepGzipImageToTargetHarbor(OfflineDeployHarborHost)
|
||||||
|
|
||||||
|
utils.BeautifulPrintListWithTitle(errorLoadImageNameList, "errorLoadImageNameList")
|
||||||
|
utils.BeautifulPrintListWithTitle(errorPushImageNameList, "errorPushImageNameList")
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,10 +21,13 @@ var MiddlewareAmd64 = []string{
|
|||||||
"kubernetesui/dashboard:v2.0.1",
|
"kubernetesui/dashboard:v2.0.1",
|
||||||
"kubernetesui/metrics-scraper:v1.0.4",
|
"kubernetesui/metrics-scraper:v1.0.4",
|
||||||
"ossrs/srs:v4.0-r3",
|
"ossrs/srs:v4.0-r3",
|
||||||
|
"ossrs/srs:v5.0.195",
|
||||||
"nginx:1.21.3",
|
"nginx:1.21.3",
|
||||||
"redis:6.0.20-alpine",
|
"redis:6.0.20-alpine",
|
||||||
"dyrnq/nfs-subdir-external-provisioner:v4.0.2",
|
"dyrnq/nfs-subdir-external-provisioner:v4.0.2",
|
||||||
"busybox:latest",
|
"busybox:latest",
|
||||||
|
"harbor.cdcyy.com.cn/cmii/cmii-live-operator:5.2.0",
|
||||||
|
"harbor.cdcyy.com.cn/cmii/cmii-srs-oss-adaptor:2023-SA",
|
||||||
}
|
}
|
||||||
|
|
||||||
var Rancher1204Amd64 = []string{
|
var Rancher1204Amd64 = []string{
|
||||||
@@ -91,3 +94,70 @@ var Rancher1204Amd64 = []string{
|
|||||||
"rancher/sonobuoy-sonobuoy:v0.16.3",
|
"rancher/sonobuoy-sonobuoy:v0.16.3",
|
||||||
"rancher/system-upgrade-controller:v0.6.2",
|
"rancher/system-upgrade-controller:v0.6.2",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Cmii520DemoImageList = []string{
|
||||||
|
"cmii-admin-data:5.2.0",
|
||||||
|
"cmii-admin-gateway:5.2.0",
|
||||||
|
"cmii-admin-user:5.2.0",
|
||||||
|
"cmii-app-release:4.2.0-validation",
|
||||||
|
"cmii-open-gateway:5.2.0",
|
||||||
|
"cmii-suav-supervision:5.2.0",
|
||||||
|
"cmii-uav-airspace:5.2.0",
|
||||||
|
"cmii-uav-alarm:5.2.0",
|
||||||
|
"cmii-uav-autowaypoint:4.1.6-cm-0828",
|
||||||
|
"cmii-uav-brain:5.2.0",
|
||||||
|
"cmii-uav-cloud-live:5.2.0",
|
||||||
|
"cmii-uav-clusters:5.2.0",
|
||||||
|
"cmii-uav-cms:5.2.0",
|
||||||
|
"cmii-uav-data-post-process:5.2.0",
|
||||||
|
"cmii-uav-depotautoreturn:4.2.0",
|
||||||
|
"cmii-uav-developer:5.2.0-25858",
|
||||||
|
"cmii-uav-device:5.2.0",
|
||||||
|
"cmii-uav-emergency:5.2.0",
|
||||||
|
"cmii-uav-gateway:5.2.0",
|
||||||
|
"cmii-uav-gis-server:5.2.0",
|
||||||
|
"cmii-uav-grid-datasource:5.2.0-24810",
|
||||||
|
"cmii-uav-grid-engine:5.1.0",
|
||||||
|
"cmii-uav-grid-manage:5.1.0",
|
||||||
|
"cmii-uav-industrial-portfolio:5.2.0-25268-12",
|
||||||
|
"cmii-uav-integration:5.2.0-25447",
|
||||||
|
"cmii-uav-kpi-monitor:5.2.0",
|
||||||
|
"cmii-uav-logger:5.2.0",
|
||||||
|
"cmii-uav-material-warehouse:5.2.0",
|
||||||
|
"cmii-uav-mission:5.2.0-25840",
|
||||||
|
"cmii-uav-mqtthandler:5.2.0-25340-1",
|
||||||
|
"cmii-uav-notice:5.2.0",
|
||||||
|
"cmii-uav-oauth:5.2.0",
|
||||||
|
"cmii-uav-process:5.2.0",
|
||||||
|
"cmii-uav-surveillance:5.2.0-21794",
|
||||||
|
"cmii-uav-threedsimulation:5.2.0",
|
||||||
|
"cmii-uav-tower:5.3.0",
|
||||||
|
"cmii-uav-user:5.2.0",
|
||||||
|
"cmii-uav-waypoint:5.2.0-011102",
|
||||||
|
"cmii-suav-platform-supervision:5.2.0",
|
||||||
|
"cmii-suav-platform-supervisionh5:5.2.0",
|
||||||
|
"cmii-uav-platform:5.2.0",
|
||||||
|
"cmii-uav-platform-ai-brain:5.2.0",
|
||||||
|
"cmii-uav-platform-armypeople:5.2.0-24538",
|
||||||
|
"cmii-uav-platform-base:5.2.0",
|
||||||
|
"cmii-uav-platform-cms-portal:5.2.0",
|
||||||
|
"cmii-uav-platform-detection:5.2.0",
|
||||||
|
"cmii-uav-platform-emergency-rescue:5.2.0",
|
||||||
|
"cmii-uav-platform-hljtt:5.2.0",
|
||||||
|
"cmii-uav-platform-jiangsuwenlv:4.1.3-jiangsu-0427",
|
||||||
|
"cmii-uav-platform-logistics:5.2.0",
|
||||||
|
"cmii-uav-platform-media:5.2.0",
|
||||||
|
"cmii-uav-platform-multiterminal:5.2.0",
|
||||||
|
"cmii-uav-platform-mws:5.2.0",
|
||||||
|
"cmii-uav-platform-oms:5.2.0",
|
||||||
|
"cmii-uav-platform-open:5.2.0",
|
||||||
|
"cmii-uav-platform-qingdao:4.1.6-24238-qingdao",
|
||||||
|
"cmii-uav-platform-qinghaitourism:4.1.0-21377-0508",
|
||||||
|
"cmii-uav-platform-security:4.1.6",
|
||||||
|
"cmii-uav-platform-securityh5:5.2.0",
|
||||||
|
"cmii-uav-platform-seniclive:5.2.0",
|
||||||
|
"cmii-uav-platform-share:5.2.0",
|
||||||
|
"cmii-uav-platform-splice:5.2.0",
|
||||||
|
"cmii-uav-platform-threedsimulation:5.2.0-21392",
|
||||||
|
"cmii-uav-platform-visualization:5.2.0",
|
||||||
|
}
|
||||||
|
|||||||
@@ -100,18 +100,18 @@ public class AppFuncScheduler {
|
|||||||
);
|
);
|
||||||
|
|
||||||
List<AppFunctionEnum> appFunctionEnumList = List.of(
|
List<AppFunctionEnum> appFunctionEnumList = List.of(
|
||||||
AppFunctionEnum.DEPLOY_CHRONY_SERVER,
|
// AppFunctionEnum.DEPLOY_CHRONY_SERVER,
|
||||||
AppFunctionEnum.DEPLOY_RKE
|
// AppFunctionEnum.DEPLOY_RKE
|
||||||
// AppFunctionEnum.DEPLOY_K8S_DASHBOARD,
|
// AppFunctionEnum.DEPLOY_K8S_DASHBOARD,
|
||||||
// AppFunctionEnum.DEPLOY_NFS,
|
// AppFunctionEnum.DEPLOY_NFS,
|
||||||
// AppFunctionEnum.DEPLOY_TEST_NFS,
|
// AppFunctionEnum.DEPLOY_TEST_NFS,
|
||||||
// AppFunctionEnum.DEPLOY_K8S_NAMESPACE,
|
// AppFunctionEnum.DEPLOY_K8S_NAMESPACE
|
||||||
// AppFunctionEnum.DEPLOY_K8S_PVC,
|
// AppFunctionEnum.DEPLOY_K8S_PVC,
|
||||||
// AppFunctionEnum.DEPLOY_K8S_MYSQL,
|
// AppFunctionEnum.DEPLOY_K8S_MYSQL,
|
||||||
// AppFunctionEnum.DEPLOY_K8S_REDIS,
|
// AppFunctionEnum.DEPLOY_K8S_REDIS,
|
||||||
// AppFunctionEnum.DEPLOY_K8S_MIDDLEWARES,
|
// AppFunctionEnum.DEPLOY_K8S_MIDDLEWARES,
|
||||||
// AppFunctionEnum.DEPLOY_INGRESS
|
// AppFunctionEnum.DEPLOY_INGRESS
|
||||||
// AppFunctionEnum.DEPLOY_FRONTEND
|
AppFunctionEnum.DEPLOY_FRONTEND
|
||||||
// AppFunctionEnum.DEPLOY_BACKEND
|
// AppFunctionEnum.DEPLOY_BACKEND
|
||||||
// AppFunctionEnum.DEPLOY_K8S_SRS
|
// AppFunctionEnum.DEPLOY_K8S_SRS
|
||||||
|
|
||||||
|
|||||||
@@ -96,9 +96,8 @@ public class BaseFuncScheduler {
|
|||||||
|
|
||||||
List<BaseFunctionEnum> masterNodeProcedureList = List.of(
|
List<BaseFunctionEnum> masterNodeProcedureList = List.of(
|
||||||
BaseFunctionEnum.DISABLE_SWAP,
|
BaseFunctionEnum.DISABLE_SWAP,
|
||||||
BaseFunctionEnum.DISABLE_SELINUX,
|
|
||||||
BaseFunctionEnum.SHUTDOWN_FIREWALL,
|
BaseFunctionEnum.SHUTDOWN_FIREWALL,
|
||||||
BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY
|
BaseFunctionEnum.DISABLE_SELINUX
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -132,10 +131,9 @@ public class BaseFuncScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<BaseFunctionEnum> masterNodeDurationTaskList = List.of(
|
List<BaseFunctionEnum> masterNodeDurationTaskList = List.of(
|
||||||
// BaseFunctionEnum.INSTALL_NFS_SERVER_ONLINE,
|
BaseFunctionEnum.INSTALL_DOCKER,
|
||||||
// BaseFunctionEnum.INSTALL_DOCKER,
|
BaseFunctionEnum.INSTALL_DOCKER_COMPOSE,
|
||||||
// BaseFunctionEnum.INSTALL_DOCKER_COMPOSE,
|
BaseFunctionEnum.MODIFY_DOCKER_CONFIG
|
||||||
// BaseFunctionEnum.MODIFY_DOCKER_CONFIG,
|
|
||||||
// BaseFunctionEnum.INSTALL_HARBOR
|
// BaseFunctionEnum.INSTALL_HARBOR
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import io.wdd.func.auto.beans.HarborFunctionEnum;
|
|||||||
import io.wdd.func.auto.beans.ProjectDeployContext;
|
import io.wdd.func.auto.beans.ProjectDeployContext;
|
||||||
import io.wdd.server.beans.po.ServerInfoPO;
|
import io.wdd.server.beans.po.ServerInfoPO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -182,8 +183,8 @@ public class HarborFuncScheduler {
|
|||||||
syncHarborArgList.add(masterNode.getServerIpInV4());
|
syncHarborArgList.add(masterNode.getServerIpInV4());
|
||||||
|
|
||||||
// second arg sourceHarborHost
|
// second arg sourceHarborHost
|
||||||
String sourceHarborHost = getIPv4Address();
|
// String sourceHarborHost = getIPv4Address();
|
||||||
syncHarborArgList.add(sourceHarborHost);
|
syncHarborArgList.add("harbor.wdd.io");
|
||||||
|
|
||||||
// third arg sync project name
|
// third arg sync project name
|
||||||
syncHarborArgList.add(projectDeployContext.getCurrentSynchronizingProject());
|
syncHarborArgList.add(projectDeployContext.getCurrentSynchronizingProject());
|
||||||
@@ -218,14 +219,16 @@ public class HarborFuncScheduler {
|
|||||||
String os = System
|
String os = System
|
||||||
.getProperty("os.name")
|
.getProperty("os.name")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
String devHarborSourceHost = "10.250.0.100";
|
// String devHarborSourceHost = "10.250.0.100";
|
||||||
|
String devHarborSourceHost = "20.4.16.200"; // cqga
|
||||||
if (os.contains("linux")) {
|
if (os.contains("linux")) {
|
||||||
try {
|
try {
|
||||||
InetAddress localhost = InetAddress.getLocalHost();
|
InetAddress localhost = InetAddress.getLocalHost();
|
||||||
|
|
||||||
|
|
||||||
if (localhost.getHostAddress() != null && !localhost
|
if (localhost.getHostAddress() != null && !localhost
|
||||||
.getHostAddress()
|
.getHostAddress()
|
||||||
.isEmpty()) {
|
.isEmpty() && !StringUtils.startsWith(localhost.getHostAddress(), "127")) {
|
||||||
return localhost.getHostAddress();
|
return localhost.getHostAddress();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ public class AcceptAgentInitInfo {
|
|||||||
"London",
|
"London",
|
||||||
7,
|
7,
|
||||||
"LosAngeles",
|
"LosAngeles",
|
||||||
7,
|
|
||||||
"Beijing",
|
|
||||||
8,
|
8,
|
||||||
"Paripark",
|
"Beijing",
|
||||||
9
|
9,
|
||||||
|
"Chongqing",
|
||||||
|
10
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
public static Set<String> ALL_SERVER_ARCH_INFO = new HashSet<>(
|
public static Set<String> ALL_SERVER_ARCH_INFO = new HashSet<>(
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
server:
|
server:
|
||||||
port: 9999
|
port: 9999
|
||||||
|
|
||||||
# shanghai 10.250.0.100
|
# shanghai 20.4.16.200
|
||||||
# local 10.250.0.100
|
# local 20.4.16.200
|
||||||
|
# cqga 20.4.16.200
|
||||||
spring:
|
spring:
|
||||||
main:
|
main:
|
||||||
allow-circular-references: true
|
allow-circular-references: true
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: 10.250.0.100
|
host: 20.4.16.200
|
||||||
port: 20672
|
port: 20672
|
||||||
username: boge
|
username: boge
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
@@ -23,7 +24,7 @@ spring:
|
|||||||
max-interval: 65000
|
max-interval: 65000
|
||||||
initial-interval: 65000
|
initial-interval: 65000
|
||||||
redis:
|
redis:
|
||||||
host: 10.250.0.100
|
host: 20.4.16.200
|
||||||
port: 21370
|
port: 21370
|
||||||
database: 0
|
database: 0
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
@@ -46,7 +47,7 @@ spring:
|
|||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://10.250.0.100:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
url: jdbc:mysql://20.4.16.200:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||||
username: boge
|
username: boge
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ import io.wdd.func.auto.service.AppFuncScheduler;
|
|||||||
import io.wdd.func.auto.service.BaseFuncScheduler;
|
import io.wdd.func.auto.service.BaseFuncScheduler;
|
||||||
import io.wdd.func.auto.service.HarborFuncScheduler;
|
import io.wdd.func.auto.service.HarborFuncScheduler;
|
||||||
import io.wdd.server.beans.po.ServerInfoPO;
|
import io.wdd.server.beans.po.ServerInfoPO;
|
||||||
import io.wdd.server.beans.request.ServerQueryEntity;
|
import io.wdd.server.beans.vo.ProjectServerVO;
|
||||||
|
import io.wdd.server.coreService.CoreProjectServerService;
|
||||||
import io.wdd.server.coreService.CoreServerService;
|
import io.wdd.server.coreService.CoreServerService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class TestBaseFuncScheduler {
|
public class TestBaseFuncScheduler {
|
||||||
@@ -27,37 +30,67 @@ public class TestBaseFuncScheduler {
|
|||||||
@Resource
|
@Resource
|
||||||
CoreServerService serverService;
|
CoreServerService serverService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CoreProjectServerService coreProjectServerService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRunProcedure() {
|
public void testRunProcedure() {
|
||||||
|
|
||||||
ProjectDeployContext projectDeployContext = new ProjectDeployContext();
|
ProjectDeployContext projectDeployContext = new ProjectDeployContext();
|
||||||
|
|
||||||
// projectDeployContext.setProjectId(1716372290994155522L); // vultr
|
Long projectServerId = 1751084188582440961L;// cqga
|
||||||
projectDeployContext.setProjectId(1722453318596550657L); // lappro
|
// Long projectServerId = 1722453318596550657L;// lappro
|
||||||
|
|
||||||
|
projectDeployContext.setProjectId(projectServerId);
|
||||||
|
|
||||||
|
|
||||||
ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
|
// ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
|
||||||
// exsi server
|
// // exsi server
|
||||||
serverQueryEntity.setServerName("Chengdu-amd64-99");
|
//// serverQueryEntity.setServerName("Chengdu-amd64-99");
|
||||||
|
// // lappro
|
||||||
|
//// serverQueryEntity.setServerName("Chengdu-amd64-65");
|
||||||
|
//
|
||||||
|
// // cqga
|
||||||
|
// serverQueryEntity.setServerName();
|
||||||
|
// ServerInfoPO serverInfoPO = serverService
|
||||||
|
// .serverGetByPage(serverQueryEntity)
|
||||||
|
// .getRecords()
|
||||||
|
// .get(0);
|
||||||
|
|
||||||
// lappro
|
String serverName = "Chongqing-amd64-01"; // cgga
|
||||||
// serverQueryEntity.setServerName("Chengdu-amd64-65");
|
// String serverName = "Chengdu-amd64-99"; // lap pro
|
||||||
|
|
||||||
ServerInfoPO serverInfoPO = serverService
|
ProjectServerVO projectServerVO = coreProjectServerService.projectServerOne(projectServerId);
|
||||||
.serverGetByPage(serverQueryEntity)
|
|
||||||
.getRecords()
|
|
||||||
.get(0);
|
|
||||||
|
|
||||||
|
Optional<ServerInfoPO> serverInfoPOOptional = projectServerVO.getBindingServerList().stream().filter(
|
||||||
|
serverInfoPO -> StringUtils.contains(serverInfoPO.getServerName(), serverName)
|
||||||
|
).findFirst();
|
||||||
|
|
||||||
|
if (serverInfoPOOptional.isEmpty()) {
|
||||||
|
System.out.printf("project of %s server of %s is empty", projectServerVO, serverName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerInfoPO serverInfoPO = serverInfoPOOptional.get();
|
||||||
System.out.println("serverInfoPO = " + serverInfoPO);
|
System.out.println("serverInfoPO = " + serverInfoPO);
|
||||||
|
|
||||||
projectDeployContext.setMasterNode(serverInfoPO);
|
projectDeployContext.setMasterNode(serverInfoPO);
|
||||||
|
|
||||||
|
// baseFuncScheduler.runProcedure(projectDeployContext);
|
||||||
|
|
||||||
baseFuncScheduler.runProcedure(projectDeployContext);
|
// projectServerVO.getBindingServerList().forEach(
|
||||||
|
// serverInfoPO1 -> {
|
||||||
|
// if (!StringUtils.contains(serverInfoPO1.getServerName(), "01")) {
|
||||||
|
// projectDeployContext.setMasterNode(serverInfoPO1);
|
||||||
|
//
|
||||||
|
// baseFuncScheduler.runProcedure(projectDeployContext);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
// harborFuncScheduler.runProcedure(projectDeployContext);
|
// harborFuncScheduler.runProcedure(projectDeployContext);
|
||||||
|
|
||||||
// appFuncScheduler.runProcedure(projectDeployContext);
|
appFuncScheduler.runProcedure(projectDeployContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user