10
11
12
13
14
15
16
17
18
|
# File 'app/models/concerns/foreman_name_generator/host_extensions.rb', line 10
def generate_name
if (self.name.nil? || self.name.empty?) && new_record? && (Setting['name_generator_type'] == 'MAC' || Setting['name_generator_type'] == 'MAC+RANDOM')
generator = ForemanNameGenerator::MacGenerator.new
self.name = generator.generate(self.mac).join('-').downcase
end
if (self.name.nil? || self.name.empty?) && new_record? && (Setting['name_generator_type'] == 'RANDOM' || Setting['name_generator_type'] == 'MAC+RANDOM')
self.generated_random_name = self.name = Setting::NameGenerator.next_generated_name.join('-').downcase
end
end
|