Skip to content

Commit

Permalink
Merge pull request vmware#3444 from rubinthomasdev/issue-3443
Browse files Browse the repository at this point in the history
govc: Add feature to pass fullname and org for windows vm customization
  • Loading branch information
dougm authored Jun 7, 2024
2 parents 34edab3 + 5677b0e commit b9a71f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions govc/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6366,9 +6366,11 @@ Options:
-mac=[] MAC address
-name= Host name
-netmask=[] Netmask
-org= Windows only : name of the org that owns the VM
-prefix= Host name generator prefix
-type=Linux Customization type if spec NAME is not specified (Linux|Windows)
-tz= Time zone
-username= Windows only : full name of the end user in firstname lastname format
-vm= Virtual machine [GOVC_VM]
```

Expand Down
16 changes: 10 additions & 6 deletions govc/vm/customize.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type customize struct {
dnsserver flags.StringList
dnssuffix flags.StringList
kind string
username string
org string
}

func init() {
Expand Down Expand Up @@ -75,6 +77,8 @@ func (cmd *customize) Register(ctx context.Context, f *flag.FlagSet) {
f.Var(&cmd.dnssuffix, "dns-suffix", "DNS suffix list")
cmd.dnssuffix = nil
f.StringVar(&cmd.kind, "type", "Linux", "Customization type if spec NAME is not specified (Linux|Windows)")
f.StringVar(&cmd.username, "username", "", "Windows only : full name of the end user in firstname lastname format")
f.StringVar(&cmd.org, "org", "", "Windows only : name of the org that owns the VM")
}

func (cmd *customize) Usage() string {
Expand Down Expand Up @@ -211,12 +215,12 @@ func (cmd *customize) Run(ctx context.Context, f *flag.FlagSet) error {
sysprep, isWindows := spec.Identity.(*types.CustomizationSysprep)
linprep, _ := spec.Identity.(*types.CustomizationLinuxPrep)

if cmd.domain != "" {
if isWindows {
sysprep.Identification.JoinDomain = cmd.domain
} else {
linprep.Domain = cmd.domain
}
if isWindows {
sysprep.Identification.JoinDomain = cmd.domain
sysprep.UserData.FullName = cmd.username
sysprep.UserData.OrgName = cmd.org
} else {
linprep.Domain = cmd.domain
}

if len(cmd.dnsserver) != 0 {
Expand Down

0 comments on commit b9a71f7

Please sign in to comment.