@@ -21,6 +21,7 @@ import (
2121
2222 "github.com/vmware/photon-controller-cli/Godeps/_workspace/src/github.com/codegangsta/cli"
2323 "github.com/vmware/photon-controller-cli/Godeps/_workspace/src/github.com/vmware/photon-controller-go-sdk/photon"
24+ "regexp"
2425)
2526
2627// Creates a cli.Command for vm
@@ -76,6 +77,10 @@ func GetVMCommand() cli.Command {
7677 Name : "affinities, a" ,
7778 Usage : "VM Locality(kind id)" ,
7879 },
80+ cli.StringFlag {
81+ Name : "networks, w" ,
82+ Usage : "VM Networks(id1, id2)" ,
83+ },
7984 cli.StringFlag {
8085 Name : "tenant, t" ,
8186 Usage : "Tenant name" ,
@@ -333,6 +338,7 @@ func createVM(c *cli.Context) error {
333338 affinities := c .String ("affinities" )
334339 tenantName := c .String ("tenant" )
335340 projectName := c .String ("project" )
341+ networks := c .String ("networks" )
336342
337343 client .Esxclient , err = client .GetClient (c .GlobalIsSet ("non-interactive" ))
338344 if err != nil {
@@ -390,13 +396,19 @@ func createVM(c *cli.Context) error {
390396 return err
391397 }
392398
399+ var networkList []string
400+ if (len (networks ) > 0 ) {
401+ networkList = regexp .MustCompile (`\s*,\s*` ).Split (networks , - 1 )
402+ }
403+
393404 vmSpec := photon.VmCreateSpec {}
394405 vmSpec .Name = name
395406 vmSpec .Flavor = flavor
396407 vmSpec .SourceImageID = imageID
397408 vmSpec .AttachedDisks = disksList
398409 vmSpec .Affinities = affinitiesList
399410 vmSpec .Environment = environmentMap
411+ vmSpec .Networks = networkList
400412
401413 if ! c .GlobalIsSet ("non-interactive" ) {
402414 fmt .Printf ("\n Creating VM: %s(%s)\n " , vmSpec .Name , vmSpec .Flavor )
0 commit comments