-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrhui-check.py
executable file
·52 lines (46 loc) · 1.31 KB
/
rhui-check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3
"""This script will perform an instance repository check and attempt
to fix any issues which prevent the instance from installing packages
from yum repositories """
import argparse
import datetime
import json
import logging
import os
import re
import requests
import shlex
import shutil
import socket
import subprocess
import sys
import time
import urllib.error
import urllib.request
from requests.packages import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
VERSION = "1.0.0"
SCRIPT_NAME = "rhui-checks"
def get_framework():
"""Check which public cloud framework script is running in"""
cmd = ["dmidecode"]
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
except subprocess.CalledProcessError as e:
logging.error("dmidecode error: %s" % e)
sys.exit()
except FileNotFoundError:
logging.error("dmidecode binary not found.")
sys.exit()
else:
dmidecode_output = str(proc.stdout.read().lower())
if "microsoft" in dmidecode_output:
framework = "azure"
elif "amazon" in dmidecode_output:
framework = "ec2"
elif "google" in dmidecode_output:
framework = "gce"
else:
logging.error("No supported framework. Quitting.")
sys.exit()
return framework