gogetit 0.12.4 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0f13b5df25763b6b37fa24f18706e2f58579806
4
- data.tar.gz: cb56da342f4477e93a731039d6fe3e0a18922a22
3
+ metadata.gz: fbfc744d5a525b73c6e5e8678f2759ed2d89c897
4
+ data.tar.gz: 64f3822d9769c1b8cad49398cdad55d2e76d27b9
5
5
  SHA512:
6
- metadata.gz: 47a396841a95400ee9996411ae3a2306dd3224e2fcf5a0c1ce4c5d7ff0a2eb0f71a5266c26d0753c22863a4414e24d416258d86f023e86bbd72620b7b1dd58ea
7
- data.tar.gz: 14e411b2ce7f3cfc39ac0372283742b0770a9ab677164c4860f4e815b5bb0d4ae545f18d6aaffe8383d2b20700c910a5cde93b31afd39ed5b5f3bb5d8b8dbdd8
6
+ metadata.gz: 79f413b370f4dc96cc15e95b18ec1e454f02a41516961b97f4d7bf528abecbf1971329b622ba11d31da9da113cb8caeff149dea264b7c6d98254abf53c5d0662
7
+ data.tar.gz: a9d76a466ac176a8769283d54fcb2cb38c2d2f338450373244301cef070c4c9926329ffedb86ff9b186702f3f3feaf441e2af2a7ccfa072ec7d2f5ea1a973f95
@@ -41,4 +41,5 @@ Gem::Specification.new do |spec|
41
41
  spec.add_runtime_dependency 'net-ssh', '~> 4.1.0'
42
42
  spec.add_runtime_dependency 'thor', '~> 0.19.0'
43
43
  spec.add_runtime_dependency 'hashie', '~> 3.5.5'
44
+ spec.add_runtime_dependency 'table_print', '~> 1.5.6'
44
45
  end
@@ -28,10 +28,24 @@ module Gogetit
28
28
  end
29
29
 
30
30
  desc 'list', 'List containers and instances, running currently.'
31
+ method_option :out, :aliases => '-o', :type => :string, \
32
+ :default => '', :desc => 'to list from all remotes'
31
33
  def list
32
- puts "Listing LXD containers on #{config[:lxd][:nodes][0][:url]}.."
33
- system("lxc list #{config[:lxd][:nodes][0][:name]}:")
34
- puts ''
34
+ case options[:out]
35
+ when 'custom'
36
+ lxd.list_all_containers
37
+ when 'all'
38
+ config[:lxd][:nodes].each do |node|
39
+ puts "Listing LXD containers on #{node[:url]}.."
40
+ system("lxc list #{node[:name]}:")
41
+ end
42
+ when ''
43
+ puts "Listing LXD containers on #{config[:lxd][:nodes][0][:url]}.."
44
+ system("lxc list #{config[:lxd][:nodes][0][:name]}:")
45
+ puts ''
46
+ else
47
+ puts "Invalid option or command"
48
+ end
35
49
  puts "Listing KVM domains on #{config[:libvirt][:nodes][0][:url]}.."
36
50
  system("virsh -c #{config[:libvirt][:nodes][0][:url]} list --all")
37
51
  end
@@ -1,3 +1,3 @@
1
1
  module Gogetit
2
- VERSION = "0.12.4"
2
+ VERSION = "0.13.1"
3
3
  end
@@ -2,6 +2,7 @@ require 'hyperkit'
2
2
  require 'gogetit/util'
3
3
  require 'yaml'
4
4
  require 'hashie'
5
+ require 'table_print'
5
6
 
6
7
  module Gogetit
7
8
  class GogetLXD
@@ -14,11 +15,43 @@ module Gogetit
14
15
  @conn = Hyperkit::Client.new(
15
16
  api_endpoint: config[:lxd][:nodes][0][:url],
16
17
  verify_ssl: false
17
- )
18
+ )
18
19
  @maas = maas
19
20
  @logger = logger
20
21
  end
21
22
 
23
+ def list_all_containers
24
+ logger.debug("Calling <#{__method__.to_s}>")
25
+
26
+ config[:lxd][:nodes].each do |node|
27
+ puts "Listing LXC containers on #{node[:url]}..."
28
+ conn = Hyperkit::Client.new(
29
+ api_endpoint: node[:url],
30
+ verify_ssl: false
31
+ )
32
+
33
+ nodes = []
34
+ conn.containers.each do |con|
35
+ row = {}
36
+ row[:name] = conn.container(con).to_hash[:name]
37
+ row[:status] = conn.container_state(con).to_hash[:status].upcase
38
+ if conn.container_state(con).to_hash[:network] && \
39
+ conn.container_state(con).to_hash[:network][:eth0] && \
40
+ conn.container_state(con).to_hash[:network][:eth0][:addresses] && \
41
+ conn.container_state(con).to_hash[:network][:eth0][:addresses][0] && \
42
+ conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
43
+ row[:ipv4] = \
44
+ conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
45
+ else
46
+ row[:ipv4] = "NA"
47
+ end
48
+ nodes << row
49
+ end
50
+ tp nodes, :name, :status, :ipv4
51
+ puts
52
+ end
53
+ end
54
+
22
55
  def list
23
56
  logger.info("Calling <#{__method__.to_s}>")
24
57
  conn.containers
@@ -50,6 +83,8 @@ module Gogetit
50
83
 
51
84
  args[:config] = {}
52
85
 
86
+ args[:config][:"user.user-data"]['maas'] = true
87
+
53
88
  if options['no-maas']
54
89
  args[:config][:'user.user-data'] = \
55
90
  YAML.load_file(options['file'])[:config]['user.user-data']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gogetit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Draper
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 3.5.5
195
+ - !ruby/object:Gem::Dependency
196
+ name: table_print
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 1.5.6
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 1.5.6
195
209
  description: |2
196
210
  This provides the ways that deal with mutiple virtualized and containerized solutions such as Libvirt(KVM) and LXD.
197
211
  This uses MAAS for bare-metal provision(KVM machine using Libvirt), DHCP and DNS.