예제 #1
0
 private void teardownAuthTokenFile() {
   if (authTokenFile != null)
     try {
       authTokenFile.delete();
     } catch (WindowsException ex) {
       logger.warning(Strings.get("cant.delete", dcomInfo.getHost(), authTokenFilePath));
     }
 }
예제 #2
0
  /* hack TODO do not know how to get int status back from Windows
   * Stick in code that handles particular commands that we can figure out
   * the status.
   */
  private int determineStatus(List<String> args) {
    if (args == null) throw new NullPointerException();

    if (args.size() < 2) return 0;

    String instanceName = args.get(args.size() - 1);

    if (isCommand(args, "_delete-instance-filesystem")) {
      try {
        String dir = Paths.getInstanceDirPath(node, instanceName);
        WindowsRemoteFile instanceDir = new WindowsRemoteFile(dcomInfo.getCredentials(), dir);
        return instanceDir.exists() ? 1 : 0;
      } catch (WindowsException ex) {
        return 0;
      }
    } else if (isCommand(args, "_create-instance-filesystem")) {
      try {
        String dir = Paths.getDasPropsPath(node);
        WindowsRemoteFile dasProps = new WindowsRemoteFile(dcomInfo.getCredentials(), dir);

        if (dasProps.exists()) return 0;

        // uh-oh.  Wipe out the instance directory that was created
        dir = Paths.getInstanceDirPath(node, instanceName);
        WindowsRemoteFile instanceDir = new WindowsRemoteFile(dcomInfo.getCredentials(), dir);
        instanceDir.delete();
        return 1;
      } catch (WindowsException ex) {
        return 1;
      }
    }
    return 0;
  }
예제 #3
0
  /*
   * BE CAREFUL -- Don't introduce "Distributed Concurrency Bugs"
   * e.g. you have to make sure the filename is unique.
   * 1. create a remote file
   * 2. copy the token/auth stuff into it
   * 3. add the correct args to the remote commandline
   *    Put the file in the same directory that nadmin lives in (lib)
   */
  private void setupAuthTokenFile(List<String> cmd, List<String> stdin) throws WindowsException {
    WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(dcomInfo.getCredentials());
    authTokenFilePath =
        dcomInfo.getNadminParentPath()
            + "\\token_"
            + System.nanoTime()
            + new Random().nextInt(1000);
    authTokenFilePath = createUniqueFilename(dcomInfo.getNadminParentPath());
    authTokenFile = new WindowsRemoteFile(wrfs, authTokenFilePath);
    authTokenFile.copyFrom(stdin);

    cmd.add(AsadminInput.CLI_INPUT_OPTION);
    cmd.add(authTokenFilePath);
  }