Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #391 and #418 #419

Merged
merged 7 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions plugins/module_utils/ndb/database_clones.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ def get_clone_refresh_spec(self):
payload["snapshotId"] = self.module.params.get("snapshot_uuid")
elif self.module.params.get("pitr_timestamp"):
payload["userPitrTimestamp"] = self.module.params.get("pitr_timestamp")
elif self.module.params.get("latest_snapshot", False):
payload["latestSnapshot"] = True
else:
return (
None,
"snapshot_uuid or pitr_timestamp is required for database clone refresh",
"One of snapshot_uuid, pitr_timestamp or latest_snapshot is required for database clone refresh",
)

payload["timeZone"] = self.module.params.get("timezone")
Expand Down Expand Up @@ -237,10 +239,12 @@ def _build_spec_time_machine(self, payload, time_machine):
payload["snapshotId"] = time_machine.get("snapshot_uuid")
elif time_machine.get("pitr_timestamp"):
payload["userPitrTimestamp"] = time_machine.get("pitr_timestamp")
elif time_machine.get("latest_snapshot", False):
payload["latestSnapshot"] = True
else:
return (
None,
"Required snapshot_uuid or pitr_timestamp for source of db clone",
"Required one of snapshot_uuid, pitr_timestamp or latest_snapshot for source of db clone",
)

payload["timeZone"] = time_machine.get("timezone")
Expand Down
7 changes: 5 additions & 2 deletions plugins/module_utils/ndb/time_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def get_time_machine(self, uuid=None, name=None, query=None):
if uuid:
resp = self.read(uuid=uuid, query=query)
elif name:
endpoint = "{0}/{1}".format("name", name)
resp = self.read(endpoint=endpoint, query=query)
if not query:
query = {}
query["value_type"] = "name"
query["value"] = name
resp = self.read(query=query)
if isinstance(resp, list):
if not resp:
return None, "Time machine with name {0} not found".format(name)
Expand Down
5 changes: 3 additions & 2 deletions plugins/modules/ntnx_ndb_database_clone_refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def get_module_spec():
snapshot_uuid=dict(type="str", required=False),
timezone=dict(type="str", default="Asia/Calcutta", required=False),
pitr_timestamp=dict(type="str", required=False),
latest_snapshot=dict(type="bool", required=False)
)
return module_args

Expand Down Expand Up @@ -340,12 +341,12 @@ def refresh_clone(module, result):

def run_module():
mutually_exclusive_list = [
("snapshot_uuid", "pitr_timestamp"),
("snapshot_uuid", "pitr_timestamp", "latest_snapshot"),
]
module = NdbBaseModule(
argument_spec=get_module_spec(),
supports_check_mode=True,
required_if=[("state", "present", ("snapshot_uuid", "pitr_timestamp"), True)],
required_if=[("state", "present", ("snapshot_uuid", "pitr_timestamp", "latest_snapshot"), True)],
mutually_exclusive=mutually_exclusive_list,
)
remove_param_with_none_value(module.params)
Expand Down
3 changes: 2 additions & 1 deletion plugins/modules/ntnx_ndb_database_clones.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ def get_module_spec():
uuid=dict(type="str", required=False),
snapshot_uuid=dict(type="str", required=False),
pitr_timestamp=dict(type="str", required=False),
latest_snapshot=dict(type="bool", required=False),
timezone=dict(type="str", default="Asia/Calcutta", required=False),
)

Expand Down Expand Up @@ -700,7 +701,7 @@ def get_module_spec():
time_machine=dict(
type="dict",
options=time_machine,
mutually_exclusive=[("snapshot_uuid", "pitr_timestamp")],
mutually_exclusive=[("snapshot_uuid", "pitr_timestamp", "latest_snapshot")],
required=False,
),
postgres=dict(type="dict", options=postgres, required=False),
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ntnx_ndb_time_machines_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def get_time_machine(module, result):
resp, err = tm.get_time_machine(uuid=uuid, name=name, query=query_params)
if err:
result["error"] = err
module.fail_json(msg="Failed fetching sla info", **result)
module.fail_json(msg="Failed fetching time machine info", **result)
result["response"] = resp


Expand Down
Loading