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

« back to all changes in this revision

Viewing changes to bin/euca-release-address

  • 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, AddressValidationError, Util
 
36
from euca2ools import Euca2ool, AddressValidationError, Util, ConnectionFailed
37
37
 
38
38
usage_string = """
39
39
Releases a public IP address.
48
48
 
49
49
"""
50
50
 
51
 
version_string = """    euca-release-address version: 1.0 (BSD)"""
52
51
 
53
 
def usage():
 
52
def usage(status=1):
54
53
    print usage_string
55
54
    Util().usage()
 
55
    sys.exit(status)
56
56
 
57
57
def version():
58
 
    print version_string
 
58
    print Util().version()
59
59
    sys.exit()
60
60
 
61
61
def main():
70
70
 
71
71
    for name, value in euca.opts:
72
72
        if name in ('-h', '--help'):
73
 
            usage()
 
73
            usage(0)
74
74
        elif name == '--version':
75
75
            version()
76
76
 
86
86
            print 'Invalid address' 
87
87
            sys.exit(1)
88
88
 
89
 
        euca_conn = euca.make_connection()
 
89
        try:
 
90
            euca_conn = euca.make_connection()
 
91
        except ConnectionFailed, e:
 
92
            print e.message
 
93
            sys.exit(1)
90
94
        try:
91
95
            return_code = euca_conn.release_address(ip)
92
96
        except Exception, ex: