Пример #1
0
        private void installRemotely()
        {
            try
            {
                if (_instance.isPortReady() == false)
                {
                    Dispatcher.Invoke(new SetDeploymentStatus(setDeploymentStatus), ConstantString.InstanceReady);
                    _instance.waitForPortReady();
                }

                Dispatcher.Invoke(new SetDeploymentStatus(setDeploymentStatus), ConstantString.UploadMsi);
                CEc2Instance.SDeployInfo deployInfo = _instance.uploadAndInstallMsi(_password, _msiPath);
                if (string.IsNullOrEmpty(deployInfo.installId) == false)
                {
                    Dispatcher.Invoke(new SetDeploymentStatus(setDeploymentStatus), ConstantString.InstallProgress);
                    _instance.checkDeploymentStatus(deployInfo);
                }
            }
            catch (ThreadAbortException)
            {
                succeed = false;
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
                succeed = false;
            }

            Dispatcher.Invoke(new StopProgressbarCallback(disableProgressBar));
            Dispatcher.Invoke(new SetDeploymentDone(deploymentDone));
            oThread = null;
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                if (args != null)
                {
                    if (args[0] == "-h" || args[0] == "/h")
                    {
                        Console.WriteLine("This will launch an instance of ami-11af4978 and prompt you to install a msi program on the created instance. You will be charged by Amazon on an hourly rate.");
                        Console.WriteLine("Make sure these environent variables are set:");
                        Console.WriteLine("    AWS_ACCESS_KEY_ID");
                        Console.WriteLine("    AWS_SECRET_ACCESS_KEY");
                        Console.WriteLine("    EC2_PRIVATE_KEY");
                        Console.WriteLine("    EC2_HOME");
                        Console.WriteLine("    JAVA_HOME");
                        Console.WriteLine("Then run Ec2Bootstrapper [password]");
                        Console.WriteLine("where the password is the AMI instance administrator's password. It is optional if you have not changed it yet.");
                        return;
                    }
                }
                if (checkEnvironment() == false)
                {
                    return;
                }

                string accessKey = Environment.GetEnvironmentVariable("AWS_ACCESS_KEY_ID");
                string secretKey = Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY");

                Ec2Bootstrapperlib.CEc2Instance instance = new Ec2Bootstrapperlib.CEc2Instance();
                instance.imageId = Ec2Bootstrapperlib.CEc2Instance.deployableAmiImageId;
                instance.launch();
                if (instance.isPortReady() == false)
                {
                    Console.WriteLine("Waiting for the instance reachable. This might take upto 5 minutes...");
                    instance.waitForPortReady();
                }

                CEc2Instance.SDeployInfo deployInfo = instance.uploadAndInstallMsi(args[0], null);
                if (string.IsNullOrEmpty(deployInfo.installId) == true)
                {
                    Console.WriteLine("Installation is not started on the instance successfully.");
                    return;
                }
                Console.WriteLine("Installation is started on the instance successfully. Checking installation progress...");
                instance.checkDeploymentStatus(deployInfo);

                Console.WriteLine("Installtaion succeeds");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught exception: " + ex.Message);
            }
        }