Package starcluster :: Package commands :: Module removeimage
[hide private]
[frames] | no frames]

Source Code for Module starcluster.commands.removeimage

 1  #!/usr/bin/env python 
 2   
 3  from starcluster.logger import log 
 4   
 5  from completers import ImageCompleter 
 6   
 7   
8 -class CmdRemoveImage(ImageCompleter):
9 """ 10 removeami [options] <imageid> 11 12 Deregister an EC2 image (AMI) and remove it from S3 13 14 WARNING: This command *permanently* removes an AMI from 15 EC2/S3 including all AMI parts and manifest. Be careful! 16 17 Example: 18 19 $ starcluster removeami ami-999999 20 """ 21 names = ['removeimage', 'ri'] 22
23 - def addopts(self, parser):
24 parser.add_option("-p", "--pretend", dest="pretend", 25 action="store_true", default=False, 26 help="pretend run, dont actually remove anything") 27 parser.add_option("-c", "--confirm", dest="confirm", 28 action="store_true", default=False, 29 help="do not prompt for confirmation, just " + \ 30 "remove the image")
31
32 - def execute(self, args):
33 if not args: 34 self.parser.error("no images specified. exiting...") 35 for arg in args: 36 imageid = arg 37 self.ec2.get_image(imageid) 38 confirmed = self.opts.confirm 39 pretend = self.opts.pretend 40 if not confirmed: 41 if not pretend: 42 resp = raw_input("**PERMANENTLY** delete %s (y/n)? " % \ 43 imageid) 44 if resp not in ['y', 'Y', 'yes']: 45 log.info("Aborting...") 46 return 47 self.ec2.remove_image(imageid, pretend=pretend)
48