from mgr_module import MgrModule
import mgr_util
import orchestrator
-from orchestrator import OrchestratorError, HostSpec, OrchestratorValidationError
+from orchestrator import OrchestratorError, HostPlacementSpec, OrchestratorValidationError
from . import remotes
* requires a placement_spec
- `place(host_pool)` needs to return a List[HostSpec, ..]
+ `place(host_pool)` needs to return a List[HostPlacementSpec, ..]
"""
def __init__(self, placement_spec):
self.placement_spec = placement_spec
def place(self, host_pool, count=None):
- # type: (List, Optional[int]) -> List[HostSpec]
+ # type: (List, Optional[int]) -> List[HostPlacementSpec]
raise NotImplementedError
super(SimpleScheduler, self).__init__(placement_spec)
def place(self, host_pool, count=None):
- # type: (List, Optional[int]) -> List[HostSpec]
+ # type: (List, Optional[int]) -> List[HostPlacementSpec]
if not host_pool:
raise Exception('List of host candidates is empty')
- host_pool = [HostSpec(x, '', '') for x in host_pool]
+ host_pool = [HostPlacementSpec(x, '', '') for x in host_pool]
# shuffle for pseudo random selection
random.shuffle(host_pool)
return host_pool[:count]
# NOTE: This currently queries for all hosts without label restriction
if self.spec.placement.label:
logger.info("Found labels. Assinging nodes that match the label")
- candidates = [HostSpec(x[0], '', '') for x in self.get_hosts_func()] # TODO: query for labels
+ candidates = [HostPlacementSpec(x[0], '', '') for x in self.get_hosts_func()] # TODO: query for labels
logger.info('Assigning nodes to spec: {}'.format(candidates))
self.spec.placement.set_hosts(candidates)
logger = logging.getLogger(__name__)
-class HostSpec(namedtuple('HostSpec', ['hostname', 'network', 'name'])):
+class HostPlacementSpec(namedtuple('HostPlacementSpec', ['hostname', 'network', 'name'])):
def __str__(self):
res = ''
res += self.hostname
return res
-def parse_host_specs(host, require_network=True):
+def parse_host_placement_specs(host, require_network=True):
+ # type: (str, Optional[bool]) -> HostPlacementSpec
"""
Split host into host, network, and (optional) daemon name parts. The network
part can be an IP, CIDR, or ceph addrvec like '[v2:1.2.3.4:3300,v1:1.2.3.4:6789]'.
name_re = r'=(.*?)$'
# assign defaults
- host_spec = HostSpec('', '', '')
+ host_spec = HostPlacementSpec('', '', '')
match_host = re.search(host_re, host)
if match_host:
# type: (Optional[str], Optional[List], Optional[int]) -> None
self.label = label
if hosts:
- if all([isinstance(host, HostSpec) for host in hosts]):
- self.hosts = hosts # type: List[HostSpec]
+ if all([isinstance(host, HostPlacementSpec) for host in hosts]):
+ self.hosts = hosts # type: List[HostPlacementSpec]
else:
- self.hosts = [parse_host_specs(x, require_network=False) for x in hosts if x]
+ self.hosts = [parse_host_placement_specs(x, require_network=False) for x in hosts if x]
else:
self.hosts = []
from orchestrator import raise_if_exception, RGWSpec, Completion, ProgressReference
from orchestrator import InventoryNode, ServiceDescription
from orchestrator import OrchestratorValidationError
-from orchestrator import parse_host_specs
+from orchestrator import parse_host_placement_specs
@pytest.mark.parametrize("test_input,expected, require_network",
("myhost:[v1:10.1.1.10:6789,v2:10.1.1.11:3000]", ('myhost', '[v1:10.1.1.10:6789,v2:10.1.1.11:3000]', ''), True),
("myhost:[v1:10.1.1.10:6789,v2:10.1.1.11:3000]=sname", ('myhost', '[v1:10.1.1.10:6789,v2:10.1.1.11:3000]', 'sname'), True),
])
-def test_parse_host_specs(test_input, expected, require_network):
- ret = parse_host_specs(test_input, require_network=require_network)
+def test_parse_host_placement_specs(test_input, expected, require_network):
+ ret = parse_host_placement_specs(test_input, require_network=require_network)
assert ret == expected
assert str(ret) == test_input
# empty string
("myhost=1"),
])
-def test_parse_host_specs_raises(test_input):
+def test_parse_host_placement_specs_raises(test_input):
with pytest.raises(ValueError):
- ret = parse_host_specs(test_input)
+ ret = parse_host_placement_specs(test_input)
def _test_resource(data, resource_class, extra=None):