added a flag to parse user data only if a certain hash line is detected
authorPaul Tonelli <paul.tonelli@logilab.fr>
Wed, 27 Mar 2013 17:06:28 +0100
changeset 111 a881ea816c4e
parent 110 9cabb9379a03
child 112 1a3ea03a1668
added a flag to parse user data only if a certain hash line is detected
others/ec2_ami_parser.py
readme.rst
--- a/others/ec2_ami_parser.py	Wed Mar 27 19:19:59 2013 +0100
+++ b/others/ec2_ami_parser.py	Wed Mar 27 17:06:28 2013 +0100
@@ -29,5 +29,9 @@
         myfile = open(argv[1],'r')
     else:
         myfile = open(urllib.urlretrieve(url)[0],'r')
+    found_flag = False
     for line in myfile:
-        parse_line(line)
+        if line.startswith("#salt-grains"):
+            found_flag = True
+        if found_flag:
+            parse_line(line)
--- a/readme.rst	Wed Mar 27 19:19:59 2013 +0100
+++ b/readme.rst	Wed Mar 27 17:06:28 2013 +0100
@@ -52,7 +52,7 @@
    from the default repo)::
 
      ====== START =======
-     ## salt-grains #interpreter flag
+     #salt-grains #interpreter flag
      ### necessary unless you want the standard image ###
      ami.hg_address_variation: http://hg.logilab.org/users/ptonelli/ami_creator/variation
      ami.hg_rev_variation: 9ed741a55f17 #optionnal