mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-10-21 17:49:28 +00:00

* Add Ingress support to supervisor * Update security * cleanup add-on extraction * update description * fix header part * fix * Fix header check * fix tox * Migrate docker interface typing * Update home assistant to new docker * Migrate supervisor * Fix host add-on problem * Update hassos * Update API * Expose data to API * Check on API ingress support * Add ingress URL * Some cleanups * debug * disable uvloop * Fix issue * test * Fix bug * Fix flow * Fix interface * Fix network * Fix metadata * cleanups * Fix exception * Migrate to token system * Fix webui * Fix update * Fix relaod * Update log messages * Attach ingress url only if enabled * Cleanup ingress url handling * Ingress update * Support check version * Fix raise error * Migrate default port * Fix junks * search error * Fix content filter * Add debug * Update log * Update flags * Update documentation * Cleanup debugs * Fix lint * change default port to 8099 * Fix lint * fix lint
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
"""Init file for Hass.io Docker object."""
|
|
from ipaddress import IPv4Address
|
|
import logging
|
|
import os
|
|
|
|
import docker
|
|
|
|
from ..coresys import CoreSysAttributes
|
|
from ..exceptions import DockerAPIError
|
|
from .interface import DockerInterface
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
|
"""Docker Hass.io wrapper for Supervisor."""
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
"""Return name of Docker container."""
|
|
return os.environ["SUPERVISOR_NAME"]
|
|
|
|
@property
|
|
def ip_address(self) -> IPv4Address:
|
|
"""Return IP address of this container."""
|
|
return self.sys_docker.network.supervisor
|
|
|
|
def _attach(self) -> None:
|
|
"""Attach to running docker container.
|
|
|
|
Need run inside executor.
|
|
"""
|
|
try:
|
|
docker_container = self.sys_docker.containers.get(self.name)
|
|
except docker.errors.DockerException:
|
|
raise DockerAPIError() from None
|
|
|
|
self._meta = docker_container.attrs
|
|
_LOGGER.info(
|
|
"Attach to Supervisor %s with version %s", self.image, self.version
|
|
)
|
|
|
|
# If already attach
|
|
if docker_container in self.sys_docker.network.containers:
|
|
return
|
|
|
|
# Attach to network
|
|
_LOGGER.info("Connect Supervisor to Hass.io Network")
|
|
self.sys_docker.network.attach_container(
|
|
docker_container, alias=["hassio"], ipv4=self.sys_docker.network.supervisor
|
|
)
|