mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-27 11:06:32 +00:00
cleanup old stuff.
This commit is contained in:
parent
5a642cafa4
commit
b0a6d50d32
@ -35,7 +35,7 @@ class HassIO(object):
|
|||||||
self.host_controll = HostControll(self.loop)
|
self.host_controll = HostControll(self.loop)
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
"""Start HassIO."""
|
"""Start HassIO orchestration."""
|
||||||
await self.supervisor.attach()
|
await self.supervisor.attach()
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"Attach to supervisor image %s version %s", self.supervisor.image,
|
"Attach to supervisor image %s version %s", self.supervisor.image,
|
||||||
@ -50,22 +50,34 @@ class HassIO(object):
|
|||||||
# first start of supervisor?
|
# first start of supervisor?
|
||||||
if self.config.homeassistant_tag is None:
|
if self.config.homeassistant_tag is None:
|
||||||
_LOGGER.info("No HomeAssistant docker found. Install it now")
|
_LOGGER.info("No HomeAssistant docker found. Install it now")
|
||||||
|
await self._setup_homeassistant()
|
||||||
# read homeassistant tag and install it
|
|
||||||
current = None
|
|
||||||
while True:
|
|
||||||
current = await tools.fetch_current_versions(self.websession)
|
|
||||||
if current and HOMEASSISTANT_TAG in current:
|
|
||||||
resp = await self.homeassistant.install(
|
|
||||||
current[HOMEASSISTANT_TAG])
|
|
||||||
if resp:
|
|
||||||
break
|
|
||||||
_LOGGER.warning("Can't fetch info from github. Retry in 60.")
|
|
||||||
await asyncio.sleep(60, loop=self.loop)
|
|
||||||
|
|
||||||
self.config.homeassistant_tag = current[HOMEASSISTANT_TAG]
|
|
||||||
else:
|
else:
|
||||||
_LOGGER.info("HomeAssistant docker exists. Run it now")
|
_LOGGER.info("HomeAssistant docker exists. Run it now")
|
||||||
|
|
||||||
# run HomeAssistant
|
# run HomeAssistant
|
||||||
await self.homeassistant.run()
|
await self.homeassistant.run()
|
||||||
|
|
||||||
|
async def stop(self):
|
||||||
|
"""Stop a running orchestration."""
|
||||||
|
tasks = [self.websession.close()]
|
||||||
|
await asyncio.wait(tasks, loop=self.loop)
|
||||||
|
|
||||||
|
self.loop.close()
|
||||||
|
|
||||||
|
async def _setup_homeassistant(self):
|
||||||
|
"""Install a homeassistant docker container."""
|
||||||
|
current = None
|
||||||
|
while True:
|
||||||
|
# read homeassistant tag and install it
|
||||||
|
current = await tools.fetch_current_versions(self.websession)
|
||||||
|
if current and HOMEASSISTANT_TAG in current:
|
||||||
|
resp = await self.homeassistant.install(
|
||||||
|
current[HOMEASSISTANT_TAG])
|
||||||
|
if resp:
|
||||||
|
break
|
||||||
|
_LOGGER.warning("Error on setup HomeAssistant. Retry in 60.")
|
||||||
|
await asyncio.sleep(60, loop=self.loop)
|
||||||
|
|
||||||
|
# store version
|
||||||
|
self.config.homeassistant_tag = current[HOMEASSISTANT_TAG]
|
||||||
|
_LOGGER.info("HomeAssistant docker now exists.")
|
||||||
|
@ -11,13 +11,12 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class DockerBase(object):
|
class DockerBase(object):
|
||||||
"""Docker hassio wrapper."""
|
"""Docker hassio wrapper."""
|
||||||
|
|
||||||
def __init__(self, config, loop, dock, image=None, tag=None):
|
def __init__(self, config, loop, dock, image=None):
|
||||||
"""Initialize docker base wrapper."""
|
"""Initialize docker base wrapper."""
|
||||||
self.config = config
|
self.config = config
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
self.dock = dock
|
self.dock = dock
|
||||||
self.image = image
|
self.image = image
|
||||||
self.tag = tag
|
|
||||||
self.container = None
|
self.container = None
|
||||||
self.version = None
|
self.version = None
|
||||||
|
|
||||||
@ -64,6 +63,8 @@ class DockerBase(object):
|
|||||||
if not self.container:
|
if not self.container:
|
||||||
try:
|
try:
|
||||||
self.container = self.dock.containers.get(self.docker_name)
|
self.container = self.dock.containers.get(self.docker_name)
|
||||||
|
self.version = get_version_from_env(
|
||||||
|
self.container.attrs['Config']['Env'])
|
||||||
except docker.errors.DockerException:
|
except docker.errors.DockerException:
|
||||||
return False
|
return False
|
||||||
return self.container.status == 'running'
|
return self.container.status == 'running'
|
||||||
|
@ -16,10 +16,7 @@ class DockerHomeAssistant(DockerBase):
|
|||||||
|
|
||||||
def __init__(self, config, loop, dock):
|
def __init__(self, config, loop, dock):
|
||||||
"""Initialize docker homeassistant wrapper."""
|
"""Initialize docker homeassistant wrapper."""
|
||||||
super().__init__(
|
super().__init__(config, loop, dock, image=config.homeassistant_image)
|
||||||
config, loop, dock, image=config.homeassistant_image,
|
|
||||||
tag=config.homeassistant_tag
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def docker_name(self):
|
def docker_name(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user