cloud66_agent 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGZlMDlhMTNmNjlhNzBjZTQwYWZjODUxNzQ3YTkwZDAxMjgzOTdkYw==
4
+ ZjNmOWJiODVlYjQ3NzE1NGQ2ZGI4ODY2YzBiMjBjYTM4ODVlZDhjZQ==
5
5
  data.tar.gz: !binary |-
6
- MmNkNWZlYjJkZDliOTVlOTQ3ODc0M2E3YzUwMzgzYzRjZjVmZTA4OQ==
6
+ ZDM1YTU2ODYwZmQzMDRhODVmM2IxYzljODEyOGUzNzhmNTE2OTUxMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDNkNWZmNmUwYmU0ODc1NzZkYTgzYzFlNGM1OTgxNjM3ZGM2NjY1NDg3YTU5
10
- NmViZTA2NjEzNzZjNWE4NTgxYjUyZTMyYzM2M2Y5MjdlYWY2MTg5MmRhNjNl
11
- ZmQyN2Q5NzM1OGYxNGJmMDk2MmI2MzZjNDk0MjEyMjdkOTZmOTY=
9
+ Yzk1ZWEyMTQ3ZDdkZTJiN2JmNmQwYTZjYTRmYzIyN2U5YjliZjUwYjM4ZjZj
10
+ MTllOTViYTc2ZDllNzdmMGFmYzFiZTFkZjVhYTA4YWMzZTBlN2Y2NmYxYWVk
11
+ N2M0Y2M0YTlhODgxYWNmODM0MGIzODk0N2I3MDMxYzAxN2IwMDk=
12
12
  data.tar.gz: !binary |-
13
- NThmOGNiNzAxNWE5NTBkNjA0ZTFjN2Q4YTFmNGNkZmRmMjJmOWQ2YzZjZDI2
14
- NDljNjE5NjJmYzU4Yzc3NzExYjEwYmVmMjFkYWJhZjI4NjNmNDdjYWNiZjg0
15
- ODg0MjBjNWI2YTAxNWVjMWJkMDc0MGQ3OTIyODQ1ZmM5MWFmZGE=
13
+ MTJkY2VhNWZkMDE3MDdjNWQxZWY5ZDI2YzAxYzFlYTgyNGE1M2EwMDkxMDIw
14
+ MmJmMjc0OWI1N2U5YjNmNTcyMDg3MzM0OWY0YWE4MTY3ODc5YmY1YTY2NjFl
15
+ NGRhZWExNTJjODEzMmUyZTY1YWE5ZmZiNTAwMjU1YzBjMjVmN2U=
@@ -24,17 +24,14 @@ module Cloud66
24
24
  # use the passed in value
25
25
  $config.is_gc = (cloud == 'googlecloud')
26
26
  end
27
-
28
- address_info = Utils::VitalSigns.address_info
29
27
  data = {
30
28
  :timezone => Time.new.zone,
31
29
  :server_uid => server_uid,
32
- :ext_ipv4 => address_info[:ext_ipv4],
33
- :int_ipv4 => address_info[:int_ipv4],
34
- :ext_ipv6 => address_info[:ext_ipv6],
35
- :int_ipv6 => address_info[:int_ipv6],
36
30
  :version => Utils::Version.current,
37
31
  :system => Utils::VitalSigns.system_info }
32
+
33
+ address_info = Utils::VitalSigns.address_info
34
+ data = data.merge(address_info)
38
35
  rescue => exc
39
36
  data = { error: exc.message }
40
37
  end
@@ -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, 2, 1
16
+ MAJOR, MINOR, PATCH = 1, 2, 2
17
17
 
18
18
  #ie. PRERELEASE_MODIFIER = 'beta1' or nil
19
19
  PRERELEASE_MODIFIER = nil
@@ -8,39 +8,36 @@ module Cloud66
8
8
  end
9
9
 
10
10
  def self.address_info
11
- # address information
12
- hash = parse_data(`facter ipaddress ipaddress_eth0 ipaddress6 ipaddress6_eth0`)
13
-
14
11
  result = {}
15
12
  # AWS special case
16
13
  if $config.is_aws
17
14
  reported_ip = `/usr/bin/curl -s http://169.254.169.254/latest/meta-data/public-ipv4`
18
15
  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]?)$/
19
- # GC special case
16
+ reported_ip = `/usr/bin/curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
17
+ 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
+ # GC special case
20
19
  elsif $config.is_gc
21
20
  external_ip = `/usr/bin/curl -s -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip`
22
21
  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]?)$/
23
- else
24
- # set general external ip address
25
- result[:ext_ipv4] = hash['ipaddress']
26
- end
27
-
28
- # GC special case
29
- if $config.is_gc
30
22
  internal_ip = `/usr/bin/curl -s -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/ip`
31
23
  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]?)$/
32
24
  else
33
- result[:int_ipv4] = hash['ipaddress_eth0'] if hash.has_key?('ipaddress_eth0')
34
- end
35
-
36
- result[:ext_ipv6] = hash['ipaddress6'] if hash.has_key?('ipaddress6')
37
- result[:int_ipv6] = hash['ipaddress6_eth0'] if hash.has_key?('ipaddress6_eth0')
25
+ interfaces_raw = `facter interfaces`
26
+ interfaces = interfaces_raw.split(',').select { |interface| interface =~ /^eth/ }
27
+
28
+ # don't have any ip address info
29
+ raise 'no address information' if interfaces.empty?
38
30
 
39
- # don't have any ip address info
40
- raise 'no address information' if result.empty? || !result.has_key?(:ext_ipv4)
31
+ # address information
32
+ facter_command = "facter #{interfaces.map { |interface| "ipaddress_#{interface} ipaddress6_#{interface}" }.join(' ')}"
33
+ hash = parse_data(`#{facter_command}`)
41
34
 
42
- # return ip address info
43
- return result
35
+ # don't have any ip address info
36
+ raise 'no address information' if hash.empty?
37
+
38
+ # return all interface information
39
+ return hash
40
+ end
44
41
  end
45
42
 
46
43
  def self.is_aws?
@@ -74,8 +71,8 @@ module Cloud66
74
71
  hash = {}
75
72
  data.lines.each do |line|
76
73
  split = line.split('=>')
77
- key = split[0]
78
74
  if split.size == 2
75
+ key = split[0]
79
76
  value = split[1]
80
77
  unless value.nil?
81
78
  value = value.strip
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud66_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloud 66