Code:
port2_result=os.popen('ipmitool raw 0x3a 0x11 0x2a 0x6f 0x00 8').read()
Code:
def SSH (user,host,PROMPT) :
os.system('rm -f /root/.ssh/known_hosts')
SSHd = 'ssh '+user+'@'+host
ssh_obj = pexpect.spawn(SSHd)
try :
ssh_obj.logfile=None;
ssh_obj.expect('\(yes\/no\)\?',timeout=50)
ssh_obj.sendline('yes')
except :
print "Unable to login to "+host
sys.exit(3)
try:
ssh_obj.expect(PROMPT,timeout=50)
except:
print "Unable to login to "+host
sys.exit(3)
try:
ssh_obj.sendline('XYZ')
ssh_obj.expect('found',timeout=10)
ssh_obj.sendline('PS1="RTM_SHOW>"')
ret=ssh_obj.expect(['RTM_SHOW>','#'],timeout=5)
if ret == 1:
ssh_obj.expect('RTM_SHOW>',timeout=5)
except:
print "Unable to change Prompt"
sys.exit(3)
ssh_obj.logfile=sys.stdout;
return ssh_obj
Code:
if node != host :
print "YES",
try:
local=SSH("root",node,'#')
local.logfile=sys.stdout
except:
print "unable to do SSH."
try:
# reg=re.compile(r'^\s\d.+')
reg=re.compile('.*')
print "cmdsend"
local.sendline('ipmitool raw 0x3a 0x11 0x2a 0x6f 0x00 7')
ret=local.expect([reg,'RTM_SHOW>'],timeout=15)
if ret == 0:
port1_result=local.match.group()
print "my",port1_result
else:
sys.exit(1)
port2_result = os.popen('ipmitool raw 0x3a 0x11 0x2a 0x6f 0x00 8').read()
parse_output(port1_result,port2_result)
except:
print "error EXECUTING ssh commands."