staypuft 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,12 +7,6 @@ module Staypuft
7
7
  end
8
8
 
9
9
  def new
10
- if Deployment.first
11
- flash[:warning] = _('Deployment already exists.')
12
- redirect_to deployments_url
13
- return
14
- end
15
-
16
10
  base_hostgroup = Hostgroup.get_base_hostgroup
17
11
 
18
12
  deployment = Deployment.new(:name => Deployment::NEW_NAME_PREFIX+SecureRandom.hex)
@@ -24,16 +18,18 @@ module Staypuft
24
18
  deployment.hostgroup = deployment_hostgroup
25
19
  deployment.save!
26
20
 
27
- redirect_to deployment_steps_path
21
+ redirect_to deployment_steps_path(deployment_id: deployment)
28
22
  end
29
23
 
30
24
  def show
31
25
  @deployment = Deployment.find(params[:id])
26
+ @hostgroup = ::Hostgroup.find_by_id(params[:hostgroup_id]) ||
27
+ @deployment.child_hostgroups.deploy_order.first
32
28
  end
33
29
 
34
30
  def summary
35
- @deployment = Deployment.find(params[:id])
36
- @services = @deployment.services
31
+ @deployment = Deployment.find(params[:id])
32
+ @service_hostgroup_map = @deployment.services_hostgroup_map
37
33
  end
38
34
 
39
35
  def destroy
@@ -42,21 +38,23 @@ module Staypuft
42
38
  end
43
39
 
44
40
  def deploy
45
- task = ForemanTasks.async_task ::Actions::Staypuft::Deployment::Deploy, Deployment.first
41
+ deployment = Deployment.find(params[:id])
42
+ task = ForemanTasks.async_task ::Actions::Staypuft::Deployment::Deploy, deployment
46
43
  redirect_to foreman_tasks_task_url(id: task)
47
44
  end
48
45
 
49
46
  # TODO remove, it's temporary
50
47
  def populate
51
48
  task = ForemanTasks.async_task ::Actions::Staypuft::Deployment::Populate,
52
- Deployment.first,
49
+ Deployment.find(params[:id]),
53
50
  fake: !!params[:fake],
54
51
  assign: !!params[:assign]
55
52
  redirect_to foreman_tasks_task_url(id: task)
56
53
  end
57
54
 
58
55
  def associate_host
59
- hostgroup = ::Hostgroup.find params[:hostgroup_id]
56
+ deployment = Deployment.find(params[:id])
57
+ hostgroup = ::Hostgroup.find params[:hostgroup_id]
60
58
 
61
59
  targeted_hosts = ::Host::Base.find Array(params[:host_ids])
62
60
  assigned_hosts = hostgroup.hosts
@@ -82,7 +80,8 @@ module Staypuft
82
80
  host.save!
83
81
  end
84
82
 
85
- redirect_to deployment_path(id: ::Staypuft::Deployment.first)
83
+ redirect_to show_with_hostgroup_selected_deployment_path(
84
+ id: deployment, hostgroup_id: hostgroup)
86
85
  end
87
86
 
88
87
  private
@@ -1,5 +1,5 @@
1
1
  module Staypuft
2
- class DeploymentStepsController < ApplicationController
2
+ class StepsController < ApplicationController
3
3
  include Wicked::Wizard
4
4
  steps :deployment_settings, :services_selection, :services_configuration
5
5
 
@@ -10,7 +10,7 @@ module Staypuft
10
10
  when :deployment_settings
11
11
  @layouts = ordered_layouts
12
12
  when :services_configuration
13
- @services = @deployment.services.order(:name)
13
+ @service_hostgroup_map = @deployment.services_hostgroup_map
14
14
  end
15
15
 
16
16
  render_wizard
@@ -31,7 +31,7 @@ module Staypuft
31
31
  @deployment.form_step = Deployment::STEP_SELECTION unless @deployment.form_complete?
