1616// under the License.
1717package org .apache .cloudstack .storage .template ;
1818
19- import java .io .BufferedReader ;
2019import java .io .File ;
2120import java .io .FileInputStream ;
2221import java .io .IOException ;
6059import org .apache .cloudstack .storage .command .DownloadCommand .ResourceType ;
6160import org .apache .cloudstack .storage .command .DownloadProgressCommand ;
6261import org .apache .cloudstack .storage .command .DownloadProgressCommand .RequestType ;
62+ import org .apache .cloudstack .storage .NfsMountManagerImpl .PathParser ;
6363import org .apache .cloudstack .storage .resource .NfsSecondaryStorageResource ;
6464import org .apache .cloudstack .storage .resource .SecondaryStorageResource ;
6565import org .apache .commons .collections .CollectionUtils ;
8282import com .cloud .utils .StringUtils ;
8383import com .cloud .utils .component .ManagerBase ;
8484import com .cloud .utils .exception .CloudRuntimeException ;
85- import com .cloud .utils .script .OutputInterpreter ;
8685import com .cloud .utils .script .Script ;
8786import com .cloud .utils .storage .QCOW2Utils ;
8887import org .apache .cloudstack .utils .security .ChecksumValue ;
@@ -850,8 +849,12 @@ private List<String> listVolumes(String rootdir) {
850849
851850 Script script = new Script (listVolScr , LOGGER );
852851 script .add ("-r" , rootdir );
853- ZfsPathParser zpp = new ZfsPathParser (rootdir );
852+ PathParser zpp = new PathParser (rootdir );
854853 script .execute (zpp );
854+ if (script .getExitValue () != 0 ) {
855+ LOGGER .error ("Error while executing script " + script .toString ());
856+ throw new CloudRuntimeException ("Error while executing script " + script .toString ());
857+ }
855858 result .addAll (zpp .getPaths ());
856859 LOGGER .info ("found " + zpp .getPaths ().size () + " volumes" + zpp .getPaths ());
857860 return result ;
@@ -862,8 +865,12 @@ private List<String> listTemplates(String rootdir) {
862865
863866 Script script = new Script (listTmpltScr , LOGGER );
864867 script .add ("-r" , rootdir );
865- ZfsPathParser zpp = new ZfsPathParser (rootdir );
868+ PathParser zpp = new PathParser (rootdir );
866869 script .execute (zpp );
870+ if (script .getExitValue () != 0 ) {
871+ LOGGER .error ("Error while executing script " + script .toString ());
872+ throw new CloudRuntimeException ("Error while executing script " + script .toString ());
873+ }
867874 result .addAll (zpp .getPaths ());
868875 LOGGER .info ("found " + zpp .getPaths ().size () + " templates" + zpp .getPaths ());
869876 return result ;
@@ -961,33 +968,6 @@ public Map<Long, TemplateProp> gatherVolumeInfo(String rootDir) {
961968 return result ;
962969 }
963970
964- public static class ZfsPathParser extends OutputInterpreter {
965- String _parent ;
966- List <String > paths = new ArrayList <String >();
967-
968- public ZfsPathParser (String parent ) {
969- _parent = parent ;
970- }
971-
972- @ Override
973- public String interpret (BufferedReader reader ) throws IOException {
974- String line = null ;
975- while ((line = reader .readLine ()) != null ) {
976- paths .add (line );
977- }
978- return null ;
979- }
980-
981- public List <String > getPaths () {
982- return paths ;
983- }
984-
985- @ Override
986- public boolean drain () {
987- return true ;
988- }
989- }
990-
991971 public DownloadManagerImpl () {
992972 }
993973
0 commit comments