108: def destroy(inst_ids=[], &each_inst)
109: instances = list(:running, inst_ids, &each_inst) || []
110: raise NoRunningInstances if instances.empty?
111:
112: inst_ids = objects_to_instance_ids(inst_ids)
113:
114: response = Rudy::AWS::EC2.execute_request({}) {
115: @@ec2.terminate_instances(:instance_id => inst_ids)
116: }
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128: raise MalformedResponse unless response['instancesSet'].is_a?(Hash)
129: instances_shutdown = []
130: response['instancesSet']['item'].collect do |inst|
131: next unless inst['shutdownState'].is_a?(Hash) && inst['shutdownState']['name'] == 'shutting-down'
132: instances_shutdown << inst['instanceId']
133: end
134: success = instances_shutdown.size == inst_ids.size
135: success
136: end