public FetchPassword(CEc2Instance ins) { this.InitializeComponent(); StatusBk.Text = ConstantString.ContactAmazon; oThread = new Thread(getPassword); oThread.Start(ins); okButton.IsEnabled = false; enableProgressBar(); }
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); } }
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); } }
public List <CEc2Instance> describeInstances() { List <CEc2Instance> myInstances = new List <CEc2Instance>(); try { DescribeInstancesRequest request = new DescribeInstancesRequest(); DescribeInstancesResponse response = _service.DescribeInstances(request); if (response.IsSetDescribeInstancesResult()) { DescribeInstancesResult describeInstancesResult = response.DescribeInstancesResult; List <Reservation> reservationList = describeInstancesResult.Reservation; foreach (Reservation reservation in reservationList) { List <RunningInstance> runningInstanceList = reservation.RunningInstance; foreach (RunningInstance runningInstance in runningInstanceList) { CEc2Instance inst = new CEc2Instance(); if (runningInstance.IsSetInstanceId()) { inst.instanceId = runningInstance.InstanceId; } if (runningInstance.IsSetImageId()) { inst.imageId = runningInstance.ImageId; } if (runningInstance.IsSetInstanceState()) { InstanceState instanceState = runningInstance.InstanceState; if (instanceState.IsSetName()) { inst.status = instanceState.Name; } } if (runningInstance.IsSetPublicDnsName()) { inst.publicDns = runningInstance.PublicDnsName; } if (runningInstance.IsSetKeyName()) { inst.keyPairName = runningInstance.KeyName; } if (runningInstance.IsSetInstanceType()) { inst.type = runningInstance.InstanceType; } if (runningInstance.IsSetLaunchTime()) { inst.launchTime = runningInstance.LaunchTime; } if (runningInstance.IsSetPlacement()) { if (runningInstance.Placement.IsSetAvailabilityZone()) { inst.zone = runningInstance.Placement.AvailabilityZone; } } if (runningInstance.IsSetPlatform()) { inst.platform = runningInstance.Platform; } myInstances.Add(inst); } } } } catch (AmazonEC2Exception ex) { throw new Exception("Caught Exception: " + ex.XML); } return(myInstances); }
public List<CEc2Instance> describeInstances() { List<CEc2Instance> myInstances = new List<CEc2Instance>(); try { DescribeInstancesRequest request = new DescribeInstancesRequest(); DescribeInstancesResponse response = _service.DescribeInstances(request); if (response.IsSetDescribeInstancesResult()) { DescribeInstancesResult describeInstancesResult = response.DescribeInstancesResult; List<Reservation> reservationList = describeInstancesResult.Reservation; foreach (Reservation reservation in reservationList) { List<RunningInstance> runningInstanceList = reservation.RunningInstance; foreach (RunningInstance runningInstance in runningInstanceList) { CEc2Instance inst = new CEc2Instance(); if (runningInstance.IsSetInstanceId()) inst.instanceId = runningInstance.InstanceId; if (runningInstance.IsSetImageId()) inst.imageId = runningInstance.ImageId; if (runningInstance.IsSetInstanceState()) { InstanceState instanceState = runningInstance.InstanceState; if (instanceState.IsSetName()) inst.status = instanceState.Name; } if (runningInstance.IsSetPublicDnsName()) inst.publicDns = runningInstance.PublicDnsName; if (runningInstance.IsSetKeyName()) inst.keyPairName = runningInstance.KeyName; if (runningInstance.IsSetInstanceType ()) inst.type = runningInstance.InstanceType; if (runningInstance.IsSetLaunchTime()) inst.launchTime = runningInstance.LaunchTime; if (runningInstance.IsSetPlacement()) if(runningInstance.Placement.IsSetAvailabilityZone()) inst.zone = runningInstance.Placement.AvailabilityZone; if (runningInstance.IsSetPlatform()) inst.platform = runningInstance.Platform; myInstances.Add(inst); } } } } catch (AmazonEC2Exception ex) { throw new Exception("Caught Exception: " + ex.XML); } return myInstances; }