88 async : true ,
99 success : function ( data ) {
1010 args . response . success ( {
11- doInstall : ! ( data . listzonesresponse . zone && data . listzonesresponse . zone . length )
12- } ) ;
11+ doInstall : ! data . listzonesresponse . zone
12+ } ) ;
1313 }
1414 } ) ;
15+ } ,
16+
17+ action : function ( args ) {
18+ var complete = args . response . success ;
19+
20+ var createZone = function ( args ) {
21+ $ . ajax ( {
22+ url : createURL ( 'createZone' ) ,
23+ data : {
24+ name : 'brian-zone' ,
25+ networktype : 'Basic' ,
26+ dns1 : '8.8.8.8' ,
27+ internaldns1 : '10.223.110.223'
28+ } ,
29+ dataType : 'json' ,
30+ async : true ,
31+ success : function ( data ) {
32+ createPod ( {
33+ data : {
34+ zone : data . createzoneresponse . zone
35+ }
36+ } ) ;
37+ }
38+ } ) ;
39+ } ;
40+
41+ var createPod = function ( args ) {
42+ $ . ajax ( {
43+ url : createURL ( 'createPod' ) ,
44+ data : {
45+ name : 'brian-pod' ,
46+ zoneid : args . data . zone . id ,
47+ gateway : '10.223.183.1' ,
48+ netmask : '255.255.255.0' ,
49+ startip : '10.223.183.10' ,
50+ endip : '10.223.183.20'
51+ } ,
52+ dataType : 'json' ,
53+ async : true ,
54+ success : function ( data ) {
55+ createIPRange ( {
56+ data : $ . extend ( args . data , {
57+ pod : data . createpodresponse . pod
58+ } )
59+ } ) ;
60+ }
61+ } ) ;
62+ } ;
63+
64+ var createIPRange = function ( args ) {
65+ $ . ajax ( {
66+ url : createURL ( 'createVlanIpRange' ) ,
67+ data : {
68+ name : 'brian-zone' ,
69+ zoneid : args . data . zone . id ,
70+ vlan : 'untagged' ,
71+ gateway : '10.223.183.1' ,
72+ netmask : '255.255.255.0' ,
73+ startip : '10.223.183.50' ,
74+ endip : '10.223.183.100'
75+ } ,
76+ dataType : 'json' ,
77+ async : true ,
78+ success : function ( data ) {
79+ createCluster ( {
80+ data : $ . extend ( args . data , {
81+ ipRange : data . createvlaniprangeresponse . vlan
82+ } )
83+ } ) ;
84+ }
85+ } ) ;
86+ } ;
87+
88+ var createCluster = function ( args ) {
89+ $ . ajax ( {
90+ url : createURL ( 'addCluster' ) ,
91+ data : {
92+ clustername : 'brian-cluster-xen' ,
93+ podid : args . data . pod . id ,
94+ zoneid : args . data . zone . id ,
95+ hypervisor : 'XenServer' ,
96+ clustertype : 'CloudManaged'
97+ } ,
98+ dataType : 'json' ,
99+ async : true ,
100+ success : function ( data ) {
101+ createHost ( {
102+ data : $ . extend ( args . data , {
103+ cluster : data . addclusterresponse . cluster [ 0 ]
104+ } )
105+ } ) ;
106+ }
107+ } ) ;
108+ } ;
109+
110+ var createHost = function ( args ) {
111+ $ . ajax ( {
112+ url : createURL ( 'addHost' ) ,
113+ data : {
114+ clustername : 'brian-cluster-xen' ,
115+ zoneid : args . data . zone . id ,
116+ podid : args . data . pod . id ,
117+ hypervisor : 'XenServer' ,
118+ clustertype : 'CloudManaged' ,
119+ url : 'http://10.223.183.2' ,
120+ username : 'root' ,
121+ password : 'password'
122+ } ,
123+ dataType : 'json' ,
124+ async : true ,
125+ success : function ( data ) {
126+ createPrimaryStorage ( {
127+ data : $ . extend ( args . data , {
128+ host : data . addhostresponse . host [ 0 ]
129+ } )
130+ } ) ;
131+ }
132+ } ) ;
133+ } ;
134+
135+ var createPrimaryStorage = function ( args ) {
136+ $ . ajax ( {
137+ url : createURL ( 'createStoragePool' ) ,
138+ data : {
139+ name : 'brian-primary-storage' ,
140+ clusterid : args . data . cluster . id ,
141+ zoneid : args . data . zone . id ,
142+ podid : args . data . pod . id ,
143+ hypervisor : 'XenServer' ,
144+ clustertype : 'CloudManaged' ,
145+ url : 'nfs://10.223.110.232/export/home/bfederle/primary'
146+ } ,
147+ dataType : 'json' ,
148+ async : true ,
149+ success : function ( data ) {
150+ createSecondaryStorage ( {
151+ data : $ . extend ( args . data , {
152+ host : data . createstoragepoolresponse . storagepool
153+ } )
154+ } ) ;
155+ }
156+ } ) ;
157+ } ;
158+
159+ var createSecondaryStorage = function ( args ) {
160+ $ . ajax ( {
161+ url : createURL ( 'addSecondaryStorage' ) ,
162+ data : {
163+ clusterid : args . data . cluster . id ,
164+ zoneid : args . data . zone . id ,
165+ url : 'nfs://10.223.110.232/export/home/bfederle/secondary'
166+ } ,
167+ dataType : 'json' ,
168+ async : true ,
169+ success : function ( data ) {
170+ pollSystemVMs ( ) ;
171+ }
172+ } ) ;
173+ } ;
174+
175+ var pollSystemVMs = function ( ) {
176+ var poll = setInterval ( function ( ) {
177+ $ . ajax ( {
178+ url : createURL ( 'listSystemVMs' ) ,
179+ dataType : 'json' ,
180+ async : true ,
181+ success : function ( data ) {
182+ if ( data . listsystemvmsresponse . systemvm ) {
183+ clearInterval ( poll ) ;
184+ complete ( ) ;
185+ }
186+ }
187+ } ) ;
188+ } ) ;
189+ } ;
190+
191+ createZone ( ) ;
15192 }
16193 } ;
17194} ( jQuery , cloudStack , testData ) ) ;
0 commit comments