Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add built in policy to prevent transformed VM from starting. #17389

Merged
merged 2 commits into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/service_template_transformation_plan_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def task_finished
vm_resource.update_attributes(:status => status == 'Ok' ? ServiceResource::STATUS_COMPLETED : ServiceResource::STATUS_FAILED)
end

def mark_vm_migrated
source.tag_with("migrated", :ns => "/managed", :cat => "transformation_status")
end

def task_active
vm_resource.update_attributes(:status => ServiceResource::STATUS_ACTIVE)
end
Expand Down
17 changes: 17 additions & 0 deletions db/fixtures/classifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1070,3 +1070,20 @@
:parent_id: 0
:default: true
:single_value: "0"
- :description: Transformation Status
:entries:
- :description: Migrated
:read_only: "0"
:syntax: string
:name: migrated
:example_text:
:default: true
:single_value: "1"
:read_only: "0"
:syntax: string
:show: true
:name: transformation_status
:example_text: VM has been migrated.
:parent_id: 0
:default: true
:single_value: "1"
13 changes: 13 additions & 0 deletions product/policy/built_in_policies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@
:modifier: deny
:mode: control
:action: vm_suspend
- :name: Prevent Transformed VM from Starting
:description: Prevent Transformed VM from starting
:towhat: Vm
:event: request_vm_start
:applies_to?: true
:active: true
:condition:
"CONTAINS":
tag: Vm.managed-transformation_status
value: migrated
:modifier: deny
:mode: control
:action: prevent
- :name: Stop Retired VM
:description: Stop Retired VM
:towhat: Vm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,12 @@
expect(task.transformation_log).to eq(msg)
end
end

describe '#mark_vm_migrated' do
it 'should tag VM as migrated' do
task.mark_vm_migrated
expect(vm).to be_is_tagged_with("migrated", :ns => "/managed", :cat => "transformation_status")
end
end
end
end