New returns a new instance of VM
()
| 11 | |
| 12 | // New returns a new instance of VM |
| 13 | func (g *GctScriptManager) New() *VM { |
| 14 | if VMSCount.Len() >= g.GetMaxVirtualMachines() { |
| 15 | if g.config.Verbose { |
| 16 | log.Warnf(log.GCTScriptMgr, "GCTScript MaxVirtualMachines (%v) hit, unable to start further instances", |
| 17 | g.GetMaxVirtualMachines()) |
| 18 | } |
| 19 | return nil |
| 20 | } |
| 21 | VMSCount.add() |
| 22 | vm := g.NewVM() |
| 23 | if vm == nil { |
| 24 | VMSCount.remove() |
| 25 | } else { |
| 26 | AllVMSync.Store(vm.ID, vm) |
| 27 | } |
| 28 | return vm |
| 29 | } |
| 30 | |
| 31 | // Validate will attempt to execute a script in a test/non-live environment |
| 32 | // to confirm it passes requirements for execution |