Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Use metalsmith for getting OC servers in inventory when available
Browse files Browse the repository at this point in the history
The tripleo-inventory role gets a list of server ips
from which to collect logs.
This review allows that list to be gathered from metalsmith
rather than nova when that package is available and
baremetal_provision is defined and set to true.

Change-Id: I40dd4870327408c6151ceb7eb7fdd316c0018b14
  • Loading branch information
rlandy authored and sshnaidm committed Feb 10, 2020
1 parent f811893 commit d113a69
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions roles/tripleo-inventory/templates/get-overcloud-nodes.py.j2
Expand Up @@ -19,6 +19,9 @@ import os
from distutils.version import LooseVersion
from keystoneauth1.identity import v3
from keystoneauth1 import session
{% if baremetal_provision|default(false)|bool %}
from metalsmith import Provisioner
{% endif %}
from novaclient import __version__ as nc_version
from novaclient import client
try:
Expand Down Expand Up @@ -55,7 +58,15 @@ else:
session = session.Session(auth=auth, verify=False)
nova = client.Client(2, session=session)

{% if baremetal_provision|default(false)|bool %}
provisioner = Provisioner(session=session)
servers_list = provisioner.list_instances()
oc_servers = {server.hostname: server.ip_addresses()['ctlplane'][0]
for server in servers_list
if server.ip_addresses().get('ctlplane')}
{% else %}
oc_servers = {server.name: server.networks['ctlplane'][0]
for server in nova.servers.list()
if server.networks.get('ctlplane')}
{% endif %}
print(json.dumps(oc_servers, indent=4))

0 comments on commit d113a69

Please sign in to comment.