File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 283283 var poll = setInterval ( function ( ) {
284284 $ . ajax ( {
285285 url : createURL ( 'listSystemVms' ) ,
286- dataType : 'json' ,
287- async : true ,
288286 success : function ( data ) {
289287 var systemVMs = data . listsystemvmsresponse . systemvm ;
290288
293291 return vm . state == 'Running' ;
294292 } ) . length ) {
295293 clearInterval ( poll ) ;
296- message ( 'Installation completed! ' ) ;
297- setTimeout ( success , 2000 ) ;
294+ message ( 'System VMs ready. ' ) ;
295+ setTimeout ( pollBuiltinTemplates , 500 ) ;
298296 }
299297 }
300298 }
301299 } ) ;
302300 } , 5000 ) ;
303301 } ;
304302
303+ // Wait for builtin template to be present -- otherwise VMs cannot launch
304+ var pollBuiltinTemplates = function ( ) {
305+ message ( 'Waiting for builtin templates to load...' ) ;
306+ var poll = setInterval ( function ( ) {
307+ $ . ajax ( {
308+ url : createURL ( 'listTemplates' ) ,
309+ data : {
310+ templatefilter : 'all'
311+ } ,
312+ success : function ( data ) {
313+ var templates = data . listtemplatesresponse . template ?
314+ data . listtemplatesresponse . template : [ ] ;
315+ var builtinTemplates = $ . grep ( templates , function ( template ) {
316+ return template . templatetype == 'BUILTIN' ;
317+ } ) ;
318+
319+ if ( builtinTemplates . length ) {
320+ clearInterval ( poll ) ;
321+ message ( 'Your CloudStack is ready!' ) ;
322+ setTimeout ( success , 1000 ) ;
323+ }
324+ }
325+ } ) ;
326+ } , 5000 ) ;
327+ } ;
328+
305329 enableZone ( ) ;
306330 }
307331 }
You can’t perform that action at this time.
0 commit comments