projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update changelog for 0.4.0
[osm/N2VC.git]
/
juju
/
placement.py
diff --git
a/juju/placement.py
b/juju/placement.py
index
62cd570
..
d0d42f7
100644
(file)
--- a/
juju/placement.py
+++ b/
juju/placement.py
@@
-6,9
+6,10
@@
# module should be deprecated.
#
# module should be deprecated.
#
+from .client import client
+
MACHINE_SCOPE = "#"
MACHINE_SCOPE = "#"
-from .client import client
def parse(directive):
"""
def parse(directive):
"""
@@
-17,25
+18,41
@@
def parse(directive):
back over the websocket API.
"""
back over the websocket API.
"""
- if
directive == ""
:
+ if
not directive
:
# Handle null case
return None
# Handle null case
return None
- if type(directive) in [dict, client.Placement]:
+ if isinstance(directive, (list, tuple)):
+ results = []
+ for d in directive:
+ results.extend(parse(d))
+ return results
+
+ if isinstance(directive, (dict, client.Placement)):
# We've been handed something that we can simply hand back to
# the api. (Forwards compatibility)
# 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(":")
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.)
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:
+ # e.g. "0/lxd/0"
+ # https://github.com/juju/juju/blob/master/instance/placement_test.go#L29
+ return [
+ client.Placement(scope=MACHINE_SCOPE, directive=directive),
+ ]
# Planner has probably given us a container type. Leave it up to
# juju core to verify that it is valid.
# 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)]