Page MenuHomeDevCentral

D2554.id6454.diff
No OneTemporary

D2554.id6454.diff

diff --git a/Makefile b/Makefile
new file mode 100644
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+# -------------------------------------------------------------
+# Nasqueron - API
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Description: Build API files
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+API_FILES=infra/servers.json
+YAML_TO_JSON=_utils/yaml2json.py
+
+RM=rm -f
+
+# -------------------------------------------------------------
+# Main targets
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+all: $(API_FILES)
+
+clean:
+ ${RM} ${API_FILES}
+
+# -------------------------------------------------------------
+# API targets
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+infra/servers.json:
+ ${YAML_TO_JSON} infra/datasource.yml servers > infra/servers.json
diff --git a/_utils/yaml2json.py b/_utils/yaml2json.py
new file mode 100755
--- /dev/null
+++ b/_utils/yaml2json.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python3
+
+# -------------------------------------------------------------
+# Nasqueron - API
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Description: Create a JSON document from a YAML datasource
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+
+import json
+import sys
+import yaml
+
+
+# -------------------------------------------------------------
+# Convert
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def to_json(source_path, key=None):
+ with open(source_path) as fd:
+ data = yaml.safe_load(fd)
+
+ if key:
+ data = data[key]
+
+ return json.dumps(data, indent=4)
+
+
+# -------------------------------------------------------------
+# Application entry point
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def run(source_path, key=None):
+ print(to_json(source_path, key))
+
+
+if __name__ == "__main__":
+ argc = len(sys.argv)
+
+ if argc < 2:
+ print(f"Usage: {sys.argv[0]} <YAML datasource> [key to take]", file=sys.stderr)
+ sys.exit(1)
+
+ run(*sys.argv[1:3])
diff --git a/index.html b/index.html
--- a/index.html
+++ b/index.html
@@ -15,6 +15,7 @@
<ul>
<li><strong><a href="/servers-log/all.json">/servers-log/all.json</a></strong> — Servers log</li>
<li><strong><a href="/docker/registry">/docker/registry</a></strong> — Docker registry API</li>
+ <li><strong><a href="/infra/servers.json">/infra/servers.json</a></strong> — Servers list</li>
</ul>
<h2>Tools</h2>
<ul>
diff --git a/infra/datasource.yml b/infra/datasource.yml
new file mode 100644
--- /dev/null
+++ b/infra/datasource.yml
@@ -0,0 +1,31 @@
+servers:
+
+ windriver:
+ name: WindRiver
+ hostname: windriver.nasqueron.org
+ description: Development server
+ configurator: salt
+
+ ysul:
+ name: Ysul
+ hostname: ysul.nasqueron.org
+ description: Development server (legacy)
+ configurator: salt
+
+ cloudhugger:
+ name: CloudHugger
+ hostname: cloudhugger.nasqueron.org
+ description: OpenSearch testing
+ configurator: salt
+
+ docker-001:
+ name: docker-001
+ hostname: docker-001.nasqueron.org
+ description: Docker engine (prod)
+ configurator: salt
+
+ dwellers:
+ name: Dwellers
+ hostname: dwellers.nasqueron.org
+ description: Docker engine (dev)
+ configurator: salt
diff --git a/infra/servers.json b/infra/servers.json
new file mode 100644
--- /dev/null
+++ b/infra/servers.json
@@ -0,0 +1,32 @@
+{
+ "windriver": {
+ "name": "WindRiver",
+ "hostname": "windriver.nasqueron.org",
+ "description": "Development server",
+ "configurator": "salt"
+ },
+ "ysul": {
+ "name": "Ysul",
+ "hostname": "ysul.nasqueron.org",
+ "description": "Development server (legacy)",
+ "configurator": "salt"
+ },
+ "cloudhugger": {
+ "name": "CloudHugger",
+ "hostname": "cloudhugger.nasqueron.org",
+ "description": "OpenSearch testing",
+ "configurator": "salt"
+ },
+ "docker-001": {
+ "name": "docker-001",
+ "hostname": "docker-001.nasqueron.org",
+ "description": "Docker engine (prod)",
+ "configurator": "salt"
+ },
+ "dwellers": {
+ "name": "Dwellers",
+ "hostname": "dwellers.nasqueron.org",
+ "description": "Docker engine (dev)",
+ "configurator": "salt"
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 09:35 (21 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2272766
Default Alt Text
D2554.id6454.diff (4 KB)

Event Timeline