starcluster.commands.removekey

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

# Source Code for Module starcluster.commands.removekey

     1  #!/usr/bin/env python
     2
     3  from starcluster.logger import log
     4
     5  from base import CmdBase
     6
     7
     8 -class CmdRemoveKey(CmdBase):
     9      """
    10      removekey [options] <name>
    11
    12      Remove a keypair from Amazon EC2
    13      """
    14      names = ['removekey', 'rk']
    15
    16 -    def addopts(self, parser):
    17          parser.add_option("-c", "--confirm", dest="confirm",
    18                            action="store_true", default=False,
    19                            help="do not prompt for confirmation, just " + \
    20                            "remove the keypair")
    21
    22 -    def execute(self, args):
    23          if len(args) != 1:
    24              self.parser.error("please provide a key name")
    25          name = args[0]
    26          kp = self.ec2.get_keypair(name)
    27          if not self.opts.confirm:
    28              resp = raw_input("**PERMANENTLY** delete keypair %s (y/n)? " % \
    29                               name)
    30              if resp not in ['y', 'Y', 'yes']:
    31                  log.info("Aborting...")
    32                  return
    33          log.info("Removing keypair: %s" % name)
    34          kp.delete()
    35