| 1 | #! /usr/local/sbin/rexx
|
|---|
| 2 |
|
|---|
| 3 | /* Change the #! line to point to your rexx/regina interpreter
|
|---|
| 4 | Change vmbase to point to the top level directory where your VM images are saved.
|
|---|
| 5 | This directory and any sub-directories will be scanned for .vbox, .udi, and .vmdk files.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | vmbase = '/VMs/'
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | paths. = 0
|
|---|
| 12 | cnt = 0
|
|---|
| 13 |
|
|---|
| 14 | ADDRESS COMMAND "find" vmbase "-path '*.vdi'" WITH output stem tmp.
|
|---|
| 15 | DO i = 1 TO tmp.0
|
|---|
| 16 | cnt = cnt + 1
|
|---|
| 17 | key = tmp.i
|
|---|
| 18 | paths.cnt = key
|
|---|
| 19 | paths.key = 1
|
|---|
| 20 | END
|
|---|
| 21 |
|
|---|
| 22 | ADDRESS COMMAND "find" vmbase "-path '*.vmdk'" WITH output stem tmp.
|
|---|
| 23 | DO i = 1 TO tmp.0
|
|---|
| 24 | cnt = cnt + 1
|
|---|
| 25 | key = tmp.i
|
|---|
| 26 | paths.cnt = key
|
|---|
| 27 | paths.key = 1
|
|---|
| 28 | END
|
|---|
| 29 |
|
|---|
| 30 | ADDRESS COMMAND "find" vmbase "-path '*.vbox' -or -path '*.xml'" WITH output stem tmp.
|
|---|
| 31 | DO i = 1 TO tmp.0
|
|---|
| 32 | file_in=tmp.i
|
|---|
| 33 | CALL Check_files file_in
|
|---|
| 34 | END
|
|---|
| 35 |
|
|---|
| 36 | SAY '**** unused images ****'
|
|---|
| 37 | SAY
|
|---|
| 38 |
|
|---|
| 39 | DO i = 1 TO cnt
|
|---|
| 40 | key = paths.i
|
|---|
| 41 | IF ( paths.key = 1 ) THEN DO
|
|---|
| 42 | SAY key
|
|---|
| 43 | END
|
|---|
| 44 | END
|
|---|
| 45 |
|
|---|
| 46 | EXIT
|
|---|
| 47 |
|
|---|
| 48 | /* **** subroutines **** */
|
|---|
| 49 |
|
|---|
| 50 | Check_files:
|
|---|
| 51 | PROCEDURE EXPOSE paths. cnt
|
|---|
| 52 | PARSE ARG file_in
|
|---|
| 53 |
|
|---|
| 54 | machine = file_in
|
|---|
| 55 | enihcam = REVERSE(STRIP(machine))
|
|---|
| 56 | PARSE VAR enihcam . '/' htap
|
|---|
| 57 | path = REVERSE(htap)
|
|---|
| 58 |
|
|---|
| 59 | CALL STREAM file_in,'c','close'
|
|---|
| 60 | DO i = 1 WHILE( LINES(file_in) > 0 )
|
|---|
| 61 | string = LINEIN(file_in)
|
|---|
| 62 | IF ( POS('<HardDisk ',string) > 1 ) THEN DO
|
|---|
| 63 | PARSE VAR string . 'uuid="' uuid '"' . 'location="' location '"' .
|
|---|
| 64 | location = STRIP(location)
|
|---|
| 65 | location = path'/'location
|
|---|
| 66 | IF ( paths.location > 0 ) THEN paths.location = 2
|
|---|
| 67 | ELSE IF ( paths.location = 0 ) THEN DO
|
|---|
| 68 | SAY 'File:' location 'not found.'
|
|---|
| 69 | PARSE VAR location '/' parta '/'partb '/' partc
|
|---|
| 70 | machine = '/'parta'/'partb'/'
|
|---|
| 71 | SAY 'choices FOR' machine 'Are:'
|
|---|
| 72 | DO i = 1 TO cnt
|
|---|
| 73 | key = paths.i
|
|---|
| 74 | IF ( (POS(machine,key) > 0) & (paths.key = 1) ) THEN DO
|
|---|
| 75 | SAY key
|
|---|
| 76 | END
|
|---|
| 77 | END
|
|---|
| 78 | SAY
|
|---|
| 79 | END
|
|---|
| 80 | END
|
|---|
| 81 | END
|
|---|
| 82 | CALL STREAM file_in,'c','close'
|
|---|
| 83 | RETURN
|
|---|