Skip to content

ISPLAT-13588: RedHat CoreOS POC - Initial commit #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions os-discovery-tool/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu

# Install necessary packages
RUN apt-get update && \
apt-get update --fix-missing && \
apt-get install -y lshw kmod hwinfo pciutils && \
apt-get clean

# Create a volume for the code
VOLUME /app

# Copy the HCL Scripts to collect driver information
COPY ./netdriver.sh /app/
COPY ./rhcosdockernetversions.sh /app/
COPY ./netdev.sh /app/
COPY ./storagedriver.sh /app/
COPY ./storagedev.sh /app/
COPY ./storagedevnames.sh /app/

# Set the working directory
WORKDIR /app
26 changes: 24 additions & 2 deletions os-discovery-tool/get_linux_inv_to_intersight.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OsType:
"""This class broadly identifies OS categories."""
SUSE = ["Suse", "Sles"]
DEBIAN = ["Ubuntu"]
REDHAT = ["Red Hat", "Rhel", "Centos", "Rocky"]
REDHAT = ["Red Hat", "Rhel", "Centos", "Rocky", "Rhcos"]
ORACLE = ["ol"]


Expand Down Expand Up @@ -372,6 +372,9 @@ def get_os_inv(self):
elif os_vendor == "Rocky":
os_name = self.invoke_shell(
ExecType.SCRIPT, QueryType.OS, "rocky-os-name.sh")
elif os_vendor == "Rhcos":
os_name = self.invoke_shell(
ExecType.SCRIPT, QueryType.OS, "rhcos-os-name.sh")
else:
os_name = self.invoke_shell(
ExecType.SCRIPT, QueryType.OS, "redhat-os-name.sh")
Expand All @@ -389,8 +392,9 @@ def get_os_inv(self):
ExecType.SCRIPT,
QueryType.OS,
"centos-os-name-legacy.sh")
self.os_name = os_name

if os_vendor == "Rhel":
if os_vendor in ["Rhel", "Rhcos"]:
os_vendor = "Red Hat"
elif os_vendor == "Centos":
os_vendor = "CentOS"
Expand Down Expand Up @@ -424,6 +428,15 @@ def __init__(self, hostname, os_type, host_type, os_collection):
self.host_type = host_type
self.os_collection = os_collection

def get_storage_driver_args(self, storageNames):
names = []
output = ''
for name in storageNames:
if name and name not in names:
names.append(name)
output += '"{0} "'.format(name)
return output

def get_driver_inv(self):
"""Collect device and driver data."""
kernel_version = ""
Expand Down Expand Up @@ -467,6 +480,15 @@ def get_driver_inv(self):
QueryType.DRIVER, "suse-storageversions.sh")
descriptions += self.invoke_shell(ExecType.SCRIPT,
QueryType.DRIVER, "suse-storagedev.sh")
elif self.os_type == OsType.REDHAT and "coreos" in os_name.lower():
drivers = self.invoke_shell(ExecType.SCRIPT, QueryType.DRIVER, "rhcosnetdriver.sh")
versions = self.invoke_shell(ExecType.SCRIPT, QueryType.DRIVER, "rhcosnetversions.sh")
descriptions = self.invoke_shell(ExecType.SCRIPT, QueryType.DRIVER, "rhcosnetdev.sh")
drivers += self.invoke_shell(ExecType.SCRIPT, QueryType.DRIVER, "rhcosstoragedriver.sh")
descriptions += self.invoke_shell(ExecType.SCRIPT, QueryType.DRIVER, "rhcosstoragedev.sh")
storagenames = self.invoke_shell(ExecType.SCRIPT, QueryType.DRIVER, "rhcosstoragedevnames.sh")
storagenameasargs = self.get_storage_driver_args(storagenames)
versions += self.invoke_shell(ExecType.SCRIPT, QueryType.DRIVER, "rhcosstoragedevversion.sh " + storagenameasargs)
else:
drivers = self.invoke_shell(
ExecType.SCRIPT, QueryType.DRIVER, "netdriver.sh")
Expand Down
Empty file modified os-discovery-tool/netdev.sh
100644 → 100755
Empty file.
Empty file modified os-discovery-tool/netdriver.sh
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions os-discovery-tool/rhcos-os-name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
cat /etc/redhat-release | awk '{print $1" "$2" "$3" "$4" "$5" "$7}'
25 changes: 25 additions & 0 deletions os-discovery-tool/rhcosdockernetversions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
export PATH=$PATH:/sbin:/usr/sbin
lshwcmd=`which lshw`
lspcicmd=`which lspci`
modinfocmd=`which modinfo`
enicdrivername="enic"
for pciaddress in $(${lshwcmd} -C Network 2>/dev/null | grep "pci@" | awk -F":" '{print $3":"$4}');
do
drivername=`${lspcicmd} -v -s $pciaddress | grep "Kernel driver" | awk -F":" '{print $2}'`
if [[ $drivername == *"$enicdrivername"* ]]
then
kernalversion=`uname -r`
echo ${kernalversion%.*}
else
versionstring=`${lspcicmd} -v -s $pciaddress | grep "Kernel driver" | \
awk -F":" '{print $2}' | xargs ${modinfocmd} 2>/dev/null | grep ^version: | head -n1 | awk '{print $2}' | xargs`
if [ -z "${versionstring}" ]
then
echo `${lspcicmd} -v -s $pciaddress | grep "Kernel driver" | awk -F":" '{print $2}' | \
xargs ${modinfocmd} 2>/dev/null | grep ^vermagic: | awk '{print $2}'`
else
echo ${versionstring}
fi
fi
done
2 changes: 2 additions & 0 deletions os-discovery-tool/rhcosnetdev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
podman run --rm --privileged hcltools:v1 /app/netdev.sh
2 changes: 2 additions & 0 deletions os-discovery-tool/rhcosnetdriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
podman run --rm --privileged hcltools:v1 /app/netdriver.sh
2 changes: 2 additions & 0 deletions os-discovery-tool/rhcosnetversions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
podman run --rm --privileged hcltools:v1 /app/rhcosdockernetversions.sh
2 changes: 2 additions & 0 deletions os-discovery-tool/rhcosstoragedev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
podman run --rm --privileged hcltools:v1 /app/storagedev.sh
2 changes: 2 additions & 0 deletions os-discovery-tool/rhcosstoragedevnames.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
podman run --rm --privileged hcltools:v1 /app/storagedevnames.sh
7 changes: 7 additions & 0 deletions os-discovery-tool/rhcosstoragedevversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
export PATH=$PATH:/sbin:/usr/sbin
modinfocmd=`which modinfo`
for var in "$@"
do
${modinfocmd} ${var} 2>/dev/null| grep -i "version" | head -n1 | awk '{print $2}'
done
2 changes: 2 additions & 0 deletions os-discovery-tool/rhcosstoragedriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
podman run --rm --privileged hcltools:v1 /app/storagedriver.sh
Empty file modified os-discovery-tool/storagedev.sh
100644 → 100755
Empty file.
9 changes: 9 additions & 0 deletions os-discovery-tool/storagedevnames.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
export PATH=$PATH:/sbin:/usr/sbin
lshwcmd=`which lshw`
lspcicmd=`which lspci`
modinfocmd=`which modinfo`
for pciaddress in $(${lshwcmd} -C Storage 2>/dev/null | grep "pci@" | awk -F":" '{print $3":"$4}');
do
${lspcicmd} -v -s ${pciaddress} | grep "Kernel driver" | awk -F":" '{print $2}' | xargs;
done
Empty file modified os-discovery-tool/storagedriver.sh
100644 → 100755
Empty file.