#! /usr/bin/python3

# ve-os-launcher
# Copyright (C) 2017-2018 NEC Corporation
# This file is part of VE system initialization
#
# VE system initialization is free software; you can redistribute it and/or 
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# VE system initialization is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with VE system initialization; if not, see
# <http://www.gnu.org/licenses/>

'''
This script monitors os_state of the VE node specified by
the argument as follows:
  ve-os-state-monitor 0
starts VE OS for VE#0.
'''
import sys
sys.path.append('/opt/nec/ve/veos/lib/python3.12/site-packages')
import veosstatemon

CONF_DIR = '/etc/opt/nec/ve/veos/ve-os-state-monitor.d'
CONF_DIR_NODE_FMT = CONF_DIR + '/%d'

def main():
    if len(sys.argv) != 2:
        sys.exit("Usage: %s VE#" % sys.argv[0])

    vedev = int(sys.argv[1])
    options_dirs = [CONF_DIR, CONF_DIR_NODE_FMT % vedev]
    veosstatemon.start(vedev, options_dirs)

if __name__ == "__main__":
    main()
