parameters: (self, restorepkt)
return_statement: return bareosfd.bRC_OK
docstring: For the time being, assumes that the virtual disk already
          exists with the same name that has been backed up.
          This should work for restoring the same VM.
          For restoring to a new different VM, additional steps
          must be taken, because the disk path will be different.
docstring_summary: For the time being, assumes that the virtual disk already
          exists with the same name that has been backed up.
          This should work for restoring the same VM.
          For restoring to a new different VM, additional steps
          must be taken, because the disk path will be different.
docstring_tokens: For the time being assumes that the virtual disk already exists with the same name that has been backed up . This should work for restoring the same VM . For restoring to a new different VM additional steps must be taken because the disk path will be different .
function: def create_file(self, restorepkt):
          """
          For the time being, assumes that the virtual disk already
          exists with the same name that has been backed up.
          This should work for restoring the same VM.
          For restoring to a new different VM, additional steps
          must be taken, because the disk path will be different.
          """
          bareosfd.DebugMessage(
              100,
              "BareosFdPluginVMware:create_file() called with %s\n" % (restorepkt),
          )
  
          tmp_path = "/var/tmp/bareos-vmware-plugin"
          if restorepkt.where != "":
              objectname = "/" + os.path.relpath(restorepkt.ofname, restorepkt.where)
          else:
              objectname = restorepkt.ofname
  
          json_filename = tmp_path + objectname + "_cbt.json"
          # for now, restore requires no snapshot to exist so disk to
          # be written must be the the root-disk, even if a manual snapshot
          # existed when the backup was run. So the diskPath in JSON will
          # be set to diskPathRoot
          cbt_data = self.vadp.restore_objects_by_objectname[objectname]["data"]
          cbt_data["DiskParams"]["diskPath"] = cbt_data["DiskParams"]["diskPathRoot"]
          self.vadp.writeStringToFile(json_filename, json.dumps(cbt_data))
          self.cbt_json_local_file_path = json_filename
  
          if self.options.get("localvmdk") == "yes":
              self.vadp.restore_vmdk_file = (
                  restorepkt.where + "/" + cbt_data["DiskParams"]["diskPathRoot"]
              )
              # check if this is the "Full" part of restore, for inc/diff the
              # the restorepkt.ofname has trailing "+I+..." or "+D+..."
              if os.path.basename(self.vadp.restore_vmdk_file) == os.path.basename(
                  restorepkt.ofname
              ):
                  if os.path.exists(self.vadp.restore_vmdk_file):
                      if restorepkt.replace in (bReplace["IFNEWER"], bReplace["IFOLDER"]):
                          bareosfd.JobMessage(
                              bareosfd.M_FATAL,
                              "This Plugin only implements Replace Mode 'Always' or 'Never'\n",
                          )
                          self.vadp.cleanup_tmp_files()
                          return bareosfd.bRC_Error
  
                      if restorepkt.replace == bReplace["NEVER"]:
                          bareosfd.JobMessage(
                              bareosfd.M_FATAL,
                              "File %s exist, but Replace Mode is 'Never'\n"
                              % (StringCodec.encode(self.vadp.restore_vmdk_file)),
                          )
                          self.vadp.cleanup_tmp_files()
                          return bareosfd.bRC_Error
  
                      # Replace Mode is ALWAYS if we get here
                      try:
                          os.unlink(self.vadp.restore_vmdk_file)
                      except OSError as e:
                          bareosfd.JobMessage(
                              bareosfd.M_FATAL,
                              "Error deleting File %s cause: %s\n"
                              % (
                                  StringCodec.encode(self.vadp.restore_vmdk_file),
                                  e.strerror,
                              ),
                          )
                          self.vadp.cleanup_tmp_files()
                          return bareosfd.bRC_Error
  
          if not self.vadp.start_dumper("restore"):
              return bareosfd.bRC_ERROR
  
          if restorepkt.type == bareosfd.FT_REG:
              restorepkt.create_status = bareosfd.CF_EXTRACT
          return bareosfd.bRC_OK
function_tokens: def create_file ( self , restorepkt ) : bareosfd . DebugMessage ( 100 , "BareosFdPluginVMware:create_file() called with %s\n" % ( restorepkt ) , ) tmp_path = "/var/tmp/bareos-vmware-plugin" if restorepkt . where != "" : objectname = "/" + os . path . relpath ( restorepkt . ofname , restorepkt . where ) else : objectname = restorepkt . ofname json_filename = tmp_path + objectname + "_cbt.json" # for now, restore requires no snapshot to exist so disk to # be written must be the the root-disk, even if a manual snapshot # existed when the backup was run. So the diskPath in JSON will # be set to diskPathRoot cbt_data = self . vadp . restore_objects_by_objectname [ objectname ] [ "data" ] cbt_data [ "DiskParams" ] [ "diskPath" ] = cbt_data [ "DiskParams" ] [ "diskPathRoot" ] self . vadp . writeStringToFile ( json_filename , json . dumps ( cbt_data ) ) self . cbt_json_local_file_path = json_filename if self . options . get ( "localvmdk" ) == "yes" : self . vadp . restore_vmdk_file = ( restorepkt . where + "/" + cbt_data [ "DiskParams" ] [ "diskPathRoot" ] ) # check if this is the "Full" part of restore, for inc/diff the # the restorepkt.ofname has trailing "+I+..." or "+D+..." if os . path . basename ( self . vadp . restore_vmdk_file ) == os . path . basename ( restorepkt . ofname ) : if os . path . exists ( self . vadp . restore_vmdk_file ) : if restorepkt . replace in ( bReplace [ "IFNEWER" ] , bReplace [ "IFOLDER" ] ) : bareosfd . JobMessage ( bareosfd . M_FATAL , "This Plugin only implements Replace Mode 'Always' or 'Never'\n" , ) self . vadp . cleanup_tmp_files ( ) return bareosfd . bRC_Error if restorepkt . replace == bReplace [ "NEVER" ] : bareosfd . JobMessage ( bareosfd . M_FATAL , "File %s exist, but Replace Mode is 'Never'\n" % ( StringCodec . encode ( self . vadp . restore_vmdk_file ) ) , ) self . vadp . cleanup_tmp_files ( ) return bareosfd . bRC_Error # Replace Mode is ALWAYS if we get here try : os . unlink ( self . vadp . restore_vmdk_file ) except OSError as e : bareosfd . JobMessage ( bareosfd . M_FATAL , "Error deleting File %s cause: %s\n" % ( StringCodec . encode ( self . vadp . restore_vmdk_file ) , e . strerror , ) , ) self . vadp . cleanup_tmp_files ( ) return bareosfd . bRC_Error if not self . vadp . start_dumper ( "restore" ) : return bareosfd . bRC_ERROR if restorepkt . type == bareosfd . FT_REG : restorepkt . create_status = bareosfd . CF_EXTRACT return bareosfd . bRC_OK