mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-18 22:56:31 +00:00
Rename Hass.io -> Supervisor (#1522)
* Rename Hass.io -> Supervisor * part 2 * fix lint * fix auth name
This commit is contained in:
parent
e9f5b13aa5
commit
4ac7f7dcf0
@ -1,31 +1,24 @@
|
|||||||
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
|
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
|
||||||
{
|
{
|
||||||
"name": "Hass.io dev",
|
"name": "Supervisor dev",
|
||||||
"context": "..",
|
"context": "..",
|
||||||
"dockerFile": "Dockerfile",
|
"dockerFile": "Dockerfile",
|
||||||
"appPort": "9123:8123",
|
"appPort": "9123:8123",
|
||||||
"runArgs": [
|
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
|
||||||
"-e",
|
"extensions": [
|
||||||
"GIT_EDITOR=code --wait",
|
"ms-python.python",
|
||||||
"--privileged"
|
"visualstudioexptteam.vscodeintellicode",
|
||||||
],
|
"esbenp.prettier-vscode"
|
||||||
"extensions": [
|
],
|
||||||
"ms-python.python",
|
"settings": {
|
||||||
"visualstudioexptteam.vscodeintellicode",
|
"python.pythonPath": "/usr/local/bin/python",
|
||||||
"esbenp.prettier-vscode"
|
"python.linting.pylintEnabled": true,
|
||||||
],
|
"python.linting.enabled": true,
|
||||||
"settings": {
|
"python.formatting.provider": "black",
|
||||||
"python.pythonPath": "/usr/local/bin/python",
|
"python.formatting.blackArgs": ["--target-version", "py37"],
|
||||||
"python.linting.pylintEnabled": true,
|
"editor.formatOnPaste": false,
|
||||||
"python.linting.enabled": true,
|
"editor.formatOnSave": true,
|
||||||
"python.formatting.provider": "black",
|
"editor.formatOnType": true,
|
||||||
"python.formatting.blackArgs": [
|
"files.trimTrailingWhitespace": true
|
||||||
"--target-version",
|
}
|
||||||
"py37"
|
}
|
||||||
],
|
|
||||||
"editor.formatOnPaste": false,
|
|
||||||
"editor.formatOnSave": true,
|
|
||||||
"editor.formatOnType": true,
|
|
||||||
"files.trimTrailingWhitespace": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -34,4 +34,4 @@ COPY entry.sh /bin/
|
|||||||
ENTRYPOINT ["/bin/entry.sh"]
|
ENTRYPOINT ["/bin/entry.sh"]
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
CMD [ "python3", "-m", "hassio" ]
|
CMD [ "python3", "-m", "supervisor" ]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[](https://dev.azure.com/home-assistant/Hass.io/_build/latest?definitionId=2&branchName=dev)
|
[](https://dev.azure.com/home-assistant/Hass.io/_build/latest?definitionId=2&branchName=dev)
|
||||||
|
|
||||||
# Hass.io
|
# Home Assistant Supervisor
|
||||||
|
|
||||||
## First private cloud solution for home automation
|
## First private cloud solution for home automation
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
"""Init file for Hass.io."""
|
|
@ -1 +0,0 @@
|
|||||||
"""Special object and tools for Hass.io."""
|
|
@ -14,5 +14,5 @@ cd hassio
|
|||||||
./script/build_hassio
|
./script/build_hassio
|
||||||
|
|
||||||
# Copy frontend
|
# Copy frontend
|
||||||
rm -f ../../hassio/api/panel/chunk.*
|
rm -f ../../supervisor/hassio/api/panel/chunk.*
|
||||||
cp -rf build/* ../../hassio/api/panel/
|
cp -rf build/* ../../supervisor/api/panel/
|
22
setup.py
22
setup.py
@ -1,10 +1,10 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
from hassio.const import HASSIO_VERSION
|
from supervisor.const import SUPERVISOR_VERSION
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="HassIO",
|
name="Supervisor",
|
||||||
version=HASSIO_VERSION,
|
version=SUPERVISOR_VERSION,
|
||||||
license="BSD License",
|
license="BSD License",
|
||||||
author="The Home Assistant Authors",
|
author="The Home Assistant Authors",
|
||||||
author_email="hello@home-assistant.io",
|
author_email="hello@home-assistant.io",
|
||||||
@ -24,19 +24,19 @@ setup(
|
|||||||
"Topic :: Scientific/Engineering :: Atmospheric Science",
|
"Topic :: Scientific/Engineering :: Atmospheric Science",
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
"Programming Language :: Python :: 3.6",
|
"Programming Language :: Python :: 3.7",
|
||||||
],
|
],
|
||||||
keywords=["docker", "home-assistant", "api"],
|
keywords=["docker", "home-assistant", "api"],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
platforms="any",
|
platforms="any",
|
||||||
packages=[
|
packages=[
|
||||||
"hassio",
|
"supervisor",
|
||||||
"hassio.docker",
|
"supervisor.docker",
|
||||||
"hassio.addons",
|
"supervisor.addons",
|
||||||
"hassio.api",
|
"supervisor.api",
|
||||||
"hassio.misc",
|
"supervisor.misc",
|
||||||
"hassio.utils",
|
"supervisor.utils",
|
||||||
"hassio.snapshots",
|
"supervisor.snapshots",
|
||||||
],
|
],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
)
|
)
|
||||||
|
1
supervisor/__init__.py
Normal file
1
supervisor/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""Init file for Supervisor."""
|
@ -1,10 +1,10 @@
|
|||||||
"""Main file for Hass.io."""
|
"""Main file for Supervisor."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from hassio import bootstrap
|
from supervisor import bootstrap
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ if __name__ == "__main__":
|
|||||||
# Init async event loop
|
# Init async event loop
|
||||||
loop = initialize_event_loop()
|
loop = initialize_event_loop()
|
||||||
|
|
||||||
# Check if all information are available to setup Hass.io
|
# Check if all information are available to setup Supervisor
|
||||||
if not bootstrap.check_environment():
|
if not bootstrap.check_environment():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -37,27 +37,27 @@ if __name__ == "__main__":
|
|||||||
executor = ThreadPoolExecutor(thread_name_prefix="SyncWorker")
|
executor = ThreadPoolExecutor(thread_name_prefix="SyncWorker")
|
||||||
loop.set_default_executor(executor)
|
loop.set_default_executor(executor)
|
||||||
|
|
||||||
_LOGGER.info("Initialize Hass.io setup")
|
_LOGGER.info("Initialize Supervisor setup")
|
||||||
coresys = loop.run_until_complete(bootstrap.initialize_coresys())
|
coresys = loop.run_until_complete(bootstrap.initialize_coresys())
|
||||||
loop.run_until_complete(coresys.core.connect())
|
loop.run_until_complete(coresys.core.connect())
|
||||||
|
|
||||||
bootstrap.supervisor_debugger(coresys)
|
bootstrap.supervisor_debugger(coresys)
|
||||||
bootstrap.migrate_system_env(coresys)
|
bootstrap.migrate_system_env(coresys)
|
||||||
|
|
||||||
_LOGGER.info("Setup HassIO")
|
_LOGGER.info("Setup Supervisor")
|
||||||
loop.run_until_complete(coresys.core.setup())
|
loop.run_until_complete(coresys.core.setup())
|
||||||
|
|
||||||
loop.call_soon_threadsafe(loop.create_task, coresys.core.start())
|
loop.call_soon_threadsafe(loop.create_task, coresys.core.start())
|
||||||
loop.call_soon_threadsafe(bootstrap.reg_signal, loop)
|
loop.call_soon_threadsafe(bootstrap.reg_signal, loop)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_LOGGER.info("Run Hass.io")
|
_LOGGER.info("Run Supervisor")
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
finally:
|
finally:
|
||||||
_LOGGER.info("Stopping Hass.io")
|
_LOGGER.info("Stopping Supervisor")
|
||||||
loop.run_until_complete(coresys.core.stop())
|
loop.run_until_complete(coresys.core.stop())
|
||||||
executor.shutdown(wait=False)
|
executor.shutdown(wait=False)
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
_LOGGER.info("Close Hass.io")
|
_LOGGER.info("Close Supervisor")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io add-ons."""
|
"""Init file for Supervisor add-ons."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import logging
|
import logging
|
||||||
@ -25,7 +25,7 @@ AnyAddon = Union[Addon, AddonStore]
|
|||||||
|
|
||||||
|
|
||||||
class AddonManager(CoreSysAttributes):
|
class AddonManager(CoreSysAttributes):
|
||||||
"""Manage add-ons inside Hass.io."""
|
"""Manage add-ons inside Supervisor."""
|
||||||
|
|
||||||
def __init__(self, coresys: CoreSys):
|
def __init__(self, coresys: CoreSys):
|
||||||
"""Initialize Docker base wrapper."""
|
"""Initialize Docker base wrapper."""
|
||||||
@ -57,7 +57,7 @@ class AddonManager(CoreSysAttributes):
|
|||||||
return self.store.get(addon_slug)
|
return self.store.get(addon_slug)
|
||||||
|
|
||||||
def from_token(self, token: str) -> Optional[Addon]:
|
def from_token(self, token: str) -> Optional[Addon]:
|
||||||
"""Return an add-on from Hass.io token."""
|
"""Return an add-on from Supervisor token."""
|
||||||
for addon in self.installed:
|
for addon in self.installed:
|
||||||
if token == addon.hassio_token:
|
if token == addon.hassio_token:
|
||||||
return addon
|
return addon
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io add-ons."""
|
"""Init file for Supervisor add-ons."""
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
@ -65,7 +65,7 @@ RE_WEBUI = re.compile(
|
|||||||
|
|
||||||
|
|
||||||
class Addon(AddonModel):
|
class Addon(AddonModel):
|
||||||
"""Hold data for add-on inside Hass.io."""
|
"""Hold data for add-on inside Supervisor."""
|
||||||
|
|
||||||
def __init__(self, coresys: CoreSys, slug: str):
|
def __init__(self, coresys: CoreSys, slug: str):
|
||||||
"""Initialize data holder."""
|
"""Initialize data holder."""
|
||||||
@ -163,12 +163,12 @@ class Addon(AddonModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def hassio_token(self) -> Optional[str]:
|
def hassio_token(self) -> Optional[str]:
|
||||||
"""Return access token for Hass.io API."""
|
"""Return access token for Supervisor API."""
|
||||||
return self.persist.get(ATTR_ACCESS_TOKEN)
|
return self.persist.get(ATTR_ACCESS_TOKEN)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ingress_token(self) -> Optional[str]:
|
def ingress_token(self) -> Optional[str]:
|
||||||
"""Return access token for Hass.io API."""
|
"""Return access token for Supervisor API."""
|
||||||
return self.persist.get(ATTR_INGRESS_TOKEN)
|
return self.persist.get(ATTR_INGRESS_TOKEN)
|
||||||
|
|
||||||
@property
|
@property
|
@ -1,4 +1,4 @@
|
|||||||
"""Hass.io add-on build environment."""
|
"""Supervisor add-on build environment."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Dict
|
from typing import TYPE_CHECKING, Dict
|
||||||
@ -16,7 +16,7 @@ class AddonBuild(JsonConfig, CoreSysAttributes):
|
|||||||
"""Handle build options for add-ons."""
|
"""Handle build options for add-ons."""
|
||||||
|
|
||||||
def __init__(self, coresys: CoreSys, addon: AnyAddon) -> None:
|
def __init__(self, coresys: CoreSys, addon: AnyAddon) -> None:
|
||||||
"""Initialize Hass.io add-on builder."""
|
"""Initialize Supervisor add-on builder."""
|
||||||
self.coresys: CoreSys = coresys
|
self.coresys: CoreSys = coresys
|
||||||
self.addon = addon
|
self.addon = addon
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io add-on data."""
|
"""Init file for Supervisor add-on data."""
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
@ -23,7 +23,7 @@ Config = Dict[str, Any]
|
|||||||
|
|
||||||
|
|
||||||
class AddonsData(JsonConfig, CoreSysAttributes):
|
class AddonsData(JsonConfig, CoreSysAttributes):
|
||||||
"""Hold data for installed Add-ons inside Hass.io."""
|
"""Hold data for installed Add-ons inside Supervisor."""
|
||||||
|
|
||||||
def __init__(self, coresys: CoreSys):
|
def __init__(self, coresys: CoreSys):
|
||||||
"""Initialize data holder."""
|
"""Initialize data holder."""
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io add-ons."""
|
"""Init file for Supervisor add-ons."""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Awaitable, Dict, List, Optional
|
from typing import Any, Awaitable, Dict, List, Optional
|
||||||
|
|
||||||
@ -137,12 +137,12 @@ class AddonModel(CoreSysAttributes):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def hassio_token(self) -> Optional[str]:
|
def hassio_token(self) -> Optional[str]:
|
||||||
"""Return access token for Hass.io API."""
|
"""Return access token for Supervisor API."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ingress_token(self) -> Optional[str]:
|
def ingress_token(self) -> Optional[str]:
|
||||||
"""Return access token for Hass.io API."""
|
"""Return access token for Supervisor API."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -326,7 +326,7 @@ class AddonModel(CoreSysAttributes):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def access_hassio_api(self) -> bool:
|
def access_hassio_api(self) -> bool:
|
||||||
"""Return True if the add-on access to Hass.io REASTful API."""
|
"""Return True if the add-on access to Supervisor REASTful API."""
|
||||||
return self.data[ATTR_HASSIO_API]
|
return self.data[ATTR_HASSIO_API]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -336,7 +336,7 @@ class AddonModel(CoreSysAttributes):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def hassio_role(self) -> str:
|
def hassio_role(self) -> str:
|
||||||
"""Return Hass.io role for API."""
|
"""Return Supervisor role for API."""
|
||||||
return self.data[ATTR_HASSIO_ROLE]
|
return self.data[ATTR_HASSIO_ROLE]
|
||||||
|
|
||||||
@property
|
@property
|
@ -59,7 +59,7 @@ def rating_security(addon: AddonModel) -> int:
|
|||||||
):
|
):
|
||||||
rating += -1
|
rating += -1
|
||||||
|
|
||||||
# API Hass.io role
|
# API Supervisor role
|
||||||
if addon.hassio_role == ROLE_MANAGER:
|
if addon.hassio_role == ROLE_MANAGER:
|
||||||
rating += -1
|
rating += -1
|
||||||
elif addon.hassio_role == ROLE_ADMIN:
|
elif addon.hassio_role == ROLE_ADMIN:
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io RESTful API."""
|
"""Init file for Supervisor RESTful API."""
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@ -29,7 +29,7 @@ MAX_CLIENT_SIZE: int = 1024 ** 2 * 16
|
|||||||
|
|
||||||
|
|
||||||
class RestAPI(CoreSysAttributes):
|
class RestAPI(CoreSysAttributes):
|
||||||
"""Handle RESTful API for Hass.io."""
|
"""Handle RESTful API for Supervisor."""
|
||||||
|
|
||||||
def __init__(self, coresys: CoreSys):
|
def __init__(self, coresys: CoreSys):
|
||||||
"""Initialize Docker base wrapper."""
|
"""Initialize Docker base wrapper."""
|
||||||
@ -93,7 +93,7 @@ class RestAPI(CoreSysAttributes):
|
|||||||
web.post("/os/update", api_hassos.update),
|
web.post("/os/update", api_hassos.update),
|
||||||
web.post("/os/update/cli", api_hassos.update_cli),
|
web.post("/os/update/cli", api_hassos.update_cli),
|
||||||
web.post("/os/config/sync", api_hassos.config_sync),
|
web.post("/os/config/sync", api_hassos.config_sync),
|
||||||
# Remove with old Hass.io fallback
|
# Remove with old Supervisor fallback
|
||||||
web.get("/hassos/info", api_hassos.info),
|
web.get("/hassos/info", api_hassos.info),
|
||||||
web.post("/hassos/update", api_hassos.update),
|
web.post("/hassos/update", api_hassos.update),
|
||||||
web.post("/hassos/update/cli", api_hassos.update_cli),
|
web.post("/hassos/update/cli", api_hassos.update_cli),
|
||||||
@ -165,7 +165,7 @@ class RestAPI(CoreSysAttributes):
|
|||||||
web.post("/core/start", api_hass.start),
|
web.post("/core/start", api_hass.start),
|
||||||
web.post("/core/check", api_hass.check),
|
web.post("/core/check", api_hass.check),
|
||||||
web.post("/core/rebuild", api_hass.rebuild),
|
web.post("/core/rebuild", api_hass.rebuild),
|
||||||
# Remove with old Hass.io fallback
|
# Remove with old Supervisor fallback
|
||||||
web.get("/homeassistant/info", api_hass.info),
|
web.get("/homeassistant/info", api_hass.info),
|
||||||
web.get("/homeassistant/logs", api_hass.logs),
|
web.get("/homeassistant/logs", api_hass.logs),
|
||||||
web.get("/homeassistant/stats", api_hass.stats),
|
web.get("/homeassistant/stats", api_hass.stats),
|
||||||
@ -192,7 +192,7 @@ class RestAPI(CoreSysAttributes):
|
|||||||
web.post("/core/api/{path:.+}", api_proxy.api),
|
web.post("/core/api/{path:.+}", api_proxy.api),
|
||||||
web.get("/core/api/{path:.+}", api_proxy.api),
|
web.get("/core/api/{path:.+}", api_proxy.api),
|
||||||
web.get("/core/api/", api_proxy.api),
|
web.get("/core/api/", api_proxy.api),
|
||||||
# Remove with old Hass.io fallback
|
# Remove with old Supervisor fallback
|
||||||
web.get("/homeassistant/api/websocket", api_proxy.websocket),
|
web.get("/homeassistant/api/websocket", api_proxy.websocket),
|
||||||
web.get("/homeassistant/websocket", api_proxy.websocket),
|
web.get("/homeassistant/websocket", api_proxy.websocket),
|
||||||
web.get("/homeassistant/api/stream", api_proxy.stream),
|
web.get("/homeassistant/api/stream", api_proxy.stream),
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io Home Assistant RESTful API."""
|
"""Init file for Supervisor Home Assistant RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Awaitable, Dict, List
|
from typing import Any, Awaitable, Dict, List
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io auth/SSO RESTful API."""
|
"""Init file for Supervisor auth/SSO RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
@ -76,7 +76,7 @@ class APIAuth(CoreSysAttributes):
|
|||||||
return await self._process_dict(request, addon, data)
|
return await self._process_dict(request, addon, data)
|
||||||
|
|
||||||
raise HTTPUnauthorized(
|
raise HTTPUnauthorized(
|
||||||
headers={WWW_AUTHENTICATE: 'Basic realm="Hass.io Authentication"'}
|
headers={WWW_AUTHENTICATE: 'Basic realm="Home Assistant Authentication"'}
|
||||||
)
|
)
|
||||||
|
|
||||||
@api_process
|
@api_process
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io network RESTful API."""
|
"""Init file for Supervisor network RESTful API."""
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from .utils import api_process, api_validate
|
from .utils import api_process, api_validate
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io DNS RESTful API."""
|
"""Init file for Supervisor DNS RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Awaitable, Dict
|
from typing import Any, Awaitable, Dict
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io hardware RESTful API."""
|
"""Init file for Supervisor hardware RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io HassOS RESTful API."""
|
"""Init file for Supervisor HassOS RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Awaitable, Dict
|
from typing import Any, Awaitable, Dict
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io Home Assistant RESTful API."""
|
"""Init file for Supervisor Home Assistant RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Coroutine, Dict, Any
|
from typing import Coroutine, Dict, Any
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io host RESTful API."""
|
"""Init file for Supervisor host RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io info RESTful API."""
|
"""Init file for Supervisor info RESTful API."""
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
"""Hass.io Add-on ingress service."""
|
"""Supervisor Add-on ingress service."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
import logging
|
import logging
|
||||||
@ -81,7 +81,7 @@ class APIIngress(CoreSysAttributes):
|
|||||||
async def handler(
|
async def handler(
|
||||||
self, request: web.Request
|
self, request: web.Request
|
||||||
) -> Union[web.Response, web.StreamResponse, web.WebSocketResponse]:
|
) -> Union[web.Response, web.StreamResponse, web.WebSocketResponse]:
|
||||||
"""Route data to Hass.io ingress service."""
|
"""Route data to Supervisor ingress service."""
|
||||||
self._check_ha_access(request)
|
self._check_ha_access(request)
|
||||||
|
|
||||||
# Check Ingress Session
|
# Check Ingress Session
|
@ -23,7 +23,7 @@ class APIProxy(CoreSysAttributes):
|
|||||||
"""API Proxy for Home Assistant."""
|
"""API Proxy for Home Assistant."""
|
||||||
|
|
||||||
def _check_access(self, request: web.Request):
|
def _check_access(self, request: web.Request):
|
||||||
"""Check the Hass.io token."""
|
"""Check the Supervisor token."""
|
||||||
if AUTHORIZATION in request.headers:
|
if AUTHORIZATION in request.headers:
|
||||||
bearer = request.headers[AUTHORIZATION]
|
bearer = request.headers[AUTHORIZATION]
|
||||||
hassio_token = bearer.split(" ")[-1]
|
hassio_token = bearer.split(" ")[-1]
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io network RESTful API."""
|
"""Init file for Supervisor network RESTful API."""
|
||||||
|
|
||||||
from .utils import api_process, api_validate
|
from .utils import api_process, api_validate
|
||||||
from ..const import (
|
from ..const import (
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io snapshot RESTful API."""
|
"""Init file for Supervisor snapshot RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io Supervisor RESTful API."""
|
"""Init file for Supervisor Supervisor RESTful API."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Awaitable, Dict
|
from typing import Any, Awaitable, Dict
|
||||||
@ -36,7 +36,7 @@ from ..const import (
|
|||||||
ATTR_VERSION,
|
ATTR_VERSION,
|
||||||
ATTR_WAIT_BOOT,
|
ATTR_WAIT_BOOT,
|
||||||
CONTENT_TYPE_BINARY,
|
CONTENT_TYPE_BINARY,
|
||||||
HASSIO_VERSION,
|
SUPERVISOR_VERSION,
|
||||||
UpdateChannels,
|
UpdateChannels,
|
||||||
)
|
)
|
||||||
from ..coresys import CoreSysAttributes
|
from ..coresys import CoreSysAttributes
|
||||||
@ -91,7 +91,7 @@ class APISupervisor(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ATTR_VERSION: HASSIO_VERSION,
|
ATTR_VERSION: SUPERVISOR_VERSION,
|
||||||
ATTR_LAST_VERSION: self.sys_updater.version_hassio,
|
ATTR_LAST_VERSION: self.sys_updater.version_hassio,
|
||||||
ATTR_CHANNEL: self.sys_updater.channel,
|
ATTR_CHANNEL: self.sys_updater.channel,
|
||||||
ATTR_ARCH: self.sys_supervisor.arch,
|
ATTR_ARCH: self.sys_supervisor.arch,
|
@ -1,4 +1,4 @@
|
|||||||
"""Init file for Hass.io util for RESTful API."""
|
"""Init file for Supervisor util for RESTful API."""
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
@ -29,7 +29,7 @@ def excract_supervisor_token(request: web.Request) -> Optional[str]:
|
|||||||
if supervisor_token:
|
if supervisor_token:
|
||||||
return supervisor_token
|
return supervisor_token
|
||||||
|
|
||||||
# Remove with old Hass.io fallback
|
# Remove with old Supervisor fallback
|
||||||
supervisor_token = request.headers.get(HEADER_TOKEN_OLD)
|
supervisor_token = request.headers.get(HEADER_TOKEN_OLD)
|
||||||
if supervisor_token:
|
if supervisor_token:
|
||||||
return supervisor_token
|
return supervisor_token
|
@ -1,4 +1,4 @@
|
|||||||
"""Bootstrap Hass.io."""
|
"""Bootstrap Supervisor."""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -12,7 +12,7 @@ from .api import RestAPI
|
|||||||
from .arch import CpuArch
|
from .arch import CpuArch
|
||||||
from .auth import Auth
|
from .auth import Auth
|
||||||
from .const import SOCKET_DOCKER, UpdateChannels
|
from .const import SOCKET_DOCKER, UpdateChannels
|
||||||
from .core import HassIO
|
from .core import Core
|
||||||
from .coresys import CoreSys
|
from .coresys import CoreSys
|
||||||
from .dbus import DBusManager
|
from .dbus import DBusManager
|
||||||
from .discovery import Discovery
|
from .discovery import Discovery
|
||||||
@ -40,11 +40,11 @@ MACHINE_ID = Path("/etc/machine-id")
|
|||||||
|
|
||||||
|
|
||||||
async def initialize_coresys():
|
async def initialize_coresys():
|
||||||
"""Initialize HassIO coresys/objects."""
|
"""Initialize supervisor coresys/objects."""
|
||||||
coresys = CoreSys()
|
coresys = CoreSys()
|
||||||
|
|
||||||
# Initialize core objects
|
# Initialize core objects
|
||||||
coresys.core = HassIO(coresys)
|
coresys.core = Core(coresys)
|
||||||
coresys.dns = CoreDNS(coresys)
|
coresys.dns = CoreDNS(coresys)
|
||||||
coresys.arch = CpuArch(coresys)
|
coresys.arch = CpuArch(coresys)
|
||||||
coresys.auth = Auth(coresys)
|
coresys.auth = Auth(coresys)
|
||||||
@ -89,51 +89,53 @@ def initialize_system_data(coresys: CoreSys):
|
|||||||
)
|
)
|
||||||
config.path_homeassistant.mkdir()
|
config.path_homeassistant.mkdir()
|
||||||
|
|
||||||
# hassio ssl folder
|
# supervisor ssl folder
|
||||||
if not config.path_ssl.is_dir():
|
if not config.path_ssl.is_dir():
|
||||||
_LOGGER.info("Create Hass.io SSL/TLS folder %s", config.path_ssl)
|
_LOGGER.info("Create Supervisor SSL/TLS folder %s", config.path_ssl)
|
||||||
config.path_ssl.mkdir()
|
config.path_ssl.mkdir()
|
||||||
|
|
||||||
# hassio addon data folder
|
# supervisor addon data folder
|
||||||
if not config.path_addons_data.is_dir():
|
if not config.path_addons_data.is_dir():
|
||||||
_LOGGER.info("Create Hass.io Add-on data folder %s", config.path_addons_data)
|
_LOGGER.info("Create Supervisor Add-on data folder %s", config.path_addons_data)
|
||||||
config.path_addons_data.mkdir(parents=True)
|
config.path_addons_data.mkdir(parents=True)
|
||||||
|
|
||||||
if not config.path_addons_local.is_dir():
|
if not config.path_addons_local.is_dir():
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"Create Hass.io Add-on local repository folder %s", config.path_addons_local
|
"Create Supervisor Add-on local repository folder %s",
|
||||||
|
config.path_addons_local,
|
||||||
)
|
)
|
||||||
config.path_addons_local.mkdir(parents=True)
|
config.path_addons_local.mkdir(parents=True)
|
||||||
|
|
||||||
if not config.path_addons_git.is_dir():
|
if not config.path_addons_git.is_dir():
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"Create Hass.io Add-on git repositories folder %s", config.path_addons_git
|
"Create Supervisor Add-on git repositories folder %s",
|
||||||
|
config.path_addons_git,
|
||||||
)
|
)
|
||||||
config.path_addons_git.mkdir(parents=True)
|
config.path_addons_git.mkdir(parents=True)
|
||||||
|
|
||||||
# hassio tmp folder
|
# supervisor tmp folder
|
||||||
if not config.path_tmp.is_dir():
|
if not config.path_tmp.is_dir():
|
||||||
_LOGGER.info("Create Hass.io temp folder %s", config.path_tmp)
|
_LOGGER.info("Create Supervisor temp folder %s", config.path_tmp)
|
||||||
config.path_tmp.mkdir(parents=True)
|
config.path_tmp.mkdir(parents=True)
|
||||||
|
|
||||||
# hassio backup folder
|
# supervisor backup folder
|
||||||
if not config.path_backup.is_dir():
|
if not config.path_backup.is_dir():
|
||||||
_LOGGER.info("Create Hass.io backup folder %s", config.path_backup)
|
_LOGGER.info("Create Supervisor backup folder %s", config.path_backup)
|
||||||
config.path_backup.mkdir()
|
config.path_backup.mkdir()
|
||||||
|
|
||||||
# share folder
|
# share folder
|
||||||
if not config.path_share.is_dir():
|
if not config.path_share.is_dir():
|
||||||
_LOGGER.info("Create Hass.io share folder %s", config.path_share)
|
_LOGGER.info("Create Supervisor share folder %s", config.path_share)
|
||||||
config.path_share.mkdir()
|
config.path_share.mkdir()
|
||||||
|
|
||||||
# apparmor folder
|
# apparmor folder
|
||||||
if not config.path_apparmor.is_dir():
|
if not config.path_apparmor.is_dir():
|
||||||
_LOGGER.info("Create Hass.io Apparmor folder %s", config.path_apparmor)
|
_LOGGER.info("Create Supervisor Apparmor folder %s", config.path_apparmor)
|
||||||
config.path_apparmor.mkdir()
|
config.path_apparmor.mkdir()
|
||||||
|
|
||||||
# dns folder
|
# dns folder
|
||||||
if not config.path_dns.is_dir():
|
if not config.path_dns.is_dir():
|
||||||
_LOGGER.info("Create Hass.io DNS folder %s", config.path_dns)
|
_LOGGER.info("Create Supervisor DNS folder %s", config.path_dns)
|
||||||
config.path_dns.mkdir()
|
config.path_dns.mkdir()
|
||||||
|
|
||||||
# Update log level
|
# Update log level
|
||||||
@ -239,7 +241,7 @@ def supervisor_debugger(coresys: CoreSys) -> None:
|
|||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable=import-outside-toplevel
|
||||||
import ptvsd
|
import ptvsd
|
||||||
|
|
||||||
_LOGGER.info("Initialize Hass.io debugger")
|
_LOGGER.info("Initialize Supervisor debugger")
|
||||||
|
|
||||||
ptvsd.enable_attach(address=("0.0.0.0", 33333), redirect_output=True)
|
ptvsd.enable_attach(address=("0.0.0.0", 33333), redirect_output=True)
|
||||||
if coresys.config.debug_block:
|
if coresys.config.debug_block:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user