Esempio n. 1
0
        public static bool CreatePartitionAndFormat(int diskNumber)
        {
            PSInvoker invoker = new PSInvoker();

            try
            {
                string initScript = VanScript.CreateNewPartitionAndFormat(diskNumber);
                logger.Debug("init Script :" + initScript);
                Collection <PSObject> result = invoker.ExecuteCommand(initScript);
                // return result.Count == 1 ? true : false;
                return(true);
            }
            catch (psInvokerException ex)
            {
                string exceptionString = string.Empty;
                foreach (PSObject item in ex.errorRecords)
                {
                    exceptionString = item.ToString();
                    logger.Error("Create Partition And Format psInvokerException : " + item.ToString());
                    break;
                }
                throw new Exception(exceptionString);
            }
            catch (Exception ex)
            {
                logger.Error("Create Partition And Format fail : " + ex.ToString());
                return(true);
            }
        }
Esempio n. 2
0
        public static bool CreateCluster(string clusterName, string clusterComputer, string clusterIP, string ignoreIP = "")
        {
            PSInvoker invoker       = new PSInvoker();
            string    createCluster = string.Empty;

            if (string.IsNullOrEmpty(ignoreIP))
            {
                createCluster = VanScript.CreateClusterNoIgnore(clusterName, clusterComputer, clusterIP);
            }
            else
            {
                createCluster = VanScript.CreateCluster(clusterName, clusterComputer, clusterIP, ignoreIP);
            }

            try
            {
                //  ProcessCaller.ProcessOpenByPowershell(createCluster);
                Collection <PSObject> result = invoker.ExecuteCommand(createCluster);
            }
            catch (psInvokerException ex)
            {
                // logger.Debug("ex string : " + ex.);
                // logger.Debug("ex Message " + ex.Message);
                // logger.Debug("ex errorRecords : " + (ex.errorRecords == null ? "false" : ex.errorRecords.Count.ToString()));
                // logger.Debug("ex Data count : " + ex.Data.Count ?? "false");
                foreach (PSObject item in ex.errorRecords)
                {
                    throw new Exception(item.ToString());
                    // logger.Debug("ex item value: " + item.ToString());
                }
                // return false;
            }
            return(false);
        }
Esempio n. 3
0
        public static bool CreateVSwitch(string adapterName, string switchName)
        {
            PSInvoker invoker = new PSInvoker();

            logger.Debug("init Script :" + VanScript.CreateVirtualSwitch(adapterName, switchName));
            Collection <PSObject> serviceResult = invoker.ExecuteCommand(VanScript.CreateVirtualSwitch(adapterName, switchName));

            return(true);
        }
Esempio n. 4
0
        public static bool SetDiskStatus(int diskNumber, bool online)
        {
            PSInvoker invoker = new PSInvoker();

            try
            {
                if (online)
                {
                    Collection <PSObject> result = invoker.ExecuteCommand(VanScript.SetDiskOnline(diskNumber));
                }
                else
                {
                    Collection <PSObject> result = invoker.ExecuteCommand(VanScript.SetDiskOffline(diskNumber));
                }
                return(true);
            }
            catch (Exception ex)
            {
                logger.Debug("SetDiskOnline " + ex.ToString());
                return(false);
            }
        }