mirror of
https://github.com/Napsty/check_esxi_hardware.git
synced 2024-11-22 02:13:46 +01:00
Remove python2 and pywbem 0.7.0 compatibility
This commit is contained in:
parent
7aaaae4337
commit
e63f9fee6a
122
.github/workflows/python3check.yml
vendored
122
.github/workflows/python3check.yml
vendored
@ -6,109 +6,27 @@ name: Python3 check
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
simple-output:
|
||||
simple-job:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Simple hello world
|
||||
run: echo "Hello World"
|
||||
# python3-pywbem-latest:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# - uses: actions/setup-python@v1
|
||||
# with:
|
||||
# python-version: '3.8'
|
||||
# - name: Install latest pywbem from pip
|
||||
# run: |
|
||||
# sudo apt-get install -qq -yy python3-pip
|
||||
# pip3 install pywbem
|
||||
# - name: Set environment PYTHONPATH
|
||||
# run: |
|
||||
# export PYTHONPATH=/opt/hostedtoolcache/Python/3.8.0/x64/lib/python3.8/site-packages
|
||||
# - name: Verify python sys.path
|
||||
# run: (echo "import sys"; echo "print(', '.join(sys.path))") | python
|
||||
# - name: Launch script with --help
|
||||
# run: |
|
||||
# ./check_esxi_hardware.py --help
|
||||
# python3-pywbem-08:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# - uses: actions/setup-python@v1
|
||||
# with:
|
||||
# python-version: '3.x'
|
||||
# - name: Install latest pywbem from pip
|
||||
# run: |
|
||||
# sudo apt-get install -qq -yy python3-pip
|
||||
# pip3 install pywbem==0.8.4
|
||||
# - name: Set environment PYTHONPATH
|
||||
# run: |
|
||||
# export PYTHONPATH=/opt/hostedtoolcache/Python
|
||||
# - name: Launch script with --help
|
||||
# run: |
|
||||
# ./check_esxi_hardware.py --help
|
||||
# python3-pywbem-012:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# - uses: actions/setup-python@v1
|
||||
# with:
|
||||
# python-version: '3.x'
|
||||
# - name: Install latest pywbem from pip
|
||||
# run: |
|
||||
# sudo apt-get install -qq -yy python3-pip
|
||||
# pip3 install pywbem==0.12.6
|
||||
# - name: Set environment PYTHONPATH
|
||||
# run: |
|
||||
# export PYTHONPATH=/opt/hostedtoolcache/Python
|
||||
# - name: Launch script with --help
|
||||
# run: |
|
||||
# ./check_esxi_hardware.py --help
|
||||
# python3-pywbem-013:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# - uses: actions/setup-python@v1
|
||||
# with:
|
||||
# python-version: '3.x'
|
||||
# - name: Install latest pywbem from pip
|
||||
# run: |
|
||||
# sudo apt-get install -qq -yy python3-pip
|
||||
# pip3 install pywbem==0.13.1
|
||||
# - name: Set environment PYTHONPATH
|
||||
# run: |
|
||||
# export PYTHONPATH=/opt/hostedtoolcache/Python
|
||||
# - name: Launch script with --help
|
||||
# run: |
|
||||
# ./check_esxi_hardware.py --help
|
||||
# python3-pywbem-014:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# - uses: actions/setup-python@v1
|
||||
# with:
|
||||
# python-version: '3.x'
|
||||
# - name: Install latest pywbem from pip
|
||||
# run: |
|
||||
# sudo apt-get install -qq -yy python3-pip
|
||||
# pip3 install pywbem==0.14.6
|
||||
# - name: Set environment PYTHONPATH
|
||||
# run: |
|
||||
# export PYTHONPATH=/opt/hostedtoolcache/Python
|
||||
# - name: Launch script with --help
|
||||
# run: |
|
||||
# ./check_esxi_hardware.py --help
|
||||
# find-pywbem:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# - uses: actions/setup-python@v1
|
||||
# with:
|
||||
# python-version: '3.x'
|
||||
# - name: Install latest pywbem from pip
|
||||
# run: |
|
||||
# sudo apt-get install -qq -yy python-pip
|
||||
# pip install pywbem
|
||||
# - name: Find pywbem module
|
||||
# run: |
|
||||
# find / -name 'pywbem-*'
|
||||
python3-pywbem-latest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: Install latest pywbem from pip
|
||||
run: |
|
||||
sudo apt-get install -qq -yy python3-pip
|
||||
pip3 install pywbem
|
||||
- name: Set environment PYTHONPATH
|
||||
run: |
|
||||
export PYTHONPATH=/opt/hostedtoolcache/Python/3.8.0/x64/lib/python3.8/site-packages:${PYTHONPATH}
|
||||
- name: Verify python sys.path
|
||||
run: (echo "import sys"; echo "print(', '.join(sys.path))") | python
|
||||
- name: Launch script with --help
|
||||
run: |
|
||||
./check_esxi_hardware.py --help
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# Script for checking global health of host running VMware ESX/ESXi
|
||||
@ -22,7 +22,7 @@
|
||||
# Copyright (c) 2008 David Ligeret
|
||||
# Copyright (c) 2009 Joshua Daniel Franklin
|
||||
# Copyright (c) 2010 Branden Schneider
|
||||
# Copyright (c) 2010-2022 Claudio Kuenzler
|
||||
# Copyright (c) 2010-2024 Claudio Kuenzler
|
||||
# Copyright (c) 2010 Samir Ibradzic
|
||||
# Copyright (c) 2010 Aaron Rogers
|
||||
# Copyright (c) 2011 Ludovic Hutin
|
||||
@ -293,17 +293,21 @@
|
||||
#@ Author : Claudio Kuenzler
|
||||
#@ Reason : Fix bug when missing S/N (issue #68)
|
||||
#@---------------------------------------------------
|
||||
#@ Date : 20241025
|
||||
#@ Author : Claudio Kuenzler
|
||||
#@ Reason : Fix pkg_resources deprecation warning
|
||||
# Remove python2 compatibility
|
||||
# Remove pywbem 0.7.0 compatibility
|
||||
#@---------------------------------------------------
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import time
|
||||
import pywbem
|
||||
import re
|
||||
import pkg_resources
|
||||
import json
|
||||
from optparse import OptionParser,OptionGroup
|
||||
|
||||
version = '20221230'
|
||||
version = '20241025'
|
||||
|
||||
NS = 'root/cimv2'
|
||||
hosturl = ''
|
||||
@ -729,29 +733,9 @@ if not get_intrusion:
|
||||
ignore_list.append("System Chassis 1 Chassis Intru: Unknown")
|
||||
|
||||
# connection to host
|
||||
verboseoutput("Connection to "+hosturl)
|
||||
# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
|
||||
try:
|
||||
pywbemversion = pywbem.__version__
|
||||
except:
|
||||
pywbemversion = pkg_resources.get_distribution("pywbem").version
|
||||
else:
|
||||
pywbemversion = pywbem.__version__
|
||||
verboseoutput("Found pywbem version "+pywbemversion)
|
||||
|
||||
if '0.7.' in pywbemversion:
|
||||
try:
|
||||
conntest = pywbem.WBEMConnection(hosturl, (user,password))
|
||||
c = conntest.EnumerateInstances('CIM_Card')
|
||||
except:
|
||||
#raise
|
||||
verboseoutput("Connection error, disable SSL certificate verification (probably patched pywbem)")
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), no_verification=True)
|
||||
else:
|
||||
verboseoutput("Connection worked")
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
|
||||
# pywbem 0.8.0 and later
|
||||
else:
|
||||
verboseoutput("Connection to "+hosturl)
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)
|
||||
|
||||
# Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout.
|
||||
|
Loading…
Reference in New Issue
Block a user