Older cephadm clusters lack the 'hostname' key in the host spec. e.g.,
"cpach": {"addr": "cpach", "labels": ["mon"]}, "eutow": {"addr": "eutow", "labels": ["mon"]}, "stud": {"addr": "stud", "labels": ["mon"]}}
Populate hostname from the dict key if necessary for compatibility.
Signed-off-by: Sage Weil <sage@newdream.net>
i = self.mgr.get_store('inventory')
if i:
self._inventory: Dict[str, dict] = json.loads(i)
+ # handle old clusters missing 'hostname' key from hostspec
+ for k, v in self._inventory.items():
+ if 'hostname' not in v:
+ v['hostname'] = k
else:
self._inventory = dict()
logger.debug('Loaded inventory %s' % self._inventory)