コード例 #1
0
ファイル: entry.py プロジェクト: jashook/ev6
def vmware_post_run(_VirtualMachine):

   if _VirtualMachine._m_startup_file != None:

      _Command = "sudo vmrun -T ws snapshot " + "\"" + _VirtualMachine._m_directory + _VirtualMachine._m_config_file + "\"" + " NewMachineSnapShot2"

      print "Creating Snapshot"

      os.system(_Command)

      time.sleep(15) # make sure the snapshot finishes before starting

      _Vmdk = vm_util.find_last_snapshot(_VirtualMachine)

      _Command = "sudo cp " + "\"" + _VirtualMachine._m_directory + _Vmdk + "\"" + " " + "\"" + _VirtualMachine._m_collection + "\""
      print _Command

      os.system(_Command)

      print "Deleting snapshot"

      _Command = "sudo vmrun -T ws deleteSnapshot " + "\"" + _VirtualMachine._m_directory + _VirtualMachine._m_config_file + "\"" + " NewMachineSnapshot2"

      os.system(_Command)

      time.sleep(20)

      vm_util.mount_vmdk(_VirtualMachine, 3, _VirtualMachine._m_mount_directory)

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "pictures" "\"" + " "+ "\"" + _VirtualMachine._m_collection + "/pictures" + "\""
      
      print _Command

      os.system(_Command)

      time.sleep(.1)

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "pcaps" "\"" + " "+ "\"" + _VirtualMachine._m_collection + "/pcaps" + "\""
      print _Command

      os.system(_Command)

      time.sleep(.1)

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "cookies" "\"" + " "+ "\"" + _VirtualMachine._m_collection + "/cookies" + "\""
      print _Command

      os.system(_Command)

      time.sleep(.1)

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "source" "\"" + " "+ "\"" + _VirtualMachine._m_collection + "/source" + "\""
      print _Command

      os.system(_Command)

      time.sleep(5)

      vm_util.umount_vmdk(_VirtualMachine, _VirtualMachine._m_mount_directory)
コード例 #2
0
def vmware_post_run(_VirtualMachine):

   if _VirtualMachine._m_snap_shot:

      #####################################################
      # Logic:
      #
      # Create a new Snapshot
      # Copy it to the output destination
      # delete the Snapshot so it looks like it was never made.
      #####################################################

      if os.environ.get('OS','') == 'Windows_NT':

         ############################################
         # Win32 Support
         ############################################

         _Command = "vmrun -T ws snapshot " + "\"" + _VirtualMachine._m_directory + _VirtualMachine._m_config_file + "\"" + " NewMachineSnapShot2"

      else:

         _Command = "sudo vmrun -T ws snapshot " + "\"" + _VirtualMachine._m_directory + _VirtualMachine._m_config_file + "\"" + " NewMachineSnapShot2"

      print "Creating Snapshot"

      os.system(_Command)

      time.sleep(15) # make sure the snapshot finishes before starting

      _Vmdk = vm_util.find_last_snapshot(_VirtualMachine)

      if os.environ.get('OS','') == 'Windows_NT':

         ############################################
         # Win32 Support
         ############################################

         _Command = "copy " + "\"" + _VirtualMachine._m_directory + _Vmdk + "\"" + " " + "\"" + _VirtualMachine._m_collection + "\""

      else:

         _Command = "sudo cp " + "\"" + _VirtualMachine._m_directory + _Vmdk + "\"" + " " + "\"" + _VirtualMachine._m_collection + "\""

      print _Command

      os.system(_Command)

      print "Deleting snapshot"

      if os.environ.get('OS','') == 'Windows_NT':

         ############################################
         # Win32 Support
         ############################################

         _Command = "vmrun -T ws deleteSnapshot " + "\"" + _VirtualMachine._m_directory + _VirtualMachine._m_config_file + "\"" + " NewMachineSnapshot2"

      else:

         _Command = "sudo vmrun -T ws deleteSnapshot " + "\"" + _VirtualMachine._m_directory + _VirtualMachine._m_config_file + "\"" + " NewMachineSnapshot2"

      os.system(_Command)

      time.sleep(20) # make sure there is enough time for the snapshot to be deleted

   ########################################################
   # Mount the third partition, which contains output data
   # Check the User Manual for a reference to VM partitions
   ########################################################

   vm_util.mount_vmdk(_VirtualMachine, 3, _VirtualMachine._m_mount_directory)

   ########################################################
   # sudo cp -r <directory of mounted VM filesystem>/* <directory of output>
   ########################################################

   if os.environ.get('OS','') == 'Windows_NT':

      ############################################
      # Win32 Support
      ############################################

      _Command = "copy " + "\"" + _VirtualMachine._m_mount_directory + "pcaps" + "\"" + " " +"\"" + _VirtualMachine._m_collection + "/" + "\""

   else:

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "pcaps" + "\"" + " " +"\"" + _VirtualMachine._m_collection + "/" + "\""
      
   print _Command

   os.system(_Command)

   if os.environ.get('OS','') == 'Windows_NT':

      ############################################
      # Win32 Support
      ############################################

      _Command = "copy " + "\"" + _VirtualMachine._m_mount_directory + "cookies" + "\"" + " " + "\"" + _VirtualMachine._m_collection + "/" + "\""

   else:

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "cookies" + "\"" + " " + "\"" + _VirtualMachine._m_collection + "/" + "\""
      
   print _Command

   os.system(_Command)

   
   if os.environ.get('OS','') == 'Windows_NT':

      ############################################
      # Win32 Support
      ############################################

      _Command = "copy " + "\"" + _VirtualMachine._m_mount_directory + "pictures" + "\"" + " " + "\"" + _VirtualMachine._m_collection + "/" + "\""

   else:

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "pictures" + "\"" + " " + "\"" + _VirtualMachine._m_collection + "/" + "\""
      
   print _Command

   os.system(_Command)

   if os.environ.get('OS','') == 'Windows_NT':

      ############################################
      # Win32 Support
      ############################################

      _Command = "copy " + "\"" + _VirtualMachine._m_mount_directory + "source" + "\"" + " " +"\"" + _VirtualMachine._m_collection + "/" + "\""

   else:

      _Command = "sudo cp -r " + "\"" + _VirtualMachine._m_mount_directory + "source" + "\"" + " " +"\"" + _VirtualMachine._m_collection + "/" + "\""
      
   print _Command

   os.system(_Command)

   time.sleep(5)

   ########################################################
   # Unmount the partition and return to continue execution
   ########################################################

   vm_util.umount_vmdk(_VirtualMachine, _VirtualMachine._m_mount_directory)