Skip to content

Commit

Permalink
Add the option to describe a VM using the annotation option in Config…
Browse files Browse the repository at this point in the history
…Spec (#657)
  • Loading branch information
bastienbc authored and dougm committed Jan 24, 2017
1 parent 505fcf9 commit e66c834
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions govc/vm/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type clone struct {
template bool
customization string
waitForIP bool
annotation string

Client *vim25.Client
Datacenter *object.Datacenter
Expand Down Expand Up @@ -99,6 +100,7 @@ func (cmd *clone) Register(ctx context.Context, f *flag.FlagSet) {
f.BoolVar(&cmd.template, "template", false, "Create a Template")
f.StringVar(&cmd.customization, "customization", "", "Customization Specification Name")
f.BoolVar(&cmd.waitForIP, "waitip", false, "Wait for VM to acquire IP address")
f.StringVar(&cmd.annotation, "annotation", "", "VM description")
}

func (cmd *clone) Usage() string {
Expand Down Expand Up @@ -226,6 +228,7 @@ func (cmd *clone) Run(ctx context.Context, f *flag.FlagSet) error {
if cmd.memory > 0 {
vmConfigSpec.MemoryMB = int64(cmd.memory)
}
vmConfigSpec.Annotation = cmd.annotation
task, err := vm.Reconfigure(ctx, vmConfigSpec)
if err != nil {
return err
Expand Down
11 changes: 7 additions & 4 deletions govc/vm/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type create struct {
on bool
force bool
controller string
annotation string

iso string
isoDatastoreFlag *flags.DatastoreFlag
Expand Down Expand Up @@ -107,6 +108,7 @@ func (cmd *create) Register(ctx context.Context, f *flag.FlagSet) {
f.BoolVar(&cmd.on, "on", true, "Power on VM. Default is true if -disk argument is given.")
f.BoolVar(&cmd.force, "force", false, "Create VM if vmx already exists")
f.StringVar(&cmd.controller, "disk.controller", "scsi", "Disk controller type")
f.StringVar(&cmd.annotation, "annotation", "", "VM description")

f.StringVar(&cmd.iso, "iso", "", "ISO path")
cmd.isoDatastoreFlag, ctx = flags.NewCustomDatastoreFlag(ctx)
Expand Down Expand Up @@ -274,10 +276,11 @@ func (cmd *create) createVM(ctx context.Context) (*object.Task, error) {
var err error

spec := &types.VirtualMachineConfigSpec{
Name: cmd.name,
GuestId: cmd.guestID,
NumCPUs: int32(cmd.cpus),
MemoryMB: int64(cmd.memory),
Name: cmd.name,
GuestId: cmd.guestID,
NumCPUs: int32(cmd.cpus),
MemoryMB: int64(cmd.memory),
Annotation: cmd.annotation,
}

devices, err = cmd.addStorage(nil)
Expand Down

0 comments on commit e66c834

Please sign in to comment.