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

Source Code for Module starcluster.commands.createkey

 1  from starcluster.logger import log 
 2   
 3  from base import CmdBase 
 4   
 5   
6 -class CmdCreateKey(CmdBase):
7 """ 8 createkey [options] <name> 9 10 Create a new Amazon EC2 keypair 11 """ 12 names = ['createkey', 'ck'] 13
14 - def addopts(self, parser):
15 parser.add_option("-o", "--output-file", dest="output_file", 16 action="store", type="string", default=None, 17 help="Save the new keypair to a file")
18 #parser.add_option("-a","--add-to-config", dest="add_to_config", 19 #action="store_true", default=False, 20 #help="add new keypair to StarCluster config") 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 ofile = self.opts.output_file 27 kp = self.ec2.create_keypair(name, output_file=ofile) 28 log.info("Successfully created keypair: %s" % name) 29 log.info("fingerprint: %s" % kp.fingerprint) 30 log.info("contents: \n%s" % kp.material) 31 if ofile: 32 log.info("keypair written to %s" % ofile)
33