New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method `ex_copy_image` to the GCE driver. #258

Closed
wants to merge 1 commit into
base: trunk
from

Conversation

Projects
None yet
3 participants
@fcuny
Contributor

fcuny commented Mar 10, 2014

The ex_copy_image method allow to copy an image from a Google Cloud
Storage URL in the specified project.

I'm going to need this to implement this part in Ansible soon.

Thanks.

@Kami

This comment has been minimized.

Show comment
Hide comment
@Kami
Member

Kami commented Mar 10, 2014

/cc @wrigri

@wrigri

View changes

Show outdated Hide outdated libcloud/compute/drivers/gce.py
# the URL for an image can start with gs://
if url.startswith('gs://'):
url = ('http://storage.googleapis.com/' + url[len('gs://'):])

This comment has been minimized.

@wrigri

wrigri Mar 10, 2014

Contributor

The URL should be 'https:' not 'http:'

Also, the [len('gs://'):] construct seems overly complicated. Maybe something like this instead?
url.replace('gs://', 'https://storage.googleapis.com/', 1)

(I can't imagine what a url would look like that had more than one 'gs://' in it, but added the '1' to the parameters just in case.)

@wrigri

wrigri Mar 10, 2014

Contributor

The URL should be 'https:' not 'http:'

Also, the [len('gs://'):] construct seems overly complicated. Maybe something like this instead?
url.replace('gs://', 'https://storage.googleapis.com/', 1)

(I can't imagine what a url would look like that had more than one 'gs://' in it, but added the '1' to the parameters just in case.)

@wrigri

View changes

Show outdated Hide outdated libcloud/test/compute/fixtures/gce/global_images.json
"containerType": "TAR",
"source": ""
},
"selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/operations/operation-global_image_post",

This comment has been minimized.

@wrigri

wrigri Mar 10, 2014

Contributor

This link should probably be a link to the image, not to the operation.

@wrigri

wrigri Mar 10, 2014

Contributor

This link should probably be a link to the image, not to the operation.

@@ -501,6 +501,14 @@ def test_ex_get_image(self):
self.assertEqual(image.name, 'debian-6-squeeze-v20130926')
self.assertTrue(image.extra['description'].startswith('Debian'))
def test_ex_copy_image(self):
name = 'coreos'

This comment has been minimized.

@wrigri

wrigri Mar 10, 2014

Contributor

Your names don't seem to match here. The targetLink in the test fixtures references 'core-os' and this is 'coreos'. The tests don't currently care about that level of detail, but it would be nice to have it consistent.

@wrigri

wrigri Mar 10, 2014

Contributor

Your names don't seem to match here. The targetLink in the test fixtures references 'core-os' and this is 'coreos'. The tests don't currently care about that level of detail, but it would be nice to have it consistent.

@wrigri

This comment has been minimized.

Show comment
Hide comment
@wrigri

wrigri Mar 10, 2014

Contributor

Looks good overall. A couple of minor things, but otherwise it seems like a good addition.

Contributor

wrigri commented Mar 10, 2014

Looks good overall. A couple of minor things, but otherwise it seems like a good addition.

@wrigri

View changes

Show outdated Hide outdated libcloud/compute/drivers/gce.py
:param name: The name of the image
:type name: ``str``
:param url: The URL to the image. The URL can starts with `gs://`

This comment has been minimized.

@wrigri

wrigri Mar 10, 2014

Contributor

s/starts/start/

@wrigri

wrigri Mar 10, 2014

Contributor

s/starts/start/

@fcuny

This comment has been minimized.

Show comment
Hide comment
@fcuny

fcuny Mar 10, 2014

Contributor

Thanks @wrigri, I'll update this patch later today.

Contributor

fcuny commented Mar 10, 2014

Thanks @wrigri, I'll update this patch later today.

@Kami

View changes

Show outdated Hide outdated libcloud/compute/drivers/gce.py
# the URL for an image can start with gs://
if url.startswith('gs://'):
url.replace('gs://', 'https://storage.googleapis.com/', 1)

This comment has been minimized.

@Kami

Kami Mar 14, 2014

Member

Python strings are immutable and .replace returns a new string. This means you should do:

url = url.replace('gs://', 'https://storage.googleapis.com/', 1)
@Kami

Kami Mar 14, 2014

Member

Python strings are immutable and .replace returns a new string. This means you should do:

url = url.replace('gs://', 'https://storage.googleapis.com/', 1)

This comment has been minimized.

@Kami

Kami Mar 14, 2014

Member

Besides that, LGTM.

@Kami

Kami Mar 14, 2014

Member

Besides that, LGTM.

Add method `ex_copy_image` to the GCE driver.
The `ex_copy_image` method allow to copy an image from a Google Cloud
Storage URL in the specified project.

@asfgit asfgit closed this in 2434ef5 Mar 17, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment