3333 </q-item-section >
3434 <q-item-section >Disk (Block)</q-item-section >
3535 </q-item >
36+ <q-item
37+ clickable
38+ v-ripple
39+ :active =" option === 'disk-iscsi'"
40+ @click =" option = 'disk-iscsi'"
41+ active-class =" my-menu-link"
42+ >
43+ <q-item-section avatar >
44+ <q-icon color =" primary" name =" mdi-harddisk" />
45+ </q-item-section >
46+ <q-item-section >Disk (iSCSI)</q-item-section >
47+ </q-item >
3648 <q-item
3749 clickable
3850 v-ripple
92104 hint =" Enter the path to the physical disk device"
93105 />
94106 </q-card-section >
107+ <q-card-section v-if =" diskiscsiLayout" >
108+ <q-input filled v-model =" diskIscsiName" label =" Disk Name" class =" q-pb-md" />
109+ <q-select
110+ class =" q-pb-md"
111+ v-model =" diskIscsiBusType"
112+ :options =" diskBusTypes"
113+ label =" Disk Bus"
114+ filled
115+ />
116+ <q-select
117+ class =" q-pb-md"
118+ v-model =" diskIscsiDeviceType"
119+ :options =" diskDeviceTypes"
120+ label =" Device Type"
121+ filled
122+ />
123+ <q-input
124+ filled
125+ v-model =" diskIscsiIqn"
126+ label =" iSCSI Name (IQN)"
127+ hint =" e.g., iqn.2013-07.com.example:iscsi-nopool/2"
128+ class =" q-pb-md"
129+ />
130+ <q-input
131+ filled
132+ v-model =" diskIscsiHost"
133+ label =" iSCSI Host"
134+ hint =" e.g., example.com or 192.168.1.100"
135+ class =" q-pb-md"
136+ />
137+ <q-input
138+ filled
139+ v-model =" diskIscsiPort"
140+ type =" number"
141+ label =" iSCSI Port"
142+ hint =" Default: 3260"
143+ />
144+ </q-card-section >
95145 <q-card-section v-if =" networkLayout" class =" q-py-none" >
96146 <q-select
97147 class =" q-pb-md"
128178 <q-btn color =" primary" icon =" check" flat @click =" diskBlockCreate" v-if =" diskblockLayout" >
129179 <ToolTip content =" Create" />
130180 </q-btn >
181+ <q-btn color =" primary" icon =" check" flat @click =" diskIscsiCreate" v-if =" diskiscsiLayout" >
182+ <ToolTip content =" Create" />
183+ </q-btn >
131184 </q-card-actions >
132185 </q-card >
133186 </q-dialog >
@@ -155,6 +208,7 @@ export default {
155208 optionLayout: true ,
156209 diskfileLayout: false ,
157210 diskblockLayout: false ,
211+ diskiscsiLayout: false ,
158212 networkLayout: false ,
159213 networkInterfaceTypes: [
160214 { label: ' VirtIO' , value: ' virtio' },
@@ -184,6 +238,12 @@ export default {
184238 diskBlockBusType: ' virtio' ,
185239 diskBlockDeviceType: ' disk' ,
186240 diskBlockSource: ' ' ,
241+ diskIscsiName: ' ' ,
242+ diskIscsiBusType: ' virtio' ,
243+ diskIscsiDeviceType: ' disk' ,
244+ diskIscsiIqn: ' ' ,
245+ diskIscsiHost: ' ' ,
246+ diskIscsiPort: 3260 ,
187247 }
188248 },
189249 emits: [' finished' ],
@@ -199,6 +259,7 @@ export default {
199259 this .optionLayout = true
200260 this .diskfileLayout = false
201261 this .diskblockLayout = false
262+ this .diskiscsiLayout = false
202263 this .networkLayout = false
203264 },
204265 optionChose () {
@@ -216,6 +277,15 @@ export default {
216277 this .diskBlockDeviceType = this .diskDeviceTypes [0 ]
217278 this .diskBlockName = ' '
218279 this .diskBlockSource = ' '
280+ } else if (this .option === ' disk-iscsi' ) {
281+ this .optionLayout = false
282+ this .diskiscsiLayout = true
283+ this .diskIscsiBusType = this .diskBusTypes [0 ]
284+ this .diskIscsiDeviceType = this .diskDeviceTypes [0 ]
285+ this .diskIscsiName = ' '
286+ this .diskIscsiIqn = ' '
287+ this .diskIscsiHost = ' '
288+ this .diskIscsiPort = 3260
219289 } else if (this .option === ' network' ) {
220290 this .optionLayout = false
221291 this .networkLayout = true
@@ -294,6 +364,38 @@ export default {
294364 ])
295365 })
296366 },
367+ diskIscsiCreate () {
368+ if (this .diskIscsiIqn == ' ' ) {
369+ this .$refs .errorDialog .show (' Error' , [' iSCSI IQN is required' ])
370+ return
371+ }
372+ if (this .diskIscsiHost == ' ' ) {
373+ this .$refs .errorDialog .show (' Error' , [' iSCSI Host is required' ])
374+ return
375+ }
376+ if (this .diskIscsiName == ' ' ) {
377+ this .$refs .errorDialog .show (' Error' , [' Disk name is required' ])
378+ return
379+ }
380+ this .$api
381+ .post (' /vm/' + this .vmid + ' /devices/disk-iscsi' , {
382+ name: this .diskIscsiName ,
383+ disk_bus: this .diskIscsiBusType .value ,
384+ device_type: this .diskIscsiDeviceType .value ,
385+ iscsi_name: this .diskIscsiIqn ,
386+ iscsi_host: this .diskIscsiHost ,
387+ iscsi_port: this .diskIscsiPort ,
388+ })
389+ .then (() => {
390+ this .layout = false
391+ this .$emit (' finished' )
392+ })
393+ .catch ((error ) => {
394+ this .$refs .errorDialog .show (' Error creating iSCSI device' , [
395+ error .response ? .data ? .detail || error .message ,
396+ ])
397+ })
398+ },
297399 },
298400}
299401< / script>
0 commit comments