Exemple #1
0
        public async Task <Vm> Deploy(VmTemplate template)
        {
            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);
            _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.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));
        }
Exemple #2
0
        public async Task <int> VerifyDisks(VmTemplate template)
        {
            if (template.Disks.Length == 0)
            {
                return(100); //show good if no disks to verify
            }
            foreach (VimClient vhost in _hostCache.Values)
            {
                int progress = await vhost.TaskProgress(template.Id);

                if (progress >= 0)
                {
                    return(progress);
                }
            }

            // string pattern = @"blank-(\d+)([^\.]+)";
            // Match match = Regex.Match(template.Disks[0].Path, pattern);
            // if (match.Success)
            // {
            //     return 100; //show blank disk as created
            // }

            VimClient host = FindHostByRandom();

            NormalizeTemplate(template, host.Options);
            // if (template.Disks.Length > 0)
            // {
            _logger.LogDebug(template.Source + " " + template.Disks[0].Path);
            if (await host.FileExists(template.Disks[0].Path))
            {
                return(100);
            }
            // }
            return(-1);
        }