Merge lp:~smoser/cloud-init/add-gce-datasource into lp:~jablonskis/cloud-init/add-gce-datasource

Proposed by Scott Moser on 2014-02-13
Status: Merged
Merge reported by: Scott Moser
Merged at revision: not available
Proposed branch: lp:~smoser/cloud-init/add-gce-datasource
Merge into: lp:~jablonskis/cloud-init/add-gce-datasource
Diff against target: 43 lines (+13/-2)
1 file modified
cloudinit/sources/DataSourceGCE.py (+13/-2)
To merge this branch: bzr merge lp:~smoser/cloud-init/add-gce-datasource
Reviewer Review Type Date Requested Status
Vaidas Jablonskis 2014-02-13 Pending
Review via email: mp+206070@code.launchpad.net

Description of the Change

  support configuration of MD_URL, disable if not resolvable.

  this allows the metadata url to be
  configured by setting:
   datasource:
     GCE:
      metadata_url: <value>

  Then also, if its not resolvable, we just deactivate the datasource quickly.
diff:

To post a comment you must log in.
Chad Smith (chad.smith) wrote :

Hello Scott,

Looks like this content is already merged into git master. Closing this as merged.

- chad

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/sources/DataSourceGCE.py'
2--- cloudinit/sources/DataSourceGCE.py 2014-02-08 20:59:52 +0000
3+++ cloudinit/sources/DataSourceGCE.py 2014-02-13 01:02:11 +0000
4@@ -16,19 +16,25 @@
5
6
7 from cloudinit import log as logging
8+from cloudinit import util
9 from cloudinit import sources
10 from cloudinit import url_helper
11
12 LOG = logging.getLogger(__name__)
13
14-MD_URL = 'http://metadata/computeMetadata/v1/'
15+BUILTIN_DS_CONFIG = {
16+ 'metadata_url': 'http://metadata.google.internal./computeMetadata/v1/'
17+}
18
19
20 class DataSourceGCE(sources.DataSource):
21 def __init__(self, sys_cfg, distro, paths):
22 sources.DataSource.__init__(self, sys_cfg, distro, paths)
23- self.metadata_address = MD_URL
24 self.metadata = {}
25+ self.ds_cfg = util.mergemanydict([
26+ util.get_cfg_by_path(sys_cfg, ["datasource", "GCE"], {}),
27+ BUILTIN_DS_CONFIG])
28+ self.metadata_address = self.ds_cfg['metadata_url']
29
30 # GCE takes sshKeys attribute in the format of '<user>:<public_key>'
31 # so we have to trim each key to remove the username part
32@@ -51,6 +57,11 @@
33 'local-hostname': self.metadata_address + 'instance/hostname',
34 }
35
36+ # if we cannot resolve the metadata server, then no point in trying
37+ if not util.is_resolvable(self.metadata_address):
38+ LOG.debug("%s is not resolvable", self.metadata_address)
39+ return False
40+
41 for mkey in url_map.iterkeys():
42 try:
43 resp = url_helper.readurl(url=url_map[mkey], headers=headers)

Subscribers

People subscribed via source and target branches

to all changes: