X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fplacement.py;h=561bc40a9df0c0189aa694740590212653bba78a;hb=0d70179f2088da28e47bcad569366fb3dddd6e6d;hp=6f91aed0a83f131e789b89392ce4e1f587cd0e22;hpb=d0d72bc5f59b0931f835e1c3df29c9d988f3f02a;p=osm%2FN2VC.git diff --git a/juju/placement.py b/juju/placement.py index 6f91aed..561bc40 100644 --- a/juju/placement.py +++ b/juju/placement.py @@ -25,18 +25,28 @@ def parse(directive): if type(directive) in [dict, client.Placement]: # We've been handed something that we can simply hand back to # the api. (Forwards compatibility) - return directive + return [directive] + + # Juju 2.0 can't handle lxc containers. + directive = directive.replace('lxc', 'lxd') if ":" in directive: # Planner has given us a scope and directive in string form scope, directive = directive.split(":") - return client.Placement(scope=scope, directive=directive) + return [client.Placement(scope=scope, directive=directive)] if directive.isdigit(): # Planner has given us a machine id (we rely on juju core to # verify its validity.) - return client.Placement(scope=MACHINE_SCOPE, directive=directive) + return [client.Placement(scope=MACHINE_SCOPE, directive=directive)] + + if "/" in directive: + machine, container, container_num = directive.split("/") + return [ + client.Placement(scope=MACHINE_SCOPE, directive=machine), + client.Placement(scope=container, directive=container_num) + ] # Planner has probably given us a container type. Leave it up to # juju core to verify that it is valid. - return client.Placement(scope=directive) + return [client.Placement(scope=directive)]