You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by er...@apache.org on 2016/02/24 16:47:18 UTC
libcloud git commit: [google compute] allow bypassing image search in
standard project list
Repository: libcloud
Updated Branches:
refs/heads/trunk 1ba38fac9 -> 7013b6a19
[google compute] allow bypassing image search in standard project list
Support not using standard projects on images get and support families from copy image.
Signed-off-by: Eric Johnson <er...@google.com>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7013b6a1
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7013b6a1
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7013b6a1
Branch: refs/heads/trunk
Commit: 7013b6a190c0017ab13e0cea95a36eaeceb2abb2
Parents: 1ba38fa
Author: Max Illfelder <il...@google.com>
Authored: Tue Feb 23 11:24:32 2016 -0800
Committer: Eric Johnson <er...@google.com>
Committed: Wed Feb 24 15:46:32 2016 +0000
----------------------------------------------------------------------
CHANGES.rst | 4 ++++
libcloud/compute/drivers/gce.py | 25 +++++++++++++++++++------
libcloud/test/compute/test_gce.py | 10 +++++++++-
3 files changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/7013b6a1/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 4fb634a..889e09e 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -31,6 +31,10 @@ General
Compute
~~~~~~~
+- [google compute] allow bypassing image search in standard project list
+ (GITHUB-713)
+ [Max Illfelder]
+
- Add support for requesting a MKS token for accessing the remote console in VMware
vCloud driver
(GITHUB-706)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/7013b6a1/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index c3fcf6b..7b4960d 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -4060,7 +4060,8 @@ class GCENodeDriver(NodeDriver):
response = self.connection.request(request, method='GET').object
return self._to_forwarding_rule(response)
- def ex_get_image(self, partial_name, ex_project_list=None):
+ def ex_get_image(self, partial_name, ex_project_list=None,
+ ex_standard_projects=True):
"""
Return an GCENodeImage object based on the name or link provided.
@@ -4068,6 +4069,14 @@ class GCENodeDriver(NodeDriver):
image.
:type partial_name: ``str``
+ :param ex_project_list: The name of the project to list for images.
+ Examples include: 'debian-cloud'.
+ :type ex_project_List: ``str``, ``list`` of ``str``, or ``None``
+
+ :param ex_standard_projects: If true, check in standard projects if
+ the image is not found.
+ :type ex_standard_projects: ``bool``
+
:return: GCENodeImage object based on provided information or None if
an image with that name is not found.
:rtype: :class:`GCENodeImage` or raise ``ResourceNotFoundError``
@@ -4076,7 +4085,7 @@ class GCENodeDriver(NodeDriver):
response = self.connection.request(partial_name, method='GET')
return self._to_node_image(response.object)
image = self._match_images(ex_project_list, partial_name)
- if not image:
+ if not image and ex_standard_projects:
for img_proj, short_list in self.IMAGE_PROJECTS.items():
for short_name in short_list:
if partial_name.startswith(short_name):
@@ -4319,7 +4328,7 @@ class GCENodeDriver(NodeDriver):
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.
@@ -4332,6 +4341,9 @@ class GCENodeDriver(NodeDriver):
: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``
@@ -4344,6 +4356,7 @@ class GCENodeDriver(NodeDriver):
image_data = {
'name': name,
'description': description,
+ 'family': family,
'sourceType': 'RAW',
'rawDisk': {
'source': url,
@@ -4490,9 +4503,9 @@ class GCENodeDriver(NodeDriver):
supplied project. If no project is given, it will search your own
project.
- :param project: The name of the project to search for images.
- Examples include: 'debian-cloud' and 'centos-cloud'.
- :type project: ``str`` or ``None``
+ :param project: The name of the project to search for images.
+ Examples include: 'debian-cloud' and 'centos-cloud'.
+ :type project: ``str``, ``list`` of ``str``, or ``None``
:param partial_name: The full name or beginning of a name for an
image.
http://git-wip-us.apache.org/repos/asf/libcloud/blob/7013b6a1/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index 15247e3..ef6a158 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -1139,13 +1139,21 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
image = self.driver.ex_get_image(partial_name, ['debian-cloud'])
self.assertEqual(image.name, 'debian-7-wheezy-v20131120')
+ partial_name = 'debian-7'
+ self.assertRaises(ResourceNotFoundError, self.driver.ex_get_image,
+ partial_name, 'suse-cloud',
+ ex_standard_projects=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'