if __name__ == "__main__":
# When running on the server locally use the following commented values
# iLO_https_url = "blobstore://."
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError as excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception as excp:
raise excp
ex4_reset_server(REDFISH_OBJ)
REDFISH_OBJ.redfish_client.logout()
上面是我写的脚本的“登录”部分。在这部分REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
中,我想用一个变量替换iLO_https_url
,该变量的值将从一个简单的CSV文件中提取。CSV将有3列…ip,username,pwd。你知道吗
我试图在CSV文件的每个IP上执行脚本的另一部分,这里没有显示。我需要用python来做这个。你知道吗
最简单的方法是将open()函数与split()函数一起使用。你知道吗
尝试以下操作: 你知道吗
with open("data.csv", encoding="utf-8") as csv_file: iLO_account, iLO_password, iLO_https_url = csv_file.readline().split(",")
如果要用换行符分隔条目,只需将
","
替换为"\n"
相关问题 更多 >
编程相关推荐