Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C25717F34 for ; Tue, 5 May 2015 13:26:06 +0000 (UTC) Received: (qmail 8282 invoked by uid 500); 5 May 2015 13:25:57 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 8221 invoked by uid 500); 5 May 2015 13:25:57 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 7968 invoked by uid 99); 5 May 2015 13:25:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 May 2015 13:25:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B35D2E10BE; Tue, 5 May 2015 13:25:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebgoa@apache.org To: commits@cloudstack.apache.org Date: Tue, 05 May 2015 13:26:26 -0000 Message-Id: <24d55d39c4934594bd5d936d8e7323d5@git.apache.org> In-Reply-To: <221c3e069cfc492fb79c05f2b8305f09@git.apache.org> References: <221c3e069cfc492fb79c05f2b8305f09@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [33/50] cloudstack-ec2stack git commit: Remove instance disk - always use same sutom disk 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 Authored: Mon Aug 18 18:40:21 2014 +0100 Committer: BroganD1993 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'