~ubuntu-branches/ubuntu/maverick/euca2ools/maverick-updates

« back to all changes in this revision

Viewing changes to bin/euca-describe-keypairs

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2010-03-05 16:59:25 UTC
  • Revision ID: james.westby@ubuntu.com-20100305165925-40rmhda8swzojyva
Tags: 1.2-0ubuntu5
* Cherry pick fixes from upstream, up to bzr r265, fixes:
  - LP: #522398 - throw exceptions instead of sys.exit(1)
  - LP: #522396 - fix version string
  - LP: #523332 - check rsync return code
  - LP: #516738 - upstream fix for image store
  - LP: #525137 - don't sys.exit(1)
  - LP: #526697 - merge upstream fix for this one
  - LP: #531076 - fix euca-describe-instances against one instance
  - LP: #526591 - fix config file parsing

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
# Author: Neil Soman neil@eucalyptus.com
34
34
 
35
35
import getopt, sys, os
36
 
from euca2ools import Euca2ool, Util
 
36
from euca2ools import Euca2ool, Util, ConnectionFailed
37
37
 
38
38
usage_string = """
39
39
Shows information about keypairs.
47
47
 
48
48
"""
49
49
 
50
 
version_string = """    euca-describe-key-pairs version: 1.0 (BSD)"""
51
50
 
52
 
def usage():
 
51
def usage(status=1):
53
52
    print usage_string
54
53
    Util().usage()
 
54
    sys.exit(status)
55
55
 
56
56
def version():
57
 
    print version_string
 
57
    print Util().version()
58
58
    sys.exit()
59
59
 
60
60
def display_keypairs(keypairs, keypair_ids):
79
79
 
80
80
    for name, value in euca.opts:
81
81
        if name in ('-h', '--help'):
82
 
            usage()
 
82
            usage(0)
83
83
        elif name == '--version':
84
84
            version()
85
85
    
86
86
    keypair_ids = euca.process_args()
87
 
    euca_conn = euca.make_connection()
 
87
    try:
 
88
        euca_conn = euca.make_connection()
 
89
    except ConnectionFailed, e:
 
90
        print e.message
 
91
        sys.exit(1)
88
92
    try:
89
93
        keypairs = euca_conn.get_all_key_pairs()
90
94
    except Exception, ex: