Skip to content

Commit

Permalink
Merge pull request #2241 from sseago/resize_approval
Browse files Browse the repository at this point in the history
Use approval workflow for instance resize operation
  • Loading branch information
martinpovolny committed Oct 27, 2017
2 parents bf2886f + 6d0b07c commit 73838dc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/controllers/mixins/actions/vm_actions/resize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def resize_vm
flavor_id = params['flavor_id']
flavor = find_record_with_rbac(Flavor, flavor_id)
old_flavor_name = @record.flavor.try(:name) || _("unknown")
@record.resize_queue(session[:userid], flavor)
# TODO: still need to determine whether the next line should be deleted or replaced
@request_id = nil
options = {:src_ids => [@record.id],
:instance_type => flavor_id}
VmCloudReconfigureRequest.make_request(@request_id, options, current_user)
add_flash(_("Reconfiguring Instance \"%{name}\" from %{old_flavor} to %{new_flavor}") % {
:name => @record.name,
:old_flavor => old_flavor_name,
Expand Down
6 changes: 6 additions & 0 deletions app/views/miq_request/_reconfigure_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
= _("Remove Disks")
.col-md-8
= h(@options[:disk_remove].size)
- if @options[:instance_type]
.form-group
%label.control-label.col-md-2
= _("Flavor")
.col-md-8
= h(Flavor.find(@options[:instance_type]).name_with_details)
%hr
%h3
= _("Affected VMs")
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/vm_cloud_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
flavor = FactoryGirl.create(:flavor_openstack)
allow(controller).to receive(:load_edit).and_return(true)
allow(controller).to receive(:previous_breadcrumb_url).and_return("/vm_cloud/explorer")
expect_any_instance_of(VmCloud).to receive(:resize_queue).with(controller.current_user.userid, flavor)
expect(VmCloudReconfigureRequest).to receive(:make_request)
post :resize_vm, :params => {
:button => 'submit',
:id => vm_openstack.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
let(:request) { "SomeRequest" }
let(:username) { user.name }
let(:state) { "xx" }
%w(MiqProvisionRequest MiqHostProvisionRequest VmReconfigureRequest
%w(MiqProvisionRequest MiqHostProvisionRequest VmReconfigureRequest VmCloudReconfigureRequest
VmMigrateRequest AutomationRequest ServiceTemplateProvisionRequest).each do |cls|
context "id = miq_request_approve" do
before do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

let(:view_context) { setup_view_context_with_sandbox({}) }
let(:user) { FactoryGirl.create(:user) }
%w(MiqProvisionRequest MiqHostProvisionRequest VmReconfigureRequest
%w(MiqProvisionRequest MiqHostProvisionRequest VmReconfigureRequest VmCloudReconfigureRequest
VmMigrateRequest AutomationRequest ServiceTemplateProvisionRequest).each do |cls|
let(:request) { "MiqProvisionRequest" }
let(:username) { user.name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
let(:request) { "SomeRequest" }
let(:username) { user.name }
let(:state) { "xx" }
%w(MiqProvisionRequest MiqHostProvisionRequest VmReconfigureRequest
%w(MiqProvisionRequest MiqHostProvisionRequest VmReconfigureRequest VmCloudReconfigureRequest
VmMigrateRequest AutomationRequest ServiceTemplateProvisionRequest).each do |cls|
context 'miq_request_edit' do
before do
Expand Down

0 comments on commit 73838dc

Please sign in to comment.