cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject [33/50] cloudstack-ec2stack git commit: Remove instance disk - always use same sutom disk
Date Tue, 05 May 2015 13:26:26 GMT
Remove instance disk - always use same sutom disk


Project: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/commit/3d419b8c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/tree/3d419b8c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/diff/3d419b8c

Branch: refs/heads/master
Commit: 3d419b8c1e5c47d377d1faeb5206ebe4d1ecaa37
Parents: 9335852
Author: BroganD1993 <darrenbrogan@hotmail.com>
Authored: Mon Aug 18 18:40:21 2014 +0100
Committer: BroganD1993 <darrenbrogan@hotmail.com>
Committed: Mon Aug 18 18:40:21 2014 +0100

----------------------------------------------------------------------
 ec2stack/configure.py                      |  10 ---
 ec2stack/providers/cloudstack/instances.py |  11 +--
 pylint.rc                                  |   2 +-
 tests/instances_tests.py                   | 112 ++++++++++++++++++++++++
 4 files changed, 116 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/blob/3d419b8c/ec2stack/configure.py
----------------------------------------------------------------------
diff --git a/ec2stack/configure.py b/ec2stack/configure.py
index 5c4ffee..cc2e6f6 100644
--- a/ec2stack/configure.py
+++ b/ec2stack/configure.py
@@ -168,16 +168,6 @@ def _set_optional_attributes_of_profile(config, profile):
     @param profile: the profile to set the attribute in.
     @return: configparser configuration.
     """
-
-    configure_instance_disk = raw_input(
-        'Do you wish to input a second custom storage disk for instances? (Yes/No): '
-    )
-
-    if configure_instance_disk.lower() in ['yes', 'y']:
-        config = _set_attribute_of_profile(
-            config, profile, 'cloudstack_instance_custom_disk_offering', 'Cloudstack custom
instance disk offering name', 'CustomInstance'
-        )
-
     configure_instance_type_mapings = raw_input(
         'Do you wish to input instance type mappings? (Yes/No): '
     )

http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/blob/3d419b8c/ec2stack/providers/cloudstack/instances.py
----------------------------------------------------------------------
diff --git a/ec2stack/providers/cloudstack/instances.py b/ec2stack/providers/cloudstack/instances.py
index 3e8115b..01d2127 100644
--- a/ec2stack/providers/cloudstack/instances.py
+++ b/ec2stack/providers/cloudstack/instances.py
@@ -178,14 +178,9 @@ def _run_instance_request():
     if helpers.get('BlockDeviceMapping.1.Ebs.VolumeType') is not None:
         disk_type = helpers.get('BlockDeviceMapping.1.Ebs.VolumeType')
         if disk_type == 'gp2':
-             if 'CLOUDSTACK_INSTANCE_CUSTOM_DISK_OFFERING' in current_app.config:
-                args['diskofferingid'] = disk_offerings.get_disk_offering(
-                    current_app.config['CLOUDSTACK_INSTANCE_CUSTOM_DISK_OFFERING']
-                )['id']
-             else:
-                errors.invalid_request(
-                    "Unable to configure secondary disk, please run ec2stack-configure and
choose to "
-                    "configure an instance disk")
+            args['diskofferingid'] = disk_offerings.get_disk_offering(
+                current_app.config['CLOUDSTACK_CUSTOM_DISK_OFFERING']
+            )['id']
 
         if helpers.get('BlockDeviceMapping.1.Ebs.VolumeSize') is None:
             errors.invalid_request("VolumeSize not found in BlockDeviceMapping")

http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/blob/3d419b8c/pylint.rc
----------------------------------------------------------------------
diff --git a/pylint.rc b/pylint.rc
index c45bc02..1819a65 100644
--- a/pylint.rc
+++ b/pylint.rc
@@ -236,7 +236,7 @@ max-locals=20
 max-returns=6
 
 # Maximum number of branch for function / method body
-max-branchs=12
+max-branches=16
 
 # Maximum number of statements in function / method body
 max-statements=50

http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/blob/3d419b8c/tests/instances_tests.py
----------------------------------------------------------------------
diff --git a/tests/instances_tests.py b/tests/instances_tests.py
index f1986c2..a53fa0b 100644
--- a/tests/instances_tests.py
+++ b/tests/instances_tests.py
@@ -315,6 +315,118 @@ class InstancesTestCase(Ec2StackAppTestCase):
         self.assert_ok(response)
         assert 'RunInstancesResponse' in response.data
 
+    def test_run_instance_gp2(self):
+        data = self.get_example_data()
+        data['Action'] = 'RunInstances'
+        data['ImageId'] = 'a32d70ee-95e4-11e3-b2e4-d19c9d3e5e1d'
+        data['MinCount'] = '0'
+        data['MaxCount'] = '0'
+        data['SecurityGroupId.1'] = 'example-security-group-id'
+        data['SecurityGroup.1'] = 'example-security-group-name'
+        data['KeyName'] = 'example-ssh-key-name'
+        data['UserData'] = 'example-user-data'
+        data['BlockDeviceMapping.1.Ebs.VolumeType'] = 'gp2'
+        data['BlockDeviceMapping.1.Ebs.VolumeSize'] = '20'
+        data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')
+
+        get = mock.Mock()
+        get.return_value.text = read_file(
+            'tests/data/valid_run_instance.json'
+        )
+        get.return_value.status_code = 200
+
+        get_disk_offering = mock.Mock()
+        get_disk_offering.return_value = json.loads(read_file(
+            'tests/data/disk_offering_search.json'
+        ))
+
+        get_service_offering = mock.Mock()
+        get_service_offering.return_value = json.loads(read_file(
+            'tests/data/service_offering_search.json'
+        ))
+
+        get_zone = mock.Mock()
+        get_zone.return_value = json.loads(read_file(
+            'tests/data/zones_search.json'
+        ))
+
+        with mock.patch('requests.get', get):
+            with mock.patch(
+                    'ec2stack.providers.cloudstack.disk_offerings.get_disk_offering',
+                    get_disk_offering
+            ):
+                with mock.patch(
+                        'ec2stack.providers.cloudstack.service_offerings.get_service_offering',
+                        get_service_offering
+                ):
+                    with mock.patch(
+                            'ec2stack.providers.cloudstack.zones.get_zone',
+                            get_zone
+                    ):
+                        response = self.post(
+                            '/',
+                            data=data
+                        )
+
+        self.assert_ok(response)
+        assert 'RunInstancesResponse' in response.data
+
+    def test_run_instance_gp2_no_volume_size(self):
+        data = self.get_example_data()
+        data['Action'] = 'RunInstances'
+        data['ImageId'] = 'a32d70ee-95e4-11e3-b2e4-d19c9d3e5e1d'
+        data['MinCount'] = '0'
+        data['MaxCount'] = '0'
+        data['SecurityGroupId.1'] = 'example-security-group-id'
+        data['SecurityGroup.1'] = 'example-security-group-name'
+        data['KeyName'] = 'example-ssh-key-name'
+        data['UserData'] = 'example-user-data'
+        data['BlockDeviceMapping.1.Ebs.VolumeType'] = 'gp2'
+        data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')
+
+        get = mock.Mock()
+        get.return_value.text = read_file(
+            'tests/data/valid_run_instance.json'
+        )
+        get.return_value.status_code = 200
+
+        get_disk_offering = mock.Mock()
+        get_disk_offering.return_value = json.loads(read_file(
+            'tests/data/disk_offering_search.json'
+        ))
+
+        get_service_offering = mock.Mock()
+        get_service_offering.return_value = json.loads(read_file(
+            'tests/data/service_offering_search.json'
+        ))
+
+        get_zone = mock.Mock()
+        get_zone.return_value = json.loads(read_file(
+            'tests/data/zones_search.json'
+        ))
+
+        with mock.patch('requests.get', get):
+            with mock.patch(
+                    'ec2stack.providers.cloudstack.disk_offerings.get_disk_offering',
+                    get_disk_offering
+            ):
+                with mock.patch(
+                        'ec2stack.providers.cloudstack.service_offerings.get_service_offering',
+                        get_service_offering
+                ):
+                    with mock.patch(
+                            'ec2stack.providers.cloudstack.zones.get_zone',
+                            get_zone
+                    ):
+                        response = self.post(
+                            '/',
+                            data=data
+                        )
+
+        self.assert_bad_request(response)
+        assert 'VolumeSize not found in BlockDeviceMapping' in response.data
+
+
     def test_run_instance_with_zone_and_type_(self):
         data = self.get_example_data()
         data['Action'] = 'RunInstances'


Mime
View raw message