Project

General

Profile

« Previous | Next » 

Revision ff61accf

Added by Ohad Levy almost 12 years ago

  • ID ff61accf873d0920258da126caea1ef72e45924b

fixes #1752 - fixes clone from keeping internal data (such as vm external uuid).

View differences:

app/controllers/hosts_controller.rb
def clone
new = @host.clone
load_vars_for_ajax
new.puppetclasses = @host.puppetclasses
# Clone any parameters as well
@host.host_parameters.each{|param| new.host_parameters << HostParameter.new(:name => param.name, :value => param.value)}
flash[:warning] = "The marked fields will need reviewing"
new.valid?
@host = new
app/models/host.rb
read_attribute(:root_pass) || hostgroup.try(:root_pass) || Setting[:root_pass]
end
def clone
new = super
new.puppetclasses = puppetclasses
# Clone any parameters as well
host_parameters.each{|param| new.host_parameters << HostParameter.new(:name => param.name, :value => param.value, :nested => true)}
# clear up the system specific attributes
[:name, :mac, :ip, :uuid, :certname, :last_report, :sp_mac, :sp_ip, :sp_name, :puppet_status, ].each do |attr|
new.send "#{attr}=", nil
end
new
end
private
# align common mac and ip address input
def normalize_addresses
app/models/orchestration.rb
# we keep the before update host object in order to compare changes
def setup_clone
return if new_record?
@old = clone
@old = dup
for key in (changed_attributes.keys - ["updated_at"])
@old.send "#{key}=", changed_attributes[key]
# At this point the old cached bindings may still be present so we force an AR association reload

Also available in: Unified diff