from vscode
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -32,3 +32,4 @@ build/
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
/agent-go/output/
|
||||
/agent-go/agent-go
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<working_directory value="$PROJECT_DIR$/agent-go" />
|
||||
<useCustomBuildTags value="true" />
|
||||
<parameters value="-version=shanghai -agentServerInfoConf=$PROJECT_DIR$/agent-go/server-env.yaml" />
|
||||
<sudo value="true" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="agent-go" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
|
||||
@@ -907,19 +907,19 @@ func (op *AgentOsOperator) installHarbor() [][]string {
|
||||
//{
|
||||
// "rm",
|
||||
// "-rf",
|
||||
// "/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
// "/root/wdd/harbor-offline-installer-v2.9.0.tgz",
|
||||
//},
|
||||
//{
|
||||
// "wget",
|
||||
// "--no-check-certificate",
|
||||
// op.OssOfflinePrefix + "harbor-offline-installer-v2.1.0.tgz",
|
||||
// op.OssOfflinePrefix + "harbor-offline-installer-v2.9.0.tgz",
|
||||
// "-O",
|
||||
// "/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
// "/root/wdd/harbor-offline-installer-v2.9.0.tgz",
|
||||
//},
|
||||
{
|
||||
"tar",
|
||||
"-zvxf",
|
||||
"/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
"/root/wdd/harbor-offline-installer-v2.9.0.tgz",
|
||||
"-C",
|
||||
"/root/wdd/",
|
||||
},
|
||||
@@ -994,7 +994,7 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
resultOk, resultLog := AllCommandExecutor([]string{
|
||||
"docker-compose",
|
||||
"-f",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
"/root/wdd/harbor/docker-compose.yml",
|
||||
"up",
|
||||
"-d",
|
||||
})
|
||||
@@ -1008,7 +1008,7 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
}
|
||||
|
||||
// download offline file
|
||||
harborOfflineFileURL := op.OssOfflinePrefix + "harbor-offline-installer-v2.1.0.tgz"
|
||||
harborOfflineFileURL := op.OssOfflinePrefix + "harbor-offline-installer-v2.9.0.tgz"
|
||||
log.InfoF("[install harbor] - start to download harbor offline installer from => %s !", harborOfflineFileURL)
|
||||
resultOk, resultLog := AllCompleteExecutor([][]string{
|
||||
{
|
||||
@@ -1019,7 +1019,7 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
{
|
||||
"rm",
|
||||
"-rf",
|
||||
"/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
"/root/wdd/harbor-offline-installer-v2.9.0.tgz",
|
||||
},
|
||||
{
|
||||
"rm",
|
||||
@@ -1031,14 +1031,14 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
"--no-check-certificate",
|
||||
harborOfflineFileURL,
|
||||
"-qO",
|
||||
"/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
"/root/wdd/harbor-offline-installer-v2.9.0.tgz",
|
||||
}},
|
||||
)
|
||||
if !resultOk {
|
||||
return false, append(resultLog, "download harbor offline installer failed!")
|
||||
}
|
||||
|
||||
if !BasicFileExistAndNotNull("/root/wdd/harbor-offline-installer-v2.1.0.tgz") {
|
||||
if !BasicFileExistAndNotNull("/root/wdd/harbor-offline-installer-v2.9.0.tgz") {
|
||||
return false, []string{"download harbor offline installer failed!"}
|
||||
}
|
||||
|
||||
@@ -1047,7 +1047,7 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
{
|
||||
"tar",
|
||||
"-zvxf",
|
||||
"/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
"/root/wdd/harbor-offline-installer-v2.9.0.tgz",
|
||||
"-C",
|
||||
"/root/wdd/",
|
||||
},
|
||||
@@ -1077,19 +1077,19 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/$HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
||||
"s/HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/$HarborHostPort/8033/g",
|
||||
"s/HarborHostPort/8033/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/$HarborAdminPas/V2ryStr@ngPss/g",
|
||||
"s/HarborAdminPas/V2ryStr@ngPss/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
@@ -1103,12 +1103,16 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
|
||||
// install
|
||||
log.Info("[install harbor] - going to start harbor !")
|
||||
ReadTimeCommandExecutor([]string{
|
||||
executor := ReadTimeCommandExecutor([]string{
|
||||
"bash",
|
||||
"/root/wdd/harbor/install.sh",
|
||||
"--with-chartmuseum",
|
||||
},
|
||||
)
|
||||
if !executor {
|
||||
return false, []string{
|
||||
"[install harbor] - harbor start FAILED !",
|
||||
}
|
||||
}
|
||||
|
||||
msg := "[install harbor] - harbor start complete !"
|
||||
log.Info(msg)
|
||||
|
||||
@@ -82,7 +82,7 @@ func Execute(em *ExecutionMessage) (bool, []string) {
|
||||
if err != nil {
|
||||
resultLog = append(resultLog, " 命令执行错误如下 ", err.Error())
|
||||
}
|
||||
resultLog = append(resultLog, fmt.Sprintf("命令 %s 执行结果为 %s", executionContent, strconv.FormatBool(ok)))
|
||||
resultLog = append(resultLog, fmt.Sprintf("命令 %v 执行结果为 %s", executionContent, strconv.FormatBool(ok)))
|
||||
// debug
|
||||
log.DebugF("%v", resultLog)
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ func PureResultSingleExecuteBatch(singleCommandList [][]string) (resultOK bool)
|
||||
}
|
||||
|
||||
// ReadTimeCommandExecutor 执行命令,并且实时返回结果
|
||||
func ReadTimeCommandExecutor(singleLineCommand []string) {
|
||||
func ReadTimeCommandExecutor(singleLineCommand []string) bool {
|
||||
cmd := exec.Command(singleLineCommand[0], singleLineCommand[1:]...)
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
@@ -205,8 +205,10 @@ func ReadTimeCommandExecutor(singleLineCommand []string) {
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
log.ErrorF("command %v result error => %v", singleLineCommand, err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func realTimeOutput(r io.Reader) {
|
||||
|
||||
@@ -3,9 +3,10 @@ package executor
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/mittwald/goharbor-client/v5/apiv2"
|
||||
"github.com/mittwald/goharbor-client/v5/apiv2/model"
|
||||
"net"
|
||||
)
|
||||
|
||||
type HarborOperator struct {
|
||||
@@ -58,18 +59,20 @@ func (hOp *HarborOperator) CreateProjectExec(funcArgs []string) (bool, []string)
|
||||
|
||||
targetHarborHost := funcArgs[0]
|
||||
parseIP := net.ParseIP(targetHarborHost)
|
||||
if parseIP != nil {
|
||||
if parseIP == nil {
|
||||
return false, []string{
|
||||
"[Harbor CreateProjectExec] - ip format is wrong!",
|
||||
fmt.Sprintf("[Harbor CreateProjectExec] - ip format is wrong! parseIP is => %s ", parseIP),
|
||||
}
|
||||
}
|
||||
|
||||
hOp.TargetHarborHost = string(parseIP) + ":" + hOp.HarborPort
|
||||
hOp.TargetHarborHost = "http://" + targetHarborHost + ":" + hOp.HarborPort + "/api"
|
||||
|
||||
log.DebugF("[Harbor CreateProjectExec] - harbor host is => %s", hOp.TargetHarborHost)
|
||||
|
||||
// check connection
|
||||
client, err := apiv2.NewRESTClientForHost(hOp.TargetHarborHost, hOp.HarborAdminUser, hOp.HarborAdminPass, nil)
|
||||
if err != nil {
|
||||
errorLog := fmt.Sprintf("Error creating REST client: %v\n", err)
|
||||
errorLog := fmt.Sprintf("Error creating REST client: %s\n", err.Error())
|
||||
log.Error(errorLog)
|
||||
return false, []string{errorLog}
|
||||
}
|
||||
@@ -94,13 +97,13 @@ func (hOp *HarborOperator) CreateProjectExec(funcArgs []string) (bool, []string)
|
||||
ctx := context.Background()
|
||||
err = client.NewProject(ctx, cmiiProject)
|
||||
if err != nil {
|
||||
errorLog := fmt.Sprintf("Error creating project: %v\n", err)
|
||||
errorLog := fmt.Sprintf("Error creating project: %s\n", err.Error())
|
||||
return false, []string{errorLog}
|
||||
}
|
||||
|
||||
err = client.NewProject(ctx, rancherProject)
|
||||
if err != nil {
|
||||
errorLog := fmt.Sprintf("Error creating project: %v\n", err)
|
||||
errorLog := fmt.Sprintf("Error creating project: %s\n", err.Error())
|
||||
return false, []string{errorLog}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ octopus:
|
||||
executor:
|
||||
# agent执行一条Command的最长超时时间
|
||||
processMaxTimeOut: 60
|
||||
ossOfflinePrefix: "https://oss-s1.107421.xyz"
|
||||
# ossOfflinePrefix: "https://oss-s1.107421.xyz"
|
||||
ossOfflinePrefix: "http://10.250.0.65:9000/octopus/"
|
||||
status:
|
||||
app:
|
||||
- Nginx/nginx
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
serverName: "Chengdu-amd64-90"
|
||||
serverName: "Chengdu-amd64-65"
|
||||
serverIpPbV4: "183.220.149.17"
|
||||
serverIpInV4: ""
|
||||
serverIpInV4: "10.250.0.65 "
|
||||
serverIpPbV6: ""
|
||||
serverIpInV6: ""
|
||||
location: "Chengdu Sichuan CN"
|
||||
provider: "AS139080 The Internet Data Center of Sichuan Mobile Communication Company Limited"
|
||||
managePort: "22"
|
||||
cpuCore: "12 @ 4299.998 MHz"
|
||||
cpuBrand: "Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz"
|
||||
cpuBrand: "Intel(R) Core(TM) i7-8250U CPU @ 2.90GHz"
|
||||
memoryTotal: "7.6 GB"
|
||||
diskTotal: "914.9 GB"
|
||||
diskUsage: "12.3 GB"
|
||||
@@ -15,9 +15,9 @@ archInfo: "x86_64 (64 Bit)"
|
||||
osInfo: "
|
||||
Ubuntu 20.04.5 LTS"
|
||||
osKernelInfo: "5.4.0-135-generic"
|
||||
tcpControl: "cubic "
|
||||
tcpControl: "bbr "
|
||||
virtualization: "Dedicated"
|
||||
ioSpeed: "150 MB/s "
|
||||
machineId: "fakemachinid123 "
|
||||
machineId: " lapwdd-machinid123 "
|
||||
agentVersion: ""
|
||||
topicName: ""
|
||||
|
||||
Reference in New Issue
Block a user