[Podified] Recognition of the compute/networker/other edpm nodes
With this patch Tobiko can recognize edpm nodes and put it in one of the following groups: - edpm-compute - nodes which have "nova" or "nova-custom" service defined in OpenStackDataplaneNodeset, - edpm-networker - nodes which have "ovn" but don't have "nova" nor "nova-custom" service defined in OpenStackDataplaneNodeset, - edpm-other - every node which don't fit into any of the groups above. All edpm nodes discovered in the environment are also placed in "legacy" group called "compute". Related-Jira: #OSP-22166 Change-Id: I64c4099e3e04df49b090f93a14f95e5fa6b74189
This commit is contained in:
@@ -24,6 +24,13 @@ OSP_CONTROLPLANE = 'openstackcontrolplane'
|
||||
OSP_DP_NODESET = 'openstackdataplanenodeset'
|
||||
DP_SSH_SECRET_NAME = 'secret/dataplane-ansible-ssh-private-key-secret'
|
||||
|
||||
OVN_DP_SERVICE_NAME = 'ovn'
|
||||
COMPUTE_DP_SERVICE_NAMES = ['nova', 'nova-custom']
|
||||
|
||||
EDPM_COMPUTE_GROUP = 'edpm-compute'
|
||||
EDPM_NETWORKER_GROUP = 'edpm-networker'
|
||||
EDPM_OTHER_GROUP = 'edpm-other'
|
||||
|
||||
|
||||
def _is_oc_client_available() -> bool:
|
||||
try:
|
||||
@@ -34,6 +41,15 @@ def _is_oc_client_available() -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _get_group(services):
|
||||
for compute_dp_service in COMPUTE_DP_SERVICE_NAMES:
|
||||
if compute_dp_service in services:
|
||||
return EDPM_COMPUTE_GROUP
|
||||
if OVN_DP_SERVICE_NAME in services:
|
||||
return EDPM_NETWORKER_GROUP
|
||||
return EDPM_OTHER_GROUP
|
||||
|
||||
|
||||
def has_podified_cp() -> bool:
|
||||
if not _is_oc_client_available():
|
||||
LOG.debug("Openshift CLI client isn't installed.")
|
||||
@@ -61,12 +77,15 @@ def list_edpm_nodes():
|
||||
nodes = []
|
||||
nodeset_sel = oc.selector(OSP_DP_NODESET)
|
||||
for nodeset in nodeset_sel.objects():
|
||||
node_template = nodeset.as_dict()['spec']['nodeTemplate']
|
||||
nodeset_nodes = nodeset.as_dict()['spec']['nodes']
|
||||
nodeset_spec = nodeset.as_dict()['spec']
|
||||
node_template = nodeset_spec['nodeTemplate']
|
||||
nodeset_nodes = nodeset_spec['nodes']
|
||||
group_name = _get_group(nodeset_spec['services'])
|
||||
for node in nodeset_nodes.values():
|
||||
node_dict = {
|
||||
'hostname': node.get('hostName'),
|
||||
'host': node['ansible']['ansibleHost'],
|
||||
'group': group_name,
|
||||
'port': (
|
||||
node.get('ansible', {}).get('ansiblePort') or
|
||||
node_template.get('ansible', {}).get('ansiblePort')),
|
||||
|
||||
@@ -13,14 +13,17 @@
|
||||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import typing
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
import tobiko
|
||||
from tobiko.openstack import neutron
|
||||
from tobiko.openstack import topology
|
||||
from tobiko import rhosp
|
||||
from tobiko.podified import _edpm
|
||||
from tobiko.podified import _openshift
|
||||
from tobiko import rhosp
|
||||
from tobiko.shell import ssh
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
@@ -29,6 +32,16 @@ skip_if_not_podified = tobiko.skip_unless(
|
||||
"Podified deployment not configured", _openshift.has_podified_cp
|
||||
)
|
||||
|
||||
# In Podified topology there are groups like 'edpm-compute', 'edpm-networker'
|
||||
# and 'edpm-other' but we need to provide also "virtual" group which will
|
||||
# contain all of those "sub groups"
|
||||
COMPUTE_GROUPS = [
|
||||
_openshift.EDPM_COMPUTE_GROUP,
|
||||
_openshift.EDPM_NETWORKER_GROUP,
|
||||
_openshift.EDPM_OTHER_GROUP
|
||||
]
|
||||
ALL_COMPUTES_GROUP_NAME = 'compute'
|
||||
|
||||
|
||||
class PodifiedTopology(rhosp.RhospTopology):
|
||||
|
||||
@@ -52,6 +65,29 @@ class PodifiedTopology(rhosp.RhospTopology):
|
||||
neutron.FRR: 'frr'
|
||||
}
|
||||
|
||||
def add_node(self,
|
||||
hostname: typing.Optional[str] = None,
|
||||
address: typing.Optional[str] = None,
|
||||
group: typing.Optional[str] = None,
|
||||
ssh_client: typing.Optional[ssh.SSHClientFixture] = None,
|
||||
**create_params) \
|
||||
-> topology.OpenStackTopologyNode:
|
||||
node = super(PodifiedTopology, self).add_node(
|
||||
hostname=hostname,
|
||||
address=address,
|
||||
group=group,
|
||||
ssh_client=ssh_client,
|
||||
**create_params
|
||||
)
|
||||
# NOTE(slaweq): additionally lets add every edpm node to the "legacy"
|
||||
# group named "compute"
|
||||
if group and group in COMPUTE_GROUPS:
|
||||
group_nodes = self.add_group(group=ALL_COMPUTES_GROUP_NAME)
|
||||
if node and node not in group_nodes:
|
||||
group_nodes.append(node)
|
||||
node.add_group(group=ALL_COMPUTES_GROUP_NAME)
|
||||
return node
|
||||
|
||||
def create_node(self, name, ssh_client, **kwargs):
|
||||
return EdpmNode(topology=self,
|
||||
name=name,
|
||||
@@ -74,10 +110,11 @@ class PodifiedTopology(rhosp.RhospTopology):
|
||||
for node in _openshift.list_edpm_nodes():
|
||||
LOG.debug(f"Found EDPM node {node['hostname']} "
|
||||
f"(IP: {node['host']})")
|
||||
group = node.pop('group')
|
||||
host_config = _edpm.edpm_host_config(node)
|
||||
ssh_client = _edpm.edpm_ssh_client(host_config=host_config)
|
||||
node = self.add_node(address=host_config.host,
|
||||
group='compute',
|
||||
group=group,
|
||||
ssh_client=ssh_client)
|
||||
assert isinstance(node, EdpmNode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user