~milner/cloud-init/lint-cleanups

« back to all changes in this revision

Viewing changes to cloud-init-query.py

  • Committer: Mike Milner
  • Date: 2012-01-18 01:23:09 UTC
  • mfrom: (502.2.5 trunk)
  • Revision ID: mike.milner@canonical.com-20120118012309-aqzzfh04frni7q0y
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import cloudinit
22
22
import cloudinit.CloudConfig
23
23
 
24
 
def Usage(out = sys.stdout):
 
24
 
 
25
def Usage(out=sys.stdout):
25
26
    out.write("Usage: %s name\n" % sys.argv[0])
26
 
    
 
27
 
 
28
 
27
29
def main():
28
30
    # expect to be called with name of item to fetch
29
31
    if len(sys.argv) != 2:
30
32
        Usage(sys.stderr)
31
33
        sys.exit(1)
32
34
 
33
 
    cc = cloudinit.CloudConfig.CloudConfig(cloudinit.cloud_config)
 
35
    cfg_path = cloudinit.get_ipath_cur("cloud_config")
 
36
    cc = cloudinit.CloudConfig.CloudConfig(cfg_path)
34
37
    data = {
35
 
        'user_data' : cc.cloud.get_userdata(),
36
 
        'user_data_raw' : cc.cloud.get_userdata_raw(),
37
 
        'instance_id' : cc.cloud.get_instance_id(),
 
38
        'user_data': cc.cloud.get_userdata(),
 
39
        'user_data_raw': cc.cloud.get_userdata_raw(),
 
40
        'instance_id': cc.cloud.get_instance_id(),
38
41
    }
39
42
 
40
 
    name = sys.argv[1].replace('-','_')
 
43
    name = sys.argv[1].replace('-', '_')
41
44
 
42
45
    if name not in data:
43
46
        sys.stderr.write("unknown name '%s'.  Known values are:\n  %s\n" %