Class: ForemanOrchestration::Stack
- Inherits:
-
Object
- Object
- ForemanOrchestration::Stack
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- app/models/foreman_orchestration/stack.rb
Instance Attribute Summary collapse
-
#compute_resource_id ⇒ Object
Returns the value of attribute compute_resource_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#template_id ⇒ Object
Returns the value of attribute template_id.
-
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
Instance Method Summary collapse
- #compute_resource ⇒ Object
- #destroy ⇒ Object
-
#initialize(params = {}) ⇒ Stack
constructor
A new instance of Stack.
- #persisted? ⇒ Boolean
- #save ⇒ Object
- #template ⇒ Object
- #template_body ⇒ Object
- #tenant ⇒ Object
- #tenants ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Stack
14 15 16 17 18 19 20 21 |
# File 'app/models/foreman_orchestration/stack.rb', line 14 def initialize(params = {}) @id = params[:id] @name = params[:name] @template_id = params[:template_id] @parameters = params[:parameters] || {} compute_resource_params(params) tenant_params(params) end |
Instance Attribute Details
#compute_resource_id ⇒ Object
Returns the value of attribute compute_resource_id.
6 7 8 |
# File 'app/models/foreman_orchestration/stack.rb', line 6 def compute_resource_id @compute_resource_id end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'app/models/foreman_orchestration/stack.rb', line 6 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'app/models/foreman_orchestration/stack.rb', line 6 def name @name end |
#parameters ⇒ Object
Returns the value of attribute parameters.
7 8 9 |
# File 'app/models/foreman_orchestration/stack.rb', line 7 def parameters @parameters end |
#template_id ⇒ Object
Returns the value of attribute template_id.
6 7 8 |
# File 'app/models/foreman_orchestration/stack.rb', line 6 def template_id @template_id end |
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
6 7 8 |
# File 'app/models/foreman_orchestration/stack.rb', line 6 def tenant_id @tenant_id end |
Instance Method Details
#compute_resource ⇒ Object
57 58 59 60 61 |
# File 'app/models/foreman_orchestration/stack.rb', line 57 def compute_resource if compute_resource_id @compute_resource ||= Foreman::Model::Openstack.find(compute_resource_id) end end |
#destroy ⇒ Object
35 36 37 |
# File 'app/models/foreman_orchestration/stack.rb', line 35 def destroy tenant.delete_stack(self) end |
#persisted? ⇒ Boolean
23 24 25 |
# File 'app/models/foreman_orchestration/stack.rb', line 23 def persisted? false end |
#save ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/models/foreman_orchestration/stack.rb', line 27 def save if valid? tenant.create_stack(self) else false end end |
#template ⇒ Object
39 40 41 42 43 |
# File 'app/models/foreman_orchestration/stack.rb', line 39 def template if template_id @template ||= StackTemplate.find(template_id) end end |
#template_body ⇒ Object
45 46 47 48 49 |
# File 'app/models/foreman_orchestration/stack.rb', line 45 def template_body if template YAML.load(template.template) end end |
#tenant ⇒ Object
51 52 53 54 55 |
# File 'app/models/foreman_orchestration/stack.rb', line 51 def tenant if tenant_id && compute_resource @tenant ||= compute_resource.orchestration_client_for(tenant_id) end end |
#tenants ⇒ Object
63 64 65 66 67 68 |
# File 'app/models/foreman_orchestration/stack.rb', line 63 def tenants # TODO: find a better place for this method if compute_resource @tenants ||= compute_resource.orchestration_clients end end |