mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-10-10 20:29:37 +00:00

* Refactory code / object handling * Next step * fix lint * Step 2 * Cleanup API code * cleanup addons code * cleanup data handling * Cleanup addons data handling * Cleanup docker api * clean docker api p2 * next cleanup round * cleanup start on snapshots * update format strings * fix setup * fix lint * fix lint * fix lint * fix tox * Fix wrong import of datetime module * Fix bug with attributes * fix extraction * Update core * Update logs * Expand scheduler * add support for time interval objects * next updates on tasks * Fix some things * Cleanup code / supervisor * fix lint * Fix some code styles * rename stuff * cleanup api call reload * fix lock replacment * fix lint * fix lint * fix bug * fix wrong config links * fix bugs * fix bug * Update version on startup * Fix some bugs * fix bug * Fix snapshot * Add wait boot options * fix lint * fix default config * fix snapshot * fix snapshot * load snapshots on startup * add log message at the end * Some cleanups * fix bug * add logger * add logger for supervisor update * Add more logger
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""Init file for HassIO docker object."""
|
|
import logging
|
|
import os
|
|
|
|
import docker
|
|
|
|
from .interface import DockerInterface
|
|
from ..coresys import CoreSysAttributes
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
|
"""Docker hassio wrapper for HomeAssistant."""
|
|
|
|
@property
|
|
def name(self):
|
|
"""Return name of docker container."""
|
|
return os.environ['SUPERVISOR_NAME']
|
|
|
|
def _attach(self):
|
|
"""Attach to running docker container.
|
|
|
|
Need run inside executor.
|
|
"""
|
|
try:
|
|
container = self._docker.containers.get(self.name)
|
|
except docker.errors.DockerException:
|
|
return False
|
|
|
|
self._meta = container.attrs
|
|
_LOGGER.info("Attach to supervisor %s with version %s",
|
|
self.image, self.version)
|
|
|
|
# if already attach
|
|
if container in self._docker.network.containers:
|
|
return True
|
|
|
|
# attach to network
|
|
return self._docker.network.attach_container(
|
|
container, alias=['hassio'], ipv4=self._docker.network.supervisor)
|