Class: Orchestrator::ControlSystem
- Inherits:
-
Couchbase::Model
- Object
- Couchbase::Model
- Orchestrator::ControlSystem
- Includes:
- CouchbaseId::Generator
- Defined in:
- app/models/orchestrator/control_system.rb
Class Method Summary collapse
Instance Method Summary collapse
- #expire_cache(noUpdate = nil) ⇒ Object
-
#module_data ⇒ Object
Methods for obtaining the modules and zones as objects.
- #name=(new_name) ⇒ Object
- #zone_data ⇒ Object
Class Method Details
.find_by_name(name) ⇒ Object
33 34 35 36 |
# File 'app/models/orchestrator/control_system.rb', line 33 def self.find_by_name(name) id = ControlSystem.bucket.get("sysname-#{self.name.downcase}", {quiet: true}) ControlSystem.find_by_id(id) if id end |
.in_zone(zone_id) ⇒ Object
66 67 68 |
# File 'app/models/orchestrator/control_system.rb', line 66 def self.in_zone(zone_id) by_zones({key: zone_id, stale: false}) end |
.using_module(mod_id) ⇒ Object
61 62 63 |
# File 'app/models/orchestrator/control_system.rb', line 61 def self.using_module(mod_id) by_modules({key: mod_id, stale: false}) end |
Instance Method Details
#expire_cache(noUpdate = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/orchestrator/control_system.rb', line 44 def expire_cache(noUpdate = nil) ::Orchestrator::System.expire(self.id || @old_id) ctrl = ::Orchestrator::Control.instance # If not deleted and control is running # then we want to trigger updates on the logic modules if !@old_id && noUpdate.nil? && ctrl.ready (::Orchestrator::Module.find_by_id(self.modules) || []).each do |mod| if mod.control_system_id manager = ctrl.loaded? mod.id manager.reloaded(mod) if manager end end end end |
#module_data ⇒ Object
Methods for obtaining the modules and zones as objects
73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/models/orchestrator/control_system.rb', line 73 def module_data (::Orchestrator::Module.find_by_id(modules) || []).collect do |mod| mod.as_json({ include: { dependency: { only: [:name, :module_name] } } }) end end |
#name=(new_name) ⇒ Object
39 40 41 42 |
# File 'app/models/orchestrator/control_system.rb', line 39 def name=(new_name) new_name.strip! write_attribute(:name, new_name) end |
#zone_data ⇒ Object
85 86 87 |
# File 'app/models/orchestrator/control_system.rb', line 85 def zone_data ::Orchestrator::Zone.find_by_id(zones) || [] end |