32
32
  when :services_configuration
33
33
  # Collect services across all deployment's roles
34
- @services = @deployment.services.order(:name)
34
+ @service_hostgroup_map = @deployment.services_hostgroup_map
35
35
  if params[:staypuft_deployment]
36
36
  @deployment.form_step = Deployment::STEP_CONFIGURATION unless @deployment.form_complete?
37
37
  param_data = params[:staypuft_deployment][:hostgroup_params]
@@ -52,7 +52,7 @@ module Staypuft
52
52
 
53
53
  private
54
54
  def get_deployment
55
- @deployment = Deployment.first
55
+ @deployment = Deployment.find(params[:deployment_id])
56
56
  @deployment.name = nil if @deployment.name.starts_with?(Deployment::NEW_NAME_PREFIX)
57
57
  end
58
58
 
@@ -32,12 +32,14 @@ module Actions
32
32
  end
33
33
 
34
34
  def humanized_output
35
- # TODO: fix dynflow to allow better progress getting
35
+ # TODO: use Action::Progress.calculate in new dynflow version
36
36
  steps = planned_actions.inject([]) { |s, a| s + a.steps[1..2] }.compact
37
37
  progress = if steps.empty?
38
38
  'done'
39
39
  else
40
- format '%3d%%', steps.map(&:progress_done).reduce(&:+) / steps.size * 100
40
+ total = steps.map { |s| s.progress_done * s.progress_weight }.reduce(&:+)
41
+ weighted_count = steps.map(&:progress_weight).reduce(&:+)
42
+ format '%3d%%', total / weighted_count * 100
41
43
  end
42
44
  format '%s Host: %s', progress, input[:host][:name]
43
45
  end
@@ -31,6 +31,14 @@ module Actions
31
31
  external_task
32
32
  end
33
33
 
34
+ def run_progress_weight
35
+ 4
36
+ end
37
+
38
+ def run_progress
39
+ 0.1
40
+ end
41
+
34
42
  private
35
43
 
36
44
  def invoke_external_task
@@ -73,6 +81,7 @@ module Actions
73
81
  fail(::Staypuft::Exception, "Latest Puppet Run Contains Failures for Host: #{id}")
74
82
  end
75
83
  end
84
+
76
85
  end
77
86
  end
78
87
  end
@@ -38,6 +38,14 @@ module Actions
38
38
  plan_self host_id: host_id
39
39
  end
40
40
 
41
+ def run_progress_weight
42
+ 4
43
+ end
44
+
45
+ def run_progress
46
+ 0.1
47
+ end
48
+
41
49
  end
42
50
  end
43
51
  end
@@ -6,7 +6,7 @@ module Staypuft::Concerns::HostgroupExtensions
6
6
  has_one :parent_deployment, :through => :deployment_role_hostgroup, :class_name => 'Staypuft::Deployment'
7
7
  has_one :role, :through => :deployment_role_hostgroup, :class_name => 'Staypuft::Role'
8
8
 
9
- has_one :deployment, :class_name => 'Staypuft::Deployment'
9
+ has_one :deployment, :class_name => 'Staypuft::Deployment', through: :deployment_role_hostgroup
10
10
 
11
11
  scope :deploy_order,
12
12
  lambda { reorder "#{::Staypuft::DeploymentRoleHostgroup.table_name}.deploy_order" }
@@ -2,12 +2,12 @@ module Staypuft
2
2
  class Deployment < ActiveRecord::Base
3
3
 
4
4
  # Form step states
5
- STEP_INACTIVE = :inactive
6
- STEP_SETTINGS = :settings
5
+ STEP_INACTIVE = :inactive
6
+ STEP_SETTINGS = :settings
7
7
  STEP_CONFIGURATION = :configuration
