Java 类com.vmware.vim25.FileTransferInformation 实例源码

项目:jcloud-vsphere    文件:VSphereComputeServiceAdapter.java   
private void waitForPort(VirtualMachine vm, int port, long timeout) {
   GuestOperationsManager gom = serviceInstance.get().getInstance().getGuestOperationsManager();
   GuestAuthManager gam = gom.getAuthManager(vm);
   NamePasswordAuthentication npa = new NamePasswordAuthentication();
   npa.setUsername("root");
   npa.setPassword(vmInitPassword);
   GuestProgramSpec gps = new GuestProgramSpec();
   gps.programPath = "/bin/sh";

   StringBuilder openPortScript = new StringBuilder("netstat -nat | grep LIST | grep -q ':" + port + " ' && touch /tmp/portopen.txt");


   gps.arguments = "-c \"" + openPortScript.toString() + "\"";

   List<String> env = Lists.newArrayList("PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin",
           "SHELL=/bin/bash");

   gps.setEnvVariables(env.toArray(new String[env.size()]));
   GuestProcessManager gpm = gom.getProcessManager(vm);
   try {
      long pid = gpm.startProgramInGuest(npa, gps);

      GuestFileManager guestFileManager = vm.getServerConnection().getServiceInstance().getGuestOperationsManager().getFileManager(vm);
      FileTransferInformation fti = guestFileManager.initiateFileTransferFromGuest(npa, "/tmp/portopen.txt");
      if (fti.getSize() == 0)
         logger.debug(" ");
   } catch (RemoteException e) {
      logger.error(e.getMessage(), e);
      Throwables.propagate(e);
   }
}
项目:vijava    文件:GuestFileManager.java   
public FileTransferInformation initiateFileTransferFromGuest(GuestAuthentication auth, String guestFilePath) throws GuestOperationsFault, InvalidState, TaskInProgress, FileFault, RuntimeFault, RemoteException
{
  return getVimService().initiateFileTransferFromGuest(getMOR(), vm.getMOR(), auth, guestFilePath);  
}