Skip to content

Commit

Permalink
govc: Add feature to pass fullname and org for windows vm customization
Browse files Browse the repository at this point in the history
Closes: vmware#3443
  • Loading branch information
rubinthomasdev committed May 18, 2024
1 parent 077b0b0 commit c01aa22
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 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", "", "for windows vms, full name of the end user in firstname lastname format")
f.StringVar(&cmd.org, "org", "", "for windows vms, name of the org that owns the VM")
}

func (cmd *customize) Usage() string {
Expand Down Expand Up @@ -246,6 +250,18 @@ func (cmd *customize) Run(ctx context.Context, f *flag.FlagSet) error {
}
}

if cmd.username != "" {
if isWindows {
sysprep.UserData.FullName = cmd.username
}
}

if cmd.org != "" {
if isWindows {
sysprep.UserData.OrgName = cmd.org
}
}

if cmd.alc != 0 {
if !isWindows {
return fmt.Errorf("option '-auto-login' is Windows only")
Expand Down

0 comments on commit c01aa22

Please sign in to comment.