Skip to content

Commit

Permalink
feat: support for site's restore and resinstall operations for manage…
Browse files Browse the repository at this point in the history
…d database service
  • Loading branch information
saurabh6790 committed May 28, 2024
1 parent 1a1111c commit 2ecbe00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
28 changes: 22 additions & 6 deletions press/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,20 @@ def new_site(self, site):

def reinstall_site(self, site):
database_server = frappe.db.get_value("Bench", site.bench, "database_server")
data = {
"mariadb_root_password": get_decrypted_password(

mariadb_root_password = (
site.get_password("db_password")
if site.managed_database
else get_decrypted_password(
"Database Server", database_server, "mariadb_root_password"
),
)
)

data = {
"mariadb_root_user": site.db_user,
"mariadb_root_password": mariadb_root_password,
"admin_password": site.get_password("admin_password"),
"managed_database": site.managed_database,
}

return self.create_agent_job(
Expand All @@ -141,16 +150,23 @@ def restore_site(self, site: "Site", skip_failing_patches=False):
public_link = frappe.get_doc("Remote File", site.remote_public_file).download_link
if site.remote_private_file:
private_link = frappe.get_doc("Remote File", site.remote_private_file).download_link

if site.managed_database:
mariadb_root_password = site.get_password("db_password")
else:
mariadb_root_password = get_decrypted_password(
"Database Server", database_server, "mariadb_root_password"
)
data = {
"apps": apps,
"mariadb_root_password": get_decrypted_password(
"Database Server", database_server, "mariadb_root_password"
),
"mariadb_root_password": mariadb_root_password,
"admin_password": site.get_password("admin_password"),
"database": frappe.get_doc("Remote File", site.remote_database_file).download_link,
"public": public_link,
"private": private_link,
"skip_failing_patches": skip_failing_patches,
"managed_database": site.managed_database,
"mariadb_root_user": site.db_user,
}

return self.create_agent_job(
Expand Down
2 changes: 1 addition & 1 deletion press/press/doctype/site/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def update_config_preview(self):
self.config = json.dumps(new_config, indent=4)

def _get_managed_db_config(self):
if self.db_host and self.db_user and self.db_password:
if self.managed_database:
return {
"managed_database": self.managed_database,
"db_host": self.db_host,
Expand Down

0 comments on commit 2ecbe00

Please sign in to comment.