[jira] [Commented] (LIBCLOUD-687) Unable to set GCE metadata if no metadata already exists
[ https://issues.apache.org/jira/browse/LIBCLOUD-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14542681#comment-14542681 ] ASF subversion and git services commented on LIBCLOUD-687: -- Commit aaa8e9e3a3a73d44aa6632089d60e8806f0f2de4 in libcloud's branch refs/heads/trunk from [~erjohnso] [ https://git-wip-us.apache.org/repos/asf?p=libcloud.git;h=aaa8e9e ] [google compute] Fixes LIBCLOUD-687: handle empty project metadata Closes #521 Signed-off-by: Eric Johnson erjoh...@google.com Unable to set GCE metadata if no metadata already exists Key: LIBCLOUD-687 URL: https://issues.apache.org/jira/browse/LIBCLOUD-687 Project: Libcloud Issue Type: Bug Components: Compute Reporter: Eli Courtwright Assignee: Eric Johnson The {{libcloud.compute.drivers.gce.GCENodeDriver}} class has a nonstandard method {{ex_set_common_metadata}} which we can use to (among other things) set SSH keys. When calling this method on the latest libcloud 0.17.0 (which is not currently a listed version in Jira), I get the following error: {code} conn.ex_set_common_instance_metadata({}) Traceback (most recent call last): File stdin, line 1, in module File /opt/sideboard/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py, line 1129, in ex_set_common_instance_metadata for md in current_metadata['items']: KeyError: 'items' {code} I get this error regardless of what data I pass to the {{ex_set_common_instance_metadata}} method. From delving into the libcloud code, I find the following block of code: {code} project = self.ex_get_project() current_metadata = project.extra['commonInstanceMetadata'] fingerprint = current_metadata['fingerprint'] # grab copy of current 'sshKeys' in case we want to retain them current_keys = for md in current_metadata['items']: {code} So it looks as if the method assumes that {{self.ex_get_project()}} will return: - an object with a {{.extra}} dictionary (which it does) - that dictionary will have a commonInstanceMetadata key which maps to another dictionary (which is correct) - that sub-dictionary will have an items key whose value is iterable (which is wrong) That last assumption is only wrong if there is no project metadata already associated with the project, e.g. for a new project. I'm working around this problem currently by monkeypatching libcloud: {code} def patch_gce_ex_get_project(): orig_get_project = GCENodeDriver.ex_get_project def ex_get_project(self): project = orig_get_project(self) project.extra['commonInstanceMetadata'].setdefault('items', []) return project GCENodeDriver.ex_get_project = ex_get_project {code} but having a real fix would be great for the next version. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LIBCLOUD-687) Unable to set GCE metadata if no metadata already exists
[ https://issues.apache.org/jira/browse/LIBCLOUD-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14542682#comment-14542682 ] ASF GitHub Bot commented on LIBCLOUD-687: - Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/521 Unable to set GCE metadata if no metadata already exists Key: LIBCLOUD-687 URL: https://issues.apache.org/jira/browse/LIBCLOUD-687 Project: Libcloud Issue Type: Bug Components: Compute Reporter: Eli Courtwright Assignee: Eric Johnson The {{libcloud.compute.drivers.gce.GCENodeDriver}} class has a nonstandard method {{ex_set_common_metadata}} which we can use to (among other things) set SSH keys. When calling this method on the latest libcloud 0.17.0 (which is not currently a listed version in Jira), I get the following error: {code} conn.ex_set_common_instance_metadata({}) Traceback (most recent call last): File stdin, line 1, in module File /opt/sideboard/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py, line 1129, in ex_set_common_instance_metadata for md in current_metadata['items']: KeyError: 'items' {code} I get this error regardless of what data I pass to the {{ex_set_common_instance_metadata}} method. From delving into the libcloud code, I find the following block of code: {code} project = self.ex_get_project() current_metadata = project.extra['commonInstanceMetadata'] fingerprint = current_metadata['fingerprint'] # grab copy of current 'sshKeys' in case we want to retain them current_keys = for md in current_metadata['items']: {code} So it looks as if the method assumes that {{self.ex_get_project()}} will return: - an object with a {{.extra}} dictionary (which it does) - that dictionary will have a commonInstanceMetadata key which maps to another dictionary (which is correct) - that sub-dictionary will have an items key whose value is iterable (which is wrong) That last assumption is only wrong if there is no project metadata already associated with the project, e.g. for a new project. I'm working around this problem currently by monkeypatching libcloud: {code} def patch_gce_ex_get_project(): orig_get_project = GCENodeDriver.ex_get_project def ex_get_project(self): project = orig_get_project(self) project.extra['commonInstanceMetadata'].setdefault('items', []) return project GCENodeDriver.ex_get_project = ex_get_project {code} but having a real fix would be great for the next version. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LIBCLOUD-687) Unable to set GCE metadata if no metadata already exists
[ https://issues.apache.org/jira/browse/LIBCLOUD-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14394496#comment-14394496 ] Eric Johnson commented on LIBCLOUD-687: --- Thanks for this most excellent bug report Eli! I'll work on a fix soon and hopefully get it into a 0.17.1 release. Unable to set GCE metadata if no metadata already exists Key: LIBCLOUD-687 URL: https://issues.apache.org/jira/browse/LIBCLOUD-687 Project: Libcloud Issue Type: Bug Components: Compute Reporter: Eli Courtwright Assignee: Eric Johnson The {{libcloud.compute.drivers.gce.GCENodeDriver}} class has a nonstandard method {{ex_set_common_metadata}} which we can use to (among other things) set SSH keys. When calling this method on the latest libcloud 0.17.0 (which is not currently a listed version in Jira), I get the following error: {code} conn.ex_set_common_instance_metadata({}) Traceback (most recent call last): File stdin, line 1, in module File /opt/sideboard/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py, line 1129, in ex_set_common_instance_metadata for md in current_metadata['items']: KeyError: 'items' {code} I get this error regardless of what data I pass to the {{ex_set_common_instance_metadata}} method. From delving into the libcloud code, I find the following block of code: {code} project = self.ex_get_project() current_metadata = project.extra['commonInstanceMetadata'] fingerprint = current_metadata['fingerprint'] # grab copy of current 'sshKeys' in case we want to retain them current_keys = for md in current_metadata['items']: {code} So it looks as if the method assumes that {{self.ex_get_project()}} will return: - an object with a {{.extra}} dictionary (which it does) - that dictionary will have a commonInstanceMetadata key which maps to another dictionary (which is correct) - that sub-dictionary will have an items key whose value is iterable (which is wrong) That last assumption is only wrong if there is no project metadata already associated with the project, e.g. for a new project. I'm working around this problem currently by monkeypatching libcloud: {code} def patch_gce_ex_get_project(): orig_get_project = GCENodeDriver.ex_get_project def ex_get_project(self): project = orig_get_project(self) project.extra['commonInstanceMetadata'].setdefault('items', []) return project GCENodeDriver.ex_get_project = ex_get_project {code} but having a real fix would be great for the next version. -- This message was sent by Atlassian JIRA (v6.3.4#6332)