Use the term “application” rather than “service”

The term “service” is confusing because of the related Puppet resource
type. “Application” makes it clear that this doesn't track running
processes.
This commit is contained in:
Daniel Parks 2018-10-12 18:45:37 -07:00
parent d97a3dad33
commit f9b7d7cd58
No known key found for this signature in database
GPG key ID: 526AFD1C8F661806
8 changed files with 69 additions and 64 deletions

View file

@ -96,46 +96,47 @@ class Roles(Set):
return Markup('<li><a href="../roles/index.html#%s">%s</a></li>') % (role, role) return Markup('<li><a href="../roles/index.html#%s">%s</a></li>') % (role, role)
class Services(Set): class Applications(Set):
def value(self, record): def value(self, record):
profile_metadata = record["facts"].get("profile_metadata", dict()) profile_metadata = record["facts"].get("profile_metadata", dict())
return sorted(profile_metadata.get("services", list()), key=itemgetter("human_name")) applications = profile_metadata.get("services", list())
return sorted(applications, key=itemgetter("human_name"))
def item_html(self, service): def item_html(self, application):
return Markup('<li><a href="../services/%s.html">%s</a></li>') % ( return Markup('<li><a href="../applications/%s.html">%s</a></li>') % (
service["class_name"], application["class_name"],
service["human_name"]) application["human_name"])
def item_csv(self, service): def item_csv(self, application):
return service["class_name"] return application["class_name"]
class Owners(Services): class Owners(Applications):
def item_html(self, service): def item_html(self, application):
if service.get("owner_uid", ":undef") == ":undef": if application.get("owner_uid", ":undef") == ":undef":
return "" return ""
else: else:
return Markup('<li>%s</li>') % service["owner_uid"] return Markup('<li>%s</li>') % application["owner_uid"]
def item_csv(self, service): def item_csv(self, application):
if service.get("owner_uid", ":undef") == ":undef": if application.get("owner_uid", ":undef") == ":undef":
return "" return ""
else: else:
return service["owner_uid"] return application["owner_uid"]
class Teams(Services): class Teams(Applications):
def item_html(self, service): def item_html(self, application):
if service.get("team", ":undef") == ":undef": if application.get("team", ":undef") == ":undef":
return "" return ""
else: else:
return Markup('<li>%s</li>') % service["team"] return Markup('<li>%s</li>') % application["team"]
def item_csv(self, service): def item_csv(self, application):
if service.get("team", ":undef") == ":undef": if application.get("team", ":undef") == ":undef":
return "" return ""
else: else:
return service["team"] return application["team"]
class Fqdn(Base): class Fqdn(Base):

View file

@ -46,7 +46,7 @@ def output_html(inventory, directory):
report_columns = [ report_columns = [
cellformatter.Fqdn("facts", "fqdn"), cellformatter.Fqdn("facts", "fqdn"),
cellformatter.Teams("other", "teams"), cellformatter.Teams("other", "teams"),
cellformatter.Services("other", "services"), cellformatter.Applications("other", "applications"),
cellformatter.Boolean("other", "monitoring"), cellformatter.Boolean("other", "monitoring"),
cellformatter.Boolean("other", "backups"), cellformatter.Boolean("other", "backups"),
cellformatter.Boolean("other", "logging"), cellformatter.Boolean("other", "logging"),
@ -66,7 +66,7 @@ def output_html(inventory, directory):
cellformatter.Base("facts", "fqdn"), cellformatter.Base("facts", "fqdn"),
cellformatter.Teams("other", "teams"), cellformatter.Teams("other", "teams"),
cellformatter.Owners("other", "owners"), cellformatter.Owners("other", "owners"),
cellformatter.Services("other", "services"), cellformatter.Applications("other", "applications"),
cellformatter.Base("other", "icinga_notification_period", "Icinga notification period"), cellformatter.Base("other", "icinga_notification_period", "Icinga notification period"),
cellformatter.Base("other", "icinga_stage", header="Icinga stage"), cellformatter.Base("other", "icinga_stage", header="Icinga stage"),
cellformatter.Base("other", "icinga_owner", header="Icinga owner"), cellformatter.Base("other", "icinga_owner", header="Icinga owner"),
@ -111,24 +111,24 @@ def output_html(inventory, directory):
generation_time=generation_time, generation_time=generation_time,
roles=inventory.sorted_roles())) roles=inventory.sorted_roles()))
os.mkdir("{}/services".format(directory), 0o755) os.mkdir("{}/applications".format(directory), 0o755)
sorted_services = inventory.sorted_services() sorted_applications = inventory.sorted_applications()
with open("{}/services/index.html".format(directory), "w", encoding="utf-8") as html: with open("{}/applications/index.html".format(directory), "w", encoding="utf-8") as html:
html.write( html.write(
render_template("services.html", render_template("applications.html",
path="../", path="../",
generation_time=generation_time, generation_time=generation_time,
services=sorted_services)) applications=sorted_applications))
for service in sorted_services: for application in sorted_applications:
path = "{}/services/{}.html".format(directory, service["class_name"]) path = "{}/applications/{}.html".format(directory, application["class_name"])
with open(path, "w", encoding="utf-8") as html: with open(path, "w", encoding="utf-8") as html:
html.write( html.write(
render_template("service.html", render_template("application.html",
path="../", path="../",
generation_time=generation_time, generation_time=generation_time,
service=service)) application=application))
def render_template(template_name, **kwargs): def render_template(template_name, **kwargs):
data_path = os.path.dirname(os.path.abspath(__file__)) data_path = os.path.dirname(os.path.abspath(__file__))

