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