Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
services.ec2: Deprecate the PV images
Browse files Browse the repository at this point in the history
Signed-off-by: Sayan Chowdhury <[email protected]>
  • Loading branch information
sayanchowdhury committed Apr 12, 2018
1 parent 3a3fc64 commit 744b729
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 42 deletions.
17 changes: 1 addition & 16 deletions fedimg/services/ec2/ec2imgpublisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 """
Expand Down
15 changes: 2 additions & 13 deletions fedimg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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',
Expand Down
14 changes: 1 addition & 13 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 744b729

Please sign in to comment.