mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Supervisor image handler (#2757)
This commit is contained in:
parent
900b785789
commit
98f8e032e3
@ -14,6 +14,7 @@ from .const import (
|
|||||||
ATTR_DEBUG_BLOCK,
|
ATTR_DEBUG_BLOCK,
|
||||||
ATTR_DIAGNOSTICS,
|
ATTR_DIAGNOSTICS,
|
||||||
ATTR_FORCE_SECURITY,
|
ATTR_FORCE_SECURITY,
|
||||||
|
ATTR_IMAGE,
|
||||||
ATTR_LAST_BOOT,
|
ATTR_LAST_BOOT,
|
||||||
ATTR_LOGGING,
|
ATTR_LOGGING,
|
||||||
ATTR_TIMEZONE,
|
ATTR_TIMEZONE,
|
||||||
@ -69,14 +70,24 @@ class CoreConfig(FileConfiguration):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def version(self) -> AwesomeVersion:
|
def version(self) -> AwesomeVersion:
|
||||||
"""Return config version."""
|
"""Return supervisor version."""
|
||||||
return self._data[ATTR_VERSION]
|
return self._data[ATTR_VERSION]
|
||||||
|
|
||||||
@version.setter
|
@version.setter
|
||||||
def version(self, value: AwesomeVersion) -> None:
|
def version(self, value: AwesomeVersion) -> None:
|
||||||
"""Set config version."""
|
"""Set supervisor version."""
|
||||||
self._data[ATTR_VERSION] = value
|
self._data[ATTR_VERSION] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image(self) -> Optional[str]:
|
||||||
|
"""Return supervisor image."""
|
||||||
|
return self._data.get(ATTR_IMAGE)
|
||||||
|
|
||||||
|
@image.setter
|
||||||
|
def image(self, value: str) -> None:
|
||||||
|
"""Set supervisor image."""
|
||||||
|
self._data[ATTR_IMAGE] = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wait_boot(self) -> int:
|
def wait_boot(self) -> int:
|
||||||
"""Return wait time for auto boot stages."""
|
"""Return wait time for auto boot stages."""
|
||||||
|
@ -467,6 +467,9 @@ class DockerInterface(CoreSysAttributes):
|
|||||||
raise DockerError() from err
|
raise DockerError() from err
|
||||||
|
|
||||||
for image in images_list:
|
for image in images_list:
|
||||||
|
if origin.id == image.id:
|
||||||
|
continue
|
||||||
|
|
||||||
with suppress(docker.errors.DockerException, requests.RequestException):
|
with suppress(docker.errors.DockerException, requests.RequestException):
|
||||||
_LOGGER.info("Cleanup images: %s", image.tags)
|
_LOGGER.info("Cleanup images: %s", image.tags)
|
||||||
self.sys_docker.images.remove(image.id, force=True)
|
self.sys_docker.images.remove(image.id, force=True)
|
||||||
|
@ -102,6 +102,7 @@ class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
|||||||
if start_tag != "latest":
|
if start_tag != "latest":
|
||||||
continue
|
continue
|
||||||
docker_image.tag(start_image, start_tag)
|
docker_image.tag(start_image, start_tag)
|
||||||
|
docker_image.tag(start_image, version.string)
|
||||||
|
|
||||||
except (docker.errors.DockerException, requests.RequestException) as err:
|
except (docker.errors.DockerException, requests.RequestException) as err:
|
||||||
_LOGGER.error("Can't fix start tag: %s", err)
|
_LOGGER.error("Can't fix start tag: %s", err)
|
||||||
|
@ -46,7 +46,7 @@ class Supervisor(CoreSysAttributes):
|
|||||||
_LOGGER.critical("Can't setup Supervisor Docker container!")
|
_LOGGER.critical("Can't setup Supervisor Docker container!")
|
||||||
|
|
||||||
with suppress(DockerError):
|
with suppress(DockerError):
|
||||||
await self.instance.cleanup()
|
await self.instance.cleanup(old_image=self.sys_config.image)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connectivity(self) -> bool:
|
def connectivity(self) -> bool:
|
||||||
@ -161,6 +161,7 @@ class Supervisor(CoreSysAttributes):
|
|||||||
raise SupervisorUpdateError() from err
|
raise SupervisorUpdateError() from err
|
||||||
else:
|
else:
|
||||||
self.sys_config.version = version
|
self.sys_config.version = version
|
||||||
|
self.sys_config.image = self.sys_updater.image_supervisor
|
||||||
self.sys_config.save_data()
|
self.sys_config.save_data()
|
||||||
|
|
||||||
self.sys_create_task(self.sys_core.stop())
|
self.sys_create_task(self.sys_core.stop())
|
||||||
|
@ -140,6 +140,7 @@ SCHEMA_SUPERVISOR_CONFIG = vol.Schema(
|
|||||||
vol.Optional(
|
vol.Optional(
|
||||||
ATTR_VERSION, default=AwesomeVersion(SUPERVISOR_VERSION)
|
ATTR_VERSION, default=AwesomeVersion(SUPERVISOR_VERSION)
|
||||||
): version_tag,
|
): version_tag,
|
||||||
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
ATTR_ADDONS_CUSTOM_LIST,
|
ATTR_ADDONS_CUSTOM_LIST,
|
||||||
default=["https://github.com/hassio-addons/repository"],
|
default=["https://github.com/hassio-addons/repository"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user