Skip to content

Commit

Permalink
rename vgname centos
Browse files Browse the repository at this point in the history
  • Loading branch information
wanyaoqi committed Jul 23, 2020
1 parent afed84a commit 7ef340f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/hostman/hostdeployer/deployserver/deployserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"net"
"os"
"regexp"
"runtime/debug"
"strings"
"time"
Expand All @@ -28,6 +29,7 @@ import (
execlient "yunion.io/x/executor/client"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/stringutils"

comapi "yunion.io/x/onecloud/pkg/apis/compute"
common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
Expand All @@ -43,6 +45,8 @@ import (
"yunion.io/x/onecloud/pkg/util/winutils"
)

const CENTOS_VGNAME = "centos"

type DeployerServer struct{}

func (*DeployerServer) DeployGuestFs(ctx context.Context, req *deployapi.DeployParams,
Expand Down Expand Up @@ -337,6 +341,27 @@ func (s *SDeployService) PrepareEnv() error {
if err != nil {
log.Errorf("Failed exec lvm command pvscan: %s", output)
}
output, err = procutils.NewCommand("vgdisplay").Output()
if err == nil {
re := regexp.MustCompile(`\s+`)
for _, line := range strings.Split(string(output), "\n") {
s := strings.TrimSpace(line)
if strings.HasPrefix(s, "VG Name") {
data := re.Split(s, -1)
if len(data) == 3 {
vgName := data[2]
if vgName == CENTOS_VGNAME {
vgNewName := stringutils.UUID4()
output, err := procutils.NewCommand("vgrename", vgName, vgNewName).Output()
if err != nil {
log.Errorf("vg rename failed %s %s", err, output)
}
log.Infof("vg name %s rename to %s success", vgName, vgNewName)
}
}
}
}
}
return nil
}

Expand Down

0 comments on commit 7ef340f

Please sign in to comment.