View file

@ -77,19 +77,23 @@ class Inventory(object):
def sorted_roles(self): def sorted_roles(self):
return sorted(self.roles.items()) return sorted(self.roles.items())
def sorted_services(self): def sorted_applications(self):
services = dict() applications = dict()
for node in self.nodes.values(): for node in self.nodes.values():
profile_metadata = node["facts"].get("profile_metadata", dict()) profile_metadata = node["facts"].get("profile_metadata", dict())
# Previously we used the term “services” instead of “applications.”
# This was changed to avoid confusion since there is a related
# Puppet resource type called “Service.”
service_facts = profile_metadata.get("services", list()) service_facts = profile_metadata.get("services", list())
for service_fact in service_facts: for service_fact in service_facts:
class_name = service_fact["class_name"] class_name = service_fact["class_name"]
if class_name not in services: if class_name not in applications:
services[class_name] = service_fact applications[class_name] = service_fact
services[class_name]["nodes"] = list() applications[class_name]["nodes"] = list()
services[class_name]["nodes"].append(node) applications[class_name]["nodes"].append(node)
return sorted(services.values(), key=itemgetter("human_name")) return sorted(applications.values(), key=itemgetter("human_name"))

View file

@ -176,6 +176,6 @@ td p {
} }
body#node th, body#node th,
body#service th { body#application th {
width: 180px; width: 180px;
} }

View file

