#!/usr/bin/env python
# Copyright (c) 2006 Arastra, Inc.  All rights reserved.
# Arastra, Inc. Confidential and Proprietary.

from __future__ import absolute_import
import Tac, Agent, os, SysdbUtil

def main():
   import Fru.Agent

   tfm = Tac.singleton( 'Tac::TraceFacilityMan' )
   debugTrace = 'Fru.*/0-2,Fru.ModularSystem/9,Fru.Dep/9'
   if 'TRACE' in os.environ.keys():
      os.environ[ 'TRACE' ] += ',' + debugTrace
   else:
      os.environ[ 'TRACE' ] = debugTrace
   tfm.doReadEnvironment()

   # BUG66587: Use longer timeout when waiting for Fru to be mounted on standby 
   # Sysdb since we need to account for active Sysdb initialization time.
   if SysdbUtil.onStandbySsoSupervisor():
      startupWaitTime = SysdbUtil.standbyConnectionTimeout
   else:
      startupWaitTime = None
   container = Agent.AgentContainer( [ Fru.Agent.Fru ], passiveMount=True,
                                     startupWaitTime=startupWaitTime )

   container.addOption( "-f", "--fdlFile", action="store",
                        help="Path to the system fdl file (default %default)",
                        default='/etc/fdl',
                        agentClass=Fru.Agent.Fru )
   container.addOption( "", "--fdlFileMustExist", action="store_true",
                        help="Whether the fdl file can be non-existent",
                        agentClass=Fru.Agent.Fru )

   # Like all agents, Fru waits for Sysdb to initialize.  This means that
   # LoadConfig runs to completion before Fru, so Cli plugins must not
   # depend on state populated by Fru to do their jobs.
   container.runAgents( )

if __name__ == "__main__":
   main()
