File tree Expand file tree Collapse file tree 4 files changed +45
-6
lines changed
Expand file tree Collapse file tree 4 files changed +45
-6
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 @@ -123,12 +123,14 @@ def start(options = {})
123123
124124 def start_with_cloudinit ( options = { } )
125125 wait_for { !locked? } if options [ :blocking ]
126- user_data = if options [ :use_custom_script ]
127- { :custom_script => options [ :user_data ] }
128- else
129- Hash [ YAML . safe_load ( options [ :user_data ] ) . map { |a | [ a . first . to_sym , a . last ] } ]
130- end
131- action_status = service . vm_start_with_cloudinit ( :id => id , :user_data => user_data )
126+ action_status = service . vm_start_with_cloudinit ( :id => id , :user_data => fetch_user_data ( options ) )
127+ reload
128+ action_status
129+ end
130+
131+ def start_with_initialization ( options = { } )
132+ wait_for { !locked? } if options [ :blocking ]
133+ action_status = service . vm_start_with_initialization ( :id => id , :user_data => fetch_user_data ( options ) )
132134 reload
133135 action_status
134136 end
@@ -182,6 +184,14 @@ def save
182184 def to_s
183185 name
184186 end
187+
188+ private
189+
190+ def fetch_user_data ( options )
191+ return { :custom_script => options [ :user_data ] } if options [ :use_custom_script ]
192+
193+ Hash [ YAML . safe_load ( options [ :user_data ] ) . map { |a | [ a . first . to_sym , a . last ] } ]
194+ end
185195 end
186196 end
187197 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 2121 test ( "it should respond to #{ collection } " ) { compute . respond_to? collection }
2222 end
2323 end
24+
25+ tests ( "compute v4 with_initialization request" ) do
26+ compute = Fog ::Ovirt ::Compute . new ( :api_version => "v4" )
27+ test ( "it should respond to vm_start_with_initialization" ) { compute . respond_to? "vm_start_with_initialization" }
28+ end
2429end
You can’t perform that action at this time.
0 commit comments