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

« back to all changes in this revision

Viewing changes to bin/euca-describe-images

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland, Scott Moser, Dustin Kirkland
  • Date: 2010-03-25 15:36:43 UTC
  • Revision ID: james.westby@ubuntu.com-20100325153643-f43twxyyj52gvpqt
Tags: 1.2-0ubuntu8
[ Scott Moser ]
* euca-run-instances:
  - --keypair => --key in usage and man page, LP: #530816
  - print error rather than trace on invalid instance-count, LP: #546420
  - euca-describe-instances: output "running", not "running ", LP: #531453
* euca-revoke: only show usage once with --help
* euca-download-bundle: fix usage, LP: #546567
* euca-bundle-image:
  - fix failure on --block-device-mapping, LP: #546548
  - print usage on --help if userid has '-', LP: #546526
  - fix failure when image name string is in dest string, LP: #522060
* euca-describe-image-attribute: fix --kernel or --ramdisk when
  image did not have emi or eri, LP: #546551

[ Dustin Kirkland ]
* Cherry-pick up to upstream r266, fixes:
  - LP: #536876 - document euca-describe-availability-zones verbose
  - LP: #526591 - enhance parsing of config file
  - LP: #531076 - fix euca-describe-images against specific image

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
    try:
84
84
        euca = Euca2ool('ao:x:', compat=True) 
85
85
    except Exception, e:
86
 
        print e
 
86
        print e
87
87
        usage()
88
88
 
89
 
    all_ids = False
90
 
    owners = [ ]
91
 
    executable_by = [ ]
92
 
    image_ids = [ ]
 
89
    show_all = False
 
90
    executable_by = ['self']
 
91
    owners = ['self'] 
 
92
    defaults = True
93
93
 
94
94
    for name, value in euca.opts:
95
95
        if name in ('-h', '--help'):
96
96
            usage(0)
97
 
        elif name == '-x':
98
 
            executable_by.append(value)
99
 
        elif name == '-o':
100
 
            owners.append(value)
 
97
        elif name == '-x':
 
98
            if defaults:
 
99
                executable_by = []
 
100
                defaults = False
 
101
                owners = []
 
102
            executable_by.append(value)
 
103
        elif name == '-o':
 
104
            if defaults:
 
105
                executable_by = []
 
106
                defaults = False
 
107
            owners.append(value)             
101
108
        elif name == '-a':
102
 
            all_ids = True
103
 
        elif name == '--version':
104
 
            version()
105
 
            sys.exit(0)
 
109
            executable_by = ['self', 'all']
 
110
            owners = []
 
111
        elif name == '--version':
 
112
            version()
106
113
 
107
114
    image_ids = euca.process_args()
108
 
 
109
 
    if all_ids and ( len(owners) or len(executable_by) or len(image_ids) ):
110
 
        euca.display_error_and_exit("-a cannot be combined with owner, launch, or image list")
 
115
    if defaults and len(image_ids) > 0:
 
116
        executable_by = ['self', 'all']
 
117
        owners = []
111
118
 
112
119
    try:
113
120
        euca_conn = euca.make_connection()
115
122
        print e.message
116
123
        sys.exit(1)
117
124
 
118
 
    if len(owners) == 0 and len(executable_by) == 0 and \
119
 
       len(image_ids) == 0 and not all_ids:
120
 
        try:
121
 
           owned = euca_conn.get_all_images(image_ids = None,
122
 
               owners = ("self", ), executable_by = None )
123
 
           launchable = euca_conn.get_all_images(image_ids = None,
124
 
               owners = None, executable_by = ("self"))
125
 
 
126
 
           mylist = [ ]
127
 
           images = [ ]
128
 
           for image in owned:
129
 
               mylist.append(image.id)
130
 
               images.append(image)
131
 
           for image in launchable:
132
 
               if image.id not in mylist:
133
 
                   images.append(image)
134
 
        except Exception, ex:
135
 
            euca.display_error_and_exit('%s' % ex)
136
 
    else:
137
 
        try:
138
 
            images = euca_conn.get_all_images(image_ids=image_ids, owners=owners, executable_by=executable_by)
139
 
        except Exception, ex:
140
 
            euca.display_error_and_exit('%s' % ex)
 
125
    try:
 
126
        images = euca_conn.get_all_images(image_ids=image_ids, owners=owners, executable_by=executable_by)
 
127
    except Exception, ex:
 
128
        euca.display_error_and_exit('%s' % ex)
141
129
 
142
130
    display_images(images)
143
 
 
144
131
if __name__ == "__main__":
145
132
    main()
146
133