代码拉取完成,页面将自动刷新
from cmd import Cmd
from cmd import Ssh
class Ipmi(Cmd):
def __init__(self, ip, username, passwd):
super().__init__()
self.ip = ip
self.username = username
self.passwd = passwd
self.ssh = None
def charTohex(self, char):
h = "0x{:x}".format(ord(char))
return h
def getHex(self, chassis):
l = [self.charTohex(char) for char in chassis]
h = " ".join(l)
return h
def setSsh(self, ssh: Ssh):
self.ssh = ssh
def chassisFlash(self, chassis):
h = self.getHex(chassis)
ipmicmd1 = "ipmitool raw 0x0e 0x52 0x0b 0xa8 00 00 0x10 {chassis} 00".format(
chassis=h)
ipmicmd2 = "ipmitool raw 0x0e 0x52 0x0b 0xa8 00 00 0x20 00 00 00 00"
ipmicmd3 = "ipmitool raw 0x0e 0x52 0x0b 0xa8 0x14 00 0x10"
self.ssh.ssh(ipmicmd1)
self.ssh.ssh(ipmicmd2)
self.ssh.ssh(ipmicmd3)
def reboot(self):
self.ssh.ssh("ipmitool raw 6 2")
if __name__ == "__main__": # test
c = Ipmi("172.17.0.193", "admin", "admin")
s = Ssh("172.17.0.62", "root", "1")
c.setSsh(s)
c.chassisFlash("TG658-E12Q05")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。