cloud66_agent 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c1b13722c05c1fda8122d77b6ae685aaaea94b6
4
- data.tar.gz: 57757bb9fbd697bb9b7419d7fc16e312ead068f6
3
+ metadata.gz: 51ef1d2f57617cdc1d773ba203a52f105f47437e
4
+ data.tar.gz: 76ef024511f59e0182a94eb39e4466cb38a0070e
5
5
  SHA512:
6
- metadata.gz: 3a3c044f803a5dc271a66427c9fcfa4bbd116d5960647aa3976a6c2981085e722ad7b41258ec04f99cb1fc37ead159fd590d84d9163ceff1bd295362483f076e
7
- data.tar.gz: cf251c79ef3db7a98713f0ad7a65367dfd2260d8e35df3e29a36d5c98d36af664c26e296d0c08525ffb1f7106d529cea57fc53fde4b5d3ed69767b4c28b09510
6
+ metadata.gz: dc9c0e1e78b71b067235a022b776d68122e03f6d412e4c1b7b9c2d9c3e0a559c6044a7544b7281993921b7811ad94a3da70121247a8a4a597d77c7de351793f9
7
+ data.tar.gz: cb8c05474defa7dc3901c8dcb6dbeed028d1f7ee6f8ea52f59149ef602064bf22eaa74006adaf45b097228e2d7c85233b0880013744e5aa0972c9a18f6ac32aa
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.2.6
1
+ ruby-2.4.4
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "cloud66_agent"
8
8
  gem.version = Cloud66::Utils::Version.current
9
9
  gem.platform = Gem::Platform::RUBY
10
- gem.date = '2017-01-05'
10
+ gem.date = '2018-04-10'
11
11
  gem.authors = ["Cloud 66"]
12
12
  gem.email = ['hello@cloud66.com']
13
13
  gem.licenses = ['MIT']
@@ -13,7 +13,7 @@ module Cloud66
13
13
  # Defines the minor version
14
14
  # PATCH:
15
15
  # Defines the patch version
16
- MAJOR, MINOR, PATCH = 1, 3, 0
16
+ MAJOR, MINOR, PATCH = 1, 3, 1
17
17
 
18
18
  #ie. PRERELEASE_MODIFIER = 'beta1' or nil
19
19
  PRERELEASE_MODIFIER = nil
@@ -2,40 +2,46 @@ module Cloud66
2
2
  module Utils
3
3
  class VitalSigns
4
4
 
5
+ IP_BLOCK_REGEX = /\d{,2}|1\d{2}|2[0-4]\d|25[0-5]/
6
+ IP_REGEX = /\A#{IP_BLOCK_REGEX}\.#{IP_BLOCK_REGEX}\.#{IP_BLOCK_REGEX}\.#{IP_BLOCK_REGEX}\z/
7
+
5
8
  def self.system_info
6
9
  # system info
7
10
  return parse_data(`facter`)
8
11
  end
9
12
 
10
13
  def self.address_info
14
+ result = {}
11
15
  # AWS special case
12
16
  if $config.is_aws
13
- result = {}
14
17
  reported_ip = `/usr/bin/curl -s http://169.254.169.254/latest/meta-data/public-ipv4`
15
18
  result[:ext_ipv4] = reported_ip if reported_ip =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
16
19
  reported_ip = `/usr/bin/curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
17
20
  result[:int_ipv4] = reported_ip if reported_ip =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
18
- return result
19
21
  # GC special case
20
22
  elsif $config.is_gc
21
- result = {}
22
23
  external_ip = `/usr/bin/curl -s -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip`
23
24
  result[:ext_ipv4] = external_ip if external_ip =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
24
25
  internal_ip = `/usr/bin/curl -s -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/ip`
25
26
  result[:int_ipv4] = internal_ip if internal_ip =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
26
- return result
27
27
  else
28
- interfaces_raw = `facter interfaces`
29
- interfaces = interfaces_raw.split(',').select { |interface| interface =~ /^eth/ }
30
-
28
+ interfaces_raw = `facter interfaces`.strip
29
+ interfaces = interfaces_raw.split(',').select { |interface| interface !~ /^lo/ }
31
30
  # don't have any ip address info
32
- return {} if interfaces.empty?
33
-
34
- # return all interface information
35
- facter_command = "facter #{interfaces.map { |interface| "ipaddress_#{interface} ipaddress6_#{interface}" }.join(' ')}"
36
- hash = parse_data(`#{facter_command}`) rescue {}
37
- return hash
31
+ unless interfaces.empty?
32
+ # return all interface information
33
+ facter_command = "facter #{interfaces.map { |interface| "ipaddress_#{interface} ipaddress6_#{interface}" }.join(' ')}"
34
+ raw_data = `#{facter_command}`.strip
35
+ result = parse_data(raw_data) rescue {}
36
+ end
37
+ end
38
+ normalised_hash = {}
39
+ result.each do |key, value|
40
+ if value =~ IP_REGEX && value != '127.0.0.1' && value != '127.0.1.1'
41
+ normalised_hash[key] = value
42
+ end
38
43
  end
44
+ return normalised_hash
39
45
  end
40
46
 
41
47
  def self.is_aws?
@@ -74,13 +80,11 @@ module Cloud66
74
80
  data.lines.each do |line|
75
81
  split = line.split('=>')
76
82
  if split.size == 2
77
- key = split[0]
78
- value = split[1]
79
- unless value.nil?
80
- value = value.strip
83
+ key = split[0].strip rescue ''
84
+ value = split[1].strip rescue ''
85
+ if !value.nil? && value != 'nil'
81
86
  # exclude empty or long results (like ssh keys)
82
- if !value.empty? && value.size < 100
83
- key = key.strip
87
+ if !value.empty? && value.size < 100
84
88
  hash[key] = value
85
89
  end
86
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud66_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloud 66
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-05 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  requirements: []
162
162
  rubyforge_project:
163
- rubygems_version: 2.4.8
163
+ rubygems_version: 2.6.14.1
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Cloud 66 server component