sfpagent 0.4.11 → 0.4.12

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sfpagent might be problematic. Click here for more details.

Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/sfpagent/agent.rb +29 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd9471c4205f4b99d47c803a056e1fe3eebd86e5
4
- data.tar.gz: e79a839460f362f05f6cbd9805cff37061b35aae
3
+ metadata.gz: 04d8a36eadf932a9f6042561b7419e312bf73e2f
4
+ data.tar.gz: 7485c508076ea1c3374ca67c6bec882e971d5853
5
5
  SHA512:
6
- metadata.gz: d837d0fbaf7fa9ad9227b94f573c5d9d88fcb28dceee8b5b2da47c4e41e0a229d0bcd26b97c1672459780ff9c85ec71f9ce4516ba64ed9501e9bb976b4c4fb73
7
- data.tar.gz: 25dd5da872d24b82b22e1f5ee1a831423752d7ec14e251a6127c039dcc543686accf70f396b90a2024c814c1b16902559fa7df4a472babfa4f06cb3455297dd7
6
+ metadata.gz: ca3358ea6a730febb5aaddc77fc52f8f212ad9266537ae892ff7e07d3ec05528fdfe6fa27c5af156652c8504306410440372714d2208e1cde1140729aa374b0d
7
+ data.tar.gz: dac95e949e5134baa9ddd456df190f2068b5b2b7a2534cf54ce5c478f32e4accc15ee056cb0eaa5419066118a3640e10fd598ebbce2c0d4e0cc071ebf0ad17e7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.11
1
+ 0.4.12
@@ -634,6 +634,35 @@ module Sfp
634
634
  end
635
635
  }
636
636
  }
637
+
638
+ # update /etc/hosts so other applications can resolve the names correctly
639
+ begin
640
+ File.open('/etc/hosts', File::RDWR, 0644) do |f|
641
+ f.flock(File::LOCK_EX)
642
+ output = ''
643
+ ### remove previous records
644
+ f.read.each_line do |line|
645
+ if line =~ /# Edited by Nuri/
646
+ break
647
+ else
648
+ output << line
649
+ end
650
+ end
651
+ ### add current records
652
+ output << "# Edited by Nuri (don't change or add anything below this line)\n"
653
+ agents.each do |name,agent|
654
+ next if not (agent['sfpAddress'] =~ /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)
655
+ output << "#{agent['sfpAddress']}\t#{name}\n"
656
+ end
657
+ ### save records
658
+ f.rewind
659
+ f.write(output)
660
+ f.flush
661
+ f.truncate(f.pos)
662
+ end
663
+ rescue Exception => e
664
+ Sfp::Agent.logger.error e.to_s
665
+ end
637
666
  end
638
667
 
639
668
  true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfpagent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sfp