def invokeCommands()

in scripts/yapl/S3Helper.py [0:0]


  def invokeCommands(self, cmdDocs, start, **kwargs):
    """
      Process command docs to invoke each command in sequence that is of kind s3.  

      Processing of cmdDocs stops as soon as a doc kind that is not s3 is encountered.

      All cmdDocs that are processed are marked with a status attribute with the value PROCESSED.
             
      cmdDocs - a list of 1 or more YAML documents loaded from yaml.load_all()
      by the caller.
      
      start - index where to start processing in the cmdDocs list.
      
      NOTE: The method for each command is responsible for pulling out the arguments for the 
      underlying S3 method.  The S3 client methods only accept the arguments in the signature.
      Extraneous keyword arguments cause an exception to be raised.
    """
    if (not cmdDocs):
      raise MissingArgumentException("A non-empty list of command documents (cmdDocs) must be provided.")
    #endIf

    for i in range(start,len(cmdDocs)):
      doc = cmdDocs[i]
      
      kind = doc.get('kind')
      if (not kind or kind != 's3'): break; # done
      
      command = doc.get('command')
      if (not command):
        raise InvalidArgumentException("A helm command document: %s, must have a command attribute." % doc)
      #endIf
      
      getattr(self,command)(**doc)
      
      doc['status'] = 'PROCESSED'