From 744b729ce5ccee1b610be978c6c7a671b609ab17 Mon Sep 17 00:00:00 2001 From: Sayan Chowdhury Date: Thu, 12 Apr 2018 19:58:46 +0530 Subject: [PATCH] services.ec2: Deprecate the PV images Signed-off-by: Sayan Chowdhury --- fedimg/services/ec2/ec2imgpublisher.py | 17 +---------------- fedimg/utils.py | 15 ++------------- tests/test_utils.py | 14 +------------- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/fedimg/services/ec2/ec2imgpublisher.py b/fedimg/services/ec2/ec2imgpublisher.py index d6db295..b806491 100644 --- a/fedimg/services/ec2/ec2imgpublisher.py +++ b/fedimg/services/ec2/ec2imgpublisher.py @@ -29,8 +29,6 @@ import fedimg.messenger from fedimg.utils import external_run_command, get_item_from_regex -from fedimg.utils import get_volume_type_from_image -from fedimg.utils import get_virt_type_from_image from fedimg.utils import get_image_name_from_ami_name from fedimg.services.ec2.ec2base import EC2Base @@ -152,20 +150,7 @@ def get_volume_type_from_image(self, image): return blk_mapping[0]['ebs']['volume_type'] def get_virt_type_from_image(self, image): - if isinstance(image, str): - image_id = image - image = self._connect().get_image(image_id) - - blk_mapping = image.extra['block_device_mapping'] - if not blk_mapping: - blk_mapping = self._retry_till_blk_mapping_is_available(image) - - device_name = blk_mapping[0]['ebs']['volume_type'] - - if device_name.endswith('sda1'): - return 'hvm' - else: - return 'paravirtual' + return 'hvm' def publish_images(self, region_image_mapping=None): """ Comment goes here """ diff --git a/fedimg/utils.py b/fedimg/utils.py index c87d0d3..5a5a169 100644 --- a/fedimg/utils.py +++ b/fedimg/utils.py @@ -62,13 +62,7 @@ def get_rawxz_urls(location, images): def get_virt_types_from_url(url): """ Takes a URL to a .raw.xz image file) and returns the suspected virtualization type that the image file should be registered as. """ - file_name = url.split('/')[-1].lower() - if file_name.find('atomic') != -1: - # hvm is required for atomic images - return ['hvm'] - else: - # otherwise, build the AMIs with both virtualization types - return ['hvm', 'paravirtual'] + return ['hvm'] def region_to_driver(region): @@ -151,12 +145,7 @@ def get_volume_type_from_image(image, region): def get_virt_type_from_image(image): - device_name = image.extra['block_device_mapping'][0]['device_name'] - - if device_name.endswith('sda1'): - return 'hvm' - else: - return 'paravirtual' + return 'hvm' def get_image_name_from_image(image_url, virt_type='', region='', respin='0', diff --git a/tests/test_utils.py b/tests/test_utils.py index 4bbf69c..37c8d00 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -145,7 +145,7 @@ def test_get_rawxz_urls_empty(self): def test_get_virt_types_hvm_pv(self): url = 'https://somepage.org/Fedora-Cloud-Base-26-1.5.x86_64.raw.xz' vtypes = fedimg.utils.get_virt_types_from_url(url) - assert vtypes == ['hvm', 'paravirtual'] + assert vtypes == ['hvm'] def test_get_virt_types_only_hvm(self): url = 'https://somepage.org/Fedora-Atomic-26-1.5.x86_64.raw.xz' @@ -285,18 +285,6 @@ def test_get_virt_type_from_image_hvm(self): assert virt_type == 'hvm' - def test_get_virt_type_from_image_paravirtual(self): - mock_image = mock.Mock() - mock_image.extra = { - 'block_device_mapping': [{ - 'device_name': '/dev/sda' - }] - } - - virt_type = fedimg.utils.get_virt_type_from_image(mock_image) - - assert virt_type == 'paravirtual' - def test_region_to_driver(self): driver_1 = fedimg.utils.region_to_driver('us-east-1') driver_2 = fedimg.utils.region_to_driver('eu-west-1')