Skip to content

Commit

Permalink
gravel: ctrl/nodes: add host to orchestrator
Browse files Browse the repository at this point in the history
Signed-off-by: Joao Eduardo Luis <[email protected]>
  • Loading branch information
jecluis committed Mar 9, 2021
1 parent 9e9017c commit 890c023
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/gravel/controllers/nodes/mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ async def _handle_ready_to_add(
node: JoiningNodeModel = self._joining[address]
logger.info("=> mgr -- handle ready to add > "
f"hostname: {node.hostname}, address: {node.address}")
orch = Orchestrator()
if not orch.host_add(node.hostname, node.address):
logger.error("=> mgr -- handle ready > failed adding host to orch")


_nodemgr: Optional[NodeMgr] = None
Expand Down
34 changes: 31 additions & 3 deletions src/gravel/controllers/orch/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@

from typing import Any, Dict, List

from logging import Logger
from fastapi.logger import logger as fastapi_logger
from pydantic.tools import parse_obj_as
from gravel.controllers.orch.ceph import Mgr
from gravel.controllers.orch.models \
import OrchDevicesPerHostModel, OrchHostListModel
from gravel.controllers.orch.ceph import (
CephCommandError,
Mgr
)
from gravel.controllers.orch.models import (
OrchDevicesPerHostModel,
OrchHostListModel
)


logger: Logger = fastapi_logger


class Orchestrator:
Expand Down Expand Up @@ -61,3 +71,21 @@ def get_public_key(self) -> str:
res = self.call(cmd)
assert "result" in res
return res["result"]

def host_add(self, hostname: str, address: str) -> bool:
assert hostname
assert address

cmd = {
"prefix": "orch host add",
"hostname": hostname,
"addr": address
}
try:
self.call(cmd)
except CephCommandError:
logger.error(
f"=> orch -- host add > unable to add {hostname} {address}"
)
return False
return True

0 comments on commit 890c023

Please sign in to comment.