예제 #1
0
  @Override
  public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException {
    List<GuestFileInfo> fileInfos = new ArrayList<GuestFileInfo>();
    int index = 0;
    VsphereConnHandler connHandler = null;
    try {

      connHandler = getConnHandler();

      ManagedObjectReference fileManager = getFileManager(connHandler);
      boolean haveRemaining;
      do {
        GuestListFileInfo res =
            connHandler
                .getClient()
                .getVimPort()
                .listFilesInGuest(fileManager, vm, credentials, getPathInVm(), index, null, null);
        haveRemaining = (res.getRemaining() != 0);

        fileInfos.addAll(res.getFiles());
        index = fileInfos.size();
      } while (haveRemaining);

      String parentPath = PathUtils.removeTrailingSeparator(fileURL.getPath()) + SEPARATOR;

      Collection<AbstractFile> res = new ArrayList<AbstractFile>();
      for (GuestFileInfo f : fileInfos) {
        final String name = getFileName(f.getPath());
        if (name.equals(".") || name.equals("..")) {
          continue;
        }

        FileURL childURL = (FileURL) fileURL.clone();
        childURL.setPath(parentPath + name);

        AbstractFile newFile = new VSphereFile(childURL, this, f);
        res.add(newFile);
      }
      return res.toArray(new AbstractFile[0]);
    } catch (FileFaultFaultMsg e) {
      translateandLogException(e);
    } catch (GuestOperationsFaultFaultMsg e) {
      translateandLogException(e);
    } catch (InvalidStateFaultMsg e) {
      translateandLogException(e);
    } catch (RuntimeFaultFaultMsg e) {
      translateandLogException(e);
    } catch (TaskInProgressFaultMsg e) {
      translateandLogException(e);
    } catch (InvalidPropertyFaultMsg e) {
      translateandLogException(e);
    } catch (URISyntaxException e) {
      translateandLogException(e);
    } finally {
      releaseConnHandler(connHandler);
    }
    // we never get here..
    return null;
  }
예제 #2
0
  @Override
  public AbstractFile getRoot() {
    FileURL rootURL = (FileURL) getURL().clone();
    String rootPath = getRootPath();
    rootURL.setPath("/" + vmIdentifier + "/" + rootPath);

    return FileFactory.getFile(rootURL);
  }
예제 #3
0
  public VSphereFile(FileURL url) throws IOException {
    super(url);
    VsphereConnHandler connHandler = null;
    try {
      setPath(url.getPath());

      connHandler = getConnHandler();
      guestOperationsManager =
          connHandler.getClient().getServiceContent().getGuestOperationsManager();

      getMor(connHandler);
      fixPathInVmIfNeeded(connHandler);

      checkAttributues(connHandler);
    } catch (RuntimeFaultFaultMsg e) {
      translateandLogException(e);
    } catch (FileFaultFaultMsg e) {
      translateandLogException(e);
    } catch (GuestOperationsFaultFaultMsg e) {
      translateandLogException(e);
    } catch (InvalidStateFaultMsg e) {
      translateandLogException(e);
    } catch (TaskInProgressFaultMsg e) {
      translateandLogException(e);
    } catch (InvalidPropertyFaultMsg e) {
      translateandLogException(e);
    } catch (URISyntaxException e) {
      translateandLogException(e);
    } finally {
      releaseConnHandler(connHandler);
    }
  }
예제 #4
0
  public VSphereFile(FileURL url, VSphereFile parent, GuestFileInfo guestFileInfo)
      throws RuntimeFaultFaultMsg, IOException, FileFaultFaultMsg, GuestOperationsFaultFaultMsg,
          InvalidStateFaultMsg, TaskInProgressFaultMsg, InvalidPropertyFaultMsg,
          URISyntaxException {
    super(url);
    setPath(url.getPath());

    this.parent = parent;
    this.vm = parent.vm;
    this.guestOsId = parent.guestOsId;
    this.guestOperationsManager = parent.guestOperationsManager;

    fixPathInVmIfNeeded(null);

    updateAttributes(guestFileInfo);
  }
예제 #5
0
  public VSphereFile(FileURL url, VSphereFile related)
      throws URISyntaxException, IOException, RuntimeFaultFaultMsg, InvalidPropertyFaultMsg,
          FileFaultFaultMsg, GuestOperationsFaultFaultMsg, InvalidStateFaultMsg,
          TaskInProgressFaultMsg {
    super(url);
    setPath(url.getPath());

    this.vm = related.vm;
    this.guestOsId = related.guestOsId;
    this.guestOperationsManager = related.guestOperationsManager;

    fixPathInVmIfNeeded(null);

    VsphereConnHandler connHandler = null;
    try {
      connHandler = getConnHandler();
      checkAttributues(connHandler);
    } finally {
      releaseConnHandler(connHandler);
    }
  }