Class: Staypuft::Deployment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Staypuft::Deployment
show all
- Extended by:
- AttributeParamStorage
- Defined in:
- app/models/staypuft/deployment.rb
Defined Under Namespace
Modules: AmqpProvider, AttributeParamStorage, LayoutName, Networking, Platform, VlanRangeValuesValidator
Classes: AbstractParamScope, CephService, CinderService, GlanceService, Jail, NeutronService, NovaService, Passwords
Constant Summary
collapse
- STEP_INACTIVE =
:inactive
- STEP_SETTINGS =
:settings
- STEP_CONFIGURATION =
:configuration
- STEP_COMPLETE =
:complete
- STEP_OVERVIEW =
:overview
- STEP_NETWORKING =
:networking
- NEW_NAME_PREFIX =
'uninitialized_'
- EXPORT_PARAMS =
[:amqp_provider, :networking, :layout_name, :platform]
- EXPORT_SERVICES =
[:nova, :neutron, :glance, :cinder, :passwords, :ceph]
- SCOPES =
[[:nova, :@nova_service, NovaService],
[:neutron, :@neutron_service, NeutronService],
[:glance, :@glance_service, GlanceService],
[:cinder, :@cinder_service, CinderService],
[:passwords, :@passwords, Passwords],
[:ceph, :@ceph, CephService]]
Class Method Summary
collapse
Instance Method Summary
collapse
param_attr, param_attr_array, param_scope
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Deployment
Returns a new instance of Deployment.
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'app/models/staypuft/deployment.rb', line 80
def initialize(attributes = {}, options = {})
super({ amqp_provider: AmqpProvider::RABBITMQ,
layout_name: LayoutName::NON_HA,
networking: Networking::NEUTRON,
platform: Platform::RHEL7 }.merge(attributes),
options)
self.hostgroup = Hostgroup.new(name: name, parent: Hostgroup.get_base_hostgroup)
self.nova.set_defaults
self.neutron.set_defaults
self.glance.set_defaults
self.cinder.set_defaults
self.passwords.set_defaults
self.ceph.set_defaults
self.layout = Layout.where(:name => self.layout_name,
:networking => self.networking).first
end
|
Class Method Details
.available_locks ⇒ Object
213
214
215
|
# File 'app/models/staypuft/deployment.rb', line 213
def self.available_locks
[:deploy]
end
|
.find_by_foreman_task(foreman_task) ⇒ Object
Helper method for looking up a Deployment based on a foreman task
102
103
104
105
106
107
108
109
110
111
112
|
# File 'app/models/staypuft/deployment.rb', line 102
def self.find_by_foreman_task(foreman_task)
task = ForemanTasks::Lock.where(task_id: foreman_task.id,
name: :deploy,
resource_type: 'Staypuft::Deployment').first
unless task.nil?
Deployment.find(task.resource_id)
else
nil
end
end
|
.param_scope ⇒ Object
155
156
157
|
# File 'app/models/staypuft/deployment.rb', line 155
def self.param_scope
'deployment'
end
|
Instance Method Details
#ceph_hostgroup ⇒ Object
276
277
278
279
280
281
|
# File 'app/models/staypuft/deployment.rb', line 276
def ceph_hostgroup
Hostgroup.includes(:deployment_role_hostgroup).
where(DeploymentRoleHostgroup.table_name => { deployment_id: self,
role_id: Staypuft::Role.cephosd }).
first
end
|
#controller_hostgroup ⇒ Object
265
266
267
268
269
270
|
# File 'app/models/staypuft/deployment.rb', line 265
def controller_hostgroup
Hostgroup.includes(:deployment_role_hostgroup).
where(DeploymentRoleHostgroup.table_name => { deployment_id: self,
role_id: Staypuft::Role.controller }).
first
end
|
#deployed? ⇒ Boolean
225
226
227
|
# File 'app/models/staypuft/deployment.rb', line 225
def deployed?
self.hosts.any?(&:open_stack_deployed?)
end
|
#deployed_hosts(hostgroup, errors = false) ⇒ Object
Returns all deployed hosts with no errors (default behaviour). Set errors=true to return all deployed hosts that have errors
136
137
138
|
# File 'app/models/staypuft/deployment.rb', line 136
def deployed_hosts(hostgroup, errors=false)
in_progress? ? {} : hostgroup.openstack_hosts(errors)
end
|
237
238
239
|
# File 'app/models/staypuft/deployment.rb', line 237
def form_complete?
self.form_step.to_sym == Deployment::STEP_COMPLETE
end
|
229
230
231
|
# File 'app/models/staypuft/deployment.rb', line 229
def form_step_is_configuration?
self.form_step.to_sym == Deployment::STEP_CONFIGURATION
end
|
233
234
235
|
# File 'app/models/staypuft/deployment.rb', line 233
def form_step_is_past_configuration?
self.form_step_is_configuration? || self.form_complete?
end
|
#ha? ⇒ Boolean
241
242
243
|
# File 'app/models/staypuft/deployment.rb', line 241
def ha?
self.layout_name == LayoutName::HA
end
|
#hide_ceph_notification? ⇒ Boolean
124
125
126
|
# File 'app/models/staypuft/deployment.rb', line 124
def hide_ceph_notification?
ceph_hostgroup.hosts.empty?
end
|
#horizon_url ⇒ Object
257
258
259
260
261
262
263
|
# File 'app/models/staypuft/deployment.rb', line 257
def horizon_url
if ha?
"http://#{network_query.get_vip(:horizon_public_vip)}"
else
network_query.controller_ips(Staypuft::SubnetType::PUBLIC_API).empty? ? nil : "http://#{network_query.controller_ip(Staypuft::SubnetType::PUBLIC_API)}"
end
end
|
#in_progress? ⇒ Boolean
Helper method for checking whether this deployment is in progress or not.
120
121
122
|
# File 'app/models/staypuft/deployment.rb', line 120
def in_progress?
ForemanTasks::Lock.locked? self, nil
end
|
#in_progress_hosts(hostgroup) ⇒ Object
Returns a list of hosts that are currently being deployed.
115
116
117
|
# File 'app/models/staypuft/deployment.rb', line 115
def in_progress_hosts(hostgroup)
return in_progress? ? hostgroup.openstack_hosts : {}
end
|
#network_query ⇒ Object
283
284
285
|
# File 'app/models/staypuft/deployment.rb', line 283
def network_query
@network_query || NetworkQuery.new(self)
end
|
#neutron_networking? ⇒ Boolean
253
254
255
|
# File 'app/models/staypuft/deployment.rb', line 253
def neutron_networking?
networking == Networking::NEUTRON
end
|
#non_ha? ⇒ Boolean
245
246
247
|
# File 'app/models/staypuft/deployment.rb', line 245
def non_ha?
self.layout_name == LayoutName::NON_HA
end
|
#nova_networking? ⇒ Boolean
249
250
251
|
# File 'app/models/staypuft/deployment.rb', line 249
def nova_networking?
networking == Networking::NOVA
end
|
#progress ⇒ Object
Helper method for getting the progress of this deployment
145
146
147
148
149
150
151
152
153
|
# File 'app/models/staypuft/deployment.rb', line 145
def progress
if self.in_progress?
(self.task.progress * 100).round(1)
elsif self.deployed?
100
else
0
end
end
|
#progress_summary ⇒ Object
140
141
142
|
# File 'app/models/staypuft/deployment.rb', line 140
def progress_summary
self.in_progress? ? self.task.humanized[:output] : nil
end
|
#services_hostgroup_map ⇒ Object
217
218
219
220
221
222
223
|
# File 'app/models/staypuft/deployment.rb', line 217
def services_hostgroup_map
deployment_role_hostgroups.map do |deployment_role_hostgroup|
deployment_role_hostgroup.services.reduce({}) do |h, s|
h.update s => deployment_role_hostgroup.hostgroup
end
end.reduce(&:merge)
end
|
#task ⇒ Object
Helper method for getting the in progress foreman task for this deployment.
130
131
132
|
# File 'app/models/staypuft/deployment.rb', line 130
def task
in_progress? ? ForemanTasks::Lock.colliding_locks(self, nil).first.task : nil
end
|
#unassigned_subnet_types ⇒ Object
272
273
274
|
# File 'app/models/staypuft/deployment.rb', line 272
def unassigned_subnet_types
self.layout.subnet_types - self.subnet_types
end
|