Skip to content

improve GCE create_node, make sure ex_get_disktype function will not fail#448

Closed
mgogoulos wants to merge 1 commit intoapache:trunkfrom
mgogoulos:gce_create_node_disktype
Closed

improve GCE create_node, make sure ex_get_disktype function will not fail#448
mgogoulos wants to merge 1 commit intoapache:trunkfrom
mgogoulos:gce_create_node_disktype

Conversation

@mgogoulos
Copy link
Copy Markdown
Contributor

create_node supports passing ex_disk_type as either str or GCEDiskType. If you pass an str, or if you don't pass anything -most usual case I believe- it gets an str value of 'pd-standard' since it is a kwarg, then the function will fail because self.ex_get_disktype is called without the location, and line
request = '/zones/%s/diskTypes/%s' % (zone.name, name)

will break with a 'NoneType' object has no attribute 'name'

This can easily be fixed with this commit (also applies to ex_create_multiple_nodes).

Then nodes with ssh key deployed are easily created:

from libcloud.compute.providers import get_driver; from libcloud.compute.types import Provider; driver = get_driver('gce')
conn = driver('email', 'key', project='project')
node = conn.create_node(
                name=machine_name, # str
                image=image, # NodeImage
                size=size, # NodeSize
                location=location, # NodeLocation
                ex_metadata=metadata # {'sshKeys': 'user:%s' % public_ssh_rsa_key}
            )

@erjohnso
Copy link
Copy Markdown
Contributor

Looks good @mgogoulos, but tests are not passing. Do you think you can take a look at travis and get them fixed up? For example, https://travis-ci.org/apache/libcloud/jobs/50234015#L5396.

@mgogoulos
Copy link
Copy Markdown
Contributor Author

I've added the missing fixture for this, it should complete fine!

@mgogoulos
Copy link
Copy Markdown
Contributor Author

Forgot to include the new fixtures file..

@erjohnso
Copy link
Copy Markdown
Contributor

Great, thank you very much @mgogoulos! One last request, could you please rebase and squash into a single commit? See, https://libcloud.readthedocs.org/en/latest/development.html#squash-the-commits-and-generate-the-patch. We don't need the patch, but see the two Notes in that section for rebasing/squashing if you've never done it.

@mgogoulos mgogoulos force-pushed the gce_create_node_disktype branch from 4c2a21c to 6b82405 Compare February 12, 2015 10:55
@mgogoulos
Copy link
Copy Markdown
Contributor Author

Should be fine now, after tests complete!

@erjohnso
Copy link
Copy Markdown
Contributor

Thank you very much @mgogoulos - merging now.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants