Skip to content
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 from

Conversation

@fcuny
Copy link
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
Copy link
Member

Kami commented Mar 10, 2014

/cc @wrigri


# 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.)

"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.

@@ -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
Copy link
Contributor

wrigri commented Mar 10, 2014

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

: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/

@fcuny
Copy link
Contributor Author

fcuny commented Mar 10, 2014

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


# 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)

This comment has been minimized.

@Kami

Kami Mar 14, 2014 Member

Besides that, LGTM.

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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.