From 08f08a533dd9f2900453f485cd6ff23e2df8178b Mon Sep 17 00:00:00 2001
From: suvendhu <suvendhu.hansa@iopsys.eu>
Date: Wed, 18 Jan 2023 13:20:33 +0530
Subject: [PATCH] Added UCI schema

---
 README.md               |   9 ++-
 docs/api/.pages         |   1 +
 docs/api/uci/.pages     |   4 ++
 docs/api/uci/uci.md     | 122 ++++++++++++++++++++++++++++++++++++++++
 schemas/uci/swmodd.json |  53 +++++++++++++++++
 5 files changed, 186 insertions(+), 3 deletions(-)
 create mode 100644 docs/api/uci/.pages
 create mode 100644 docs/api/uci/uci.md
 create mode 100644 schemas/uci/swmodd.json

diff --git a/README.md b/README.md
index 698705f..16bf506 100644
--- a/README.md
+++ b/README.md
@@ -38,14 +38,17 @@ config globals 'globals'
 	option lxc_bundle_root '/data/lxc'
 ```
 
-For installation of oci based application containers, bundle path need to defined in above uci in 'oci_bundle_root' option.
-For installation of lxc based containers, bundle path need to defined in above uci in 'lxc_bundle_root' option.
-It is suggested to configure a non-volatile secondary memory location in this options. Also 'lan_bridge' need to point to a valid bridge where application containers network namespace shall be attached.
+- For installation of oci based application containers, bundle path need to defined in above uci in 'oci_bundle_root' option.
+- For installation of lxc based containers, bundle path need to defined in above uci in 'lxc_bundle_root' option.
+- It is suggested to configure a non-volatile secondary memory location in this options. Also 'lan_bridge' need to point to a valid bridge where application containers network namespace shall be attached.
+
+> Note: For more details about UCI schema click [here](https://dev.iopsys.eu/iopsys/swmodd/-/tree/devel/schema/uci/swmodd.json)
 
 ## Important topics
 * [LXC template](./docs/guide/lxc_template.md)
 * [Deployment of application containers](./docs/guide/application_container.md)
 * [UBUS methods](./docs/guide/ubus_methods.md)
+* [UCI parameters](./docs/api/uci/uci.md)
 
 ## Dependencies
 `swmodd` compile time and run time dependencies.
diff --git a/docs/api/.pages b/docs/api/.pages
index 674084e..ddcdb32 100644
--- a/docs/api/.pages
+++ b/docs/api/.pages
@@ -2,4 +2,5 @@ title: "API"
 
 nav:
     - "ubus"
+    - "uci"
     - "..."
diff --git a/docs/api/uci/.pages b/docs/api/uci/.pages
new file mode 100644
index 0000000..4c6712e
--- /dev/null
+++ b/docs/api/uci/.pages
@@ -0,0 +1,4 @@
+title: "UCI"
+
+nav:
+    - "..."
diff --git a/docs/api/uci/uci.md b/docs/api/uci/uci.md
new file mode 100644
index 0000000..98bf713
--- /dev/null
+++ b/docs/api/uci/uci.md
@@ -0,0 +1,122 @@
+# SWMODD UCI
+
+<tbody>
+  <tr>
+    <td colspan="2">
+      <div style="font-weight: bold;">swmodd</div>
+      <table style="width: 100%;">
+        <tbody>
+          <tr>
+            <td><div style="font-weight: bold; font-size: 14px;">section</div></td>
+            <td><div style="font-weight: bold; font-size: 14px;">description</div></td>
+            <td><div style="font-weight: bold; font-size: 14px;">multi</div></td>
+            <td><div style="font-weight: bold; font-size: 14px;">options</div></td>
+          </tr>
+          <tr>
+            <td class="td_row_even"><div class="td_row_even">globals</div></td>
+            <td class="td_row_even"><div class="td_row_even">Configuration of SWMODD</div></td>
+            <td class="td_row_even"><div class="td_row_even">false</div></td>
+            <td class="td_row_even">
+              <table style="width: 100%;">
+                <tbody>
+                  <tr>
+                    <td><div style="font-weight: bold; font-size: 14px;">name</div></td>
+                    <td><div style="font-weight: bold; font-size: 14px;">type</div></td>
+                    <td><div style="font-weight: bold; font-size: 14px;">required</div></td>
+                    <td><div style="font-weight: bold; font-size: 14px;">default</div></td>
+                    <td><div style="font-weight: bold; font-size: 14px;">description</div></td>
+                  </tr>
+                  <tr>
+                    <td class="td_row_even"><div class="td_row_even">enabled</div></td>
+                    <td class="td_row_even"><div class="td_row_even">boolean</div></td>
+                    <td class="td_row_even"><div class="td_row_even">yes</div></td>
+                    <td class="td_row_even"><div class="td_row_even">0</div></td>
+                    <td class="td_row_even"><div class="td_row_even">If set to <b>1</b>, SWMODD will be enabled</div></td>
+                  </tr>
+                  <tr>
+                    <td class="td_row_odd"><div class="td_row_odd">lan_bridge</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">string</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">yes</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">br-lan</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">This option is applicable for OCI based application containers only. It must be a valid bridge name where application containers network namespace shall be attached</div></td>
+                  </tr>
+                  <tr>
+                    <td class="td_row_even"><div class="td_row_even">debug</div></td>
+                    <td class="td_row_even"><div class="td_row_even">boolean</div></td>
+                    <td class="td_row_even"><div class="td_row_even">no</div></td>
+                    <td class="td_row_even"><div class="td_row_even">1</div></td>
+                    <td class="td_row_even"><div class="td_row_even">If set to <b>1</b> debugging is enabled</div></td>
+                  </tr>
+                  <tr>
+                    <td class="td_row_odd"><div class="td_row_odd">lxc_bundle_root</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">string</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">yes</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd"></div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">This option is valid for LXC based containers. It must be a non-volatile secondary memory location where LXC based containers are installed</div></td>
+                  </tr>
+                  <tr>
+                    <td class="td_row_even"><div class="td_row_even">oci_bundle_root</div></td>
+                    <td class="td_row_even"><div class="td_row_even">string</div></td>
+                    <td class="td_row_even"><div class="td_row_even">yes</div></td>
+                    <td class="td_row_even"><div class="td_row_even"></div></td>
+                    <td class="td_row_even"><div class="td_row_even">This option is valid for OCI based application containers. This must be a non-volatile secondary memory location for installation of OCI based application containers</div></td>
+                  </tr>
+                  <tr>
+                    <td class="td_row_odd"><div class="td_row_odd">log_level</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">integer</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">no</div></td>
+                    <td class="td_row_odd"><div class="td_row_odd">3</div></td>
+                    <td class="td_row_odd">
+		      <div class="td_row_odd">
+		        Specifies the log type to use. Supported values are:
+			<table>
+			  <tr>
+			    <td> value </td>
+			    <td> type </td>
+			  <tr>
+			  <tr>
+			    <td> 0 </td>
+			    <td> EMERGENCY </td>
+			  </tr>
+			  <tr>
+			    <td> 1 </td>
+			    <td> ALERT </td>
+			  </tr>
+			  <tr>
+			    <td> 2 </td>
+			    <td> CRITICAL </td>
+			  </tr>
+			  <tr>
+			    <td> 3 </td>
+			    <td> ERROR </td>
+			  </tr>
+			  <tr>
+			    <td> 4 </td>
+			    <td> WARNING </td>
+			  </tr>
+			  <tr>
+			    <td> 5 </td>
+			    <td> NOTICE </td>
+			  </tr>
+			  <tr>
+			    <td> 6 </td>
+			    <td> INFO </td>
+			  </tr>
+			  <tr>
+			    <td> 7 </td>
+			    <td> DEBUG </td>
+			  </tr>
+			</table>
+		      </div>
+		    </td>
+                  </tr>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </td>
+  </tr>
+</tbody>
+
diff --git a/schemas/uci/swmodd.json b/schemas/uci/swmodd.json
new file mode 100644
index 0000000..ef5a03c
--- /dev/null
+++ b/schemas/uci/swmodd.json
@@ -0,0 +1,53 @@
+{
+  "swmodd": [
+    {
+      "section": "globals",
+      "description": "Configuration of SWMODD",
+      "multi": "false",
+      "options": [
+        {
+          "name": "enabled",
+          "type": "boolean",
+          "required": "yes",
+          "default": "0",
+          "description": "If set to 1, SWMODD will be enabled"
+        },
+        {
+          "name": "lan_bridge",
+          "type": "string",
+          "required": "yes",
+          "default": "br-lan",
+          "description": "This option is applicable for OCI based application containers only. It must be a valid bridge name where application containers network namespace shall be attached"
+        },
+        {
+          "name": "debug",
+          "type": "boolean",
+          "required": "no",
+          "default": "1",
+          "description": "If set to 1, debugging is enabled"
+        },
+        {
+          "name": "lxc_bundle_root",
+          "type": "string",
+          "required": "yes",
+          "default": "",
+          "description": "This option is valid for LXC based containers. It must be a non-volatile secondary memory location where LXC based containers are installed"
+        },
+        {
+          "name": "oci_bundle_root",
+          "type": "string",
+          "required": "yes",
+          "default": "",
+          "description": "This option is valid for OCI based application containers. This must be a non-volatile secondary memory location for installation of OCI based application containers"
+        },
+        {
+          "name": "log_level",
+          "type": "integer",
+          "required": "no",
+          "default": "3",
+          "description": "Specifies the log type to use. Supported values are: 0(EMERGENCY), 1(ALERT), 2(CRITICAL), 3(ERROR), 4(WARNING), 5(NOTICE), 6(INFO), 7(DEBUG)"
+        }
+      ]
+    }
+  ]
+}
-- 
GitLab