예제 #1
0
파일: Inst.cs 프로젝트: nibircse/installers
        /// <summary>
        /// Running prepares-server script.
        /// </summary>
        /// <returns></returns>
        public static bool prepare_server(string appDir)
        {
            // running prepare-server.sh script
            string ssh_res   = "";
            string ssh_res_1 = "";
            bool   b_res     = false;

            Deploy.StageReporter("", "Running installation scripts");
            ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu", "sudo bash /home/ubuntu/tmpfs/prepare-server.sh", 7);
            logger.Info("Running installation scripts: {0}", ssh_res);
            if (ssh_res.Contains("Connection Error"))
            {
                if (!VMs.restart_vm(TC._cloneName))
                {
                    Program.ShowError("Can not communicate with VM, please check network and VM state and reinstall later", "No SSH");
                    Program.form1.Visible = false;
                }
                ssh_res   = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu", "ls /home/ubuntu/tmpfs/prepare-server.sh", 7);
                ssh_res_1 = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu", $"sudo ls bash /home/ubuntu/tmpfs/{TC.snapFile}", 3);
                if (ssh_res.ToLower().Contains("no such file") || ssh_res_1.ToLower().Contains("no such file"))
                {
                    b_res = upload_files(appDir);
                    if (!b_res)
                    {
                        Program.ShowError("Cannot upload Subutai files to RH, canceling", "Setting up RH");
                        Program.form1.Visible = false;
                    }
                }

                logger.Info("Running installation scripts second time: {0}", ssh_res);
                if (ssh_res.Contains("Connection Error"))
                {
                    return(false);
                }
            }
            // deploying peer options
            Thread.Sleep(5000);
            ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu", "sudo sync;sync", 3);
            Thread.Sleep(5000);
            return(true);
        }
예제 #2
0
파일: Inst.cs 프로젝트: nibircse/installers
        /// <summary>
        /// Creates TMPFS.
        /// </summary>
        /// <returns></returns>
        public static bool create_tmpfs()
        {
            string ssh_res = "";

            // creating tmpfs folder
            Deploy.StageReporter("", "Creating tmps folder");
            ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu", "mkdir tmpfs; sudo mount -t tmpfs -o size=1G tmpfs /home/ubuntu/tmpfs", 20);
            logger.Info("Creating tmpfs folder: {0}", ssh_res);
            if (ssh_res.Contains("Connection Error"))
            {
                if (!VMs.restart_vm(TC._cloneName))
                {
                    Program.ShowError("Can not communicate with VM, please check network and VM state and reinstall later", "No SSH");
                }
                ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu", "mkdir tmpfs; sudo mount -t tmpfs -o size=1G tmpfs /home/ubuntu/tmpfs", 20);
                logger.Info("Creating tmpfs folder second time: {0}", ssh_res);
                if (ssh_res.Contains("Connection Error"))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #3
0
파일: Inst.cs 프로젝트: nibircse/installers
        /// <summary>
        /// public static void install_mh_nw()
        /// Installing management host, ssh using name-password
        /// </summary>
        public static void install_mh_nw()
        {
            //installing master template

            bool b_res = import_templ_task("master");

            // installing management template
            b_res = import_templ_task("management");
            string ssh_res = "";

            if (!b_res)
            {
                logger.Info("trying import management again");
                //need to remove previouis import
                string killcmd = "sudo kill `ps -ef | grep import | grep -v grep | awk '{print $2}'`";
                ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu",
                                                killcmd, 7);
                logger.Info("Importing stuck first time, killing processes: {0}", ssh_res);

                if (ssh_res.Contains("Connection Error"))
                {
                    string kh_path = Path.Combine($"{ Program.inst_Dir}home", Environment.UserName, ".ssh", "known_hosts");
                    FD.edit_known_hosts(kh_path);

                    //restarting VM
                    if (!VMs.restart_vm(TC._cloneName))
                    {
                        //can not restart VM
                        Program.ShowError("Can not restart VM, please check VM state and try to install later", "Can not start VM");
                        Program.form1.Visible = false;
                    }
                    ;
                }
                //remove previously installed master
                ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu",
                                                "sudo subutai destroy master", 7);
                logger.Info("Destroying master to import second time: {0}", ssh_res);

                ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu",
                                                "sudo subutai destroy management", 7);
                logger.Info("Destroying management to import second time: {0}", ssh_res);

                b_res = import_templ_task("master");

                b_res = import_templ_task("management");
                if (!b_res)
                {
                    logger.Info("import management failed second time");
                    Program.form1.Invoke((MethodInvoker) delegate
                    {
                        Program.ShowError("Management template was not installed, installation failed, please try to install later", "Management template was not imported");
                        Program.form1.Visible = false;
                    });
                }
            }

            ssh_res = Deploy.SendSshCommand("127.0.0.1", 4567, "ubuntu", "ubuntu",
                                            "sudo bash subutai info ipaddr", 7);
            //todo: delete old
            logger.Info("Import management address returned by subutai info: {0}", ssh_res);

            string rhIP = Deploy.com_out(ssh_res, 1);

            if (!is_ip_address(rhIP))
            {
                logger.Error("import management failed ", "Management template was not installed");
                Program.ShowError("Management template was not installed, installation failed, removing", "Management template was not imported");
                Program.form1.Visible = false;
            }
        }