OpenShiftHosts - file /root/.config/openshift/hosts

OpenShiftHosts file is /root/.config/openshift/hosts which records nodes information. While installing openshift cluster , this installation process would read this file, and install relative rpms on every node according to the configuration.

class insights.parsers.openshift_hosts.OpenShiftHosts(context)[source]

Bases: Parser, LegacyItemAccess

Class OpenShiftHosts parses the content of the /root/.config/openshift/hosts` file. A small sample of the content of this file looks like:

[OSEv3:children]
nodes
nfs
masters
etcd
[OSEv3:vars]
openshift_master_cluster_public_hostname=None
ansible_ssh_user=root
openshift_master_cluster_hostname=None
openshift_hostname_check=false
deployment_type=openshift-enterprise
[nodes]
master.ose35.com  openshift_public_ip=192.66.208.202 openshift_ip=192.66.208.202 openshift_public_hostname=master.ose35.com openshift_hostname=master.ose35.com connect_to=master.ose35.com openshift_schedulable=False ansible_connection=local
node1.ose35.com  openshift_public_ip=192.66.208.169 openshift_ip=192.66.208.169 openshift_public_hostname=node1.ose35.com openshift_hostname=node1.ose35.com connect_to=node1.ose35.com openshift_node_labels="{'region': 'infra'}" openshift_schedulable=True
node2.ose35.com  openshift_public_ip=192.66.208.170 openshift_ip=192.66.208.170 openshift_public_hostname=node2.ose35.com openshift_hostname=node2.ose35.com connect_to=node2.ose35.com openshift_node_labels="{'region': 'infra'}" openshift_schedulable=True
[nfs]
master.ose35.com  openshift_public_ip=192.66.208.202 openshift_ip=192.66.208.202 openshift_public_hostname=master.ose35.com openshift_hostname=master.ose35.com connect_to=master.ose35.com ansible_connection=local
[masters]
master.ose35.com  openshift_public_ip=192.66.208.202 openshift_ip=192.66.208.202 openshift_public_hostname=master.ose35.com openshift_hostname=master.ose35.com connect_to=master.ose35.com ansible_connection=local
[etcd]
master.ose35.com  openshift_public_ip=192.66.208.202 openshift_ip=192.66.208.202 openshift_public_hostname=master.ose35.com openshift_hostname=master.ose35.com connect_to=master.ose35.com ansible_connection=local

Examples

>>> type(host_info)
<class 'insights.parsers.openshift_hosts.OpenShiftHosts'>
>>> host_info["OSEv3:children"]
["nodes","nfs","masters","etcd"]
>>> host_info["nodes"]["master.ose35.com"]["openshift_public_ip"]
"192.66.208.202"
>>> host_info["nodes"]["master.ose35.com"]["openshift_node_labels"]
"{'region': 'infra'}"
>>> host_info.has_node("node1.ose35.com")
True
>>> host_info.has_var("openshift_use_crio")
False
has_node(node)[source]

Indicate whether the named node is present in the configuration. Return True if the given node name is present, and False if not present.

has_node_type(node_type)[source]

Indicate whether the named node type is present in the configuration. Return True if the given node type is present, and False if not present.

has_var(var)[source]

Indicate whether the named var is present in the configuration. Return True if the given var is present, and False if not present.

parse_content(content)[source]

This method must be implemented by classes based on this class.