File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ class V4 < Fog::Service
99
1010 request :vm_action
1111 request :vm_start_with_cloudinit
12+ request :vm_start_with_initialization
1213 request :destroy_vm
1314 request :create_vm
1415 request :update_vm
Original file line number Diff line number Diff line change @@ -133,6 +133,18 @@ def start_with_cloudinit(options = {})
133133 action_status
134134 end
135135
136+ def start_with_initialization ( options = { } )
137+ wait_for { !locked? } if options [ :blocking ]
138+ user_data = if options [ :use_custom_script ]
139+ { :custom_script => options [ :user_data ] }
140+ else
141+ Hash [ YAML . safe_load ( options [ :user_data ] ) . map { |a | [ a . first . to_sym , a . last ] } ]
142+ end
143+ action_status = service . vm_start_with_initialization ( :id => id , :user_data => user_data )
144+ reload
145+ action_status
146+ end
147+
136148 def stop ( _options = { } )
137149 vm_power_action ( :stop )
138150 end
Original file line number Diff line number Diff line change 1+ module Fog
2+ module Ovirt
3+ class Compute
4+ class V4
5+ class Real
6+ def vm_start_with_initialization ( options = { } )
7+ raise ArgumentError , "instance id is a required parameter" unless options . key? :id
8+
9+ vm_service = client . system_service . vms_service . vm_service ( options [ :id ] )
10+ vm_service . start ( :use_initialization => true , :vm => { :initialization => options [ :user_data ] } )
11+ end
12+ end
13+
14+ class Mock
15+ def vm_start_with_initialization ( options = { } )
16+ raise ArgumentError , "instance id is a required parameter" unless options . key? :id
17+ true
18+ end
19+ end
20+ end
21+ end
22+ end
23+ end
Original file line number Diff line number Diff line change 1313 end
1414 end
1515
16+
1617 tests ( "Compute requests" ) do
1718 %w[ add_interface create_vm datacenters destroy_interface destroy_vm get_cluster get_template
1819 get_virtual_machine list_clusters list_networks list_template_interfaces list_templates
2122 test ( "it should respond to #{ collection } " ) { compute . respond_to? collection }
2223 end
2324 end
25+
26+ tests ( "compute v4 with_initialization request" ) do
27+ compute = Fog ::Ovirt ::Compute . new ( :api_version => "v4" )
28+ test ( "it should respond to vm_start_with_initialization" ) { compute . respond_to? "vm_start_with_initialization" }
29+ end
2430end
You can’t perform that action at this time.
0 commit comments