Project

General

Profile

« Previous | Next » 

Revision 3f482b82

Added by Ohad Levy over 11 years ago

  • ID 3f482b824d6bd6aeccca1ff32f2a3f9357f4f3ab

fixes #1957 - remove old libvirt hypervisors code

Since foreman 1.0 libvirt hypervisors are now part of compute resources
this patch removes the old code and migrate any existing hypervisors to
be libvirt based compute resources.

View differences:

app/models/hostgroup.rb
has_ancestry :orphan_strategy => :rootify
include Authorization
include HostCommon
include Vm
has_many :hostgroup_classes, :dependent => :destroy
has_many :puppetclasses, :through => :hostgroup_classes
has_and_belongs_to_many :users, :join_table => "user_hostgroups"
......
before_destroy EnsureNotUsedBy.new(:hosts)
has_many :config_templates, :through => :template_combinations
has_many :template_combinations
before_save :serialize_vm_attributes
before_save :remove_duplicated_nested_class
after_find :deserialize_vm_attributes
alias_attribute :os, :operatingsystem
alias_attribute :label, :to_label
......
end
def as_json(options={})
super({:only => [:name, :subnet_id, :operatingsystem_id, :domain_id, :environment_id, :id, :ancestry], :methods => [:label, :parameters, :puppetclass_ids].concat(Vm::PROPERTIES)})
super({:only => [:name, :subnet_id, :operatingsystem_id, :domain_id, :environment_id, :id, :ancestry], :methods => [:label, :parameters, :puppetclass_ids]})
end
def hostgroup
......
parameters
end
def vm_defaults
YAML.load(read_attribute(:vm_defaults))
rescue
{}
end
def vm_defaults=(v={})
raise "defaults must be a hash" unless v.is_a?(Hash)
v.delete_if{|attr, value| not Vm::PROPERTIES.include?(attr.to_sym)}
write_attribute :vm_defaults, v.to_yaml
end
# no need to store anything in the db if the password is our default
def root_pass
read_attribute(:root_pass) || nested_root_pw
......
nil
end
def serialize_vm_attributes
hash = {}
Vm::PROPERTIES.each do |attr|
value = self.send(attr)
hash[attr.to_s] = value if value
end
self.vm_defaults = hash
end
def deserialize_vm_attributes
hash = vm_defaults
Vm::PROPERTIES.each do |attr|
eval("@#{attr} = hash[attr.to_s]") if hash.has_key?(attr.to_s)
end
end
def remove_duplicated_nested_class
self.puppetclasses -= ancestors.map(&:puppetclasses).flatten
end

Also available in: Unified diff