Class: EC2i3

Inherits:
InstantEC2
  • Object
show all
Defined in:
lib/ec2i3.rb

Instance Method Summary collapse

Constructor Details

#initialize(reg, address: '127.0.0.1', port: '59000', async: false) ⇒ EC2i3

Returns a new instance of EC2i3.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ec2i3.rb', line 15

def initialize(reg, address: '127.0.0.1', port: '59000', async: false)

  @address, @port = address, port

  entry = reg.get_key('hkey_apps/ec2i3')

  dp = DynarexPassword.new
  passphrase = dp.reverse_lookup(entry.text('passphrase').to_s, 
                                              entry.text('lookup_file').to_s)
  enc_priv_key = entry.text('private_key').to_s.split(' ').map(&:to_i).pack('C*')
  private_key = Encrypt.load(enc_priv_key, passphrase)

  super credentials: [entry.text('access_key_id').to_s, private_key], async: async
  @sps = SPSPub.new address: @address, port: @port


  hooks = {
    running: ->(ip){ 

      msg = "EC2i3: the instance is now accessible from %s" % [ip]
      puts msg
      @sps.notice msg

    },
    stopping: ->(){ 
      msg = "EC2i3: the instance is now stopping"
      puts msg
      @sps.notice msg
    }
  }

  @hooks.merge! hooks

end