From 1a06248f485c30bd092c24d854459c1fe3c652ee Mon Sep 17 00:00:00 2001 From: Tim Van Steenburgh Date: Wed, 22 Feb 2017 11:05:32 -0500 Subject: [PATCH] Correct MB/GB constants --- examples/add_machine.py | 4 ++-- juju/constraints.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/add_machine.py b/examples/add_machine.py index 34f7869..c5f9a6c 100755 --- a/examples/add_machine.py +++ b/examples/add_machine.py @@ -13,8 +13,8 @@ import logging from juju import loop from juju.model import Model -MB = 1024 * 1024 -GB = MB * 1024 +MB = 1 +GB = 1024 async def main(): diff --git a/juju/constraints.py b/juju/constraints.py index 97529e4..c551883 100644 --- a/juju/constraints.py +++ b/juju/constraints.py @@ -21,6 +21,7 @@ import re MEM = re.compile('^[1-9][0-9]*[MGTP]$') # Multiplication factors to get Megabytes +# https://github.com/juju/juju/blob/master/constraints/constraints.go#L666 FACTORS = { "M": 1, "G": 1024, @@ -31,6 +32,7 @@ FACTORS = { SNAKE1 = re.compile(r'(.)([A-Z][a-z]+)') SNAKE2 = re.compile('([a-z0-9])([A-Z])') + def parse(constraints): """ Constraints must be expressed as a string containing only spaces -- 2.25.1