[clusterd] apply modification due to microcluster lts
Sunbeam snap is now based on microcluster LTS. This new version brings breaking changes, such as moving endpoints to different api groups, and renaming the cluster groups into core. Change-Id: I93ffd4a12d0e66ffa43fe94291a24611670896ac Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
This commit is contained in:
parent
e31972c4b7
commit
0cc6521539
@ -91,7 +91,7 @@ class ClusterdClient:
|
||||
def ready(self) -> bool:
|
||||
"""Is the cluster ready."""
|
||||
try:
|
||||
self._get("cluster/1.0/ready")
|
||||
self._get("/core/1.0/ready")
|
||||
except ClusterdUnavailableError:
|
||||
return False
|
||||
return True
|
||||
@ -99,7 +99,7 @@ class ClusterdClient:
|
||||
def shutdown(self):
|
||||
"""Shutdown local clusterd."""
|
||||
try:
|
||||
self._post("cluster/control/shutdown")
|
||||
self._post("/core/control/shutdown")
|
||||
except requests.exceptions.HTTPError as e:
|
||||
if e.response is None:
|
||||
raise e
|
||||
@ -115,7 +115,7 @@ class ClusterdClient:
|
||||
def bootstrap(self, name: str, address: str):
|
||||
"""Bootstrap clusterd."""
|
||||
data = {"bootstrap": True, "address": address, "name": name}
|
||||
self._post("/cluster/control", data=json.dumps(data))
|
||||
self._post("/core/control", data=json.dumps(data))
|
||||
|
||||
def join(self, name: str, address: str, token: str) -> None:
|
||||
"""Join node to the micro cluster.
|
||||
@ -124,11 +124,11 @@ class ClusterdClient:
|
||||
joins the node with the given name and address.
|
||||
"""
|
||||
data = {"join_token": token, "address": address, "name": name}
|
||||
self._post("cluster/control", data=json.dumps(data))
|
||||
self._post("core/control", data=json.dumps(data))
|
||||
|
||||
def get_members(self) -> list[dict]:
|
||||
"""Get cluster members."""
|
||||
cluster = self._get("/cluster/1.0/cluster")["metadata"]
|
||||
cluster = self._get("/core/1.0/cluster")["metadata"]
|
||||
return cluster
|
||||
|
||||
def get_member(self, name) -> dict:
|
||||
@ -147,7 +147,7 @@ class ClusterdClient:
|
||||
"""Delete node."""
|
||||
int_force = 1 if force else 0
|
||||
try:
|
||||
self._delete(f"/cluster/1.0/cluster/{name}?force={int_force}")
|
||||
self._delete(f"/core/1.0/cluster/{name}?force={int_force}")
|
||||
except requests.exceptions.HTTPError as e:
|
||||
if e.response is None:
|
||||
raise e
|
||||
@ -178,7 +178,7 @@ class ClusterdClient:
|
||||
Generate a new token for the node with name.
|
||||
"""
|
||||
data = {"name": name}
|
||||
result = self._post("/cluster/1.0/tokens", data=json.dumps(data))
|
||||
result = self._post("/core/control/tokens", data=json.dumps(data))
|
||||
return str(result["metadata"])
|
||||
|
||||
def set_certs(self, ca: str, cert: str, key: str):
|
||||
|
@ -179,7 +179,7 @@ class ClusterdTest(test_utils.BaseCharmTest):
|
||||
)
|
||||
def _tenacity_handler() -> Tuple[str, str]:
|
||||
voter, spare = None, None
|
||||
output = self._query_clusterd(unit, "GET", "/cluster/1.0/cluster")
|
||||
output = self._query_clusterd(unit, "GET", "/core/1.0/cluster")
|
||||
metadata = output.get("metadata")
|
||||
if metadata is None:
|
||||
logging.warning("No metadata from clusterd, %r", output)
|
||||
@ -217,6 +217,6 @@ class ClusterdTest(test_utils.BaseCharmTest):
|
||||
self.fail("No unit found for voter {}".format(voter))
|
||||
model.block_until_all_units_idle()
|
||||
model.block_until_unit_wl_status(units[0], "active", timeout=60 * 5)
|
||||
output = self._query_clusterd(units[0], "GET", "/cluster/1.0/cluster")
|
||||
output = self._query_clusterd(units[0], "GET", "/core/1.0/cluster")
|
||||
self.assertEqual(output["status_code"], 200)
|
||||
self.assertEqual(len(output["metadata"]), 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user