Skip to content

Commit

Permalink
adding clusterID to astra-connector install
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Haigh <mhaigh@netapp.com>
  • Loading branch information
MichaelHaigh committed May 3, 2024
1 parent 764560f commit 9080b48
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
17 changes: 14 additions & 3 deletions astraSDK/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,28 @@ def __init__(self, quiet=True, verbose=False, config=None):
self.headers["accept"] = "application/astra-cluster+json"
self.headers["Content-Type"] = "application/astra-cluster+json"

def main(self, cloudID, credentialID, privateRouteID=None):
def main(
self, cloudID, credentialID=None, privateRouteID=None, name=None, connectorInstall=False
):
if (not credentialID) and (not name or not connectorInstall):
raise SystemExit(
"Either credentialID or both of (name and connectorInstall) should be specified"
)
endpoint = f"topology/v1/clouds/{cloudID}/clusters"
url = self.base + endpoint
params = {}
data = {
"type": "application/astra-cluster",
"version": "1.5",
"credentialID": credentialID,
"version": "1.6",
}
if credentialID:
data["credentialID"] = credentialID
if privateRouteID:
data["privateRouteID"] = privateRouteID
if name:
data["name"] = name
if connectorInstall:
data["connectorInstall"] = "pending"

ret = super().apicall(
"post",
Expand Down
9 changes: 8 additions & 1 deletion astraSDK/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ def __init__(
def main(
self,
clusterName,
clusterID,
cloudID,
apiToken,
regCred,
Expand All @@ -1026,6 +1027,7 @@ def main(
"astra": {
"accountId": self.conf["account_id"],
"cloudId": cloudID,
"clusterId": clusterID,
"clusterName": clusterName,
"skipTLSValidation": not self.conf["session"].verify,
"tokenRef": apiToken,
Expand Down Expand Up @@ -1082,7 +1084,12 @@ def main(
"kind": "AstraConnector",
"metadata": {"name": name, "namespace": namespace},
"spec": {
"astra": {"clusterName": clusterName},
"astra": {
"clusterName": clusterName,
"clusterId": "123",
"cloudId": "123",
"accountId": "123",
},
"natsSyncClient": {"cloudBridgeURL": "127.0.0.1"},
"imageRegistry": {"name": registry, "secret": regCred},
},
Expand Down
2 changes: 1 addition & 1 deletion tkSrc/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def main(args, ard, config=None):
quiet=args.quiet, verbose=args.verbose, config=config
).main(
args.cloudID,
rc["id"],
credentialID=rc["id"],
privateRouteID=args.privateRouteID,
)
if rc is False:
Expand Down
14 changes: 13 additions & 1 deletion tkSrc/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,26 @@ def manageV3Cluster(
skip_tls_verify=skip_tls_verify,
).main(clusterName, regCred, registry)
else:
rc = astraSDK.clusters.addCluster(quiet=quiet, verbose=verbose, config=config).main(
cloudID, name=clusterName, connectorInstall=True
)
if not rc:
raise SystemExit("astraSDK.clusters.addCluster() failed")
connector = astraSDK.k8s.createAstraConnector(
quiet=quiet,
dry_run=dry_run,
verbose=verbose,
config_context=v3,
skip_tls_verify=skip_tls_verify,
config=config,
).main(clusterName, cloudID, apiToken["metadata"]["name"], regCred, registry=registry)
).main(
clusterName,
rc["id"],
cloudID,
apiToken["metadata"]["name"],
regCred,
registry=registry,
)
if not connector:
raise SystemExit("astraSDK.k8s.createAstraConnector() failed")

Expand Down

0 comments on commit 9080b48

Please sign in to comment.