@ -1,18 +1,18 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block title %}Service {{ service["human_name"] }}{% endblock %} {% block title %}{{ application["human_name"] }}{% endblock %}
{% block body %} {% block body %}
<h1>Service {{ service["human_name"] }}</h1> <h1>{{ application["human_name"] }}</h1>
<table> <table>
<tbody> <tbody>
<tr> <tr>
<th>Class</th> <th>Class</th>
<td>{{ service["class_name"] }}</td> <td>{{ application["class_name"] }}</td>
</tr> </tr>
<tr> <tr>
<th>Documentation</th> <th>Documentation</th>
<td> <td>
<ul> <ul>
{% for url in service["doc_urls"] %} {% for url in application["doc_urls"] %}
<li><a href="{{ url }}">{{url}}</a></li> <li><a href="{{ url }}">{{url}}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -20,14 +20,14 @@
</tr> </tr>
<tr> <tr>
<th>Downtime impact</th> <th>Downtime impact</th>
<td>{{ service["downtime_impact"] | unundef }}</td> <td>{{ application["downtime_impact"] | unundef }}</td>
</tr> </tr>
<tr> <tr>
<th>End users</th> <th>End users</th>
<td> <td>
{% if service["end_users"] != ":undef" %} {% if application["end_users"] != ":undef" %}
<ul> <ul>
{% for email in service["end_users"] %} {% for email in application["end_users"] %}
<li><a href="mailto:{{ email }}">{{email}}</a></li> <li><a href="mailto:{{ email }}">{{email}}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -36,14 +36,14 @@
</tr> </tr>
<tr> <tr>
<th>Escalation period</th> <th>Escalation period</th>
<td>{{ service["escalation_period"] | unundef }}</td> <td>{{ application["escalation_period"] | unundef }}</td>
</tr> </tr>
<tr> <tr>
<th>Notes</th> <th>Notes</th>
<td> <td>
<div class="notes"> <div class="notes">
{% if service["notes"] %} {% if application["notes"] %}
{{ service["notes"] | unundef | markdown }} {{ application["notes"] | unundef | markdown }}
{% endif %} {% endif %}
</div> </div>
</td> </td>
@ -52,7 +52,7 @@
<th>Other FQDNs</th> <th>Other FQDNs</th>
<td> <td>
<ul> <ul>
{% for fqdn in service["other_fqdns"] %} {% for fqdn in application["other_fqdns"] %}
<li>{{ fqdn }}</li> <li>{{ fqdn }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -60,17 +60,17 @@
</tr> </tr>
<tr> <tr>
<th>Owner</th> <th>Owner</th>
<td>{{ service["owner_uid"] | unundef }}</td> <td>{{ application["owner_uid"] | unundef }}</td>
</tr> </tr>
<tr> <tr>
<th>Team</th> <th>Team</th>
<td>{{ service["team"] | unundef }}</td> <td>{{ application["team"] | unundef }}</td>
</tr> </tr>
<tr> <tr>
<th>Nodes</th> <th>Nodes</th>
<td> <td>
<ul> <ul>
{% for node in service["nodes"] | sort(attribute='facts.fqdn') %} {% for node in application["nodes"] | sort(attribute='facts.fqdn') %}
<li><a href="../nodes/{{ node["certname"] }}.html">{{ node["facts"]["fqdn"] }}</a></li> <li><a href="../nodes/{{ node["certname"] }}.html">{{ node["facts"]["fqdn"] }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View file

@ -1,23 +1,23 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block title %}Service inventory{% endblock %} {% block title %}Application inventory{% endblock %}
{% block body %} {% block body %}
<h1>Service inventory</h1> <h1>Application inventory</h1>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Service</th> <th>Application</th>
<th>Nodes</th> <th>Nodes</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for service in services %} {% for application in applications %}
<tr id="{{ service }}"> <tr id="{{ application }}">
<th> <th>
<a href="./{{ service["class_name"] }}.html">{{ service["human_name"] }}</a> <a href="./{{ application["class_name"] }}.html">{{ application["human_name"] }}</a>
</th> </th>
<td> <td>
<ul> <ul>
{% for node in service["nodes"] | sort(attribute="facts.fqdn") %} {% for node in application["nodes"] | sort(attribute="facts.fqdn") %}
<li><a href="../nodes/{{ node["certname"] }}.html">{{ node["facts"]["fqdn"] }}</a></li> <li><a href="../nodes/{{ node["certname"] }}.html">{{ node["facts"]["fqdn"] }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View file

@ -5,6 +5,6 @@
<ul> <ul>
<li><a href="nodes/index.html">Node inventory</a></li> <li><a href="nodes/index.html">Node inventory</a></li>
<li><a href="roles/index.html">Role inventory</a></li> <li><a href="roles/index.html">Role inventory</a></li>
<li><a href="services/index.html">Service inventory</a></li> <li><a href="applications/index.html">Application inventory</a></li>
</ul> </ul>
{% endblock %} {% endblock %}

View file

@ -15,7 +15,7 @@
<li class="infinitory-logo"></li> <li class="infinitory-logo"></li>
<li><a href="{{ path }}nodes/index.html">Nodes</a></li> <li><a href="{{ path }}nodes/index.html">Nodes</a></li>
<li><a href="{{ path }}roles/index.html">Roles</a></li> <li><a href="{{ path }}roles/index.html">Roles</a></li>
<li><a href="{{ path }}services/index.html">Services</a></li> <li><a href="{{ path }}applications/index.html">Applications</a></li>
</ul> </ul>
</nav> </nav>
<main> <main>