# File lib/rudy/metadata/machine.rb, line 141
141:     def create
142:       raise "#{name} is already running" if instance_running?
143:       
144:       # Options for Rudy::AWS::EC2::Instances#create
145:       opts = {
146:         :min  => 1,
147:         :size => @size,
148:         :ami => @ami,
149:         :group => @group,
150:         :keypair => @keypair, 
151:         :zone => @zone,
152:         :machine_data => self.generate_machine_data.to_yaml
153:       }
154:       
155:       ld "OPTS: #{opts.inspect}"
156:       
157:       Rudy::AWS::EC2::Instances.create(opts) do |inst|
158:         @instid = inst.awsid
159:         @created = @started = Time.now
160:         @state = inst.state
161:         # We need to be safe when creating machines because if an exception is
162:         # raised, instances will have been created but the calling class won't know. 
163:       end
164:       
165:       self.save
166:       
167:       sleep 1 # Eventual consistency in SimpleDB
168:       
169:       self
170:     end