[Kimchi-devel] [PATCH 2/6 V6] Host's repositories management: Update REST API

Paulo Vital pvital at linux.vnet.ibm.com
Wed Feb 19 01:08:45 UTC 2014


Define Repositories collection and Repository resource according to API.md
Update API.json
Activate auth support to new collection

Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
---
 src/kimchi/API.json        | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 src/kimchi/control/host.py | 21 ++++++++++++++
 2 files changed, 93 insertions(+)

diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index c36244c..d3a8e64 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -478,6 +478,78 @@
             },
             "additionalProperties": false,
             "error": "KCHAPI0001E"
+        },
+        "repositories_create": {
+            "type": "object",
+            "properties": {
+                "repo_id": {
+                    "description": "Unique repository name for each repository, one word.",
+                    "type": "string",
+                    "error": "KCHREPOS0001E"
+                },
+                "baseurl": {
+                    "description": "URL to the directory where the repodata directory of a repository is located. Can be an http://, ftp:// or file://  URL.",
+                    "type": "string",
+                    "required": true,
+                    "error": "KCHREPOS0002E"
+                },
+                "is_mirror": {
+                    "description": "Set the given URI of baseurl as a mirror list",
+                    "type": "boolean"
+                },
+                "url_args": {
+                    "description": "Arguments to be passed to baseurl, like the list of APT repositories provided by the same baseurl.",
+                    "type": "string",
+                    "error": "KCHREPOS0003E"
+                },
+                "gpgkey": {
+                    "description": "URL pointing to the ASCII-armored GPG key file for the repository.",
+                    "type": "string",
+                    "error": "KCHREPOS0004E"
+                }
+            },
+            "additionalProperties": false,
+            "error": "KCHAPI0001E"
+        },
+        "repository_update": {
+            "type": "object",
+            "properties": {
+                "repo_id": {
+                    "description": "Unique repository name for each repository, one word.",
+                    "type": "string",
+                    "error": "KCHREPOS0001E"
+                },
+                "repo_name": {
+                    "description": "Human-readable string describing the repository.",
+                    "type": "string",
+                    "error": "KCHREPOS0005E"
+                },
+                "baseurl": {
+                    "description": "URL to the directory where the repodata directory of a repository is located. Can be an http://, ftp:// or file://  URL.",
+                    "type": "string",
+                    "error": "KCHREPOS0002E"
+                },
+                "is_mirror": {
+                    "description": "Set the given URI of baseurl as a mirror list",
+                    "type": "boolean"
+                },
+                "url_args": {
+                    "description": "Arguments to be passed to baseurl, like the list of APT repositories provided by the same baseurl.",
+                    "type": "string",
+                    "error": "KCHREPOS0003E"
+                },
+                "gpgcheck": {
+                    "description": "Indicates if a GPG signature check on the packages gotten from repository should be performed.",
+                    "type": "boolean"
+                },
+                "gpgkey": {
+                    "description": "URL pointing to the ASCII-armored GPG key file for the repository.",
+                    "type": "string",
+                    "error": "KCHREPOS0004E"
+                }
+            },
+            "additionalProperties": false,
+            "error": "KCHAPI0001E"
         }
     }
 }
diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py
index 41e0040..50edc71 100644
--- a/src/kimchi/control/host.py
+++ b/src/kimchi/control/host.py
@@ -42,6 +42,7 @@ class Host(Resource):
         self.partitions = Partitions(self.model)
         self.devices = Devices(self.model)
         self.packagesupdate = PackagesUpdate(self.model)
+        self.repositories = Repositories(self.model)
 
     @cherrypy.expose
     def swupdate(self):
@@ -107,3 +108,23 @@ class PackageUpdate(Resource):
     @property
     def data(self):
         return self.info
+
+
+class Repositories(Collection):
+    def __init__(self, model):
+        super(Repositories, self).__init__(model)
+        self.resource = Repository
+
+
+class Repository(Resource):
+    def __init__(self, model, id):
+        super(Repository, self).__init__(model, id)
+        self.update_params = ["repo_id", "repo_name", "baseurl", "mirrors",
+                              "url_args", "gpgcheck", "gpgkey"]
+        self.uri_fmt = "/host/repositories/%s"
+        self.enable = self.generate_action_handler('enable')
+        self.disable = self.generate_action_handler('disable')
+
+    @property
+    def data(self):
+        return self.info
-- 
1.8.3.1




More information about the Kimchi-devel mailing list