Revision 76f01c50 kamaki/kamaki.py

b/kamaki/kamaki.py
246 246
                            help='use flavor FLAVOR_ID')
247 247
        parser.add_option('-i', dest='image', metavar='IMAGE_ID', default=1,
248 248
                            help='use image IMAGE_ID')
249

  
249
        parser.add_option('--personality', dest='personality', action='append',
250
                            metavar='PATH,SERVERPATH',
251
                            help='add a personality file')
252
    
250 253
    def main(self, name):
251 254
        flavor_id = int(self.flavor)
252 255
        image_id = int(self.image)
253
        reply = self.client.create_server(name, flavor_id, image_id)
256
        personality = []
257
        if self.personality:
258
            for p in self.personality:
259
                lpath, sep, rpath = p.partition(',')
260
                if not lpath or not rpath:
261
                    logging.error("Invalid personality argument '%s'", p)
262
                    return
263
                if not os.path.exists(lpath):
264
                    logging.error("File %s does not exist", lpath)
265
                    return
266
                with open(lpath) as f:
267
                    personality.append((rpath, f.read()))
268
        
269
        reply = self.client.create_server(name, flavor_id, image_id,
270
                                            personality)
254 271
        print_dict(reply)
255 272

  
256 273

  

Also available in: Unified diff