abiquo-chef-agent 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODdlYWYxZWQ3M2UyMTM2MDA0MjliZjBmMDE1ZWQ4N2Y3NGE3YjFjZA==
5
+ data.tar.gz: !binary |-
6
+ NTU3ZTEyZTMxNmJhZjNmOWQxYzg5Y2Y0ODFjNzA2ODhiNWViZTc2NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTZlZTY0ZWJjMjc4NDhkZjQ1ZWJlNTNkYTQ4MWE1OGIxMjJhODk2ZGE3M2Ri
10
+ MDAxMzAyNmQwNTgyNGNiZjNkMWM2ZTI0Y2RiNWE0Y2I3YmUwZTBhZjMwN2I3
11
+ MDAzYjRmNGQxNTBjZDFjOGM5NWFkNDU1ZmI2OWNjMGFkMzE1Zjc=
12
+ data.tar.gz: !binary |-
13
+ YzJiYjk4NGNhNTE3ZGI2N2I1OGI0ZTY0MGQ1NTg2OTFlODNkNGRiZjk1MDk4
14
+ M2YzM2YyZDEyNDc2ZWRkOTkyMGM0YTA0NDE4NGU2NGJlN2IyMDRmODFiOGQ3
15
+ NWMwYjdhNTlkMGIwZThiMWY5N2EyYjZiYzk5MTMyM2RiOWU2OWI=
@@ -73,7 +73,7 @@ else
73
73
  #
74
74
  log "Requesting Chef config from API #{leases[:abiquo_api_url]} OneTime #{leases[:abiquo_api_token]}"
75
75
  begin
76
- xml = RestClient.get leases[:abiquo_api_url], :authorization => "OneTime #{leases[:abiquo_api_token]}"
76
+ xml = RestClient.get leases[:abiquo_api_url], :authorization => "OneTime #{leases[:abiquo_api_token]}", :accept => "application/vnd.abiquo.extended+xml"
77
77
  rescue Exception => e
78
78
  log "Error requesting node info from API", :error
79
79
  log e.message, :error
@@ -1,10 +1,11 @@
1
1
  require 'xmlsimple'
2
2
  require 'json'
3
+ require 'time'
3
4
 
4
5
  module Abiquo
5
6
  module Chef
6
7
 
7
- VERSION="2.0.0"
8
+ VERSION="2.0.1"
8
9
 
9
10
  class Config
10
11
  def self.chef_config_dir
@@ -115,11 +116,13 @@ module Abiquo
115
116
  #
