Top Level Namespace

Defined Under Namespace

Modules: OmfCommon, OmfEc, OmfRc Classes: Array, ExecApp, String

Instance Method Summary collapse

Methods included from OmfCommon::DefaultLogging

#debug, #error, #fatal, #get_logger, #info, #warn, #warn_deprecation, #warn_removed

Instance Method Details

#create_app(testbed) ⇒ Object

Copyright © 2012 National ICT Australia Limited (NICTA). This software may be used and distributed solely under the terms of the MIT license (License). You should find a copy of the License in LICENSE.TXT or at opensource.org/licenses/MIT. By downloading or using this software you accept the terms and the liability disclaimer in the License.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'omf_ec/lib/omf_ec/backward/exp/testbed.rb', line 6

def create_app(testbed)
  testbed.create(:application, binary_path: @cmd) do |reply|
    if reply.success?
      app = reply.resource

      app.on_subscribed do
        app.configure(state: :running)

        app.on_inform  do |m|
          case m.itype
          when 'STATUS'
            if m[:status_type] == 'APP_EVENT'
              after(2) { OmfCommon.comm.disconnect } if m[:event] =~ /DONE.(OK|ERROR)/
              info m[:msg] if m[:msg]
            else
              m.each_property do |k, v|
                info "#{k} => #{v.strip}" unless v.nil?
              end
            end
          when 'WARN'
            warn m[:reason]
          when 'ERROR'
            error m[:reason]
          end
        end
      end
    else
      error reply[:reason]
    end
  end
end