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

v2v: Pre-check install_drivers checkbox for windows VMs #170

Merged
merged 1 commit into from
Aug 31, 2017
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module ManageIQ
module Automate
module Infrastructure
module VM
module Transform
module Import
class InstallDrivers
def initialize(handle = $evm)
@handle = handle
end

def main
os = @handle.root['vm'].operating_system
is_windows = os.try(:product_name) =~ /windows/i
checkbox_values = {
'value' => is_windows ? 't' : 'f',
'read_only' => false,
'visible' => true
}
checkbox_values.each do |key, value|
@handle.object[key] = value
end
end
end
end
end
end
end
end
end

if __FILE__ == $PROGRAM_NAME
ManageIQ::Automate::Infrastructure::VM::Transform::Import::InstallDrivers.new.main
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
object_type: method
version: 1.0
object:
attributes:
name: install_drivers
display_name:
description:
scope: instance
language: ruby
location: inline
inputs: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: install_drivers
inherits:
description:
fields:
- execute:
value: install_drivers
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require_domain_file

describe ManageIQ::Automate::Infrastructure::VM::Transform::Import::InstallDrivers do
let(:operating_system) { FactoryGirl.create(:operating_system, :product_name => os_name) }
let(:vm) { FactoryGirl.create(:vm_vmware, :operating_system => operating_system) }
let(:svc_model_vm) { MiqAeMethodService::MiqAeServiceManageIQ_Providers_Vmware_InfraManager_Vm.find(vm.id) }

let(:root_object) do
Spec::Support::MiqAeMockObject.new(:vm => svc_model_vm)
end

let(:ae_service) do
Spec::Support::MiqAeMockService.new(root_object).tap do |service|
current_object = Spec::Support::MiqAeMockObject.new
current_object.parent = root_object
service.object = current_object
end
end

context 'for windows VM' do
let(:os_name) { 'Windows 10' }

it 'should pre-check the checkbox' do
described_class.new(ae_service).main

expect(ae_service.object['value']).to eq('t')
expect(ae_service.object['read_only']).to eq(false)
expect(ae_service.object['visible']).to eq(true)
end
end

context 'for linux VM' do
let(:os_name) { 'RHEL 7' }

it 'should leave the checkbox unchecked' do
described_class.new(ae_service).main

expect(ae_service.object['value']).to eq('f')
expect(ae_service.object['read_only']).to eq(false)
expect(ae_service.object['visible']).to eq(true)
end
end

context 'for undefined OS' do
let(:operating_system) { nil }

it 'should leave the checkbox unchecked' do
described_class.new(ae_service).main

expect(ae_service.object['value']).to eq('f')
expect(ae_service.object['read_only']).to eq(false)
expect(ae_service.object['visible']).to eq(true)
end
end
end