From eb6da27c4906fb600ed10530d2dffec9110a2524 Mon Sep 17 00:00:00 2001
From: Xavier Thompson <xavier.thompson@nexedi.com>
Date: Thu, 5 Sep 2024 11:10:56 +0300
Subject: [PATCH] slapconfiguration: Enable <= slap-connection

Introduce alternative names for input parameters to enable

```
[slap-configuration]
<= slap-connection
recipe = slapos.cookbook:slapconfiguration
```

instead of

```
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
```
---
 slapos/recipe/slapconfiguration.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/slapos/recipe/slapconfiguration.py b/slapos/recipe/slapconfiguration.py
index c94d4ba0c1..eff3ae68a2 100644
--- a/slapos/recipe/slapconfiguration.py
+++ b/slapos/recipe/slapconfiguration.py
@@ -52,21 +52,21 @@ class Recipe(object):
   For example {"tun": {"ipv4": <addr>}} would be available in buildout as ${instance:tun-ipv4}.
 
   Input:
-    url
+    url | server-url
       Slap server url.
       Example:
         ${slap-connection:server-url}
-    key & cert (optional)
+    key & cert | key-file & cert-file (optional)
       Path of files containing key and certificate for secure connection to
       slap server.
       Example:
         ${slap-connection:key-file}
         ${slap-connection:cert-file}
-    computer
+    computer | computer-id
       Computer identifier.
       Example:
         ${slap-connection:computer-id}
-    partition
+    partition | partition-id
       Partition identifier.
       Example:
         ${slap-connection:partition-id}
@@ -129,14 +129,16 @@ class Recipe(object):
       2. format.Partition.resource_file - for partition specific details
       """
       slap = slapos.slap.slap()
+      # BBB: or ... (right side) clauses kept for compatibility;
+      # left-side clauses correspond directly to slap-connection.
       slap.initializeConnection(
-          options['url'],
-          options.get('key'),
-          options.get('cert'),
+          options.get('server-url') or options['url'],
+          options.get('key-file') or options.get('key'),
+          options.get('cert-file') or options.get('cert'),
       )
       computer_partition = slap.registerComputerPartition(
-          options['computer'],
-          options['partition'],
+          options.get('computer-id') or options['computer'],
+          options.get('partition-id') or options['partition'],
       )
       parameter_dict = computer_partition.getInstanceParameterDict()
       options['instance-state'] = computer_partition.getState()
-- 
2.30.9