Exemple #1
0
        /// <summary>
        /// Call that locates the .vhd associated with a Virtual Machine, compresses it, and then drops it to a location.
        /// </summary>
        /// <param name="id">Guid of the Virtual Machine.</param>
        /// <param name="dropLocation">Location to drop the result to.</param>
        /// <param name="sizeOfEachVolume">Size in Megabytes for each volume.  Pass 0 for a single volume.</param>
        /// <param name="processingLocation">Optional.  Location to copy the .vhd to prior to compression.</param>
        /// <param name="usersToEmail">Optional.  List of users to send emails to.</param>
        /// <returns></returns>
        public bool FinalizeVM(String vmName, String dropLocation, long sizeOfEachVolume, String processingLocation = null, ICollection <String> usersToEmail = null)
        {
            HyperVPsInterface hyperVInterface = new HyperVPsInterface();  string vhdPath = hyperVInterface.GetVHDPath(vmName); if (String.IsNullOrEmpty(vhdPath))

            {
                return(false);
            }
            Console.WriteLine(string.Format("VHD location: {0}", vhdPath));  if (!CompressVHD(vhdPath, dropLocation, vmName + ".7z", sizeOfEachVolume))
            {
                return(false);
            }
            return(true);
        }
 /// <summary>
 /// Call that locates the .vhd associated with a Virtual Machine, compresses it, and then drops it to a location.
 /// </summary>
 /// <param name="id">Guid of the Virtual Machine.</param>
 /// <param name="dropLocation">Location to drop the result to.</param>
 /// <param name="sizeOfEachVolume">Size in Megabytes for each volume.  Pass 0 for a single volume.</param>
 /// <param name="processingLocation">Optional.  Location to copy the .vhd to prior to compression.</param>
 /// <param name="usersToEmail">Optional.  List of users to send emails to.</param>
 /// <returns></returns>
 public bool FinalizeVM(Guid id, String dropLocation, long sizeOfEachVolume, String processingLocation = null, ICollection<String> usersToEmail = null)
 {
     HyperVPsInterface hyperVInterface = new HyperVPsInterface();
     //TODO: refacture
     //string vhdPath = hyperVInterface.GetVHDPath(id);
     //if (String.IsNullOrEmpty(vhdPath))
     //{
     //    return false;
     //}
     //if (!compressVHD(vhdPath, dropLocation, sizeOfEachVolume))
     //{
     //    return false;
     //}
     ////email users
     return true;
 }
 /// <summary>
 /// Call that locates the .vhd associated with a Virtual Machine, compresses it, and then drops it to a location.
 /// </summary>
 /// <param name="id">Guid of the Virtual Machine.</param>
 /// <param name="dropLocation">Location to drop the result to.</param>
 /// <param name="sizeOfEachVolume">Size in Megabytes for each volume.  Pass 0 for a single volume.</param>
 /// <param name="processingLocation">Optional.  Location to copy the .vhd to prior to compression.</param>
 /// <param name="usersToEmail">Optional.  List of users to send emails to.</param>
 /// <returns></returns>
 public bool FinalizeVM( String vmName, String dropLocation, long sizeOfEachVolume, String processingLocation = null, ICollection<String> usersToEmail = null)
 {
     HyperVPsInterface hyperVInterface = new HyperVPsInterface();  string vhdPath = hyperVInterface.GetVHDPath(vmName); if (String.IsNullOrEmpty(vhdPath)) { return false; }  Console.WriteLine(string.Format("VHD location: {0}", vhdPath));  if (!CompressVHD(vhdPath, dropLocation, vmName + ".7z", sizeOfEachVolume)) { return false; }  return true;
 }