116
117
  def self.parse_leases_file(search_dirs = ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient'])
117
118
  files = find_leases_file(search_dirs)
119
+ leases = []
118
120
  files.each do |file|
119
- f = File.open(file)
120
121
  l = {}
121
- f.each do |line|
122
+ File.open(file).each { |line|
122
123
  case line
124
+ when /^lease \{/
125
+ l = {}
123
126
  when /fixed-address (.*);/
124
127
  l[:ip] = $1
125
128
  when /interface (.*);/
@@ -132,17 +135,18 @@ module Abiquo
132
135
  l[:routers] = $1
133
136
  when /option domain-name (.*);/
134
137
  l[:domain_name] = $1
138
+ when /renew \d+ (.+);/
139
+ l[:renew] = Time.parse $1
135
140
  when /option vendor-encapsulated-options\s*"(.*)"\s*;/
136
141
  tokens = $1.split('@@')
137
142
  l[:abiquo_api_url] = tokens[0].gsub("\\", "")
138
143
  l[:abiquo_api_token] = tokens[1]
144
+ when /^\}/
145
+ leases << l.clone if l[:abiquo_api_token]
139
146
  end
140
- end
141
- if l[:abiquo_api_token]
142
- return l
143
- end
147
+ }.close
144
148
  end
145
- return nil
149
+ return leases.sort_by { |l| l[:renew] }.last
146
150
  end
147
151
  end
148
152
  end
@@ -24,7 +24,7 @@ lease {
24
24
  option domain-name-servers 8.8.8.8;
25
25
  option dhcp-server-identifier 192.168.0.1;
26
26
  option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
27
- renew 5 2011/11/18 05:48:45;
27
+ renew 5 2012/11/18 05:48:45;
28
28
  rebind 5 2011/11/18 13:34:41;
29
29
  expire 5 2011/11/18 15:39:41;
30
30
  }
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'time'
2
3
  include Abiquo::Chef
3
4
 
4
5
  describe Util do
@@ -24,12 +25,14 @@ describe Util do
24
25
  it 'should have a valid API URL' do
25
26
  @leases[:abiquo_api_url].should match(/http(s)?:\/\//)
26
27
  end
28
+
29
+ it 'should return latest lease' do
30
+ @leases[:renew].should eql(Time.parse('2012-11-18 05:48:45 +0100'))
31
+ end
32
+
27
33
  it 'should have a valid token' do
28
34
  @leases[:abiquo_api_token].should have_at_least(5).characters
29
35
  end
30
- #it 'should have a valid mac' do
31
- # #@leases[:mac].should match(/([a-f]{2}:){3}[a-f]{2}/m)
32
- #end
33
36
 
34
37
  end
35
38
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abiquo-chef-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
5
- prerelease:
4
+ version: 2.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Salvador Girones
@@ -11,12 +10,11 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-09-19 00:00:00.000000000 Z
13
+ date: 2014-05-23 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rspec
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
19
  - - ! '>='
22
20
  - !ruby/object:Gem::Version
@@ -24,7 +22,6 @@ dependencies:
24
22
  type: :development
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
26
  - - ! '>='
30
27
  - !ruby/object:Gem::Version
@@ -32,7 +29,6 @@ dependencies:
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: bundler
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
33
  - - ~>
38
34
  - !ruby/object:Gem::Version
@@ -40,7 +36,6 @@ dependencies:
40
36
  type: :development
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
40
  - - ~>
46
41
  - !ruby/object:Gem::Version
@@ -48,7 +43,6 @@ dependencies:
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: jeweler
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
47
  - - ! '>='
54
48
  - !ruby/object:Gem::Version
@@ -56,7 +50,6 @@ dependencies:
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
54
  - - ! '>='
62
55
  - !ruby/object:Gem::Version
@@ -64,7 +57,6 @@ dependencies:
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: simplecov
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
61
  - - ! '>='
70
62
  - !ruby/object:Gem::Version
@@ -72,7 +64,6 @@ dependencies:
72
64
  type: :development
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
68
  - - ! '>='
78
69
  - !ruby/object:Gem::Version
@@ -80,7 +71,6 @@ dependencies:
80
71
  - !ruby/object:Gem::Dependency
81
72
  name: run-as-root
82
73
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
74
  requirements:
85
75
  - - ! '>='
86
76
  - !ruby/object:Gem::Version
@@ -88,7 +78,6 @@ dependencies:
88
78
  type: :runtime
89
79
  prerelease: false
90
80
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
81
  requirements:
93
82
  - - ! '>='
94
83
  - !ruby/object:Gem::Version
@@ -96,7 +85,6 @@ dependencies:
96
85
  - !ruby/object:Gem::Dependency
97
86
  name: chef
98
87
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
88
  requirements:
101
89
  - - ! '>='
102
90
  - !ruby/object:Gem::Version
@@ -104,7 +92,6 @@ dependencies:
104
92
  type: :runtime
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
95
  requirements:
109
96
  - - ! '>='
110
97
  - !ruby/object:Gem::Version
@@ -112,7 +99,6 @@ dependencies:
112
99
  - !ruby/object:Gem::Dependency
113
100
  name: daemons
114
101
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
102
  requirements:
117
103
  - - ! '>='
118
104
  - !ruby/object:Gem::Version
@@ -120,7 +106,6 @@ dependencies:
120
106
  type: :runtime
121
107
  prerelease: false
122
108
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
109
  requirements:
125
110
  - - ! '>='
126
111
  - !ruby/object:Gem::Version
@@ -128,7 +113,6 @@ dependencies:
128
113
  - !ruby/object:Gem::Dependency
129
114
  name: rest-client
130
115
  requirement: !ruby/object:Gem::Requirement
131
- none: false
132
116
  requirements:
133
117
  - - ! '>='
134
118
  - !ruby/object:Gem::Version
@@ -136,7 +120,6 @@ dependencies:
136
120
  type: :runtime
137
121
  prerelease: false
138
122
  version_requirements: !ruby/object:Gem::Requirement
139
- none: false
140
123
  requirements:
141
124
  - - ! '>='
142
125
  - !ruby/object:Gem::Version
@@ -144,7 +127,6 @@ dependencies:
144
127
  - !ruby/object:Gem::Dependency
145
128
  name: xml-simple
146
129
  requirement: !ruby/object:Gem::Requirement
147
- none: false
148
130
  requirements:
149
131
  - - ! '>='
150
132
  - !ruby/object:Gem::Version
@@ -152,7 +134,6 @@ dependencies:
152
134
  type: :runtime
153
135
  prerelease: false
154
136
  version_requirements: !ruby/object:Gem::Requirement
155
- none: false
156
137
  requirements:
157
138
  - - ! '>='
158
139
  - !ruby/object:Gem::Version
@@ -198,26 +179,25 @@ files:
198
179
  homepage: http://github.com/abiquo/abiquo-chef-agent
199
180
  licenses:
200
181
  - MIT
182
+ metadata: {}
201
183
  post_install_message:
202
184
  rdoc_options: []
203
185
  require_paths:
204
186
  - lib
205
187
  required_ruby_version: !ruby/object:Gem::Requirement
206
- none: false
207
188
  requirements:
208
189
  - - ! '>='
209
190
  - !ruby/object:Gem::Version
210
191
  version: '0'
211
192
  required_rubygems_version: !ruby/object:Gem::Requirement
212
- none: false
213
193
  requirements:
214
194
  - - ! '>='
215
195
  - !ruby/object:Gem::Version
216
196
  version: '0'
217
197
  requirements: []
218
198
  rubyforge_project:
219
- rubygems_version: 1.8.24
199
+ rubygems_version: 2.1.3
220
200
  signing_key:
221
- specification_version: 3
201
+ specification_version: 4
222
202
  summary: Abiquo Chef Agent
223
203
  test_files: []