diff --git a/infinitory/cellformatter.py b/infinitory/cellformatter.py index f61f2c1..37f6669 100644 --- a/infinitory/cellformatter.py +++ b/infinitory/cellformatter.py @@ -96,46 +96,47 @@ class Roles(Set): return Markup('
  • %s
  • ') % (role, role) -class Services(Set): +class Applications(Set): def value(self, record): 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): - return Markup('
  • %s
  • ') % ( - service["class_name"], - service["human_name"]) + def item_html(self, application): + return Markup('
  • %s
  • ') % ( + application["class_name"], + application["human_name"]) - def item_csv(self, service): - return service["class_name"] + def item_csv(self, application): + return application["class_name"] -class Owners(Services): - def item_html(self, service): - if service.get("owner_uid", ":undef") == ":undef": +class Owners(Applications): + def item_html(self, application): + if application.get("owner_uid", ":undef") == ":undef": return "" else: - return Markup('
  • %s
  • ') % service["owner_uid"] + return Markup('
  • %s
  • ') % application["owner_uid"] - def item_csv(self, service): - if service.get("owner_uid", ":undef") == ":undef": + def item_csv(self, application): + if application.get("owner_uid", ":undef") == ":undef": return "" else: - return service["owner_uid"] + return application["owner_uid"] -class Teams(Services): - def item_html(self, service): - if service.get("team", ":undef") == ":undef": +class Teams(Applications): + def item_html(self, application): + if application.get("team", ":undef") == ":undef": return "" else: - return Markup('
  • %s
  • ') % service["team"] + return Markup('
  • %s
  • ') % application["team"] - def item_csv(self, service): - if service.get("team", ":undef") == ":undef": + def item_csv(self, application): + if application.get("team", ":undef") == ":undef": return "" else: - return service["team"] + return application["team"] class Fqdn(Base): diff --git a/infinitory/cli.py b/infinitory/cli.py index b0ecc28..9700e08 100755 --- a/infinitory/cli.py +++ b/infinitory/cli.py @@ -46,7 +46,7 @@ def output_html(inventory, directory): report_columns = [ cellformatter.Fqdn("facts", "fqdn"), cellformatter.Teams("other", "teams"), - cellformatter.Services("other", "services"), + cellformatter.Applications("other", "applications"), cellformatter.Boolean("other", "monitoring"), cellformatter.Boolean("other", "backups"), cellformatter.Boolean("other", "logging"), @@ -66,7 +66,7 @@ def output_html(inventory, directory): cellformatter.Base("facts", "fqdn"), cellformatter.Teams("other", "teams"), 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_stage", header="Icinga stage"), cellformatter.Base("other", "icinga_owner", header="Icinga owner"), @@ -111,24 +111,24 @@ def output_html(inventory, directory): generation_time=generation_time, roles=inventory.sorted_roles())) - os.mkdir("{}/services".format(directory), 0o755) - sorted_services = inventory.sorted_services() + os.mkdir("{}/applications".format(directory), 0o755) + 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( - render_template("services.html", + render_template("applications.html", path="../", generation_time=generation_time, - services=sorted_services)) + applications=sorted_applications)) - for service in sorted_services: - path = "{}/services/{}.html".format(directory, service["class_name"]) + for application in sorted_applications: + path = "{}/applications/{}.html".format(directory, application["class_name"]) with open(path, "w", encoding="utf-8") as html: html.write( - render_template("service.html", + render_template("application.html", path="../", generation_time=generation_time, - service=service)) + application=application)) def render_template(template_name, **kwargs): data_path = os.path.dirname(os.path.abspath(__file__)) diff --git a/infinitory/inventory.py b/infinitory/inventory.py index 9adc3c4..9eb2c74 100644 --- a/infinitory/inventory.py +++ b/infinitory/inventory.py @@ -77,19 +77,23 @@ class Inventory(object): def sorted_roles(self): return sorted(self.roles.items()) - def sorted_services(self): - services = dict() + def sorted_applications(self): + applications = dict() for node in self.nodes.values(): 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()) for service_fact in service_facts: class_name = service_fact["class_name"] - if class_name not in services: - services[class_name] = service_fact - services[class_name]["nodes"] = list() + if class_name not in applications: + applications[class_name] = service_fact + 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")) diff --git a/infinitory/static/general.css b/infinitory/static/general.css index 3f7aa10..f645107 100644 --- a/infinitory/static/general.css +++ b/infinitory/static/general.css @@ -176,6 +176,6 @@ td p { } body#node th, -body#service th { +body#application th { width: 180px; } diff --git a/infinitory/templates/service.html b/infinitory/templates/application.html similarity index 62% rename from infinitory/templates/service.html rename to infinitory/templates/application.html index c70ad30..7804596 100644 --- a/infinitory/templates/service.html +++ b/infinitory/templates/application.html @@ -1,18 +1,18 @@ {% extends "layout.html" %} -{% block title %}Service {{ service["human_name"] }}{% endblock %} +{% block title %}{{ application["human_name"] }}{% endblock %} {% block body %} -

    Service {{ service["human_name"] }}

    +

    {{ application["human_name"] }}

    - + - + - + @@ -52,7 +52,7 @@ - + - +
    Class{{ service["class_name"] }}{{ application["class_name"] }}
    Documentation
      - {% for url in service["doc_urls"] %} + {% for url in application["doc_urls"] %}
    • {{url}}
    • {% endfor %}
    @@ -20,14 +20,14 @@
    Downtime impact{{ service["downtime_impact"] | unundef }}{{ application["downtime_impact"] | unundef }}
    End users - {% if service["end_users"] != ":undef" %} + {% if application["end_users"] != ":undef" %}
      - {% for email in service["end_users"] %} + {% for email in application["end_users"] %}
    • {{email}}
    • {% endfor %}
    @@ -36,14 +36,14 @@
    Escalation period{{ service["escalation_period"] | unundef }}{{ application["escalation_period"] | unundef }}
    Notes
    - {% if service["notes"] %} - {{ service["notes"] | unundef | markdown }} + {% if application["notes"] %} + {{ application["notes"] | unundef | markdown }} {% endif %}
    Other FQDNs
      - {% for fqdn in service["other_fqdns"] %} + {% for fqdn in application["other_fqdns"] %}
    • {{ fqdn }}
    • {% endfor %}
    @@ -60,17 +60,17 @@
    Owner{{ service["owner_uid"] | unundef }}{{ application["owner_uid"] | unundef }}
    Team{{ service["team"] | unundef }}{{ application["team"] | unundef }}
    Nodes
      - {% for node in service["nodes"] | sort(attribute='facts.fqdn') %} + {% for node in application["nodes"] | sort(attribute='facts.fqdn') %}
    • {{ node["facts"]["fqdn"] }}
    • {% endfor %}
    diff --git a/infinitory/templates/services.html b/infinitory/templates/applications.html similarity index 53% rename from infinitory/templates/services.html rename to infinitory/templates/applications.html index 59f8511..e29a40a 100644 --- a/infinitory/templates/services.html +++ b/infinitory/templates/applications.html @@ -1,23 +1,23 @@ {% extends "layout.html" %} -{% block title %}Service inventory{% endblock %} +{% block title %}Application inventory{% endblock %} {% block body %} -

    Service inventory

    +

    Application inventory

    - + - {% for service in services %} - + {% for application in applications %} +
    ServiceApplication Nodes
    - {{ service["human_name"] }} + {{ application["human_name"] }}
      - {% for node in service["nodes"] | sort(attribute="facts.fqdn") %} + {% for node in application["nodes"] | sort(attribute="facts.fqdn") %}
    • {{ node["facts"]["fqdn"] }}
    • {% endfor %}
    diff --git a/infinitory/templates/home.html b/infinitory/templates/home.html index f65ba0a..89dc8b2 100644 --- a/infinitory/templates/home.html +++ b/infinitory/templates/home.html @@ -5,6 +5,6 @@ {% endblock %} diff --git a/infinitory/templates/layout.html b/infinitory/templates/layout.html index 23df35f..d1527c6 100644 --- a/infinitory/templates/layout.html +++ b/infinitory/templates/layout.html @@ -15,7 +15,7 @@
  • Nodes
  • Roles
  • -
  • Services
  • +
  • Applications