8
- STEP_COMPLETE = :complete
9
- STEP_SELECTION = :selection
10
-
8
+ STEP_COMPLETE = :complete
9
+ STEP_SELECTION = :selection
10
+
11
11
  NEW_NAME_PREFIX="uninitialized_"
12
12
 
13
13
  attr_accessible :description, :name, :layout_id, :layout
@@ -104,6 +104,14 @@ module Staypuft
104
104
  end
105
105
  end
106
106
 
107
+ def services_hostgroup_map
108
+ deployment_role_hostgroups.map do |deployment_role_hostgroup|
109
+ deployment_role_hostgroup.services.reduce({}) do |h, s|
110
+ h.update s => deployment_role_hostgroup.hostgroup
111
+ end
112
+ end.reduce(&:merge)
113
+ end
114
+
107
115
  def deployed?
108
116
  self.hosts.any?(&:open_stack_deployed?)
109
117
  end
@@ -5,6 +5,7 @@ module Staypuft
5
5
  belongs_to :deployment
6
6
  belongs_to :hostgroup
7
7
  belongs_to :role
8
+ has_many :services, :through => :role
8
9
 
9
10
  validates :deployment, :presence => true
10
11
  validates :role, :presence => true
@@ -11,7 +11,7 @@ module Staypuft
11
11
 
12
12
  validates :name, :presence => true, :uniqueness => true
13
13
 
14
- def ui_params_for_form(hostgroup = self.hostgroups.first)
14
+ def ui_params_for_form(hostgroup)
15
15
  return [] if (hostgroup.nil?)
16
16
  if hostgroup.puppetclasses.blank?
17
17
  params_from_hash = []
@@ -0,0 +1,7 @@
1
+ Deface::Override.new(:virtual_path => "common_parameters/_inherited_parameters",
2
+ :name => "hide_subscription_manager_passwords",
3
+ :surround => 'td.col-md-7 erb[loud]:contains("parameter_value_field inherited_parameters[name]")',
4
+ :original => '<%= parameter_value_field inherited_parameters[name] %>',
5
+ :text => "<% if name == 'subscription_manager_password' %>*****<% else %><%= render_original %><% end %>"
6
+ )
7
+
@@ -1,5 +1,9 @@
1
1
  <% title _("OpenStack Deployments") %>
2
+
3
+ <% title_actions display_link_if_authorized(_("New Deployment"), hash_for_new_deployment_path, :class => 'btn-success'), help_path %>
4
+
2
5
  <% if @deployments.present? %>
6
+
3
7
  <table class="table table-bordered table-striped">
4
8
  <tr>
5
9
  <th><%= sort :name, :as => _('Deployment Name') %></th>
@@ -15,12 +19,13 @@
15
19
  <% end %>
16
20
  </table>
17
21
  <%= page_entries_info @deployments %>
18
- <%= will_paginate @deployments %>
22
+ <%= will_paginate @deployments %>
23
+
19
24
  <% else %>
20
- <% title_actions display_link_if_authorized(_("New Deployment"), hash_for_new_deployment_path, :class => 'btn-success'), help_path %>
21
25
 
22
- <%= alert :header => _('There are no deployments yet.'),
23
- :text => _('Please create at least one Deployment.'),
24
- :close => false,
25
- :class => 'alert-info' %>
26
+ <%= alert :header => _('There are no deployments yet.'),
27
+ :text => _('Please create at least one Deployment.'),
28
+ :close => false,
29
+ :class => 'alert-info' %>
30
+
26
31
  <% end %>
@@ -3,9 +3,9 @@
3
3
  <% content_for(:title_actions) do %>
4
4
 
5
5
  <%= link_to(_("Edit"), if @deployment.deployed?
6
- deployment_step_path(id: 'services_configuration')
6
+ deployment_step_path(deployment_id: @deployment, id: 'services_configuration')
7
7
  else
8
- deployment_steps_path
8
+ deployment_steps_path(deployment_id: @deployment)
9
9
  end) %>
