Revision 7d3dc857

b/image_creator/main.py
90 90
        help="Use this ACCOUNT when uploading/registring images [Default: %s]"\
91 91
        % account)
92 92

  
93
    parser.add_option("-m", "--metadata", dest="metadata", default=[],
94
        help="Add custom KEY=VALUE metadata to the image", action="append",
95
        metavar="KEY=VALUE")
96

  
93 97
    parser.add_option("-t", "--token", dest="token", type="string",
94 98
        default=token,
95 99
        help="Use this token when uploading/registring images [Default: %s]"\
......
117 121

  
118 122
    if len(args) != 1:
119 123
        parser.error('Wrong number of arguments')
124

  
120 125
    options.source = args[0]
121 126
    if not os.path.exists(options.source):
122 127
        raise FatalError("Input media `%s' is not accessible" % options.source)
......
132 137
        raise FatalError("Image uploading cannot be performed. No ~okeanos "
133 138
        "token is specified. User -t to set a token.")
134 139

  
140
    meta = {}
141
    for m in options.metadata:
142
        try:
143
            key, value = m.split('=', 1)
144
        except ValueError:
145
            raise FatalError("Metadata option: `%s' is not in "\
146
                                                    "KEY=VALUE format." % m)
147
        meta[key] = value
148
    options.metadata = meta
149

  
135 150
    return options
136 151

  
137 152

  
......
194 209
        size = options.shrink and dev.shrink() or dev.size
195 210
        metadata.update(dev.meta)
196 211

  
212
        # Add command line metadata to the collected ones...
213
        metadata.update(options.metadata)
214

  
197 215
        checksum = md5(snapshot, size)
198 216

  
199 217
        metastring = '\n'.join(

Also available in: Unified diff