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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e22ca01b2db81f1c9fcc0332a6ad701eddb36566
4
- data.tar.gz: 7656dd21e3e635bfbb80c88e251629fb6b3938fa
3
+ metadata.gz: 84071f80697d4710056550214dddb804ffa5dc16
4
+ data.tar.gz: 81ca1c10c49c0ec05558f12b57aec85858c4a1f7
5
5
  SHA512:
6
- metadata.gz: 771a0f09058b031084f92ed1b12ab0d6836cfec45900bf131e6cfb4046553d9ae437b31bcd2d7e8e1acf7254a417cce7b4dcaecb113fd7a961c06b1eb6e2f2ac
7
- data.tar.gz: 78eb6e29cc49eadd4a505e4c90423926698058fc825b1a961246519c8f16772953826a8bb99fa64eb6285595e8f4e767eec11ee004795f6f985ed3b17376b593
6
+ metadata.gz: 6dc3b64f3a23ec41378d85d239aafc4c6281082045e121c6267ca4e48c81da984151a29d21a4210b0d7d6c8c5c2c51f08d55dacf96c0e1fe8b1c76ecc61056d0
7
+ data.tar.gz: 93265ea14f9c3b576be432fb9561e680f7f0eceba10d08e97eaf5a9b8de22b3a801d899798e869ebe50e1fab88c74ee5818ed3bd185ef54757b683e357b7c5e7
@@ -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
- puts "- #{vm}.#{domain} (#{template}, #{running}/#{lifetime} hours)"
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
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Version
3
- @version = '0.3.0'
3
+ @version = '0.3.1'
4
4
 
5
5
  def self.get
6
6
  @version
@@ -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.0
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-03 00:00:00.000000000 Z
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander