2013-07-02 17:03:24 -04:00
|
|
|
#!/usr/bin/env python
|
2013-09-13 11:21:12 -05:00
|
|
|
# Copyright 2013 IBM Corporation
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2013-07-02 17:03:24 -04:00
|
|
|
"""
|
|
|
|
@author: Jarrod Johnson <jbjohnso@us.ibm.com>
|
|
|
|
"""
|
2013-09-13 11:21:12 -05:00
|
|
|
|
2013-07-02 17:03:24 -04:00
|
|
|
"""A simple little script to exemplify/test ipmi.console module
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import termios
|
2013-07-16 13:37:09 -04:00
|
|
|
import tty
|
2013-07-02 17:03:24 -04:00
|
|
|
|
2013-08-07 10:01:16 -04:00
|
|
|
from pyghmi.ipmi import console
|
2013-07-02 17:03:24 -04:00
|
|
|
|
|
|
|
tcattr = termios.tcgetattr(sys.stdin)
|
|
|
|
newtcattr = tcattr
|
2013-07-16 13:37:09 -04:00
|
|
|
#TODO(jbjohnso): add our exit handler
|
2013-07-02 17:03:24 -04:00
|
|
|
newtcattr[-1][termios.VINTR] = 0
|
|
|
|
newtcattr[-1][termios.VSUSP] = 0
|
|
|
|
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, newtcattr)
|
|
|
|
|
|
|
|
tty.setcbreak(sys.stdin.fileno())
|
|
|
|
|
|
|
|
passwd = os.environ['IPMIPASSWORD']
|
|
|
|
|
|
|
|
try:
|
|
|
|
sol = console.Console(bmc=sys.argv[1], userid=sys.argv[2], password=passwd,
|
|
|
|
iohandler=(sys.stdin, sys.stdout), force=True)
|
|
|
|
sol.main_loop()
|
|
|
|
finally:
|
|
|
|
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, tcattr)
|