Class: ForemanDiscovery::HostConverter
- Inherits:
-
Object
- Object
- ForemanDiscovery::HostConverter
- Defined in:
- app/services/host_converter.rb
Class Method Summary collapse
-
.to_managed(original_host, set_managed = true, set_build = true) ⇒ Object
must be called from SQL transaction.
Class Method Details
.to_managed(original_host, set_managed = true, set_build = true) ⇒ Object
must be called from SQL transaction
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/host_converter.rb', line 4 def self.to_managed(original_host, set_managed = true, set_build = true) if ActiveRecord::Base.connection.open_transactions <= 0 raise "This method must be executed with explicit transaction" end host = original_host.becomes(::Host::Managed) host.type = 'Host::Managed' # the following flags can be skipped when parameters are set to false if set_managed host.managed = set_managed host.primary_interface.managed = set_managed end host.build = set_build if set_build # this gets rolled back when anything in the transaction fails delete_discovery_attribute_set(host.id) host end |