예제 #1
0
        public async Task <int> DeleteDisks(VmTemplate template)
        {
            if (template.Disks.Length == 0)
            {
                return(-1);
            }

            int progress = await VerifyDisks(template);

            if (progress < 0)
            {
                return(-1);
            }

            if (progress == 100)
            {
                VimClient host = FindHostByRandom();
                foreach (VmDisk disk in template.Disks)
                {
                    //protect stock disks; only delete a disk if it is local to the workspace
                    //i.e. the disk folder matches the workspaceId
                    if (template.IsolationTag.HasValue() && disk.Path.Contains(template.IsolationTag))
                    {
                        Task deleteTask = host.DeleteDisk(disk.Path);
                    }
                }
                return(-1);
            }
            throw new Exception("Cannot delete disk that isn't fully created.");
        }