#!/usr/bin/python3.11

# Copyright (C) 2010 Novell, Inc. All rights reserved.
#
# This work is subject to U.S. and international copyright laws and treaties.
# No part of this work may be used, practiced, performed, copied, distributed,
# revised, modified, translated, abridged, condensed, expanded, collected,
# compiled, linked, recast, transformed or adapted without the prior written
# consent of Novell, Inc. Any use or exploitation of this work without authorization
# could subject the perpetrator to criminal and civil liability.

import os
import sys
sys.path.append( "/opt/novell/ncs/bin" )
import clstrlibss

def usage():
    sys.stderr.write( "Usage: " + os.path.basename( sys.argv[0] ) + " username password\n" )

#############################################################################
#
# Function: main
#
# Returns: Nothing.   
#
# Comments:
#
def main(argv):

    if 1 > len( argv ):
        usage()
        rc = 22
    else:
        ss = clstrlibss.load()
        ss.adminDn = argv[0]
        if 2 > len( argv ):
            ss.adminPw = os.getenv( "OES_NCS_DATA" )
        else:
            ss.adminPw = argv[1]

        try: 
            clstrlibss.save(ss)
            rc = 0
        except:
            rc = 5

    sys.exit(rc)


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))

