Add three StorPool API access config options
Add the 'sp-api-http-host', 'sp-api-http-port', and 'sp-auth-token'
config options. The StorPool Cinder backend driver will read them from
the Cinder configuration if specified, so that there is no need for the
/etc/storpool.conf file to exist.
Change-Id: I04669408c789ad3a337edfbc52f54d0bd59238c1
diff --git a/src/charm.py b/src/charm.py
index 02d1062..8b261c0 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -27,7 +27,13 @@
class CinderCharmBase(CinderStoragePluginCharm):
PACKAGES = ["cinder-common"]
- MANDATORY_CONFIG = ["protocol", "storpool-template"]
+ MANDATORY_CONFIG = [
+ "protocol",
+ "storpool-template",
+ "sp-api-http-host",
+ "sp-api-http-port",
+ "sp-auth-token",
+ ]
# Overriden from the parent. May be set depending on the charm's properties
stateless = True
active_active = True
@@ -53,6 +59,12 @@
if config["protocol"] == "block":
return "'protocol' value 'block' not yet supported"
+ if not (0 < config["sp-api-http-port"] < 65536):
+ return (
+ f"""'sp-api-http-port' ('{config["sp-api-http-port"]}')"""
+ "is not a valid port (0-65535)"
+ )
+
def on_config(self, event):
config = dict(self.framework.model.config)
conf_error = self._check_for_config_errors(config)
@@ -77,6 +89,9 @@
("volume_driver", volume_driver),
("volume_backend_name", backend_name),
("storpool_template", config["storpool-template"]),
+ ("sp_api_http_host", config["sp-api-http-host"]),
+ ("sp_api_http_port", config["sp-api-http-port"]),
+ ("sp_auth_token", config["sp-auth-token"]),
]
if config.get("use-multipath"):