| 264 | } |
| 265 | |
| 266 | func addNIC(ctx context.Context, vm *object.VirtualMachine, net object.NetworkReference) { |
| 267 | backing, err := net.EthernetCardBackingInfo(ctx) |
| 268 | if err != nil { |
| 269 | log.Fatalf("Unable to determine vCenter network backend\n%v", err) |
| 270 | } |
| 271 | |
| 272 | netdev, err := object.EthernetCardTypes().CreateEthernetCard("vmxnet3", backing) |
| 273 | if err != nil { |
| 274 | log.Fatalf("Unable to create vmxnet3 network interface\n%v", err) |
| 275 | } |
| 276 | |
| 277 | log.Infof("Adding VM Networking") |
| 278 | var add []types.BaseVirtualDevice |
| 279 | add = append(add, netdev) |
| 280 | |
| 281 | if err := vm.AddDevice(ctx, add...); err != nil { |
| 282 | log.Fatalf("Unable to add new networking device to VM configuration\n%v", err) |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | func addVMDK(ctx context.Context, vm *object.VirtualMachine, dss *object.Datastore, newVM vmConfig) { |
| 287 | devices, err := vm.Device(ctx) |