private void DetachVolume(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.DetachVolume(Device, InstanceId, VolumeId, Force);
         Log.LogMessage(MessageImportance.Normal, "Detached volume");
     }
 }
 private void DeleteSnapShot(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.DeleteSnapShot(SnapShotId);
         Log.LogMessage(MessageImportance.Normal, "Deleted SnapShot {0}", SnapShotId);
     }
 }
Example #3
0
 private void CreateVolume(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         VolumeId = helper.CreateNewVolume(AvailabilityZone, Size);
         Log.LogMessage(MessageImportance.Normal, "Created volume of size {0}MiB with VolumeId {1}", Size, VolumeId);
     }
 }
 private void RebootInstances(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.RebootInstance(InstanceIds);
         Log.LogMessage(MessageImportance.Normal, "Stopped Instances {0}", Join(InstanceIds));
     }
 }
 private void StartInstances(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.StartInstances(InstanceIds);
         Log.LogMessage(MessageImportance.Normal, "Started Instances {0}", Join(InstanceIds));
     }
 }
Example #6
0
 private void DeleteVolume(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.DeleteVolume(VolumeId);
         Log.LogMessage(MessageImportance.Normal, "Deleted Volume {0}", VolumeId);
     }
 }
 private void DisassociateIpAddress(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.DisassociateIpAddress(IpAddress);
         Log.LogMessage(MessageImportance.Normal, "Disassiociated IPAddress {0}", IpAddress);
     }
 }
 private void AssociateIpAddress(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.AssociateIpAddress(InstanceId, IpAddress);
         Log.LogMessage(MessageImportance.Normal, "Associated IP Address {0} with InstanceId {1}", IpAddress, InstanceId);
     }
 }
 private void CreateVolume(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         VolumeId = helper.CreateNewVolume(AvailabilityZone, Size);
         Log.LogMessage(MessageImportance.Normal, "Created volume of size {0}MiB with VolumeId {1}", Size, VolumeId);
     }
 }
Example #10
0
 private void CreateVolume(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         VolumeId = helper.CreateVolumeFromSnapshot(AvailabilityZone, SnapShotId);
         Log.LogMessage(MessageImportance.Normal, "Created volume {0} from SnapShot {1}", VolumeId, SnapShotId);
     }
 }
 private void DetachVolume(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.DetachVolume(Device, InstanceId, VolumeId, Force);
         Log.LogMessage(MessageImportance.Normal, "Detached volume");
     }
 }
Example #12
0
 private void TerminateInstances(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.TerminateInstance(InstanceIds);
         Log.LogMessage(MessageImportance.Normal, "Terminiated Instances {0}", Join(InstanceIds));
     }
 }
 private void CreateVolume(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         VolumeId = helper.CreateVolumeFromSnapshot(AvailabilityZone, SnapShotId);
         Log.LogMessage(MessageImportance.Normal, "Created volume {0} from SnapShot {1}", VolumeId, SnapShotId);
     }
 }
 private void CreateSnapShot(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         SnapShotId = helper.CreateSnapShot(VolumeId, Description);
         Log.LogMessage(MessageImportance.Normal, "Snapshot {0} created of volume {1} ", SnapShotId, VolumeId);
     }
 }
 private void WaitForInstances(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.WaitForInstances(InstanceIds, DesiredState.ToLower(), TimeOutSeconds, PollIntervalSeconds);
         Log.LogMessage(MessageImportance.Normal, "All Instances {0} in the state {1}", Join(InstanceIds), DesiredState);
     }
 }
Example #16
0
 private void AssociateIpAddress(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.AssociateIpAddress(InstanceId, IpAddress);
         Log.LogMessage(MessageImportance.Normal, "Associated IP Address {0} with InstanceId {1}", IpAddress, InstanceId);
     }
 }
 private void DeleteSnapShot(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.DeleteSnapShot(SnapShotId);
         Log.LogMessage(MessageImportance.Normal, "Deleted SnapShot {0}", SnapShotId);
     }
 }
Example #18
0
 private void DisassociateIpAddress(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         helper.DisassociateIpAddress(IpAddress);
         Log.LogMessage(MessageImportance.Normal, "Disassiociated IPAddress {0}", IpAddress);
     }
 }
        public void AssociateIpAddressWithInstance_Should_Succeed()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            ec2Helper.AssociateIpAddress(DefaultInstanceId, DefaultIpAddress);
        }
 private void RunInstances(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         // Run up the instances and return the InstanceId's
         InstanceIds = helper.RunInstance(ImageId, NumberOfInstances, KeyName, UserData, SecurityGroups, AvailabilityZone).ToArray();
         Log.LogMessage(MessageImportance.Normal, "Run {0} Instances", NumberOfInstances);
     }
 }
