Beispiel #1
0
        private void VerifyNodes()
        {
            var err_list = new List <string>();

            foreach (var host in Hosts)
            {
                if (!host.ToLower().Contains(localhost.ToLower()))
                {
                    var rs = GammaFSUtility.NetUse(host, Domain, Username, Password, Target_location.Trim().ToCharArray()[0]);
                    if (rs.Contains("error"))
                    {
                        err_list.Add(host);
                        OnOpCompleted(new OpResultArgs()
                        {
                            Hostname = host, OpResult = "net use fails, will not be configured", OpType = "net use setup"
                        });
                    }
                }
            }
            Hosts = Hosts.Except(err_list).ToList();
        }
Beispiel #2
0
        private async Task <string> InstallSingleNode(string host, bool callback = true)
        {
            //Pre-req. Setup net use
            VerifyNodes();
            var status = await RemoteServiceQuery(host, false);

            string rs = string.Empty;

            //Pre-req. Clean service
            if (status.Contains("STATE"))
            {
                if (!status.Contains("STOPPED"))
                {
                    rs = await RemoteServiceStop(host);

                    if (rs.Contains("error"))
                    {
                        return(rs);
                    }
                }
                rs = await RemoteServiceDelete(host);

                if (rs.Contains("error"))
                {
                    return(rs);
                }
            }

            //Step1. Copy file
            if (!host.ToLower().Contains(localhost.Trim().ToLower()))
            {
                rs = await RemoteCopyBinaries(host);

                if (rs.Contains("error"))
                {
                    OnOpCompleted(new OpResultArgs()
                    {
                        OpResult = rs, Hostname = host, OpType = "remote copy file"
                    });
                    return(rs);
                }
            }
            else
            {
                //local node copy file
                if (!Source_location.Trim().ToLower().Equals(Target_location.Trim().ToLower()))
                {
                    rs = GammaUtility.ShellExecutor(@"xcopy.exe", String.Format(@"/I /Y /E /V ""{0}"" ""{1}"" ", Source_location, Target_location));
                    if (rs.Contains("error"))
                    {
                        OnOpCompleted(new OpResultArgs()
                        {
                            OpResult = rs, Hostname = host, OpType = "local copy file"
                        });
                        return(rs);
                    }
                }
            }

            //Step2. Install service
            rs = await RemoteServiceInstall(host);

            if (rs.Contains("error"))
            {
                return(rs);
            }
            //Step extra, hook to do something else  before starting
            if (HasExtraTask())
            {
                ExtraTask(host);
            }
            //Step4. Start service
            rs = await RemoteServiceStart(host);

            if (rs.Contains("error"))
            {
                return(rs);
            }
            await Task.Delay(TimeSpan.FromSeconds(1));

            //Step5. Query service
            rs = await RemoteServiceQuery(host);

            return(rs);
        }