Skip to content

Commit

Permalink
Merge pull request #45 from luthermonson/ui-tweaks
Browse files Browse the repository at this point in the history
split param to vm/template/library/legacy for ui
  • Loading branch information
dramich authored Nov 4, 2019
2 parents fb18c42 + 30be8bf commit 8ebe1f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions drivers/vmwarevsphere/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
"github.com/vmware/govmomi/vim25/types"
)

var creationTypes = map[string]bool{
"vm": true,
"template": true,
"library": true,
"legacy": true,
}

func (d *Driver) GetCreateFlags() []mcnflag.Flag {
return []mcnflag.Flag{
mcnflag.IntFlag{
Expand Down Expand Up @@ -125,7 +132,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
mcnflag.StringFlag{
EnvVar: "VSPHERE_CREATION_TYPE",
Name: "vmwarevsphere-creation-type",
Usage: "Creation type when creating a new virtual machine. Supported values: default or clone",
Usage: "Creation type when creating a new virtual machine. Supported values: vm, template, library, legacy",
Value: defaultCreationType,
},
mcnflag.StringFlag{
Expand Down Expand Up @@ -217,10 +224,14 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.VAppProperties = flags.StringSlice("vmwarevsphere-vapp-property")
d.SetSwarmConfigFromFlags(flags)
d.ISO = d.ResolveStorePath(isoFilename)

d.CreationType = flags.String("vmwarevsphere-creation-type")
d.ContentLibrary = flags.String("vmwarevsphere-content-library")
if _, ok := creationTypes[d.CreationType]; !ok {
return fmt.Errorf("Creation type %s not supported", d.CreationType)
}

if d.CreationType == "clone" {
d.ContentLibrary = flags.String("vmwarevsphere-content-library")
if d.CreationType != "legacy" {
d.CloneFrom = flags.String("vmwarevsphere-clone-from")
if d.CloneFrom == "" {
return fmt.Errorf("Creation type clone needs a VM name to clone from, use --vmwarevsphere-clone-from.")
Expand Down
4 changes: 2 additions & 2 deletions drivers/vmwarevsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,14 @@ func (d *Driver) Create() error {
}

switch d.CreationType {
case "default":
case "legacy":
log.Infof("Creating VM...")
b2dutils := mcnutils.NewB2dUtils(d.StorePath)
if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil {
return err
}
return d.createManual()
case "clone":
case "vm", "template", "libary":
if d.ContentLibrary != "" {
log.Infof("Creating VM from /%s/%s...", d.ContentLibrary, d.CloneFrom)
return d.createFromLibraryName()
Expand Down

0 comments on commit 8ebe1f8

Please sign in to comment.