10
10
  <%= link_to(_("Configuration Summary"), summary_deployment_path(@deployment.id), :class => '') %>
11
11
 
@@ -48,7 +48,7 @@
48
48
  <ul class="nav nav-pills nav-stacked col-md-4" data-tabs="pills">
49
49
  <h3><%= _("Host Groups") %></h3>
50
50
  <% @deployment.child_hostgroups.deploy_order.each_with_index do |child_hostgroup, i| %>
51
- <li class="<%= 'active' if i == 0 %>">
51
+ <li class="<%= 'active' if @hostgroup == child_hostgroup %>">
52
52
  <a href="#<%= child_hostgroup.name.parameterize.underscore %>" data-toggle="tab" class="roles_list">
53
53
  <div class="col-xs-2 text-center">
54
54
  <i class="glyphicon glyphicon-ok"></i>
@@ -71,10 +71,10 @@
71
71
 
72
72
  <div class="tab-content col-md-8">
73
73
  <% @deployment.child_hostgroups.deploy_order.each_with_index do |child_hostgroup, i| %>
74
- <div class="tab-pane <%= 'active' if i == 0 %>" id="<%= child_hostgroup.name.parameterize.underscore %>">
74
+ <div class="tab-pane <%= 'active' if @hostgroup == child_hostgroup %>" id="<%= child_hostgroup.name.parameterize.underscore %>">
75
75
  <h3><%= _("Hosts") %></h3>
76
76
  <% if child_hostgroup.own_and_free_hosts.present? %>
77
- <%= form_tag(associate_host_deployments_path, class: 'form-horizontal well association') do |f| %>
77
+ <%= form_tag(associate_host_deployment_path(id: @deployment), class: 'form-horizontal well association') do |f| %>
78
78
  <p>
79
79
  <%= submit_tag _("Assign / Unassign"), :class => "btn btn-primary btn-sm" %>
80
80
  </p>
@@ -2,10 +2,10 @@
2
2
  <% title _("%s Summary") % @deployment.name %>
3
3
 
4
4
  <div class="col-md-12">
5
- <% @services.each_with_index do |service, i| %>
5
+ <% @service_hostgroup_map.each_with_index do |(service, hostgroup), i| %>
6
6
  <div class="well <%= 'active' if i == 0 %>" id="<%= service.name.parameterize.underscore %>">
7
7
  <h3><%= "#{service.name} " + _("Service Configuration") %></h3>
8
- <% if (params_hash = service.ui_params_for_form).size > 0 %>
8
+ <% if (params_hash = service.ui_params_for_form(hostgroup)).size > 0 %>
9
9
  <% params_hash.each do |param_hash| %>
10
10
  <div class="row">
11
11
  <div class="col-md-3 text-right">
@@ -8,7 +8,7 @@
8
8
  <div class="form-group tabbed_side_nav_form row">
9
9
  <ul class="nav nav-pills nav-stacked col-md-3" data-tabs="pills">
10
10
  <h3><%= _("Services") %></h3>
11
- <% @services.each_with_index do |service, i| %>
11
+ <% @service_hostgroup_map.each_with_index do |(service, hostgroup), i| %>
12
12
  <li class="<%= 'active' if i == 0 %>">
13
13
  <a href="#<%= service.name.parameterize.underscore %>" data-toggle="tab">
14
14
  <%= service.name %>
@@ -18,10 +18,10 @@
18
18
  </ul>
19
19
 
20
20
  <div class="tab-content col-md-9">
21
- <% @services.each_with_index do |service, i| %>
21
+ <% @service_hostgroup_map.each_with_index do |(service, hostgroup), i| %>
22
22
  <div class="tab-pane <%= 'active' if i == 0 %>" id="<%= service.name.parameterize.underscore %>">
23
23
  <h3><%= "#{service.name} " + _("Service Configuration") %></h3>
