Skip to content

Commit

Permalink
Merge pull request #1232 from kbrock/drop_lifecycle_event
Browse files Browse the repository at this point in the history
dropping lifecycle_event table
  • Loading branch information
Fryguy authored Oct 23, 2023
2 parents 8ac251c + 69eee04 commit 5531be1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 66 deletions.
17 changes: 0 additions & 17 deletions app/controllers/api/vms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ def set_owner_resource(type, id = nil, data = nil)
end
end

def add_lifecycle_event_resource(type, id = nil, data = nil)
lifecycle_event = lifecycle_event_from_data(data)
api_resource(type, id, "Adding Life Cycle Event #{lifecycle_event['event']} to") do |vm|
LifecycleEvent.create_event(vm, lifecycle_event)
{}
end
end

def scan_resource(type, id = nil, _data = nil)
enqueue_ems_action(type, id, "Scanning", :method_name => "scan", :supports => :smartstate_analysis, :role => "smartstate")
end
Expand Down Expand Up @@ -234,14 +226,5 @@ def resize_resource(type, id, data)
rescue => err
action_result(false, err.to_s)
end

private

def lifecycle_event_from_data(data)
data ||= {}
data = data.slice("event", "status", "message", "created_by")
data.keys.each { |k| data[k] = data[k].to_s }
data
end
end
end
4 changes: 0 additions & 4 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4646,8 +4646,6 @@
- sui_vm_details_view
- :name: edit
:identifier: vm_edit
- :name: add_lifecycle_event
:identifier: vm_edit
- :name: add_event
:identifier: vm_edit
- :name: check_compliance
Expand Down Expand Up @@ -4728,8 +4726,6 @@
:post:
- :name: edit
:identifier: vm_edit
- :name: add_lifecycle_event
:identifier: vm_edit
- :name: add_event
:identifier: vm_edit
- :name: check_compliance
Expand Down
45 changes: 0 additions & 45 deletions spec/requests/vms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1190,51 +1190,6 @@ def query_match_regexp(*tables)
end
end

context "Vm add_lifecycle_event action" do
let(:events) do
1.upto(3).collect do |n|
{:event => "event#{n}", :status => "status#{n}", :message => "message#{n}", :created_by => "system"}
end
end

it "add_lifecycle_event to an invalid vm" do
api_basic_authorize action_identifier(:vms, :add_lifecycle_event)

post(invalid_vm_url, :params => gen_request(:add_lifecycle_event, :event => "event 1"))

expect(response).to have_http_status(:not_found)
end

it "add_lifecycle_event without appropriate action role" do
api_basic_authorize

post(vm_url, :params => gen_request(:add_lifecycle_event, :event => "event 1"))

expect(response).to have_http_status(:forbidden)
end

it "add_lifecycle_event to a vm" do
api_basic_authorize action_identifier(:vms, :add_lifecycle_event)

post(vm_url, :params => gen_request(:add_lifecycle_event, events[0]))

expect_single_action_result(:success => true, :message => /adding life cycle event/i, :href => api_vm_url(nil, vm))
expect(vm.lifecycle_events.size).to eq(1)
expect(vm.lifecycle_events.first.event).to eq(events[0][:event])
end

it "add_lifecycle_event to multiple vms" do
api_basic_authorize action_identifier(:vms, :add_lifecycle_event)

post(api_vms_url, :params => gen_request(:add_lifecycle_event,
events.collect { |e| {:href => vm_url}.merge(e) }))

expect_multiple_action_result(3, :success => true)
expect(vm.lifecycle_events.size).to eq(events.size)
expect(vm.lifecycle_events.collect(&:event)).to match_array(events.collect { |e| e[:event] })
end
end

context "Vm scan action" do
it "scans an invalid vm" do
api_basic_authorize action_identifier(:vms, :scan)
Expand Down

0 comments on commit 5531be1

Please sign in to comment.