summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/orchestrator.py
diff options
context:
space:
mode:
authorSebastian Wagner <sebastian.wagner@suse.com>2019-12-13 17:32:00 +0100
committerSebastian Wagner <sebastian.wagner@suse.com>2019-12-17 16:27:57 +0100
commit70bae966aa48b932f019c1f081d66c47858faaee (patch)
treeba7f633d457a92f8aa8ee7314f953868905c34ff /src/pybind/mgr/orchestrator.py
parentmgr/ansible: Added missing type annotations (diff)
downloadceph-70bae966aa48b932f019c1f081d66c47858faaee.tar.xz
ceph-70bae966aa48b932f019c1f081d66c47858faaee.zip
mgr/orchestrator: Rename PlacementSpec.nodes -> PlacementSpec.hosts
By definition in the orchestrator's docs, we're using `host` insted of `node` Fixes wrong usage of PlacementSpec in mgr/ansible Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Diffstat (limited to 'src/pybind/mgr/orchestrator.py')
-rw-r--r--src/pybind/mgr/orchestrator.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py
index 169e8e2585f..751c62517bc 100644
--- a/src/pybind/mgr/orchestrator.py
+++ b/src/pybind/mgr/orchestrator.py
@@ -1050,22 +1050,23 @@ class PlacementSpec(object):
"""
For APIs that need to specify a node subset
"""
- def __init__(self, label=None, nodes=None, count=None):
+ def __init__(self, label=None, hosts=None, count=None):
# type: (Optional[str], Optional[List], Optional[int]) -> None
self.label = label
- if nodes:
- if all([isinstance(node, HostSpec) for node in nodes]):
- self.nodes = nodes
+ if hosts:
+ if all([isinstance(host, HostSpec) for host in hosts]):
+ self.hosts = hosts # type: List[HostSpec]
else:
- self.nodes = [parse_host_specs(x, require_network=False) for x in nodes if x]
+ self.hosts = [parse_host_specs(x, require_network=False) for x in hosts if x]
else:
- self.nodes = []
+ self.hosts = []
+
self.count = count # type: Optional[int]
- def set_nodes(self, nodes):
- # To backpopulate the .nodes attribute when using labels or count
+ def set_hosts(self, hosts):
+ # To backpopulate the .hosts attribute when using labels or count
# in the orchestrator backend.
- self.nodes = nodes
+ self.hosts = hosts
@classmethod
def from_dict(cls, data):
@@ -1074,7 +1075,7 @@ class PlacementSpec(object):
return _cls
def validate(self):
- if self.nodes and self.label:
+ if self.hosts and self.label:
# TODO: a less generic Exception
raise Exception('Node and label are mutually exclusive')
if self.count is not None and self.count <= 0:
@@ -1193,9 +1194,15 @@ class StatefulServiceSpec(object):
"""
# TODO: create base class for Stateless/Stateful service specs and propertly inherit
def __init__(self, name=None, placement=None):
- self.placement = PlacementSpec() if placement is None else placement
+ # type: (Optional[str], Optional[PlacementSpec]) -> None
+ self.placement = PlacementSpec() if placement is None else placement # type: PlacementSpec
self.name = name
- self.count = self.placement.count if self.placement is not None else 1 # for backwards-compatibility
+
+ # for backwards-compatibility
+ if self.placement is not None and self.placement.count is not None:
+ self.count = self.placement.count
+ else:
+ self.count = 1
class StatelessServiceSpec(object):
@@ -1211,12 +1218,12 @@ class StatelessServiceSpec(object):
# start the services.
def __init__(self, name, placement=None):
- self.placement = PlacementSpec() if placement is None else placement
+ self.placement = PlacementSpec() if placement is None else placement # type: PlacementSpec
#: Give this set of statelss services a name: typically it would
#: be the name of a CephFS filesystem, RGW zone, etc. Must be unique
#: within one ceph cluster.
- self.name = name
+ self.name = name # type: str
#: Count of service instances
self.count = self.placement.count if self.placement is not None else 1 # for backwards-compatibility
@@ -1273,7 +1280,7 @@ class RGWSpec(StatelessServiceSpec):
#: List of hosts where RGWs should run. Not for Rook.
if hosts:
- self.placement.hosts = hosts
+ self.placement = PlacementSpec(hosts=hosts)
#: is multisite
self.rgw_multisite = rgw_multisite