24
- <% if (params_hash = service.ui_params_for_form).size > 0 %>
24
+ <% if (params_hash = service.ui_params_for_form(hostgroup)).size > 0 %>
25
25
  <% params_hash.each do |param_hash| %>
26
26
  <div class="row">
27
27
  <div class="col-md-4 control-label">
data/config/routes.rb CHANGED
@@ -3,15 +3,19 @@ Rails.application.routes.draw do
3
3
  resources :deployments do
4
4
  collection do
5
5
  get 'auto_complete_search'
6
- post 'associate_host'
7
6
  end
8
7
  member do
8
+ match '/hostgroup/:hostgroup_id',
9
+ :to => 'deployments#show',
10
+ :as => :show_with_hostgroup_selected, :method => :get
9
11
  post 'deploy'
10
12
  get 'populate'
11
13
  get 'summary'
14
+ post 'associate_host'
12
15
  end
16
+
17
+ resources :steps
13
18
  end
14
19
 
15
- resources :deployment_steps
16
20
  end
17
21
  end
@@ -1,3 +1,5 @@
1
+ require 'deface'
2
+
1
3
  module Staypuft
2
4
  ENGINE_NAME = "staypuft"
3
5
  class Engine < ::Rails::Engine
@@ -17,6 +19,9 @@ module Staypuft
17
19
  menu :top_menu, :openstack_deployments,
18
20
  :url_hash => { :controller => 'staypuft/deployments', :action => :index },
19
21
  :caption => N_('Deployments')
22
+ menu :top_menu, :new_openstack_deployment,
23
+ :url_hash => { :controller => 'staypuft/deployments', :action => :new },
24
+ :caption => N_('New deployment')
20
25
  end
21
26
  end
22
27
  end
@@ -1,3 +1,3 @@
1
1
  module Staypuft
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14'
3
3
  end
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.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-15 00:00:00.000000000 Z
12
+ date: 2014-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: foreman-tasks
@@ -86,8 +86,8 @@ files:
86
86
  - app/assets/stylesheets/staypuft/bootstrap_and_overrides.css.scss
87
87
  - app/assets/stylesheets/staypuft/staypuft.css.scss
88
88
  - app/controllers/staypuft/application_controller.rb
89
- - app/controllers/staypuft/deployment_steps_controller.rb
90
89
  - app/controllers/staypuft/deployments_controller.rb
90
+ - app/controllers/staypuft/steps_controller.rb
91
91
  - app/helpers/staypuft/application_helper.rb
92
92
  - app/helpers/staypuft/deployments_helper.rb
93
93
  - app/lib/actions/staypuft/deployment/deploy.rb
@@ -118,14 +118,15 @@ files:
118
118
  - app/models/staypuft/service/ui_params.rb
119
119
  - app/models/staypuft/service.rb
120
120
  - app/models/staypuft/service_class.rb
121
- - app/views/staypuft/deployment_steps/_title.html.erb
122
- - app/views/staypuft/deployment_steps/deployment_settings.html.erb
123
- - app/views/staypuft/deployment_steps/services_configuration.html.erb
124
- - app/views/staypuft/deployment_steps/services_selection.html.erb
121
+ - app/overrides/hide_subscription_manager_passwords.rb
125
122
  - app/views/staypuft/deployments/index.html.erb
126
123
  - app/views/staypuft/deployments/show.html.erb
127
124
  - app/views/staypuft/deployments/summary.html.erb
128
125
  - app/views/staypuft/layouts/staypuft.html.erb
126
+ - app/views/staypuft/steps/_title.html.erb
127
+ - app/views/staypuft/steps/deployment_settings.html.erb
128
+ - app/views/staypuft/steps/services_configuration.html.erb
129
+ - app/views/staypuft/steps/services_selection.html.erb
129
130
  - config/routes.rb
130
131
  - config/staypuft.local.rb
131
132
  - db/migrate/20140309021811_create_staypuft_layouts.rb