Add backup location and mount failed repair (#93126)

* Add backup location and mount failed repair

* Fix coverage

* Change storage_location to backup_location

* Use backticks

* Update homeassistant/helpers/selector.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Mike Degatano 2023-05-24 04:33:41 -04:00 committed by GitHub
parent 9b53484e2e
commit 08a719e09e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 208 additions and 5 deletions

View file

@ -61,6 +61,7 @@ from .const import (
ATTR_FOLDERS,
ATTR_HOMEASSISTANT,
ATTR_INPUT,
ATTR_LOCATION,
ATTR_PASSWORD,
ATTR_REPOSITORY,
ATTR_SLUG,
@ -161,6 +162,9 @@ SCHEMA_BACKUP_FULL = vol.Schema(
vol.Optional(ATTR_NAME): cv.string,
vol.Optional(ATTR_PASSWORD): cv.string,
vol.Optional(ATTR_COMPRESSED): cv.boolean,
vol.Optional(ATTR_LOCATION): vol.All(
cv.string, lambda v: None if v == "/backup" else v
),
}
)

View file

@ -61,6 +61,7 @@ ATTR_VERSION = "version"
ATTR_VERSION_LATEST = "version_latest"
ATTR_CPU_PERCENT = "cpu_percent"
ATTR_CHANGELOG = "changelog"
ATTR_LOCATION = "location"
ATTR_MEMORY_PERCENT = "memory_percent"
ATTR_SLUG = "slug"
ATTR_STATE = "state"

View file

@ -85,6 +85,7 @@ UNHEALTHY_REASONS = {
# Keys (type + context) of issues that when found should be made into a repair
ISSUE_KEYS_FOR_REPAIRS = {
"issue_mount_mount_failed",
"issue_system_multiple_data_disks",
"issue_system_reboot_required",
}

View file

@ -16,6 +16,12 @@ from .issues import Issue, Suggestion, SupervisorIssues
SUGGESTION_CONFIRMATION_REQUIRED = {"system_execute_reboot"}
EXTRA_PLACEHOLDERS = {
"issue_mount_mount_failed": {
"storage_url": "/config/storage",
}
}
class SupervisorIssueRepairFlow(RepairsFlow):
"""Handler for an issue fixing flow."""
@ -42,11 +48,13 @@ class SupervisorIssueRepairFlow(RepairsFlow):
@property
def description_placeholders(self) -> dict[str, str] | None:
"""Get description placeholders for steps."""
return (
{PLACEHOLDER_KEY_REFERENCE: self.issue.reference}
if self.issue and self.issue.reference
else None
)
placeholders = {}
if self.issue:
placeholders = EXTRA_PLACEHOLDERS.get(self.issue.key, {})
if self.issue.reference:
placeholders |= {PLACEHOLDER_KEY_REFERENCE: self.issue.reference}
return placeholders or None
def _async_form_for_suggestion(self, suggestion: Suggestion) -> FlowResult:
"""Return form for suggestion."""

View file

@ -88,6 +88,12 @@ backup_full:
default: true
selector:
boolean:
location:
name: Location
description: Name of a backup network storage to put backup (or /backup)
example: my_backup_mount
selector:
backup_location:
backup_partial:
name: Create a partial backup.
@ -128,6 +134,12 @@ backup_partial:
default: true
selector:
boolean:
location:
name: Location
description: Name of a backup network storage to put backup (or /backup)
example: my_backup_mount
selector:
backup_location:
restore_full:
name: Restore from full backup.

View file

@ -17,6 +17,23 @@
}
},
"issues": {
"issue_mount_mount_failed": {
"title": "Network storage device failed",
"fix_flow": {
"step": {
"fix_menu": {
"description": "Could not connect to `{reference}`. Check host logs for errors from the mount service for more details.\n\nUse reload to try to connect again. If you need to update `{reference}`, go to [storage]({storage_url}).",
"menu_options": {
"mount_execute_reload": "Reload",
"mount_execute_remove": "Remove"
}
}
},
"abort": {
"apply_suggestion_fail": "Could not apply the fix. Check the supervisor logs for more details."
}
}
},
"issue_system_multiple_data_disks": {
"title": "Multiple data disks detected",
"fix_flow": {