Class: LoadConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/dyntool.rb

Overview

class for loading and retrieving configuration from dyn.yml

Instance Method Summary collapse

Instance Method Details

#ConfManipulate(shiftfrom, shifto) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/dyntool.rb', line 81

def ConfManipulate(shiftfrom,shifto)
	@confile = "dyn.yml"
	@tmpfile = "status.yml"
	if (shiftfrom == "") && (shifto == "")
		if File.file?(@tmpfile)
			File.delete(@tmpfile)
		end
		@rfile = "dyn" 
	else	
		if ! File.file?(@tmpfile)
			File.syscopy(@confile,@tmpfile)	
		end
		@rfile = "temp"
	end
	return(@rfile)
end

#GetContactsObject



72
73
74
# File 'lib/dyntool.rb', line 72

def GetContacts
	@contacts = @conf['contacts']
end

#GetCountries(region) ⇒ Object



51
52
53
# File 'lib/dyntool.rb', line 51

def GetCountries(region)
	@countries = @conf['regions'][region]
end

#GetDcProviders(dc) ⇒ Object



39
40
41
# File 'lib/dyntool.rb', line 39

def GetDcProviders(dc)
	@dcproviders = @conf['sites'][dc]
end

#GetDcsObject



24
25
26
# File 'lib/dyntool.rb', line 24

def GetDcs
	@dcs = @conf['sites']['names']
end

#GetDcsEnabled(region, service) ⇒ Object



54
55
56
# File 'lib/dyntool.rb', line 54

def GetDcsEnabled(region,service)
	@dcs = @conf[service][region]
end

#GetGeosObject



33
34
35
# File 'lib/dyntool.rb', line 33

def GetGeos
        @geos = @conf['geos']
end

#GetGraphiteObject



75
76
77
# File 'lib/dyntool.rb', line 75

def GetGraphite
	@graphite_server = @conf['graphite_server']
end

#GetHandlerObject



21
22
23
# File 'lib/dyntool.rb', line 21

def GetHandler
	@conf = YAML.load_file(@confFile)
end

#GetIpLabel(ip) ⇒ Object



63
64
65
# File 'lib/dyntool.rb', line 63

def GetIpLabel(ip)
	@iplabel = @conf['ips'][ip]['label']
end

#GetIPs(provider) ⇒ Object



30
31
32
# File 'lib/dyntool.rb', line 30

def GetIPs(provider)
	@ips = @conf['providers'][provider]
end

#GetIpTTL(region) ⇒ Object



69
70
71
# File 'lib/dyntool.rb', line 69

def GetIpTTL(region)
	@ttl = @conf['ttls'][region]
end

#GetIpWeight(ip, region) ⇒ Object



66
67
68
# File 'lib/dyntool.rb', line 66

def GetIpWeight(ip,region)
	@weight = @conf['ips'][ip]['weight'][region]
end

#GetNotifyAppsObject



78
79
80
# File 'lib/dyntool.rb', line 78

def GetNotifyApps
	@apps = @conf['notify_apps']
end

#GetProvidersObject



36
37
38
# File 'lib/dyntool.rb', line 36

def GetProviders
	@providers = @conf['providers']['names']
end

#GetProvierIP(provider) ⇒ Object



48
49
50
# File 'lib/dyntool.rb', line 48

def GetProvierIP(provider)
	@providerip = @conf['providers'][provider]
end

#GetRegionsObject



27
28
29
# File 'lib/dyntool.rb', line 27

def GetRegions
	@regions = @conf['regions']['names']
end

#SetConfFileObject



13
14
15
16
# File 'lib/dyntool.rb', line 13

def SetConfFile
	@pwd = Dir.pwd
	@confFile = "#{@pwd}/dyn.yml"
end

#SetDcProviders(dc, providers) ⇒ Object



42
43
44
45
46
47
# File 'lib/dyntool.rb', line 42

def SetDcProviders(dc,providers)
	@conf['sites'][dc] = providers
	File.open("#{@confFile}",'w') do |out|
                       YAML.dump(@conf,out)
               end		
end

#SetDcsEnabled(region, service, dcs) ⇒ Object



57
58
59
60
61
62
# File 'lib/dyntool.rb', line 57

def SetDcsEnabled(region,service,dcs)
	@conf[service][region] = dcs
	File.open("#{@confFile}",'w') do |out|
                       YAML.dump(@conf,out)
               end		
end

#SetTmpFileObject



17
18
19
20
# File 'lib/dyntool.rb', line 17

def SetTmpFile
	@pwd = Dir.pwd
	@confFile = "#{@pwd}/status.yml"
end