public void validate(NodeConfig node,String puppetMasterNodeDns) throws IOException {
  Command validateSudoRightsCommand=getValidateSudoRightsCommand(node);
  try {
    validateSudoRightsCommand.execute();
  }
 catch (  IOException e) {
    String errorMessage=e.getMessage();
    if (e.getCause() instanceof AgentException) {
      errorMessage=format("It seems user doesn't have sudo rights without password on node '%s'.",node.getHost());
    }
    throw new NodeException(errorMessage,e);
  }
  try {
    Command validatePuppetMasterAccessibilityCommand=getValidatePuppetMasterAccessibilityCommand(puppetMasterNodeDns,node);
    validatePuppetMasterAccessibilityCommand.execute();
  }
 catch (  IOException e) {
    String errorMessage=e.getMessage();
    if (e.getCause() instanceof AgentException) {
      errorMessage=format("It seems Puppet Master '%s:%s' is not accessible from the node '%s'",puppetMasterNodeDns,8140,node.getHost());
    }
    throw new NodeException(errorMessage,e);
  }
}

public void validate ( NodeConfig node , String puppetMasterNodeDns ) throws IOException { Command validateSudoRightsCommand = getValidateSudoRightsCommand ( node ) ; try { validateSudoRightsCommand . execute ( ) ; } catch ( IOException e ) { String errorMessage = e . getMessage ( ) ; if ( e . getCause ( ) instanceof AgentException ) { errorMessage = format ( "It seems user doesn't have sudo rights without password on node '%s'." , node . getHost ( ) ) ; } throw new NodeException ( errorMessage , e ) ; } try { Command validatePuppetMasterAccessibilityCommand = getValidatePuppetMasterAccessibilityCommand ( puppetMasterNodeDns , node ) ; validatePuppetMasterAccessibilityCommand . execute ( ) ; } catch ( IOException e ) { String errorMessage = e . getMessage ( ) ; if ( e . getCause ( ) instanceof AgentException ) { errorMessage = format ( "It seems Puppet Master '%s:%s' is not accessible from the node '%s'" , puppetMasterNodeDns , 8140 , node . getHost ( ) ) ; } throw new NodeException ( errorMessage , e ) ; } }
check if node is accessible and user on the node has sudo rights , and node is able to communicate with puppet master .
