Module: ForemanOrchestration::OpenstackExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/foreman_orchestration/openstack_extensions.rb
Instance Method Summary collapse
- #create_orchestration_client(tenant) ⇒ Object
- #default_tenant ⇒ Object
- #default_tenant_id ⇒ Object
- #default_tenant_id=(tenant_id) ⇒ Object
- #is_default ⇒ Object
- #mark_as_default ⇒ Object
- #orchestration_client_for(tenant_id) ⇒ Object
- #orchestration_clients ⇒ Object
Instance Method Details
#create_orchestration_client(tenant) ⇒ Object
16 17 18 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 16 def create_orchestration_client(tenant) ForemanOrchestration::OrchestrationClient.new(tenant, fog_credentials) end |
#default_tenant ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 43 def default_tenant if default_tenant_id orchestration_client_for(default_tenant_id) else orchestration_clients.first end end |
#default_tenant_id ⇒ Object
35 36 37 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 35 def default_tenant_id attrs[:default_tenant_id] end |
#default_tenant_id=(tenant_id) ⇒ Object
39 40 41 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 39 def default_tenant_id=(tenant_id) attrs[:default_tenant_id] = tenant_id end |
#is_default ⇒ Object
20 21 22 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 20 def is_default attrs[:is_default] end |
#mark_as_default ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 24 def mark_as_default ActiveRecord::Base.transaction do self.class.all.each do |record| record.attrs[:is_default] = false record.save! end attrs[:is_default] = true save! end end |
#orchestration_client_for(tenant_id) ⇒ Object
12 13 14 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 12 def orchestration_client_for(tenant_id) orchestration_clients.find { |client| client.id == tenant_id } end |
#orchestration_clients ⇒ Object
5 6 7 8 9 10 |
# File 'app/models/concerns/foreman_orchestration/openstack_extensions.rb', line 5 def orchestration_clients # TODO: select only enabled: true tenants? @orchestration_clients ||= tenants.map do |t| create_orchestration_client(t) end end |