Skip to content

Commit

Permalink
Require either -vmHostname or Name tag when creating VM.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Dec 31, 2018
1 parent b094a96 commit 4eae0f6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/vm-control/createVm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/Symantec/Dominator/lib/flagutil"
"github.com/Symantec/Dominator/lib/log"
"github.com/Symantec/Dominator/lib/srpc"
"github.com/Symantec/Dominator/lib/tags"
fm_proto "github.com/Symantec/Dominator/proto/fleetmanager"
hyper_proto "github.com/Symantec/Dominator/proto/hypervisor"
)
Expand Down Expand Up @@ -84,6 +85,20 @@ func callCreateVm(client *srpc.Client, request hyper_proto.CreateVmRequest,
}

func createVm(logger log.DebugLogger) error {
if *vmHostname == "" {
if name := vmTags["Name"]; name == "" {
return errors.New("no hostname specified")
} else {
*vmHostname = name
}
} else {
if name := vmTags["Name"]; name == "" {
if vmTags == nil {
vmTags = make(tags.Tags)
}
vmTags["Name"] = *vmHostname
}
}
if hypervisor, err := getHypervisorAddress(); err != nil {
return err
} else {
Expand Down

0 comments on commit 4eae0f6

Please sign in to comment.