网站优化的主要任务,soho外贸建站,网站后台模板制作流程,建网站找哪家简介#xff1a;浪潮集团#xff0c;是中国本土顶尖的大型IT企业之一#xff0c;中国领先的云计算、大数据服务商。浪潮集团旗下拥有浪潮信息、浪潮软件、浪潮国际#xff0c;业务涵盖云计算、大数据、工业互联网等新一代信息技术产业领域#xff0c;为全球120多个国家和地…简介浪潮集团是中国本土顶尖的大型IT企业之一中国领先的云计算、大数据服务商。浪潮集团旗下拥有浪潮信息、浪潮软件、浪潮国际业务涵盖云计算、大数据、工业互联网等新一代信息技术产业领域为全球120多个国家和地区提供IT产品和服务浪潮致力于成为世界一流的新一代信息技术产业龙头企业经济社会数字化转型的优秀服务商新型基础设施建设的骨干企业。浪潮服务器面向智慧时代所设计以“硬件重构软件定义”技术理念 为云计算、大数据和人工智能提供高度定制化的承载平台适合云数据中心部署环境 赋能各行业的数字化、智慧化转型与重塑。
历史攻略
Pythonrequests BMC 获取和设置服务器风速
Pythonrequests bmc开机、关机、优雅重启、强制重启
从入门到精通IPMITool 的详尽指南
案例源码仅供参考实际请按相关BMC信息配置
# -*- coding: utf-8 -*-
# time: 2023/12/06 15:36
# file: fan.py
# 公众号: 玩转测试开发
import re
import requests
import warningswarnings.filterwarnings(ignore)class Fans(object):headers {content-type: application/json,User-Agent: rMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/117.0.2045.60,}def __init__(self, host, username, password):self.host hostself.username usernameself.password passworddef get_random(self):url fhttps://{self.host}/api/randomtagres requests.get(url, headersself.headers, verifyFalse)return res.json()[random]def get_session(self, random_string):url fhttps://{self.host}/api/sessionself.headers[content-type] application/x-www-form-urlencoded; charsetUTF-8data {encrypt_flag: 0,username: self.username,password: self.password,login_tag: str(random_string)}response requests.post(url, headersself.headers, datadata, verifyFalse)token re.findall(QSESSIONID(.*?);, response.headers[Set-Cookie])[0]self.headers[X-Csrftoken] response.json()[CSRFToken]self.headers[Cookie] str(langzh-cn;QSESSIONID token ; refresh_disable1)self.headers[content-type] application/jsondef get_fans(self):url fhttps://{self.host}/api/status/fan_inforesponse requests.get(url, headersself.headers, verifyFalse).json()for k, v in response.items():if k fans:for i in v:print(i)def fans_mode(self, modemanual):url fhttps://{self.host}/api/settings/fans-mode# manual - autodata {control_mode: mode}response requests.put(url, headersself.headers, jsondata, verifyFalse)print(response:, response.text)def change_fans(self, rate100, fans24):for i in range(fans):url fhttps://{self.host}/api/settings/fan/{i}data {duty: rate}response requests.put(urlurl, jsondata, verifyFalse, headersself.headers)response.encoding utf-8print(fThe index {i} fan change to {response.json()[duty]} %, )if __name__ __main__:# e.g.bmc_host 111.1112.113.114username adminpassword 123456789f Fans(hostbmc_host, usernameusername, passwordpassword)random_string f.get_random()f.get_session(random_string)f.get_fans()f.fans_mode()f.change_fans(rate100, fans24)运行结果 注意事项
1、慎重起见请先进行抓包解析 http 网络接口数据调试再使用。 2、设置时需要先自动挡改成手动档详见方法 fans_mode()