Method: OneacctOpts.check_settings_restrictions

Defined in:
lib/oneacct_opts.rb

.check_settings_restrictionsObject

Make sure configuration is sane



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/oneacct_opts.rb', line 122

def self.check_settings_restrictions
  #make sure all mandatory parameters are set
  unless Settings['site_name'] && Settings['cloud_type'] && Settings['endpoint'] &&
      Settings['output'] && Settings.output['output_dir'] && Settings.output['output_type']
    fail ArgumentError, 'Missing some mandatory parameters. Check your configuration file.'
  end
  Settings['endpoint'].chop! if Settings['endpoint'].end_with?('/')

  #make sure log file is specified while loggin to file
  if Settings['logging'] && Settings.logging['log_type'] == 'file' &&
      !Settings.logging['log_file']
    fail ArgumentError, 'Missing file for logging. Check your configuration file.'
  end

  #make sure specified template really exists
  template_filename = OneWriter.template_filename(Settings.output['output_type'])
  unless File.exist?(template_filename)
    fail ArgumentError, "Non-existing template #{Settings.output['output_type']}."
  end
end