X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fplacement.py;h=561bc40a9df0c0189aa694740590212653bba78a;hb=e89d5d4e03bb39c0dc5f0606f6f32b77e7d152b2;hp=62cd5705902e833c319d5279aaa72190354e621e;hpb=0056d3f87102e50a1c35c05bdfa25124c387440f;p=osm%2FN2VC.git diff --git a/juju/placement.py b/juju/placement.py index 62cd570..561bc40 100644 --- a/juju/placement.py +++ b/juju/placement.py @@ -6,9 +6,10 @@ # module should be deprecated. # +from .client import client + MACHINE_SCOPE = "#" -from .client import client def parse(directive): """ @@ -17,25 +18,35 @@ def parse(directive): back over the websocket API. """ - if directive == "": + if not directive: # Handle null case return None 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)]