Module: NovaDsl::NovaConsoleWrapper

Includes:
NovaStdoutParser
Included in:
NovaList, Provision
Defined in:
lib/nova/wrapper/nova_console_wrapper.rb

Constant Summary

Constants included from NovaStdoutParser

NovaDsl::NovaStdoutParser::IP_SEARCHER

Instance Method Summary collapse

Methods included from NovaStdoutParser

#parse_nova_list_stdout, #parse_nova_show_stdout

Instance Method Details

#nova_deleteObject



52
53
54
# File 'lib/nova/wrapper/nova_console_wrapper.rb', line 52

def nova_delete

end

#nova_flavor_listObject



60
61
62
# File 'lib/nova/wrapper/nova_console_wrapper.rb', line 60

def nova_flavor_list

end

#nova_image_listObject



56
57
58
# File 'lib/nova/wrapper/nova_console_wrapper.rb', line 56

def nova_image_list

end

#nova_list(configs = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/nova/wrapper/nova_console_wrapper.rb', line 34

def nova_list(configs = {})
  LOGGER.debug("Call 'nova list' ")
  results = Common::system_call(:source => configs[:source]) {
    "/usr/local/bin/nova list"
  }

  vms = NovaDsl::NovaVmsContainer.new

  results.each do |result|
    if result[:status].eql?(0)
      vms.merge!(parse_nova_list_stdout result[:out])
    else
      LOGGER.debug("Skipping command stdout parsing because exitstatus is #{result[:status]}")
    end
  end
  vms
end

#nova_provision(configs = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nova/wrapper/nova_console_wrapper.rb', line 14

def nova_provision(configs = {})
  LOGGER.debug("Call 'nova boot' with parameters :#{configs.inspect}")
  raise NovaDsl::DslMissParameter.new("Missing 'name' attribute when calling provision at wrapper") if configs[:name].nil?
  Common::
      raise NovaDsl::DslMissParameter.new("Missing 'image' attribute when calling provision at wrapper") if configs[:image].nil?
  raise NovaDsl::DslMissParameter.new("Missing 'flavor' attribute when
                                       calling provision at wrapper") if configs[:flavor].nil?
  raise NovaDsl::DslMissParameter.new("Missing 'key' attribute when calling provision at wrapper") if configs[:key].nil?

  configs[:security_groups] ||= %w(default)

  results = Common::system_call(:source => configs[:source]) {
    "/usr/local/bin/nova boot --image #{configs[:image]} --flavor #{configs[:flavor]} --key_name #{configs[:key]} --security_groups #{configs[:security_groups]*','} #{configs[:name]}"

  }

  LOGGER.debug("Provision output:")
  LOGGER.debug("#{results[0][:out]}")
end