#!/usr/bin/env python3
# Copyright (c) 2006-2011 Arista Networks, Inc.  All rights reserved.
# Arista Networks, Inc. Confidential and Proprietary.

import Agent, ElectionMgrAgent, RedSupQueryLib, Cell, sys
import SysdbUtil

serverPort = RedSupQueryLib.defaultServerPort
sysArgvString = ' '.join( sys.argv )
if not '--pyserveripaddr' in sysArgvString: # pylint: disable=unneeded-not
   assert '--pyserverport' not in sysArgvString
   sys.argv.extend( [
      '--pyserveripaddr', '0.0.0.0',
      '--pyserverport', str( serverPort ) ] )
if not '--pyserverinterface' in sysArgvString: # pylint: disable=unneeded-not
   sys.argv.extend( [
      '--pyserverinterface', 'internal%s_1' % Cell.cellId() ] )

ssoStandby = SysdbUtil.onStandbySsoSupervisor()
bypass = not ssoStandby
container = Agent.AgentContainer( [ ElectionMgrAgent.ElectionMgr ],
                                  redundancyStatusProvider=True,
                                  bypassSysdbInit=bypass )

container.addOption( "--mgmntPortId", type=int, action="store", default=1,
                     help="Management port id",
                     agentClass=ElectionMgrAgent.ElectionMgr )
container.addOption( "--mgmntPortType", action="store", default="Management",
                     help="Management interface type",
                     agentClass=ElectionMgrAgent.ElectionMgr )
container.parseOptions()

container.runAgents()

