Skip to content

Commit

Permalink
Support families from copy image.
Browse files Browse the repository at this point in the history
  • Loading branch information
illfelder committed Feb 23, 2016
1 parent 9160272 commit 84ad97d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion libcloud/compute/drivers/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -4328,7 +4328,7 @@ def ex_get_zone(self, name):
return None
return self._to_zone(response)

def ex_copy_image(self, name, url, description=None):
def ex_copy_image(self, name, url, description=None, family=None):
"""
Copy an image to your image collection.
Expand All @@ -4341,6 +4341,9 @@ def ex_copy_image(self, name, url, description=None):
:param description: The description of the image
:type description: ``str``
:param family: The family of the image
:type family: ``str``
:return: NodeImage object based on provided information or None if an
image with that name is not found.
:rtype: :class:`NodeImage` or ``None``
Expand All @@ -4353,6 +4356,7 @@ def ex_copy_image(self, name, url, description=None):
image_data = {
'name': name,
'description': description,
'family': family,
'sourceType': 'RAW',
'rawDisk': {
'source': url,
Expand Down
7 changes: 5 additions & 2 deletions libcloud/test/compute/test_gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,15 +1141,18 @@ def test_ex_get_image(self):

partial_name = 'debian-7'
self.assertRaises(ResourceNotFoundError, self.driver.ex_get_image,
partial_name, 'suse-cloud', ex_standard_list=False)
partial_name, 'suse-cloud', ex_standard_list=False)

def test_ex_copy_image(self):
name = 'coreos'
url = 'gs://storage.core-os.net/coreos/amd64-generic/247.0.0/coreos_production_gce.tar.gz'
description = 'CoreOS beta 522.3.0'
image = self.driver.ex_copy_image(name, url, description)
family = 'coreos'
image = self.driver.ex_copy_image(name, url, description=description,
family=family)
self.assertTrue(image.name.startswith(name))
self.assertEqual(image.extra['description'], description)
self.assertEqual(image.extra['family'], family)

def test_ex_get_route(self):
route_name = 'lcdemoroute'
Expand Down

0 comments on commit 84ad97d

Please sign in to comment.