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