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

« back to all changes in this revision

Viewing changes to bin/euca-create-volume

  • 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, SizeValidationError, SnapshotValidationError, Util
 
36
from euca2ools import Euca2ool, SizeValidationError, SnapshotValidationError, Util, ConnectionFailed
37
37
 
38
38
usage_string = """
39
39
Creates a volume in a specified availability zone.
53
53
 
54
54
"""
55
55
 
56
 
version_string = """    euca-create-volume version: 1.0 (BSD)"""
57
56
 
58
 
def usage():
 
57
def usage(status=1):
59
58
    print usage_string
60
59
    Util().usage(compat=True)
 
60
    sys.exit(status)
61
61
 
62
62
def version():
63
 
    print version_string
 
63
    print Util().version()
64
64
    sys.exit()
65
65
 
66
66
def display_volume(volume):
99
99
        elif name == '--snapshot':
100
100
            snapshot_id = value 
101
101
        elif name in ('-h', '--help'):
102
 
            usage()
 
102
            usage(0)
103
103
        elif name == '--version':
104
104
            version()
105
105
 
106
 
    euca_conn = euca.make_connection()
 
106
    try:
 
107
        euca_conn = euca.make_connection()
 
108
    except ConnectionFailed, e:
 
109
        print e.message
 
110
        sys.exit(1)
107
111
 
108
112
    if (size or snapshot_id) and zone:
109
113
        if size: