Module: Gogetit
- Defined in:
- lib/executionhooks.rb,
lib/gogetit.rb,
lib/gogetit/cli.rb,
lib/gogetit/maas.rb,
lib/gogetit/util.rb,
lib/providers/lxd.rb,
lib/gogetit/config.rb,
lib/gogetit/version.rb,
lib/providers/libvirt.rb,
lib/gogetit/multilogger.rb
Overview
Defined Under Namespace
Modules: Config, ExecutionHooks, Util Classes: CLI, GogetLXD, GogetLibvirt, GogetMAAS, MultiLogger
Constant Summary collapse
- VERSION =
"0.22.0"
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.libvirt ⇒ Object
readonly
Returns the value of attribute libvirt.
-
.logger ⇒ Object
readonly
Returns the value of attribute logger.
-
.lxd ⇒ Object
readonly
Returns the value of attribute lxd.
-
.maas ⇒ Object
readonly
Returns the value of attribute maas.
Class Method Summary collapse
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/gogetit.rb', line 10 def config @config end |
.libvirt ⇒ Object (readonly)
Returns the value of attribute libvirt.
10 11 12 |
# File 'lib/gogetit.rb', line 10 def libvirt @libvirt end |
.logger ⇒ Object (readonly)
Returns the value of attribute logger.
10 11 12 |
# File 'lib/gogetit.rb', line 10 def logger @logger end |
.lxd ⇒ Object (readonly)
Returns the value of attribute lxd.
10 11 12 |
# File 'lib/gogetit.rb', line 10 def lxd @lxd end |
.maas ⇒ Object (readonly)
Returns the value of attribute maas.
10 11 12 |
# File 'lib/gogetit.rb', line 10 def maas @maas end |
Class Method Details
.list_all_types ⇒ Object
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/gogetit.rb', line 19 def self.list_all_types logger.debug("Calling <#{__method__.to_s}>") nodes = [] # for LXD conn = lxd.conn config[:lxd][:nodes].each do |node| puts "Listing LXC containers on #{node[:url]}..." conn.containers.each do |con| row = {} row[:name] = conn.container(con).to_hash[:name] row[:status] = conn.container_state(con).to_hash[:status].upcase if conn.container_state(con).to_hash[:network] && \ conn.container_state(con).to_hash[:network][:eth0] && \ conn.container_state(con).to_hash[:network][:eth0][:addresses] && \ conn.container_state(con).to_hash[:network][:eth0][:addresses][0] && \ conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address] row[:ipv4] = \ # only print the first IP address on the first interface conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address] else row[:ipv4] = "NA" end row[:host] = node[:name] row[:type] = 'LXC(LXD)' nodes << row end end # for Libvirt(KVM), machines in pods controlled by MAAS conn = maas.conn machines = conn.request(:get, ['machines']) config[:libvirt][:nodes].each do |node| puts "Listing KVM instances on #{node[:url]}..." machines.each do |machine| if machine['pod']['name'] == node[:name] row = {} row[:name] = machine['hostname'] row[:status] = machine['status_name'] if machine['interface_set'][0]['links'][0]['ip_address'] row[:ipv4] = machine['interface_set'][0]['links'][0]['ip_address'] else row[:ipv4] = 'NA' end row[:host] = node[:name] row[:type] = 'KVM(Libvirt)' nodes << row end end end puts '-------------------------------------------------------------------------' tp nodes, :name, :status, :ipv4, :host, :type puts end |