Sha256: dfbec118a563aeb077fe8c5e092e9cf14980fe9d6fca58fa562e1c75765ce227

Contents?: true

Size: 818 Bytes

Versions: 5

Compression:

Stored size: 818 Bytes

Contents

require "meroku/infrastructure/node"

module Meroku
  module Infrastructure

    def spawn(session)
      node = Meroku::Infrastructure::Node.new(session.ec2_client)
      node.associate_address
      node.install_packages
      node.tweak_configuration
      node.install_frontend_app
      puts "spawned #{node.instance.try(:instance_id)}"
    end

    def despawn
      instances = ec2_client.describe_instances(filters:[{ name: "tag:Name", values: ['node'] }, { name: 'instance-state-name', values: ['running','pending'] }]).reservations.map { |xx| xx.instances.first.instance_id }
      puts "will despawn #{instances.inspect}"
      ec2_client.terminate_instances({
                                       instance_ids: instances
                                     }) if instances.size > 0
    end


  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
meroku-2.0.8 lib/meroku/infrastructure.rb
meroku-2.0.7 lib/meroku/infrastructure.rb
meroku-2.0.6 lib/meroku/infrastructure.rb
meroku-2.0.5 lib/meroku/infrastructure.rb
meroku-2.0.4 lib/meroku/infrastructure.rb