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

Source Code for Module starcluster.commands.removevolume

 1  #!/usr/bin/env python 
 2   
 3  from starcluster.logger import log 
 4   
 5  from completers import VolumeCompleter 
 6   
 7   
8 -class CmdRemoveVolume(VolumeCompleter):
9 """ 10 removevolume [options] <volume_id> 11 12 Delete one or more EBS volumes 13 14 WARNING: This command will *PERMANENTLY* remove an EBS volume. 15 Please use caution! 16 17 Example: 18 19 $ starcluster removevolume vol-999999 20 """ 21 names = ['removevolume', 'rv'] 22
23 - def addopts(self, parser):
24 parser.add_option("-c", "--confirm", dest="confirm", 25 action="store_true", default=False, 26 help="do not prompt for confirmation, just " + \ 27 "remove the volume")
28
29 - def execute(self, args):
30 if not args: 31 self.parser.error("no volumes specified. exiting...") 32 for arg in args: 33 volid = arg 34 vol = self.ec2.get_volume(volid) 35 if vol.status in ['attaching', 'in-use']: 36 log.error("volume is currently in use. aborting...") 37 return 38 if vol.status == 'detaching': 39 log.error("volume is currently detaching. " + \ 40 "please wait a few moments and try again...") 41 return 42 if not self.opts.confirm: 43 resp = raw_input("**PERMANENTLY** delete %s (y/n)? " % volid) 44 if resp not in ['y', 'Y', 'yes']: 45 log.info("Aborting...") 46 return 47 if vol.delete(): 48 log.info("Volume %s deleted successfully" % vol.id) 49 else: 50 log.error("Error deleting volume %s" % vol.id)
51