Skip to content

Commit 94860e1

Browse files
authored
Merge pull request #423 from hnousiainen/htn_disaster_recovery
client: support disaster recovery pair handling
2 parents 71d9123 + b16d4dc commit 94860e1

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

aiven/client/cli.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ def _get_connection_info_pg(self, service_name: str) -> PGConnectionInfo:
15061506
@arg.project
15071507
@arg.service_name
15081508
@arg("-r", "--route", choices=("dynamic", "privatelink", "public"))
1509-
@arg("--usage", choices=("primary", "replica"))
1509+
@arg("--usage", choices=("primary", "replica", "disaster_recovery"))
15101510
@arg("-p", "--privatelink-connection-id")
15111511
@arg("--replica", action="store_true")
15121512
@arg("-u", "--username", default="avnadmin")
@@ -1521,7 +1521,7 @@ def service__connection_info__psql(self) -> None:
15211521
@arg.project
15221522
@arg.service_name
15231523
@arg("-r", "--route", choices=("dynamic", "privatelink", "public"))
1524-
@arg("--usage", choices=("primary", "replica"))
1524+
@arg("--usage", choices=("primary", "replica", "disaster_recovery"))
15251525
@arg("-p", "--privatelink-connection-id")
15261526
@arg("--replica", action="store_true")
15271527
@arg("-u", "--username", default="avnadmin")
@@ -1535,7 +1535,7 @@ def service__connection_info__pg__uri(self) -> None:
15351535
@arg.project
15361536
@arg.service_name
15371537
@arg("-r", "--route", choices=("dynamic", "privatelink", "public"))
1538-
@arg("--usage", choices=("primary", "replica"))
1538+
@arg("--usage", choices=("primary", "replica", "disaster_recovery"))
15391539
@arg("-p", "--privatelink-connection-id")
15401540
@arg("--replica", action="store_true")
15411541
@arg("-u", "--username", default="avnadmin")
@@ -4022,6 +4022,10 @@ def _get_plan(self) -> str:
40224022
"--read-replica-for",
40234023
help="Creates a read replica for given source service. Only applicable for certain service types",
40244024
)
4025+
@arg(
4026+
"--disaster-recovery-copy-for",
4027+
help="Cretes a disaster recovery copy for given source service. Only applicable for certain service types",
4028+
)
40254029
@arg(
40264030
"--enable-termination-protection",
40274031
action="store_true",
@@ -4062,6 +4066,13 @@ def service__create(self) -> None:
40624066
"source_service": self.args.read_replica_for,
40634067
}
40644068
)
4069+
elif self.args.disaster_recovery_copy_for:
4070+
service_integrations.append(
4071+
{
4072+
"integration_type": "disaster_recovery",
4073+
"source_service": self.args.disaster_recovery_copy_for,
4074+
}
4075+
)
40654076
elif self.args.recovery_target_time and self.args.service_to_fork_from:
40664077
user_config["service_to_fork_from"] = self.args.service_to_fork_from
40674078
user_config["recovery_target_time"] = self.args.recovery_target_time
@@ -4290,6 +4301,11 @@ def _get_maintenance(self) -> Mapping[str, str] | None:
42904301
action="store_true",
42914302
help="Do not put the service into a project VPC even if the project has one in the selected cloud",
42924303
)
4304+
@arg(
4305+
"--disaster-recovery-role",
4306+
help="Set disaster recovery role",
4307+
choices=["active", "passive", "failed"],
4308+
)
42934309
@arg.force
42944310
def service__update(self) -> None:
42954311
"""Update service settings"""
@@ -4345,6 +4361,7 @@ def service__update(self) -> None:
43454361
termination_protection=termination_protection,
43464362
project_vpc_id=project_vpc_id,
43474363
schema_registry_authorization=schema_registry_authorization,
4364+
disaster_recovery_role=self.args.disaster_recovery_role,
43484365
)
43494366
except client.Error as ex:
43504367
try:

aiven/client/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ def update_service(
14721472
termination_protection: bool | None = None,
14731473
project_vpc_id: object | str = UNDEFINED,
14741474
schema_registry_authorization: bool | None = None,
1475+
disaster_recovery_role: str | None = None,
14751476
) -> Mapping:
14761477
user_config = user_config or {}
14771478
body: dict[str, Any] = {}
@@ -1495,6 +1496,8 @@ def update_service(
14951496
body["termination_protection"] = termination_protection
14961497
if schema_registry_authorization is not None:
14971498
body["schema_registry_authz"] = schema_registry_authorization
1499+
if disaster_recovery_role is not None:
1500+
body["disaster_recovery_role"] = disaster_recovery_role
14981501
path = self.build_path("project", project, "service", service)
14991502
return self.verify(self.put, path, body=body, result_key="service")
15001503

0 commit comments

Comments
 (0)