Improved Primitive support and better testing
This changeset addresses several issues.
- Improve primitive support so the status and output of an executed
primitive can be retrieved
- Merge latest upstream libjuju (required for new primive features)
- New testing framework
This is the start of a new testing framework with the ability to
create and configure LXD containers with SSH, to use while testing proxy
charms.
- Add support for using ssh keys with proxy charms
See Feature 1429. This uses the per-proxy charm/unit ssh keypair
Signed-off-by: Adam Israel <adam.israel@canonical.com>
diff --git a/modules/libjuju/juju/constraints.py b/modules/libjuju/juju/constraints.py
index 998862d..0050673 100644
--- a/modules/libjuju/juju/constraints.py
+++ b/modules/libjuju/juju/constraints.py
@@ -29,6 +29,8 @@
"P": 1024 * 1024 * 1024
}
+LIST_KEYS = {'tags', 'spaces'}
+
SNAKE1 = re.compile(r'(.)([A-Z][a-z]+)')
SNAKE2 = re.compile('([a-z0-9])([A-Z])')
@@ -47,8 +49,10 @@
return constraints
constraints = {
- normalize_key(k): normalize_value(v) for k, v in [
- s.split("=") for s in constraints.split(" ")]}
+ normalize_key(k): (
+ normalize_list_value(v) if k in LIST_KEYS else
+ normalize_value(v)
+ ) for k, v in [s.split("=") for s in constraints.split(" ")]}
return constraints
@@ -72,13 +76,12 @@
# Translate aliases to Megabytes. e.g. 1G = 10240
return int(value[:-1]) * FACTORS[value[-1:]]
- if "," in value:
- # Handle csv strings.
- values = value.split(",")
- values = [normalize_value(v) for v in values]
- return values
-
if value.isdigit():
return int(value)
return value
+
+
+def normalize_list_value(value):
+ values = value.strip().split(',')
+ return [normalize_value(value) for value in values]