88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/opennebula/ldap_auth.rb', line 88
def generate_mapping
file=@options[:mapping_file_path]
generate = false
if File.exist?(file)
stat = File.stat(file)
age = Time.now.to_i - stat.mtime.to_i
generate = true if age > @options[:mapping_timeout]
else
generate = true
end
return if !generate
client = OpenNebula::Client.new
group_pool = OpenNebula::GroupPool.new(client)
group_pool.info
groups = group_pool.to_hash['']
groups=[group_pool.get_hash['GROUP_POOL']['GROUP']].flatten
yaml={}
groups.each do |group|
if group['TEMPLATE'] && group['TEMPLATE'][@options[:mapping_key]]
yaml[group['TEMPLATE'][@options[:mapping_key]]] = group['ID']
end
end
File.open(file, 'w') do |f|
f.write(yaml.to_yaml)
end
end
|