one_conf_compare 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. data/lib/one_conf_compare.rb +34 -5
  2. metadata +3 -3
@@ -1,13 +1,9 @@
1
1
  #!/usr/bin/ruby
2
- ### Those classes return list's from both url's and filesystem for later on comparision
3
- ### This is originallt used to compare machines that list in Onering API to Nagios filesystem for
4
- ### Auto addition of configuration files
5
2
  require 'rubygems'
6
3
  require 'net/http'
7
4
  require 'uri'
8
5
  require 'json'
9
6
  require 'ftools'
10
- ### get_machines method Returns the body which is basically one long json file
11
7
  class OneRingData
12
8
  def seturl
13
9
  @url
@@ -23,7 +19,6 @@ class OneRingData
23
19
  response.body
24
20
  end
25
21
  end
26
- ### get_files method Return list of machines in the given path
27
22
  class DirectoryScan
28
23
  def setdir
29
24
  @dir
@@ -39,4 +34,38 @@ class DirectoryScan
39
34
  end
40
35
  config_files
41
36
  end
37
+ def examine_file=( filetocheck )
38
+ @filetocheck = filetocheck
39
+ if @filetocheck.match /[a-z0-9]+-[0-9]+-[prod|stg|test]+-[nydc1|ladc1|chidc1|test].[nydc1|ladc1|chidc1|test]/
40
+ @dc = @filetocheck.split('.')
41
+ @app = @filetocheck.split('-')
42
+ if @app[2] == "test"
43
+ @dc[1] = "nydc1"
44
+ end
45
+ if @dc[1] == "nyc"
46
+ @dc[1] = "nydc1"
47
+ end
48
+ @directory = @dir + @dc[1] + "/" + @app[0]
49
+ puts @directory
50
+ if ! File.directory? @directory
51
+ Dir.mkdir(@directory)
52
+ end
53
+ @fullpath = @directory + "/" + @filetocheck + ".cfg"
54
+ end
55
+ end
56
+ def get_fullpath
57
+ @fullpath
58
+ end
59
+ def create_file=( file_to_create )
60
+ @file_to_create = file_to_create
61
+ #puts @file_to_create
62
+ File.new(@file_to_create, "w")
63
+ @file_h = File.open(@file_to_create,"w")
64
+ @file_h.puts("define host{")
65
+ @file_h.puts(" use linux-server")
66
+ @file_h.puts(" host_name " + @filetocheck)
67
+ @file_h.puts(" alias " + @filetocheck)
68
+ @file_h.puts(" hostgroups appnode,linux")
69
+ @file_h.puts("}")
70
+ end
42
71
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ariel Moskovich
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-12-23 00:00:00 +02:00
17
+ date: 2012-12-26 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20