<commit_before>package mass

import (
	"context"
	"flag"

	"github.com/vmware/govmomi/govc/cli"
	"github.com/vmware/govmomi/govc/flags"
)

type snapshot struct {
	*flags.VirtualMachineFlag

	number int
}

func init() {
	cli.Register("mass.snapshot.create", &snapshot{})
}

func (cmd *snapshot) Register(ctx context.Context, f *flag.FlagSet) {
	cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
	cmd.VirtualMachineFlag.Register(ctx, f)

	f.IntVar(&cmd.number, "n", 1, "this is mass snapshot number")
}

func (cmd *snapshot) Usage() string {
	return "NAME"
}

func (cmd *snapshot) Description() string {
	return `snapshot mass snapshot of VM with NAME.
Example:
govc mass.snapshot -vm my-vm -n 2048
`
}

func (cmd *snapshot) Process(ctx context.Context) error {
	return nil
}

func (cmd *snapshot) Run(ctx context.Context, f *flag.FlagSet) error {
	return nil
}<commit_msg>Entered prototype version of mass snapshot create command.<commit_after>package mass

import (
	"context"
	"flag"
	"fmt"

	"github.com/vmware/govmomi/find"
    "github.com/vmware/govmomi/object"
	"github.com/vmware/govmomi/govc/cli"
	"github.com/vmware/govmomi/govc/flags"

	//"github.com/vmware/govmomi/vim25/types"
)

type massSnapshotCreate struct {
	//*flags.VirtualMachineFlag
	*flags.SearchFlag

	description string
	memory      bool
	quiesce     bool
}

func init() {
	cli.Register("mass.snapshot.create", &massSnapshotCreate{})
}

func (cmd *massSnapshotCreate) Register(ctx context.Context, f *flag.FlagSet) {
	//cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
	//cmd.VirtualMachineFlag.Register(ctx, f)

	cmd.SearchFlag, ctx = flags.NewSearchFlag(ctx, flags.SearchVirtualMachines)
	cmd.SearchFlag.Register(ctx, f)

	f.BoolVar(&cmd.memory, "m", true, "Include memory state")
	f.BoolVar(&cmd.quiesce, "q", false, "Quiesce guest file system")
	f.StringVar(&cmd.description, "d", "", "Snapshot description")
}

func (cmd *massSnapshotCreate) Usage() string {
	return "NAME"
}

func (cmd *massSnapshotCreate) Description() string {
	return `Create snapshot snapshot of all VMs matching regex
Example:
govc snapshot.create-all /VMwareCode/vm/* happy-vm-state
`
}

func (cmd *massSnapshotCreate) Process(ctx context.Context) error {
	//if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
	//	return err
	//}
	if err := cmd.SearchFlag.Process(ctx); err != nil {
		return err
	}
	return nil
}

func (cmd *massSnapshotCreate) Run(ctx context.Context, f *flag.FlagSet) error {
	if f.NArg() != 1 {
		return flag.ErrHelp
	}

	_, err := cmd.Client()
	if err != nil {
		return err
	}

	vms, err := cmd.VirtualMachines(f.Args())
	if err != nil {
		if _, ok := err.(*find.NotFoundError); ok {
			// Continue with empty VM slice
		} else {
			return err
		}
	}

 	var t *object.Task
	//refs := make([]types.ManagedObjectReference, 0, len(vms))
	for _, vm := range vms {
		fmt.Printf("Making a snapshot")
		t, err = vm.CreateSnapshot(ctx, "mysnapshot", "description", cmd.memory, cmd.quiesce)
    	if err != nil {
			return err
		}
		t.Wait(ctx)
		//refs = append(refs, vm.Reference())
	}
	return nil
}
{'fraction_non_alphanumeric': 0.14258064516129032, 'fraction_numerical': 0.002903225806451613, 'mean_word_length': 4.168333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2857481', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1091, 'n_words': 268}