vmfloaty 0.3.0 → 0.3.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 +4 -4
- data/lib/vmfloaty/utils.rb +7 -1
- data/lib/vmfloaty/version.rb +1 -1
- data/spec/vmfloaty/utils_spec.rb +57 -0
- 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: 84071f80697d4710056550214dddb804ffa5dc16
|
4
|
+
data.tar.gz: 81ca1c10c49c0ec05558f12b57aec85858c4a1f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dc3b64f3a23ec41378d85d239aafc4c6281082045e121c6267ca4e48c81da984151a29d21a4210b0d7d6c8c5c2c51f08d55dacf96c0e1fe8b1c76ecc61056d0
|
7
|
+
data.tar.gz: 93265ea14f9c3b576be432fb9561e680f7f0eceba10d08e97eaf5a9b8de22b3a801d899798e869ebe50e1fab88c74ee5818ed3bd185ef54757b683e357b7c5e7
|
data/lib/vmfloaty/utils.rb
CHANGED
@@ -51,6 +51,7 @@ class Utils
|
|
51
51
|
vms[host]['template'] = vm_info[host]['template']
|
52
52
|
vms[host]['lifetime'] = vm_info[host]['lifetime']
|
53
53
|
vms[host]['running'] = vm_info[host]['running']
|
54
|
+
vms[host]['tags'] = vm_info[host]['tags']
|
54
55
|
end
|
55
56
|
end
|
56
57
|
vms
|
@@ -64,8 +65,13 @@ class Utils
|
|
64
65
|
template = info['template']
|
65
66
|
lifetime = info['lifetime']
|
66
67
|
running = info['running']
|
68
|
+
tags = info['tags'] || {}
|
67
69
|
|
68
|
-
|
70
|
+
tag_pairs = tags.map {|key,value| "#{key}: #{value}" }
|
71
|
+
duration = "#{running}/#{lifetime} hours"
|
72
|
+
metadata = [template, duration, *tag_pairs]
|
73
|
+
|
74
|
+
puts "- #{vm}.#{domain} (#{metadata.join(", ")})"
|
69
75
|
end
|
70
76
|
end
|
71
77
|
end
|
data/lib/vmfloaty/version.rb
CHANGED
data/spec/vmfloaty/utils_spec.rb
CHANGED
@@ -31,4 +31,61 @@ describe Utils do
|
|
31
31
|
expect(Utils.generate_os_hash(host_arg)).to be_empty
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
describe '#prettyprint_hosts' do
|
36
|
+
let(:host_without_tags) { 'mcpy42eqjxli9g2' }
|
37
|
+
let(:host_with_tags) { 'aiydvzpg23r415q' }
|
38
|
+
let(:url) { 'http://pooler.example.com' }
|
39
|
+
|
40
|
+
let(:host_info_with_tags) do
|
41
|
+
{
|
42
|
+
host_with_tags => {
|
43
|
+
"template" => "redhat-7-x86_64",
|
44
|
+
"lifetime" => 48,
|
45
|
+
"running" => 7.67,
|
46
|
+
"tags" => {
|
47
|
+
"user" => "bob",
|
48
|
+
"role" => "agent"
|
49
|
+
},
|
50
|
+
"domain" => "delivery.puppetlabs.net"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:host_info_without_tags) do
|
56
|
+
{
|
57
|
+
host_without_tags => {
|
58
|
+
"template" => "ubuntu-1604-x86_64",
|
59
|
+
"lifetime" => 12,
|
60
|
+
"running" => 9.66,
|
61
|
+
"domain" => "delivery.puppetlabs.net"
|
62
|
+
}
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:output_with_tags) { "- #{host_with_tags}.delivery.puppetlabs.net (redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)" }
|
67
|
+
let(:output_without_tags) { "- #{host_without_tags}.delivery.puppetlabs.net (ubuntu-1604-x86_64, 9.66/12 hours)" }
|
68
|
+
|
69
|
+
it 'prints an output with host fqdn, template and duration info' do
|
70
|
+
allow(Utils).to receive(:get_vm_info).
|
71
|
+
with(host_without_tags, false, url).
|
72
|
+
and_return(host_info_without_tags)
|
73
|
+
|
74
|
+
expect(Utils).to receive(:puts).with("Running VMs:")
|
75
|
+
expect(Utils).to receive(:puts).with(output_without_tags)
|
76
|
+
|
77
|
+
Utils.prettyprint_hosts(host_without_tags, false, url)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'prints an output with host fqdn, template, duration info, and tags when supplied' do
|
81
|
+
allow(Utils).to receive(:get_vm_info).
|
82
|
+
with(host_with_tags, false, url).
|
83
|
+
and_return(host_info_with_tags)
|
84
|
+
|
85
|
+
expect(Utils).to receive(:puts).with("Running VMs:")
|
86
|
+
expect(Utils).to receive(:puts).with(output_with_tags)
|
87
|
+
|
88
|
+
Utils.prettyprint_hosts(host_with_tags, false, url)
|
89
|
+
end
|
90
|
+
end
|
34
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmfloaty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Cain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|