gogetit 0.13.7 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/gogetit.rb +58 -0
- data/lib/gogetit/cli.rb +5 -3
- data/lib/gogetit/version.rb +1 -1
- data/lib/providers/lxd.rb +0 -36
- data/lib/sample_conf/gogetit.yml +18 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0069b408c8ca685e130a7e0d999dcada0260cd6d'
|
4
|
+
data.tar.gz: 823609fa164ac340398640d288ea7a186d398641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40df33d8170177b3404c0aba7eb180624dd4d4f9a61ec656b557cf40ce2b6c2666a05cc443066cdeaad4bf4a6e94dc001ddcc215f763016a9bf9a249cbcc1878
|
7
|
+
data.tar.gz: c7821587c326c9ff112efb1d3cccd6a56c0bfe17409df63b60ef8e87e599d73a6e1cc0c5b4fb891bd061574a7b2bd89f09fa05f593b438783efbbdaea02fa85c
|
data/README.md
CHANGED
data/lib/gogetit.rb
CHANGED
@@ -16,4 +16,62 @@ module Gogetit
|
|
16
16
|
@lxd = Gogetit::GogetLXD.new(config, maas, logger)
|
17
17
|
@libvirt = Gogetit::GogetLibvirt.new(config, maas, logger)
|
18
18
|
|
19
|
+
def self.list_all_types
|
20
|
+
logger.debug("Calling <#{__method__.to_s}>")
|
21
|
+
|
22
|
+
nodes = []
|
23
|
+
|
24
|
+
# for LXD
|
25
|
+
conn = lxd.conn
|
26
|
+
config[:lxd][:nodes].each do |node|
|
27
|
+
puts "Listing LXC containers on #{node[:url]}..."
|
28
|
+
|
29
|
+
conn.containers.each do |con|
|
30
|
+
row = {}
|
31
|
+
row[:name] = conn.container(con).to_hash[:name]
|
32
|
+
row[:status] = conn.container_state(con).to_hash[:status].upcase
|
33
|
+
if conn.container_state(con).to_hash[:network] && \
|
34
|
+
conn.container_state(con).to_hash[:network][:eth0] && \
|
35
|
+
conn.container_state(con).to_hash[:network][:eth0][:addresses] && \
|
36
|
+
conn.container_state(con).to_hash[:network][:eth0][:addresses][0] && \
|
37
|
+
conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
|
38
|
+
row[:ipv4] = \
|
39
|
+
# only print the first IP address on the first interface
|
40
|
+
conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
|
41
|
+
else
|
42
|
+
row[:ipv4] = "NA"
|
43
|
+
end
|
44
|
+
row[:host] = node[:name]
|
45
|
+
row[:type] = 'LXC(LXD)'
|
46
|
+
nodes << row
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# for Libvirt(KVM), machines in pods controlled by MAAS
|
51
|
+
conn = maas.conn
|
52
|
+
machines = conn.request(:get, ['machines'])
|
53
|
+
config[:libvirt][:nodes].each do |node|
|
54
|
+
puts "Listing KVM instances on #{node[:url]}..."
|
55
|
+
machines.each do |machine|
|
56
|
+
if machine['pod']['name'] == node[:name]
|
57
|
+
row = {}
|
58
|
+
row[:name] = machine['hostname']
|
59
|
+
row[:status] = machine['status_name']
|
60
|
+
if machine['interface_set'][0]['links'][0]['ip_address']
|
61
|
+
row[:ipv4] = machine['interface_set'][0]['links'][0]['ip_address']
|
62
|
+
else
|
63
|
+
row[:ipv4] = 'NA'
|
64
|
+
end
|
65
|
+
row[:host] = node[:name]
|
66
|
+
row[:type] = 'KVM(Libvirt)'
|
67
|
+
nodes << row
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
puts '-------------------------------------------------------------------------'
|
73
|
+
tp nodes, :name, :status, :ipv4, :host, :type
|
74
|
+
puts
|
75
|
+
end
|
76
|
+
|
19
77
|
end
|
data/lib/gogetit/cli.rb
CHANGED
@@ -33,21 +33,23 @@ module Gogetit
|
|
33
33
|
def list
|
34
34
|
case options[:out]
|
35
35
|
when 'custom'
|
36
|
-
|
36
|
+
Gogetit.list_all_types
|
37
37
|
when 'all'
|
38
38
|
config[:lxd][:nodes].each do |node|
|
39
39
|
puts "Listing LXD containers on #{node[:url]}.."
|
40
40
|
system("lxc list #{node[:name]}:")
|
41
41
|
end
|
42
|
+
puts "Listing KVM domains on #{config[:libvirt][:nodes][0][:url]}.."
|
43
|
+
system("virsh -c #{config[:libvirt][:nodes][0][:url]} list --all")
|
42
44
|
when ''
|
43
45
|
puts "Listing LXD containers on #{config[:lxd][:nodes][0][:url]}.."
|
44
46
|
system("lxc list #{config[:lxd][:nodes][0][:name]}:")
|
45
47
|
puts ''
|
48
|
+
puts "Listing KVM domains on #{config[:libvirt][:nodes][0][:url]}.."
|
49
|
+
system("virsh -c #{config[:libvirt][:nodes][0][:url]} list --all")
|
46
50
|
else
|
47
51
|
puts "Invalid option or command"
|
48
52
|
end
|
49
|
-
puts "Listing KVM domains on #{config[:libvirt][:nodes][0][:url]}.."
|
50
|
-
system("virsh -c #{config[:libvirt][:nodes][0][:url]} list --all")
|
51
53
|
end
|
52
54
|
|
53
55
|
desc 'create NAME', 'Create either a container or KVM domain.'
|
data/lib/gogetit/version.rb
CHANGED
data/lib/providers/lxd.rb
CHANGED
@@ -20,42 +20,6 @@ module Gogetit
|
|
20
20
|
@logger = logger
|
21
21
|
end
|
22
22
|
|
23
|
-
def list_all_containers
|
24
|
-
logger.debug("Calling <#{__method__.to_s}>")
|
25
|
-
|
26
|
-
nodes = []
|
27
|
-
config[:lxd][:nodes].each do |node|
|
28
|
-
puts "Listing LXC containers on #{node[:url]}..."
|
29
|
-
|
30
|
-
conn = Hyperkit::Client.new(
|
31
|
-
api_endpoint: node[:url],
|
32
|
-
verify_ssl: false
|
33
|
-
)
|
34
|
-
|
35
|
-
conn.containers.each do |con|
|
36
|
-
row = {}
|
37
|
-
row[:name] = conn.container(con).to_hash[:name]
|
38
|
-
row[:status] = conn.container_state(con).to_hash[:status].upcase
|
39
|
-
if conn.container_state(con).to_hash[:network] && \
|
40
|
-
conn.container_state(con).to_hash[:network][:eth0] && \
|
41
|
-
conn.container_state(con).to_hash[:network][:eth0][:addresses] && \
|
42
|
-
conn.container_state(con).to_hash[:network][:eth0][:addresses][0] && \
|
43
|
-
conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
|
44
|
-
row[:ipv4] = \
|
45
|
-
# only print the first IP address on the first interface
|
46
|
-
conn.container_state(con).to_hash[:network][:eth0][:addresses][0][:address]
|
47
|
-
else
|
48
|
-
row[:ipv4] = "NA"
|
49
|
-
end
|
50
|
-
row[:host] = node[:name]
|
51
|
-
nodes << row
|
52
|
-
end
|
53
|
-
end
|
54
|
-
puts '-----------------------------------------------------------'
|
55
|
-
tp nodes, :name, :status, :ipv4, :host
|
56
|
-
puts
|
57
|
-
end
|
58
|
-
|
59
23
|
def list
|
60
24
|
logger.info("Calling <#{__method__.to_s}>")
|
61
25
|
conn.containers
|
data/lib/sample_conf/gogetit.yml
CHANGED
@@ -2,24 +2,6 @@ default:
|
|
2
2
|
user: ubuntu
|
3
3
|
root_bridge: $root_bridge
|
4
4
|
|
5
|
-
cloud_init:
|
6
|
-
users:
|
7
|
-
- name: usera
|
8
|
-
gecos: usera
|
9
|
-
sudo: ALL=(ALL) NOPASSWD:ALL
|
10
|
-
groups: users, admin
|
11
|
-
shell: /bin/bash
|
12
|
-
lock_passwd: true
|
13
|
-
ca_certs:
|
14
|
-
- http://pki.example.com/site/root_ca.crt
|
15
|
-
ssh_ca_public_key:
|
16
|
-
key_url: http://pki.example.com/site/ssh_ca.pub
|
17
|
-
key_path: /etc/ssh/ca.pub
|
18
|
-
revocation_url: http://pki.example.com/site/ssh-revoked-keys
|
19
|
-
revocation_path: /etc/ssh/ca.pub
|
20
|
-
owner: root:root
|
21
|
-
permissions: '0640'
|
22
|
-
|
23
5
|
maas:
|
24
6
|
key: K:E:Y
|
25
7
|
url: http://maas.example.com/MAAS/api/2.0
|
@@ -72,3 +54,21 @@ chef:
|
|
72
54
|
install_script:
|
73
55
|
libvirt: http://chef.example.com/install_chef_script.sh
|
74
56
|
lxd: http://chef.example.com/install_chef_script_for_lxd.sh
|
57
|
+
|
58
|
+
cloud_init:
|
59
|
+
users:
|
60
|
+
- name: usera
|
61
|
+
gecos: usera
|
62
|
+
sudo: ALL=(ALL) NOPASSWD:ALL
|
63
|
+
groups: users, admin
|
64
|
+
shell: /bin/bash
|
65
|
+
lock_passwd: true
|
66
|
+
ca_certs:
|
67
|
+
- http://pki.example.com/site/root_ca.crt
|
68
|
+
ssh_ca_public_key:
|
69
|
+
key_url: http://pki.example.com/site/ssh_ca.pub
|
70
|
+
key_path: /etc/ssh/ca.pub
|
71
|
+
revocation_url: http://pki.example.com/site/ssh-revoked-keys
|
72
|
+
revocation_path: /etc/ssh/ca.pub
|
73
|
+
owner: root:root
|
74
|
+
permissions: '0640'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gogetit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Draper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|