public void Migrate(dynamic args)
        {
            Logger.Info(String.Format("MigrateDisk:{0}", args));
            oldCid = args[0].ToString();
            newCid = args[1].ToString();
            DiskUtil.UnmountGuard(BaseMessage.StorePath);
            MountStoreReadOnly(oldCid);

            if (CheckMountPoints())
            {
                Logger.Info("Copy data from old to new store disk");

                ProcessStartInfo info = new ProcessStartInfo();
                info.FileName = "robocopy";
                string systemVolumeInfo = "\"" + Path.Combine(BaseMessage.StorePath, "System Volume Information") + "\"";
                string recicleBinPath   = "\"" + Path.Combine(BaseMessage.StorePath, "$Recycle.Bin") + "\"";
                info.Arguments = String.Format(CultureInfo.InvariantCulture, "{0} {1} /MIR /R:1 /W:1 /COPYALL /XD {2} {3}", BaseMessage.StorePath, BaseMessage.StoreMigrationTarget, systemVolumeInfo, recicleBinPath);
                info.RedirectStandardOutput = true;
                info.UseShellExecute        = false;

                Process p = new Process();
                try
                {
                    p.StartInfo = info;
                    p.Start();
                    p.WaitForExit();
                    Logger.Debug(p.StandardOutput.ReadToEnd());
                    if (p.ExitCode > 2)
                    {
                        throw new MessageHandlerException(String.Format(CultureInfo.InvariantCulture, "Failed to copy data from old to new store disk with exit code {0}", p.ExitCode.ToString()));
                    }
                }
                finally
                {
                    p.Dispose();
                }
            }

            DiskUtil.UnmountGuard(BaseMessage.StorePath);
            DiskUtil.UnmountGuard(BaseMessage.StoreMigrationTarget);

            MountStore(newCid);
        }
Exemple #2
0
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        public object Process(dynamic args)
        {
            Logger.Info("Processing unmount disk :" + args.ToString());
            string cid = args[0].Value.ToString();

            int    diskId     = int.Parse(Config.Platform.LookupDiskByCid(cid), CultureInfo.InvariantCulture);
            string mountEntry = DiskUtil.MountEntry(diskId);

            if (mountEntry != null)
            {
                DiskUtil.UnmountGuard(mountEntry);
                UnmountMessage unmountMessage = new UnmountMessage();
                unmountMessage.Message = string.Format(CultureInfo.InvariantCulture, "done unmount {0} on {1}", mountEntry, diskId);
                return(unmountMessage);
            }
            else
            {
                UnmountMessage unmountMessage = new UnmountMessage();
                unmountMessage.Message = string.Format(CultureInfo.InvariantCulture, "Unknown mount for partition {0}", diskId.ToString(CultureInfo.InvariantCulture));
                return(unmountMessage);
            }
        }