Example #21
0
        private void StartInstances(AwsClientDetails clientDetails)
        {
            using (var helper = new EC2Helper(clientDetails))
            {
                RunningInstance instance = helper.DescribeInstance(InstanceId);
                Log.LogMessage(MessageImportance.Normal, "Got Instance {0} details", InstanceId);

                SetOutputProperties(instance);
            }
        }
        public void CreateNewVolume_Should_CreateNewVolume()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            // Create a 2Gb volumne.
            string volumeId = ec2Helper.CreateNewVolume("us-east-1b", "2"); // "us-east-1b"

            Assert.IsNotEmpty(volumeId, "Expected VolumeId");
        }
        public void AttachVolumeToInstance_Should_AttachVolume()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            const string device = "xvdf";
            const string volumeId = "vol-6bd56a02";
            const string instanceId = "i-6de0a406";

            ec2Helper.AttachVolume(device, instanceId, volumeId);
        }
        public void CreateSnapShotFromVolume_Should_CreateSnapShot()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            const string volumeId = "vol-d1e15eb8";
            const string description = "Test SnapShot";

            // Create a 2Gb volumne.
            string snapShotId = ec2Helper.CreateSnapShot(volumeId, description);

            Assert.IsNotEmpty(snapShotId, "Expected SnapShot Id");
        }
 private void GetPublicDNS(AwsClientDetails clientDetails)
 {
     if (Region != null)
     {
         using (var helper = new EC2Helper(clientDetails, Region))
         {
             helper.GetPublicDNS(InstanceName);
             Log.LogMessage(MessageImportance.Normal, "Public DNS and IP address for instance {0} retrived ", InstanceName);
             PublicDNS = helper.publicDNS;
             PublicIP = helper.publicIP;
         }
     }
     else
     {
         using (var helper = new EC2Helper(clientDetails))
         {
             helper.GetPublicDNS(InstanceName);
             Log.LogMessage(MessageImportance.Normal, "Public DNS and IP address for instance {0} retrived ", InstanceName);
             PublicDNS = helper.publicDNS;
             PublicIP = helper.publicIP;
         }
     }
 }
        public void TerminateInstnace_Should_TerminateInstance()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            // TODO: this instanceId will change based on the Run Instance test.
            ec2Helper.TerminateInstance(new string[] { "i-6503450e" });
        }
        private void StartInstances(AwsClientDetails clientDetails)
        {
            using (var helper = new EC2Helper(clientDetails))
            {
                RunningInstance instance = helper.DescribeInstance(InstanceId);
                Log.LogMessage(MessageImportance.Normal, "Got Instance {0} details", InstanceId);

                SetOutputProperties(instance);
            }
        }
        public void DeleteSnapShot_Should_DeleteSnapShot()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            const string snapShotId = "snap-422c832a";

            ec2Helper.DeleteSnapShot(snapShotId);
        }
        public void DeleteVolume_Should_DeleteVolume()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            const string volumeId = "vol-d1e15eb8";

            // Delete the volume
            ec2Helper.DeleteVolume(volumeId);
        }
        public void DescribeInstance_Should_ReturnInstanceDetails()
        {
            // NB: This test requires an EC2 Instance to succeed.
            const string instanceId = "i-6de0a406";

             var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            Amazon.EC2.Model.RunningInstance instance = ec2Helper.DescribeInstance(instanceId);

            Assert.IsNotNull(instance, "No instance");
        }
        public void Reboot_Should_RebootInstance()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            // TODO: this instanceId will change based on the Run Instance test.
            ec2Helper.RebootInstance(new string[] { "i-4501472e" });
        }
        public void RunInstance_Should_RunInstance()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            // Modify these to match your own AWS settings.
            const string ami = "ami-bfab42d6";
            const string keyPair = "BookSwapPair1";
            const string securityGroup = "Basic";
            const string userData = "";
            const string availabilityZone = "us-east-1a";

            List<string> instances = ec2Helper.RunInstance(ami, 1, keyPair, userData, new string[] { securityGroup }, availabilityZone);

            Assert.IsNotEmpty(instances);
        }
 private void RunInstances(AwsClientDetails clientDetails)
 {
     using (var helper = new EC2Helper(clientDetails))
     {
         // Run up the instances and return the InstanceId's
         InstanceIds = helper.RunInstance(ImageId, NumberOfInstances, KeyName, UserData, SecurityGroups, AvailabilityZone).ToArray();
         Log.LogMessage(MessageImportance.Normal, "Run {0} Instances", NumberOfInstances);
     }
 }
        public void StartInstances_Should_Start_Instance()
        {
            // Get the client details from the stored client details (rather than embed secret keys in the test).
            // Ensure that your AWS/Secret keys have been stored before running.
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            ec2Helper.StartInstances(new string[] { DefaultInstanceId });
        }
        public void StopInstances_Should_Stop_Instance()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            ec2Helper.StopInstances(new string[] { DefaultInstanceId });
        }
        public void CreateVolumeFromSnapShot_Should_CreateNewVolume()
        {
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            EC2Helper ec2Helper = new EC2Helper(clientDetails);

            const string availabilityZone = "us-east-1b";
            const string snapShotId = "snap-422c832a";

            // Create a 2Gb volumne.
            string volumeId = ec2Helper.CreateVolumeFromSnapshot(availabilityZone, snapShotId);

            Assert.IsNotEmpty(volumeId, "Expected VolumeId");
        }