staypuft 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/staypuft/deployment_steps_controller.rb +1 -0
- data/app/controllers/staypuft/deployments_controller.rb +2 -3
- data/app/lib/actions/staypuft/deployment/deploy.rb +3 -0
- data/app/lib/actions/staypuft/host/build.rb +1 -1
- data/app/lib/actions/staypuft/host/deploy.rb +14 -6
- data/app/lib/actions/staypuft/hostgroup/deploy.rb +1 -0
- data/app/models/staypuft/concerns/host_open_stack_affiliation.rb +18 -0
- data/app/models/staypuft/concerns/host_orchestration_build_hook.rb +1 -0
- data/app/models/staypuft/concerns/hostgroup_extensions.rb +34 -28
- data/app/models/staypuft/deployment.rb +20 -0
- data/app/views/staypuft/deployments/show.html.erb +50 -6
- data/db/seeds.rb +2 -1
- data/lib/staypuft/engine.rb +2 -0
- data/lib/staypuft/version.rb +1 -1
- metadata +7 -6
@@ -29,6 +29,7 @@ module Staypuft
|
|
29
29
|
Deployment.transaction do
|
30
30
|
@deployment.update_attributes(params[:staypuft_deployment])
|
31
31
|
@deployment.update_hostgroup_list
|
32
|
+
@deployment.set_networking_params
|
32
33
|
end
|
33
34
|
when :services_configuration
|
34
35
|
# Collect services across all deployment's roles
|
@@ -13,8 +13,7 @@ module Staypuft
|
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
16
|
-
base_hostgroup = Hostgroup.
|
17
|
-
raise 'missing base_hostgroup'
|
16
|
+
base_hostgroup = Hostgroup.get_base_hostgroup
|
18
17
|
|
19
18
|
deployment = Deployment.new(:name => Deployment::NEW_NAME_PREFIX+SecureRandom.hex)
|
20
19
|
deployment.layout = Layout.where(:name => "Distributed",
|
@@ -34,7 +33,7 @@ module Staypuft
|
|
34
33
|
|
35
34
|
def summary
|
36
35
|
@deployment = Deployment.find(params[:id])
|
37
|
-
@services
|
36
|
+
@services = @deployment.services
|
38
37
|
end
|
39
38
|
|
40
39
|
def destroy
|
@@ -15,6 +15,7 @@ module Actions
|
|
15
15
|
module Deployment
|
16
16
|
class Deploy < Actions::Base
|
17
17
|
|
18
|
+
include Actions::Helpers::Lock
|
18
19
|
middleware.use Actions::Staypuft::Middleware::AsCurrentUser
|
19
20
|
|
20
21
|
def plan(deployment)
|
@@ -25,6 +26,8 @@ module Actions
|
|
25
26
|
input.update id: deployment.id, name: deployment.name
|
26
27
|
|
27
28
|
plan_action Hostgroup::OrderedDeploy, ordered_hostgroups
|
29
|
+
|
30
|
+
lock! deployment
|
28
31
|
end
|
29
32
|
|
30
33
|
def humanized_input
|
@@ -20,18 +20,26 @@ module Actions
|
|
20
20
|
|
21
21
|
input.update host: { id: host.id, name: host.name }
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
unless host.open_stack_deployed?
|
24
|
+
sequence do
|
25
|
+
plan_action Host::Build, host.id
|
26
|
+
plan_action Host::WaitUntilInstalled, host.id
|
27
|
+
plan_action Host::WaitUntilHostReady, host.id
|
28
|
+
end
|
29
|
+
else
|
30
|
+
# it is already deployed
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
30
34
|
def humanized_output
|
31
35
|
# TODO: fix dynflow to allow better progress getting
|
32
36
|
steps = planned_actions.inject([]) { |s, a| s + a.steps[1..2] }.compact
|
33
|
-
progress =
|
34
|
-
|
37
|
+
progress = if steps.empty?
|
38
|
+
'done'
|
39
|
+
else
|
40
|
+
format '%3d%%', steps.map(&:progress_done).reduce(&:+) / steps.size * 100
|
41
|
+
end
|
42
|
+
format '%s Host: %s', progress, input[:host][:name]
|
35
43
|
end
|
36
44
|
|
37
45
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Staypuft
|
2
|
+
module Concerns
|
3
|
+
module HostOpenStackAffiliation
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def open_stack_deployed?
|
7
|
+
open_stack_assigned? &&
|
8
|
+
respond_to?(:environment) &&
|
9
|
+
environment != Environment.get_discovery
|
10
|
+
end
|
11
|
+
|
12
|
+
def open_stack_assigned?
|
13
|
+
respond_to?(:hostgroup) &&
|
14
|
+
hostgroup.try(:parent).try(:parent) == Hostgroup.get_base_hostgroup
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -7,44 +7,50 @@ module Staypuft::Concerns::HostgroupExtensions
|
|
7
7
|
has_one :role, :through => :deployment_role_hostgroup, :class_name => 'Staypuft::Role'
|
8
8
|
|
9
9
|
has_one :deployment, :class_name => 'Staypuft::Deployment'
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
12
|
+
def add_puppetclasses_from_resource(resource)
|
13
|
+
if resource.respond_to?(:puppetclasses)
|
14
|
+
resource.puppetclasses.each do |puppetclass|
|
15
|
+
unless puppetclasses.include?(puppetclass)
|
16
|
+
puppetclasses << puppetclass
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
return inherited_lookup_value(key)
|
22
|
+
def current_param_value(key)
|
23
|
+
if (v = LookupValue.where(:lookup_key_id => key.id, :id => lookup_values).first)
|
24
|
+
return v.value, to_label
|
26
25
|
end
|
26
|
+
return inherited_lookup_value(key)
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def current_param_value_str(key)
|
30
|
+
val = current_param_value(key)[0]
|
31
|
+
val.is_a?(Array) ? val.join(", ") : val
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
34
|
+
def set_param_value_if_changed(puppetclass, key, value)
|
35
|
+
lookup_key = puppetclass.class_params.where(:key => key).first
|
36
|
+
current_value = current_param_value(lookup_key)[0]
|
37
|
+
new_value = current_value.is_a?(Array) ? value.split(", ") : value
|
38
|
+
unless current_value == new_value
|
39
|
+
lookup = LookupValue.where(:match => hostgroup.send(:lookup_value_match),
|
40
|
+
:lookup_key_id => lookup_key.id).first_or_initialize
|
41
|
+
lookup.value = new_value
|
42
|
+
lookup.save!
|
43
43
|
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def own_and_free_hosts
|
47
|
+
# TODO update to Discovered only?
|
48
|
+
Host::Base.where('hostgroup_id = ? OR hostgroup_id IS NULL', id)
|
49
|
+
end
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
module ClassMethods
|
52
|
+
def get_base_hostgroup
|
53
|
+
Hostgroup.where(:name => Setting[:base_hostgroup]).first or raise 'missing base_hostgroup'
|
48
54
|
end
|
49
55
|
end
|
50
56
|
|
@@ -23,6 +23,10 @@ module Staypuft
|
|
23
23
|
|
24
24
|
scoped_search :on => :name, :complete_value => :true
|
25
25
|
|
26
|
+
def self.available_locks
|
27
|
+
[:deploy]
|
28
|
+
end
|
29
|
+
|
26
30
|
def destroy
|
27
31
|
child_hostgroups.each do |h|
|
28
32
|
h.destroy
|
@@ -42,6 +46,9 @@ module Staypuft
|
|
42
46
|
end
|
43
47
|
|
44
48
|
role_hostgroup.hostgroup.add_puppetclasses_from_resource(layout_role.role)
|
49
|
+
layout_role.role.services.each do |service|
|
50
|
+
role_hostgroup.hostgroup.add_puppetclasses_from_resource(service)
|
51
|
+
end
|
45
52
|
role_hostgroup.hostgroup.save!
|
46
53
|
|
47
54
|
role_hostgroup.deploy_order = layout_role.deploy_order
|
@@ -55,6 +62,19 @@ module Staypuft
|
|
55
62
|
end
|
56
63
|
end
|
57
64
|
|
65
|
+
# If layout networking is set to 'neutron', then set include_neutron on the
|
66
|
+
# hostgroup if it includes the "quickstack::pacemaker::params" puppetclass
|
67
|
+
def set_networking_params
|
68
|
+
child_hostgroups.each do |the_hostgroup|
|
69
|
+
the_hostgroup.puppetclasses.each do |pclass|
|
70
|
+
if pclass.class_params.where(:key=> "include_neutron").first
|
71
|
+
the_hostgroup.set_param_value_if_changed(pclass, "include_neutron",
|
72
|
+
(layout.networking == 'neutron') ? true : false)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
58
78
|
private
|
59
79
|
def update_hostgroup_name
|
60
80
|
hostgroup.name = self.name
|
@@ -24,8 +24,18 @@
|
|
24
24
|
</div>
|
25
25
|
<% end %>
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
<% if ForemanTasks::Lock.locked? @deployment, nil %>
|
28
|
+
<%= display_link_if_authorized(
|
29
|
+
_('Deploy in progress'),
|
30
|
+
hash_for_foreman_tasks_task_path(id: ForemanTasks::Lock.colliding_locks(@deployment, nil).first.task.id),
|
31
|
+
:class => 'btn-info') %>
|
32
|
+
<% else %>
|
33
|
+
<%= link_to(_("Deploy"),
|
34
|
+
"",
|
35
|
+
:class => %w(btn btn-success),
|
36
|
+
:'data-toggle' => "modal",
|
37
|
+
:'data-target' => "#deploy_modal") %>
|
38
|
+
<% end %>
|
29
39
|
<%= help_path %>
|
30
40
|
<% end %>
|
31
41
|
|
@@ -35,9 +45,18 @@
|
|
35
45
|
<% @deployment.child_hostgroups.each_with_index do |child_hostgroup, i| %>
|
36
46
|
<li class="<%= 'active' if i == 0 %>">
|
37
47
|
<a href="#<%= child_hostgroup.name.parameterize.underscore %>" data-toggle="tab" class="roles_list">
|
38
|
-
<div class="col-xs-2 text-center"
|
39
|
-
|
40
|
-
|
48
|
+
<div class="col-xs-2 text-center">
|
49
|
+
<span class="glyphicon glyphicon-ok"></span>
|
50
|
+
<span><%= child_hostgroup.hosts.select { |h| h.open_stack_deployed? && !h.error? }.count %></span>
|
51
|
+
</div>
|
52
|
+
<div class="col-xs-2 text-center">
|
53
|
+
<span class="glyphicon glyphicon-warning-sign"></span>
|
54
|
+
<span><%= child_hostgroup.hosts.select { |h| h.open_stack_deployed? && h.error? }.count %></span>
|
55
|
+
</div>
|
56
|
+
<div class="col-xs-2 text-center">
|
57
|
+
<span class="glyphicon glyphicon-time"></span>
|
58
|
+
<span><%= child_hostgroup.hosts.select { |h| !h.open_stack_deployed? }.count %></span>
|
59
|
+
</div>
|
41
60
|
<div class="col-xs-6"><%= child_hostgroup.name %></div>
|
42
61
|
<span class="clearfix"></span>
|
43
62
|
</a>
|
@@ -70,7 +89,12 @@
|
|
70
89
|
<% child_hostgroup.own_and_free_hosts.each do |host| %>
|
71
90
|
<tr class="checkbox_highlight <%= "success" if child_hostgroup.host_ids.include?(host.id) %>">
|
72
91
|
<td class="ca">
|
73
|
-
<%= check_box_tag
|
92
|
+
<%= check_box_tag 'host_ids[]',
|
93
|
+
host.id,
|
94
|
+
child_hostgroup.host_ids.include?(host.id),
|
95
|
+
:id => "host_ids_#{host.id}",
|
96
|
+
:disabled => host.open_stack_deployed? %>
|
97
|
+
<%= hidden_field_tag 'host_ids[]', host.id if host.open_stack_deployed? %>
|
74
98
|
</td>
|
75
99
|
<td class="ellipsis"><%= host.name %></td>
|
76
100
|
<td class="hidden-s hidden-xs"><%= host.mac %></td>
|
@@ -93,3 +117,23 @@
|
|
93
117
|
</div>
|
94
118
|
</div>
|
95
119
|
|
120
|
+
<div class="modal fade" id="deploy_modal" tabindex="-1" role="dialog" aria-labelledby="Deploy" aria-hidden="true">
|
121
|
+
<div class="modal-dialog">
|
122
|
+
<div class="modal-content">
|
123
|
+
<div class="modal-header">
|
124
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
125
|
+
<h2 class="modal-title" id="deploy_modal_label">
|
126
|
+
<span class="glyphicon glyphicon-cloud-upload">
|
127
|
+
</span> <%= _("Deploy") %>
|
128
|
+
</h2>
|
129
|
+
</div>
|
130
|
+
<div class="modal-body">
|
131
|
+
<%= (_("This action will initiate the deployment of %s ") % "<strong>#{@deployment.name}</strong>").html_safe %>
|
132
|
+
</div>
|
133
|
+
<div class="modal-footer">
|
134
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
|
135
|
+
<%= display_link_if_authorized(_("Deploy"), hash_for_deploy_deployment_path, :class => 'btn btn-primary') %>
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
</div>
|
139
|
+
</div>
|
data/db/seeds.rb
CHANGED
@@ -159,6 +159,7 @@ services = {
|
|
159
159
|
"qpid::server"]},
|
160
160
|
:glance_ha => {:name => "Glance (HA)", :class => ["quickstack::pacemaker::glance"]},
|
161
161
|
:nova_ha => {:name => "Nova (HA)", :class => ["quickstack::pacemaker::nova"]},
|
162
|
+
:cinder_ha => {:name => "Cinder (HA)", :class => ["quickstack::pacemaker::cinder"]},
|
162
163
|
:ha_db_temp => {:name => "Database (HA -- temp)", :class => ["quickstack::hamysql::singlenodetest"]}
|
163
164
|
}
|
164
165
|
services.each do |skey, svalue|
|
@@ -224,7 +225,7 @@ roles = [
|
|
224
225
|
{:name=>"HA Controller (Nova)",
|
225
226
|
:class=>[],
|
226
227
|
:layouts=>[[:ha_nova, 3]],
|
227
|
-
:services=>[:ha_controller, :keystone_ha, :load_balancer_ha, :memcached_ha, :qpid_ha, :glance_ha, :nova_ha]},
|
228
|
+
:services=>[:ha_controller, :keystone_ha, :load_balancer_ha, :memcached_ha, :qpid_ha, :glance_ha, :nova_ha, :cinder_ha]},
|
228
229
|
{:name=>"HA Controller (Neutron)",
|
229
230
|
:class=>[],
|
230
231
|
:layouts=>[[:ha_neutron, 2]],
|
data/lib/staypuft/engine.rb
CHANGED
@@ -23,6 +23,8 @@ module Staypuft
|
|
23
23
|
|
24
24
|
config.to_prepare do
|
25
25
|
::Host::Managed.send :include, Staypuft::Concerns::HostOrchestrationBuildHook
|
26
|
+
::Host::Managed.send :include, Staypuft::Concerns::HostOpenStackAffiliation
|
27
|
+
::Host::Discovered.send :include, Staypuft::Concerns::HostOpenStackAffiliation
|
26
28
|
::Puppetclass.send :include, Staypuft::Concerns::PuppetclassExtensions
|
27
29
|
::Hostgroup.send :include, Staypuft::Concerns::HostgroupExtensions
|
28
30
|
::Environment.send :include, Staypuft::Concerns::EnvironmentExtensions
|
data/lib/staypuft/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: staypuft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: foreman-tasks
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.5.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.5.3
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: dynflow
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- app/lib/staypuft/exception.rb
|
105
105
|
- app/models/setting/staypuft_provisioning.rb
|
106
106
|
- app/models/staypuft/concerns/environment_extensions.rb
|
107
|
+
- app/models/staypuft/concerns/host_open_stack_affiliation.rb
|
107
108
|
- app/models/staypuft/concerns/host_orchestration_build_hook.rb
|
108
109
|
- app/models/staypuft/concerns/hostgroup_extensions.rb
|
109
110
|
- app/models/staypuft/concerns/puppetclass_extensions.rb
|