public static void genOvfenvIsoImage(String ovfenvPropKVStr,String isoFilePath){
  byte[] bOvfenvPropKVStr=ovfenvPropKVStr.getBytes();
  String propFilePath="/tmp/ovf-env.properties";
  File propFile=new File(propFilePath);
  try {
    FileUtils.writePlainFile(propFilePath,bOvfenvPropKVStr);
  }
 catch (  Exception e1) {
    propFile.delete();
    log.error("Write to prop file failed with exception: {}",e1.getMessage());
    throw new IllegalStateException("Failed to generate ovfenv prop file.");
  }
  try {
    File isoFile=new File(isoFilePath);
    String[] genISOImageCommand={GENISO_CMD,"--label","CDROM","-f",propFilePath,"-o",isoFilePath,"ovf-env.properties","4096"};
    Exec.Result result=Exec.sudo(CMD_TIMEOUT,genISOImageCommand);
    if (!result.exitedNormally() || result.getExitValue() != 0) {
      log.error("Generating ISO image failed with exit value: {}, error: {}",result.getExitValue(),result.getStdError());
      throw new IllegalStateException("Failed to generate ISO image.");
    }
  }
 catch (  Exception e) {
    throw e;
  }
 finally {
    propFile.delete();
  }
}

public static void genOvfenvIsoImage ( String ovfenvPropKVStr , String isoFilePath ) { byte [ ] bOvfenvPropKVStr = ovfenvPropKVStr . getBytes ( ) ; String propFilePath = "/tmp/ovf-env.properties" ; File propFile = new File ( propFilePath ) ; try { FileUtils . writePlainFile ( propFilePath , bOvfenvPropKVStr ) ; } catch ( Exception e1 ) { propFile . delete ( ) ; log . error ( "Write to prop file failed with exception: {}" , e1 . getMessage ( ) ) ; throw new IllegalStateException ( "Failed to generate ovfenv prop file." ) ; } try { File isoFile = new File ( isoFilePath ) ; String [ ] genISOImageCommand = { GENISO_CMD , "--label" , "CDROM" , "-f" , propFilePath , "-o" , isoFilePath , "ovf-env.properties" , "4096" } ; Exec . Result result = Exec . sudo ( CMD_TIMEOUT , genISOImageCommand ) ; if ( ! result . exitedNormally ( ) || result . getExitValue ( ) != 0 ) { log . error ( "Generating ISO image failed with exit value: {}, error: {}" , result . getExitValue ( ) , result . getStdError ( ) ) ; throw new IllegalStateException ( "Failed to generate ISO image." ) ; } } catch ( Exception e ) { throw e ; } finally { propFile . delete ( ) ; } }
generate ovfenv iso image which will be then saved to ovfenv partition
