Class: VcenterLibMongodb::Updater
- Inherits:
-
Object
- Object
- VcenterLibMongodb::Updater
- Includes:
- Logging
- Defined in:
- lib/vcenter_lib_mongodb/updater.rb
Overview
update vms data from source to destination
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source, destination) ⇒ Updater
constructor
A new instance of Updater.
-
#update ⇒ Object
update by deleting missing vms and get a complete map of vms with facts and update or insert facts for each one.
Methods included from Logging
Constructor Details
#initialize(source, destination) ⇒ Updater
Returns a new instance of Updater.
11 12 13 14 |
# File 'lib/vcenter_lib_mongodb/updater.rb', line 11 def initialize(source, destination) @source = source @destination = destination end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
9 10 11 |
# File 'lib/vcenter_lib_mongodb/updater.rb', line 9 def destination @destination end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/vcenter_lib_mongodb/updater.rb', line 8 def source @source end |
Instance Method Details
#update ⇒ Object
update by deleting missing vms and get a complete map of vms with facts and update or insert facts for each one
for example: 1633 vms in 60.70 seconds
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vcenter_lib_mongodb/updater.rb', line 20 def update logger.info "update started (full update)" tsb = Time.now complete = source.facts source_vms = complete.keys destination_vms = destination.all_vms delete_missing(destination_vms, source_vms) errors = false complete.each do |vm, facts| begin destination.vm_update(vm, facts) rescue errors = true logger.error $! pp facts end end tse = Time.now logger.info "update updated #{source_vms.size} vms in #{tse - tsb}" if errors logger.error "we don't update metadata information due to update errors" else destination.("update", tsb, tse) end end |