Esempio n. 1
0
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        public object Process(dynamic args)
        {
            List <string> diskInfo = new List <string>();

            Logger.Info("Processing list disk");
            dynamic settings = Config.Settings;
            dynamic cids;

            cids = settings["disks"]["persistent"] ?? new string[] {};

            foreach (var cid in cids)
            {
                int diskId = int.Parse(Config.Platform.LookupDiskByCid(cid.Name));
                Logger.Info("Found disk with Id :" + diskId);

                if (!(DiskUtil.MountEntry(diskId) == null))
                {
                    diskInfo.Add(cid.Name);
                }
            }

            JArray obj = JArray.FromObject(diskInfo);

            return(obj);
        }
Esempio n. 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);
            }
        }