@@ -215,18 +215,29 @@ public JContainer AttachCommand([FromBody]dynamic cmd)
215215 {
216216 string vmName = ( string ) cmd . vmName ;
217217 DiskTO disk = DiskTO . ParseJson ( cmd . disk ) ;
218- TemplateObjectTO dataStore = disk . templateObjectTO ;
219218
220- if ( dataStore . nfsDataStoreTO != null )
219+ if ( disk . type . Equals ( "ISO" ) )
221220 {
221+ TemplateObjectTO dataStore = disk . templateObjectTO ;
222222 NFSTO share = dataStore . nfsDataStoreTO ;
223223 Utils . ConnectToRemote ( share . UncPath , share . Domain , share . User , share . Password ) ;
224-
225- // The share is mapped, now attach the iso
226- string isoPath = Utils . NormalizePath ( Path . Combine ( share . UncPath , dataStore . path ) ) ;
227- wmiCallsV2 . AttachIso ( vmName , isoPath ) ;
224+ string diskPath = Utils . NormalizePath ( Path . Combine ( share . UncPath , dataStore . path ) ) ;
225+ wmiCallsV2 . AttachIso ( vmName , diskPath ) ;
226+ result = true ;
227+ }
228+ else if ( disk . type . Equals ( "DATADISK" ) )
229+ {
230+ VolumeObjectTO volume = disk . volumeObjectTO ;
231+ PrimaryDataStoreTO primary = volume . primaryDataStore ;
232+ Utils . ConnectToRemote ( primary . UncPath , primary . Domain , primary . User , primary . Password ) ;
233+ string diskPath = Utils . NormalizePath ( volume . FullFileName ) ;
234+ wmiCallsV2 . AttachDisk ( vmName , diskPath , disk . diskSequence ) ;
228235 result = true ;
229236 }
237+ else
238+ {
239+ details = "Invalid disk type to be attached to vm " + vmName ;
240+ }
230241 }
231242 catch ( Exception sysEx )
232243 {
@@ -238,6 +249,7 @@ public JContainer AttachCommand([FromBody]dynamic cmd)
238249 {
239250 result = result ,
240251 details = details ,
252+ disk = cmd . disk ,
241253 contextMap = contextMap
242254 } ;
243255
@@ -261,16 +273,27 @@ public JContainer DetachCommand([FromBody]dynamic cmd)
261273 {
262274 string vmName = ( string ) cmd . vmName ;
263275 DiskTO disk = DiskTO . ParseJson ( cmd . disk ) ;
264- TemplateObjectTO dataStore = disk . templateObjectTO ;
265276
266- if ( dataStore . nfsDataStoreTO != null )
277+ if ( disk . type . Equals ( "ISO" ) )
267278 {
279+ TemplateObjectTO dataStore = disk . templateObjectTO ;
268280 NFSTO share = dataStore . nfsDataStoreTO ;
269- // The share is mapped, now attach the iso
270- string isoPath = Utils . NormalizePath ( Path . Combine ( share . UncPath , dataStore . path ) ) ;
271- wmiCallsV2 . DetachDisk ( vmName , isoPath ) ;
281+ string diskPath = Utils . NormalizePath ( Path . Combine ( share . UncPath , dataStore . path ) ) ;
282+ wmiCallsV2 . DetachDisk ( vmName , diskPath ) ;
272283 result = true ;
273284 }
285+ else if ( disk . type . Equals ( "DATADISK" ) )
286+ {
287+ VolumeObjectTO volume = disk . volumeObjectTO ;
288+ PrimaryDataStoreTO primary = volume . primaryDataStore ;
289+ string diskPath = Utils . NormalizePath ( volume . FullFileName ) ;
290+ wmiCallsV2 . DetachDisk ( vmName , diskPath ) ;
291+ result = true ;
292+ }
293+ else
294+ {
295+ details = "Invalid disk type to be dettached from vm " + vmName ;
296+ }
274297 }
275298 catch ( Exception sysEx )
276299 {
@@ -1649,6 +1672,14 @@ public JContainer StartupCommand([FromBody]dynamic cmdArray)
16491672 strtRouteCmd . hypervisorVersion = System . Environment . OSVersion . Version . ToString ( ) ;
16501673 strtRouteCmd . caps = "hvm" ;
16511674
1675+ dynamic details = strtRouteCmd . hostDetails ;
1676+ if ( details != null )
1677+ {
1678+ string productVersion = System . Environment . OSVersion . Version . Major . ToString ( ) + "." +
1679+ System . Environment . OSVersion . Version . Minor . ToString ( ) ;
1680+ details . Add ( "product_version" , productVersion ) ;
1681+ }
1682+
16521683 // Detect CPUs, speed, memory
16531684 uint cores ;
16541685 uint mhz ;
0 commit comments