X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fconstraints.py;h=43c048ae4fb87cc0e1434540b0725a22d31c1da1;hb=ea3d50fc8145b8182ce8dd191ae750b42f5ff2ba;hp=d7137742ccd703929d05ec45348af883fb2a678d;hpb=b87114e40c5f095103be4a9339b38552333d0190;p=osm%2FN2VC.git diff --git a/juju/constraints.py b/juju/constraints.py index d713774..43c048a 100644 --- a/juju/constraints.py +++ b/juju/constraints.py @@ -1,5 +1,5 @@ # -# Library to parse constraints +# Module that parses constraints # # The current version of juju core expects the client to take # constraints given in the form "mem=10G foo=bar" and parse them into @@ -11,6 +11,9 @@ # constraints keys are valid, and that we can successfully dump the # constraints dict to json. # +# Once https://bugs.launchpad.net/juju/+bug/1645402 is addressed, this +# module should be deprecated. +# import re @@ -34,6 +37,10 @@ def parse(constraints): if constraints is None: return None + if type(constraints) is dict: + # Fowards compatibilty: already parsed + return constraints + constraints = { normalize_key(k): normalize_value(v) for k, v in [ s.split("=") for s in constraints.split(" ")]}