public async Task <Vm> Deploy(VmTemplate template, bool privileged = false) { var vm = await Load(template.Name + "#" + template.IsolationTag); if (vm != null) { return(vm); } VimClient host = FindHostByAffinity(template.IsolationTag); _logger.LogDebug("deploy: host " + host.Name); NormalizeTemplate(template, host.Options, privileged); _logger.LogDebug("deploy: normalized " + template.Name); if (!template.Disks.IsEmpty()) { bool found = await host.FileExists(template.Disks[0].Path); if (!found) { throw new Exception("Template disks have not been prepared."); } } if (!host.Options.IsNsxNetwork && !host.Options.Uplink.StartsWith("nsx.")) { _logger.LogDebug("deploy: reserve vlans "); _vlanman.ReserveVlans(template, host.Options.IsVCenter); } _logger.LogDebug("deploy: " + template.Name + " " + host.Name); return(await host.Deploy(template)); }