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

fixing missing parameter exception for ex_add_access_config function #435

Closed
wants to merge 1 commit into from
Closed

Conversation

pmoosh
Copy link
Contributor

@pmoosh pmoosh commented Jan 18, 2015

Missing nic parameter throws exception in gce.ex_add_access_config

stderr: Traceback (most recent call last):
  File "/Users/pmoosh/.ansible/tmp/ansible-tmp-1421538564.46-10999847043196/gce_setip.py", line 139, in <module>
    main(sys.argv[1:])
  File "/Users/pmoosh/.ansible/tmp/ansible-tmp-1421538564.46-10999847043196/gce_setip.py", line 128, in main
    gce.ex_add_access_config(node = my_instance, name = ACC_CNF_NM, nat_ip = item.address)
  File "/Users/pmoosh/src/apache-libcloud/libcloud/compute/drivers/gce.py", line 941, in ex_add_access_config
    self.connection.async_request(request, method='POST', data=config)
  File "/Users/pmoosh/src/apache-libcloud/libcloud/common/base.py", line 866, in async_request
    response = request(**kwargs)
  File "/Users/pmoosh/src/apache-libcloud/libcloud/common/google.py", line 669, in request
    *args, **kwargs)
  File "/Users/pmoosh/src/apache-libcloud/libcloud/common/base.py", line 736, in request
    response = responseCls(**kwargs)
  File "/Users/pmoosh/src/apache-libcloud/libcloud/common/base.py", line 119, in __init__
    self.object = self.parse_body()
  File "/Users/pmoosh/src/apache-libcloud/libcloud/common/google.py", line 267, in parse_body
    raise InvalidRequestError(message, self.status, code)
libcloud.common.google.InvalidRequestError: {'locationType': 'parameter', 'domain': 'global', 'message': 'Required parameter: networkInterface', 'reason': 'required', 'location': 'networkInterface'}

@Kami
Copy link
Member

Kami commented Jan 18, 2015

/cc @erjohnso

@@ -934,10 +935,11 @@ def ex_add_access_config(self, node, name, nat_ip=None, config_type=None):

if nat_ip is not None:
config['natIP'] = nat_ip

params = {'accessConfig': name, 'networkInterface': nic}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmoosh - Looks like params should only contain 'networkInterface' [https://cloud.google.com/compute/docs/reference/latest/instances/addAccessConfig]. The rest of the data goes into the body of the request (the config dict). I also don't see an explicit reference to attribute/param called accessConfig. Looks like the body should be,

{
  "kind": "compute#accessConfig",
  "type": string,
  "name": string,
  "natIP": string
}

And we don't need to set kind.

@erjohnso
Copy link
Contributor

Thanks for this @pmoosh! After you remove the accessConfig, can you also squash your commits and then I'll go ahead and merge it in.

@asfgit asfgit closed this in b2caf0f Jan 21, 2015
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.

3 participants