Compare commits

..

434 Commits

Author SHA1 Message Date
Joakim Sørensen
2bb014fda5 Update frontend to 0d1c7238 (#2681) 2021-03-04 17:16:17 +01:00
Pascal Vizeli
09203f67b2 Fix defaults for builds (#2675) 2021-03-04 11:48:25 +01:00
Joakim Sørensen
169c7ec004 Update frontend to 419e5644 (#2667) 2021-03-03 16:20:04 +01:00
Joakim Sørensen
202e94615e Update frontend to bee17fce (#2665)
* Update frontend to fe50f422

* revert unrelated change

* Update frontend to bee17fce
2021-03-03 15:15:07 +01:00
Pascal Vizeli
5fe2a815ad Fix error handling with new config handling (#2666) 2021-03-03 12:46:34 +01:00
Joakim Sørensen
a13a0b4770 Guard for missing repository file (#2664)
* Guard for missing repository file

* Update supervisor/store/data.py

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2021-03-03 11:33:58 +01:00
Joakim Sørensen
455bbc457b Update frontend to 9f73f0ca (#2661)
* Update frontend to 9f73f0ca

* Update frontend to 935d97ce
2021-03-02 17:12:36 +01:00
Joakim Sørensen
d50fd3b580 Add network description to translation files (#2660) 2021-03-02 15:41:00 +01:00
Pascal Vizeli
455e80b07c Merge branch 'main' of https://github.com/home-assistant/supervisor into main 2021-03-02 13:16:09 +00:00
Joakim Sørensen
291becbdf9 Update frontend to 1642c684 (#2657) 2021-03-01 17:19:48 +01:00
Pascal Vizeli
33385b46a7 Fix add-on is not installed anymore (#2656)
* Fix add-on is not installed anymore

* Fix and add tests
2021-03-01 17:19:38 +01:00
Pascal Vizeli
df17668369 Fix add-on is not installed anymore 2021-03-01 15:43:50 +00:00
Joakim Sørensen
43449c85bb Fix translation schema (#2654)
* Fix translation schema

* really fix it

* fix migration path

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2021-03-01 16:39:00 +01:00
Stefan Agner
9e86eda05a Adjust CPU runtime allocation to support multiple add-ons (#2655)
Adjust realtime CPU runtime allocation to support multiple
add-ons/plug-ins with the runtime flag set.

The cpu.rt_runtime_us allocation is somewhat special as it
allocates the guaranteed runtime. Hence we cannot simply allocate all
time to each add-on.

Unfortunately we cannot distribute the CPU time equally based on the
number of add-ons as we don't know the number of add-ons which will use
realtime ahead of time. Also adjusting at runtime is currenlty not
supported by the Docker Python SDK (the underlying http API does
however, so this would be a possible future improvement).

This solution distributes the total available time of 950ms to up to 5
add-ons/plug-ins in equal slices. On a quad-core system this allows up
to 760ms CPU time in the real-time scheduler per 1s (76% of one CPU)
which should be sufficient for most cases.
2021-03-01 15:29:10 +01:00
Pascal Vizeli
b288554d9c Allow dynamic lookup cgroup rules based on Host udev (#2652) 2021-03-01 14:57:44 +01:00
Joakim Sørensen
bee55d08fb Create FileConfiguration baseclass (#2651) 2021-03-01 12:26:43 +01:00
Joakim Sørensen
7a542aeb38 Add support for loading add-on translation files (#2644)
* Add support for loading add-on translation files

* Fix storing translations for installed add-ons

* Allow YAML, force schema

* Adjust schema
2021-03-01 11:44:24 +01:00
dependabot[bot]
8d42513ba8 Bump gitpython from 3.1.13 to 3.1.14 (#2647)
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.13 to 3.1.14.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/master/CHANGES)
- [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.13...3.1.14)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-01 11:33:41 +01:00
dependabot[bot]
89b7247aa2 Bump home-assistant/builder from 2021.01.1 to 2021.02.0 (#2650)
Bumps [home-assistant/builder](https://github.com/home-assistant/builder) from 2021.01.1 to 2021.02.0.
- [Release notes](https://github.com/home-assistant/builder/releases)
- [Commits](https://github.com/home-assistant/builder/compare/2021.01.1...8c4b820c467894c8374aca262deac0a8aef4982d)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-01 10:56:10 +01:00
dependabot[bot]
29132e7f4c Bump coverage from 5.4 to 5.5 (#2648)
Bumps [coverage](https://github.com/nedbat/coveragepy) from 5.4 to 5.5.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/coverage-5.4...coverage-5.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-01 10:24:38 +01:00
dependabot[bot]
3fd9baf78e Bump pylint from 2.6.2 to 2.7.2 (#2649)
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.6.2 to 2.7.2.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Changelog](https://github.com/PyCQA/pylint/blob/master/ChangeLog)
- [Commits](https://github.com/PyCQA/pylint/compare/pylint-2.6.2...pylint-2.7.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-01 10:17:21 +01:00
Philip Allgaier
f3aa3757ce Fixed typos in resolution notify (#2646) 2021-03-01 09:44:16 +01:00
Joakim Sørensen
3760967f59 Allow use YAML for addon and repository config (#2645)
* Allow use YAML for addon and repository config

* pylint
2021-02-28 20:00:02 +01:00
Joakim Sørensen
f7ab8e0f7f Update frontend to 478a4b25 (#2637) 2021-02-26 15:23:15 +01:00
Joakim Sørensen
0e46ea12b2 Allways store docker and repository config (#2636) 2021-02-26 13:40:47 +01:00
Joakim Sørensen
be226b2b01 Make homeassistant optional in partial snapshot (#2635) 2021-02-26 12:51:04 +01:00
dependabot[bot]
9e1239e192 Bump aiohttp from 3.7.3 to 3.7.4 (#2633)
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.7.3 to 3.7.4.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.7.3...v3.7.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-26 09:43:45 +01:00
dependabot[bot]
2eba3d85b0 Bump pulsectl from 20.5.1 to 21.2.0 (#2634)
Bumps [pulsectl](https://github.com/mk-fg/python-pulse-control) from 20.5.1 to 21.2.0.
- [Release notes](https://github.com/mk-fg/python-pulse-control/releases)
- [Changelog](https://github.com/mk-fg/python-pulse-control/blob/master/CHANGES.rst)
- [Commits](https://github.com/mk-fg/python-pulse-control/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-26 09:42:59 +01:00
Joakim Sørensen
9b569268ab Fix add-on updates (#2632)
* Fix add-on updates

* Add to security role
2021-02-25 23:29:39 +01:00
Pascal Vizeli
31f5033dca Add throttle to job execution (#2631)
* Add throttle to job execution

* fix unittests

* Add tests

* address comments

* add comment

* better on __init__

* New text

* Simplify logic
2021-02-25 23:29:03 +01:00
Pascal Vizeli
78d9c60be5 Log issues/suggestion with info (#2629) 2021-02-25 19:52:19 +01:00
Stefan Agner
baa86f09e5 Real-time fixes (#2630)
* Fix path of cpu.rt_runtime_us sysfs file

Fix detection of CPU bandwidth allocation (CONFIG_RT_GROUP_SCHED) option
by checking the correct file location.

* Set priority limit and memory lock limit

Set a soft limit of real-time priority 90 and hard limit of 99. The
maximum is 99, to avoid add-ons using such a high priority without
second thought set the soft limit to 90. This allows a process to higher
the limit to 99, if really required.

Also set max locked memory to 128MB. Locking memory from getting paged
out is often used for the real-time process/thread to avoid delays due
to swapping/pageing in. Ideally a real-time process should only do the
real-time job, hence not need too much memory.

* Remove check for support_cpu_realtime and set correct limit for audio plug-in
2021-02-25 18:48:08 +01:00
Pascal Vizeli
a4c4b39ba8 Fix k-anonymity handling (#2627) 2021-02-25 18:16:20 +01:00
Joakim Sørensen
752068bb56 Add /store API (#2626) 2021-02-25 16:15:51 +01:00
Pascal Vizeli
739cfbb273 Small cleanups with pwned handling (#2625) 2021-02-25 15:36:02 +01:00
Pascal Vizeli
115af4cadf Optimize resolution checks / add endpoint to trigger it manual (#2622) 2021-02-25 14:05:27 +01:00
Joakim Sørensen
ae3274e559 Add home-assistant version to API response (#2621) 2021-02-25 11:44:22 +01:00
dependabot[bot]
c61f096dbd Bump docker from 4.4.3 to 4.4.4 (#2619)
Bumps [docker](https://github.com/docker/docker-py) from 4.4.3 to 4.4.4.
- [Release notes](https://github.com/docker/docker-py/releases)
- [Commits](https://github.com/docker/docker-py/compare/4.4.3...4.4.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-25 10:27:24 +01:00
dependabot[bot]
ee7b5c42fd Bump awesomeversion from 21.2.2 to 21.2.3 (#2620)
Bumps [awesomeversion](https://github.com/ludeeus/awesomeversion) from 21.2.2 to 21.2.3.
- [Release notes](https://github.com/ludeeus/awesomeversion/releases)
- [Commits](https://github.com/ludeeus/awesomeversion/compare/21.2.2...21.2.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-25 10:27:05 +01:00
Pascal Vizeli
85d527bfbc Add check for pwned secrets to resolution center (#2614)
* Add check for pwned secrets to resolution center

* restructure check

* add checks

* Add test

* Add test

* reload secrets before check

* simplify

* create notification

* Use own exceptions

* Check on startup

* Apply suggestions from code review

Co-authored-by: Franck Nijhof <git@frenck.dev>

* Add job decorator

* Update supervisor/resolution/notify.py

Co-authored-by: Franck Nijhof <git@frenck.dev>

* Update supervisor/utils/pwned.py

Co-authored-by: Franck Nijhof <git@frenck.dev>

Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-02-25 09:37:45 +01:00
Pascal Vizeli
dd561da819 Fix landingpage on check_api_state (#2615)
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2021-02-24 21:52:18 +01:00
Joakim Sørensen
cb5932cb8b Fix issue with concurrent reads (#2610)
* Fix issue with concurrent reads

* Use lock

* acquire/release

* handle ConnectionError

* No there was not mulitple issues, it's the same code just different syle.....Which is stated on the same page as that image...
2021-02-24 18:36:21 +01:00
Pascal Vizeli
8630adc54a Add execution limit for jobs (#2612)
* Add execution limit for jobs

* Add test for execution police

* Use better test

* Apply suggestions from code review

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Rename JobExecutionLimit

* fix typing

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2021-02-24 17:15:13 +01:00
Joakim Sørensen
90d8832cd2 Send event when add-on changes state (#2608)
* Send event when add-on changes state

* fix test
2021-02-23 15:12:30 +01:00
Pascal Vizeli
3802b97bb6 Add kernel docs about the device classes (#2607) 2021-02-22 15:10:28 +01:00
Pascal Vizeli
2de175e181 Remove not needed call_soon (#2606) 2021-02-22 14:41:44 +01:00
Joakim Sørensen
6b7d437b00 Signal frontend to refresh on SU startup (#2603)
* Signal frontend to refresh on SU startup

* Use sync variant
2021-02-22 14:31:48 +01:00
Pascal Vizeli
e2faf906de Use the cpu_rt support check also for rtprio (#2605) 2021-02-22 14:02:36 +01:00
Franck Nijhof
bb44ce5cd2 Fix small typo in log message (#2604) 2021-02-22 13:44:12 +01:00
Joakim Sørensen
15544ae589 Show add-on with bad config in log (#2601) 2021-02-22 13:43:03 +01:00
Pascal Vizeli
e421284471 Detect host support for CPU realtime + add an option for enable it (#2602) 2021-02-22 13:30:32 +01:00
Pascal Vizeli
785dc64787 Imrove the LXC detection (#2599) 2021-02-22 11:39:18 +01:00
Joakim Sørensen
7e7e3a7876 Update frontend to ef0bfb23 (#2598) 2021-02-22 11:22:47 +01:00
Pascal Vizeli
2b45c059e0 Support realtime scheduling for add-ons (#2593)
* Support realtime scheduling for add-ons

* support on audio

* address comments from @jens-maus
2021-02-22 11:22:36 +01:00
Joakim Sørensen
14ec61f9bd Update frontend to 2d3cf7d8 (#2594) 2021-02-22 09:41:52 +01:00
Joakim Sørensen
5cc72756f8 Fix some issues with the issue template (#2592) 2021-02-19 23:35:00 +01:00
Franck Nijhof
44785ef3e2 Update GitHub Issue Form template (#2591) 2021-02-19 23:18:23 +01:00
Franck Nijhof
e60d858feb Allow for static port in Watchdog add-on configuration (#2589) 2021-02-19 15:23:17 +01:00
Joakim Sørensen
b31ecfefcd Initial WS support (#2439)
* Initial WS support

* test

* Update frontend to fc7c4af2

* Fix issue with closing states

* log error

* make data optional

* limit stopping states

* Move wrappers to HomeAssistantWebSocket

* use info

* Use call_soon

* Use lookuptable for WS commands

* Fix tests
2021-02-19 11:57:31 +01:00
dependabot[bot]
c342231052 Bump docker from 4.4.2 to 4.4.3 (#2587)
Bumps [docker](https://github.com/docker/docker-py) from 4.4.2 to 4.4.3.
- [Release notes](https://github.com/docker/docker-py/releases)
- [Commits](https://github.com/docker/docker-py/compare/4.4.2...4.4.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-19 10:09:03 +01:00
dependabot[bot]
673666837e Bump sentry-sdk from 0.20.2 to 0.20.3 (#2588) 2021-02-19 08:59:22 +01:00
dependabot[bot]
c8f74d6c0d Bump actions/stale from v3.0.16 to v3.0.17 (#2586) 2021-02-19 08:42:14 +01:00
Pascal Vizeli
7ed9de8014 Fix device check if not exists (#2585) 2021-02-18 12:39:42 +01:00
Pascal Vizeli
8650947f04 Add capabilities for puleaudio (#2583)
* Add capabilities for puleaudio

* fix import
2021-02-17 17:21:47 +01:00
Pascal Vizeli
a0ac8ced31 Fix handling with full access / blocked devices (#2581)
* Fix handling with full access / blocked devices

* address comment

* Use name

* Add validation warning

* add GPIO check too

* remove warning

* return directly

* fix tests
2021-02-17 15:48:48 +01:00
Joakim Sørensen
2145bbea81 Update frontend to 03d41741 (#2580) 2021-02-17 13:12:37 +01:00
Pascal Vizeli
480000ee7f Fix typo in suggestion (#2578) 2021-02-17 12:49:07 +01:00
dependabot[bot]
9ec2ad022e Bump cryptography from 3.4.5 to 3.4.6 (#2576)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.4.5 to 3.4.6.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.4.5...3.4.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-17 12:01:18 +01:00
dependabot[bot]
43e40816dc Bump pylint from 2.6.0 to 2.6.2 (#2577)
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.6.0 to 2.6.2.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Changelog](https://github.com/PyCQA/pylint/blob/master/ChangeLog)
- [Commits](https://github.com/PyCQA/pylint/compare/pylint-2.6.0...pylint-2.6.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-17 12:00:59 +01:00
Pascal Vizeli
941ea3ee68 Fix audio cgroup issue (#2575) 2021-02-16 09:34:15 +01:00
Pascal Vizeli
a6e4b5159e Discovery for vlc telnet (#2573) 2021-02-16 09:31:07 +01:00
dependabot[bot]
6f542d58d5 Bump docker from 4.4.1 to 4.4.2 (#2571)
Bumps [docker](https://github.com/docker/docker-py) from 4.4.1 to 4.4.2.
- [Release notes](https://github.com/docker/docker-py/releases)
- [Commits](https://github.com/docker/docker-py/compare/4.4.1...4.4.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-16 08:41:01 +01:00
dependabot[bot]
b2b5fcee7d Bump sentry-sdk from 0.20.1 to 0.20.2 (#2572)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.20.1 to 0.20.2.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.20.1...0.20.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-16 08:40:38 +01:00
Pascal Vizeli
59a82345a9 Drop full privileged from audio plugin (#2570) 2021-02-16 08:40:19 +01:00
Pascal Vizeli
b61a747876 Kernel modules add-on flag need no extra cap (#2569) 2021-02-15 20:42:03 +01:00
dependabot[bot]
72e5d800d5 Bump cryptography from 3.4.4 to 3.4.5 (#2567)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.4.4 to 3.4.5.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.4.4...3.4.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-15 10:09:54 +01:00
dependabot[bot]
c7aa6d4804 Bump sentry-sdk from 0.20.0 to 0.20.1 (#2568)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.20.0 to 0.20.1.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.20.0...0.20.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-15 10:08:58 +01:00
Pascal Vizeli
b31063449d Fix path for tmpfs (#2565) 2021-02-13 20:34:32 +01:00
dependabot[bot]
477672459d Bump sentry-sdk from 0.19.5 to 0.20.0 (#2563)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.19.5 to 0.20.0.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.19.5...0.20.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-12 15:33:20 +01:00
Pascal Vizeli
9c33897296 Add some issues and suggestion (#2557) 2021-02-11 09:06:46 +01:00
Matheson Steplock
100cfb57c5 Fix Typos in LOGGER (#2552)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2021-02-10 21:53:37 +01:00
Pascal Vizeli
40b34071e7 Revert "Mask folder /dev/bus/usb RW (#2555)" (#2556)
This reverts commit 341833fd8f.
2021-02-10 11:35:21 +01:00
Pascal Vizeli
341833fd8f Mask folder /dev/bus/usb RW (#2555) 2021-02-10 10:37:40 +01:00
dependabot[bot]
f647fd6fea Bump cryptography from 3.4.3 to 3.4.4 (#2553)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.4.3 to 3.4.4.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.4.3...3.4.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-10 10:23:42 +01:00
dependabot[bot]
53642f2389 Bump gitpython from 3.1.12 to 3.1.13 (#2554)
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.12 to 3.1.13.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/master/CHANGES)
- [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.12...3.1.13)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-10 10:23:06 +01:00
Pascal Vizeli
b9bdd655ab Add hidraw to USB (#2549) 2021-02-09 21:09:57 +01:00
Pascal Vizeli
e9e1b5b54f Add support for hiddev on USB (#2548) 2021-02-09 19:25:16 +01:00
Franck Nijhof
be2163d635 Small tweaks to issue form (#2545) 2021-02-09 17:25:34 +01:00
Franck Nijhof
7f6dde3a5f Fix issue template forms (#2543) 2021-02-09 17:14:44 +01:00
Joakim Sørensen
334aafee23 Update frontend to c7821b9c (#2542) 2021-02-09 13:10:13 +01:00
Pascal Vizeli
1a20c18b19 Use Alpine 3.13 (#2539)
* Use Alpine 3.13

* Update builder.yml
2021-02-09 10:21:14 +01:00
dependabot[bot]
6e655b165c Bump cryptography from 3.3.1 to 3.4.3 (#2537)
* Bump cryptography from 3.3.1 to 3.4.3

Bumps [cryptography](https://github.com/pyca/cryptography) from 3.3.1 to 3.4.3.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.3.1...3.4.3)

Signed-off-by: dependabot[bot] <support@github.com>

* Update builder.yml

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2021-02-09 10:04:58 +01:00
Pascal Vizeli
d768b2fa1e Fix UI options without filter (#2536) 2021-02-08 21:37:44 +01:00
Joakim Sørensen
85bce1cfba Add core state to /info API (#2531) 2021-02-08 12:39:46 +01:00
Pascal Vizeli
a798a2466f Change Supervisor update flow with AppArmor (#2529) 2021-02-08 10:45:34 +01:00
dependabot[bot]
2a5d8a5c82 Bump actions/stale from v3.0.15 to v3.0.16 (#2527)
Bumps [actions/stale](https://github.com/actions/stale) from v3.0.15 to v3.0.16.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v3.0.15...9d6f46564a515a9ea11e7762ab3957ee58ca50da)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-08 09:40:58 +01:00
dependabot[bot]
ea62171d98 Bump pyupgrade from 2.9.0 to 2.10.0 (#2526)
Bumps [pyupgrade](https://github.com/asottile/pyupgrade) from 2.9.0 to 2.10.0.
- [Release notes](https://github.com/asottile/pyupgrade/releases)
- [Commits](https://github.com/asottile/pyupgrade/compare/v2.9.0...v2.10.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-08 09:40:46 +01:00
dependabot[bot]
196389d5ee Bump pre-commit from 2.10.0 to 2.10.1 (#2525)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.10.0 to 2.10.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.10.0...v2.10.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-08 09:40:33 +01:00
dependabot[bot]
1776021620 Bump actions/cache from v2 to v2.1.4 (#2528)
Bumps [actions/cache](https://github.com/actions/cache) from v2 to v2.1.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...26968a09c0ea4f3e233fdddbafd1166051a095f6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-08 09:39:28 +01:00
Pascal Vizeli
c42a9124d3 Fix cleanup with changed image (#2521) 2021-02-05 16:03:57 +01:00
dependabot[bot]
a44647b4cd Bump awesomeversion from 21.2.0 to 21.2.2 (#2520)
Bumps [awesomeversion](https://github.com/ludeeus/awesomeversion) from 21.2.0 to 21.2.2.
- [Release notes](https://github.com/ludeeus/awesomeversion/releases)
- [Commits](https://github.com/ludeeus/awesomeversion/compare/21.2.0...21.2.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-05 11:31:57 +01:00
Pascal Vizeli
e0c3fd87c5 Add API endpoint for add-on for his own config (#2515)
* Add API endpoint for add-on for his own config

* allow access his config
2021-02-04 16:32:48 +01:00
Pascal Vizeli
ed8f2a85b7 Fix memory stats calc (#2518) 2021-02-04 16:06:12 +01:00
Pascal Vizeli
48f8553c75 Show the current core state on message (#2516) 2021-02-04 15:52:48 +01:00
Joakim Sørensen
af4517fd1e Update frontend to 4273b72d (#2517) 2021-02-04 15:50:07 +01:00
Joakim Sørensen
78e6a46318 Update frontend to e06642e8 (#2513) 2021-02-03 18:00:43 +01:00
Pascal Vizeli
49ca923e51 Apply old udev handling like core container (#2511) 2021-02-03 12:56:25 +01:00
Pascal Vizeli
7ad22e0399 Make add-on file schema more future approved (#2510) 2021-02-03 12:06:22 +01:00
Pascal Vizeli
bb8acc6065 Fix add-on state was not fast reflected (#2509) 2021-02-03 12:02:09 +01:00
Joakim Sørensen
c0fa4a19e9 Change verbosity for hardware.trigger API (#2508) 2021-02-02 20:56:37 +01:00
Franck Nijhof
3f1741dd18 Typo: depircated -> deprecated (#2507) 2021-02-02 20:41:56 +01:00
Stefan Agner
9ef02e4110 Add eMMC life-time estimate support (#2413)
* Add eMMC life-time estimate support

Expose life time estimate as Host Info property "ssd_life_time"

* Fix pytest

* Fix path to helper

* Allow protected access in tests

* Apply suggestions from code review

Rename SSD to disk.

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>

* Rename functions as well

* Update host.py

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
2021-02-02 10:31:02 +01:00
Pascal Vizeli
15a6f38ebb Make sure device is ready initialize on udev (#2504)
* Make sure device is ready initialize on udev

* fix style

* let's start with 2sec

* better logic

* style

* add change events back
2021-02-02 09:53:09 +01:00
dependabot[bot]
227f2e5a21 Bump pyupgrade from 2.8.0 to 2.9.0 (#2505)
Bumps [pyupgrade](https://github.com/asottile/pyupgrade) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/asottile/pyupgrade/releases)
- [Commits](https://github.com/asottile/pyupgrade/compare/v2.8.0...v2.9.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-02 09:52:51 +01:00
Pascal Vizeli
517d6ee981 Lookup udev device in monitor thread (#2503) 2021-02-01 18:29:05 +01:00
Pascal Vizeli
184eeb7f49 Udev - move away form depricated callback / increase buffer (#2502)
* Use new callback from udev / only forward

* minimize loop

* Udev - move away form depricated callback / increase buffer

* code cleanup
2021-02-01 17:33:53 +01:00
Joakim Sørensen
a3555c74e8 Bump awesomeversion from 21.1.8 to 21.2.0 (#2501) 2021-02-01 15:45:35 +01:00
Pascal Vizeli
657bafd458 Fix handling with shm and shared /dev (#2499)
* Fix handling with shm and shared /dev

* address commends

* let's share shm
2021-02-01 14:44:02 +01:00
Joakim Sørensen
2ad5df420c Rerun label check on synchronize (#2500) 2021-02-01 14:37:56 +01:00
Joakim Sørensen
b24d489ec5 Update frontend to a9192ae2 (#2498) 2021-02-01 13:26:54 +01:00
Franck Nijhof
6bb0210f1f Fix add-on is_valid check (#2497) 2021-02-01 11:27:34 +01:00
dependabot[bot]
c1de50266a Bump pytz from 2020.5 to 2021.1 (#2496)
Bumps [pytz](https://github.com/stub42/pytz) from 2020.5 to 2021.1.
- [Release notes](https://github.com/stub42/pytz/releases)
- [Commits](https://github.com/stub42/pytz/compare/release_2020.5...release_2021.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-01 11:27:17 +01:00
dependabot[bot]
562e02bc64 Bump pyupgrade from 2.7.4 to 2.8.0 (#2494)
Bumps [pyupgrade](https://github.com/asottile/pyupgrade) from 2.7.4 to 2.8.0.
- [Release notes](https://github.com/asottile/pyupgrade/releases)
- [Commits](https://github.com/asottile/pyupgrade/compare/v2.7.4...v2.8.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-01 11:27:04 +01:00
dependabot[bot]
f71ec7913a Bump awesomeversion from 21.1.5 to 21.1.8 (#2493)
Bumps [awesomeversion](https://github.com/ludeeus/awesomeversion) from 21.1.5 to 21.1.8.
- [Release notes](https://github.com/ludeeus/awesomeversion/releases)
- [Commits](https://github.com/ludeeus/awesomeversion/compare/21.1.5...21.1.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-01 11:26:51 +01:00
dependabot[bot]
d98baaf660 Bump jinja2 from 2.11.2 to 2.11.3 (#2495)
Bumps [jinja2](https://github.com/pallets/jinja) from 2.11.2 to 2.11.3.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/master/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/2.11.2...2.11.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-01 11:26:30 +01:00
Pascal Vizeli
72db591576 Validate build env before using it (#2492) 2021-02-01 09:46:48 +01:00
Wouter Schoot
509a37fc04 Typofix exsist -> exist (#2491)
* Typofix exsist -> exist

* Typofix exist -> exists
2021-02-01 09:34:17 +01:00
Pascal Vizeli
17f62b6e86 Handle corrupt store branch / ignore local reset on corruption (#2490)
* Handle corrupt store branch / ignore local reset on corruption

* Update data.py

* Update data.py
2021-01-31 22:55:43 +01:00
Pascal Vizeli
b09aee7644 Filter out virtual vcs devices (#2489)
* Filter out virtual vcs devices

* fix test
2021-01-31 14:40:14 +01:00
Pascal Vizeli
babcc0de0c Cleanup supervisor/udev device action / add GPIO (#2488)
* Cleanup supervisor/udev device action / add GPIO

* Apply francks comment
2021-01-31 14:24:22 +01:00
Franck Nijhof
5cc47c9222 Re-enable old template until form is resolved (#2486) 2021-01-30 19:47:45 +01:00
Franck Nijhof
833559a3b3 Add initial GitHub Issue Form (#2485)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2021-01-30 19:35:15 +01:00
Pascal Vizeli
b8a976b344 Change handling kernel udev events (#2484)
* Change handling kernel udev events / add USB events

* finish USB

* map dev ro

* fix bind
2021-01-30 14:19:53 +01:00
Joakim Sørensen
10b14132b9 Update frontend to 86847263 (#2483) 2021-01-29 18:23:58 +01:00
Pascal Vizeli
18953f0b7c plug & play devices (#2482)
* Add support for plug&play container & full udev passtrhough

* plug & play devices

* this hack is not needed anymore

* Fix GPIO issue

* Apply suggestions from code review

Co-authored-by: Franck Nijhof <git@frenck.dev>

Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-01-29 17:17:41 +01:00
Joakim Sørensen
19f5fba3aa Bump awesomeversion from 21.1.4 to 21.1.5 (#2481) 2021-01-29 14:10:06 +01:00
Pascal Vizeli
636bc3e61a Handle GPIO / VIDEO map with subystem (#2478)
* Handle GPIO / VIDEO mapping with subystem

* fix tests

* add udev support

* init udev data

* fix
2021-01-29 11:28:16 +01:00
Pascal Vizeli
521037e1a6 Fix mknod creating of the device on runtime time (#2477) 2021-01-28 17:07:33 +01:00
Pascal Vizeli
e024c3e38d Improve device selection and show device by id if available (#2476) 2021-01-28 15:43:06 +01:00
Pascal Vizeli
6a0206c1e7 Next generation hardware handling (#2429)
* Next generation hardware handling

* need daemon for some details

* fix tests

* fix wrong coresys lookup

* test initial import

* test device lookup

* validate if device exists

* Add cgroups rules manager

* mapping udev from host

* Modify validation/options handling

* lookup devices

* add support for host udev mapping

* next

* Add policy support to add-ons

* Depricate hardware trigger call

* next cleanup round

* detect USB linking

* optimize

* readd udev utils for backwards compatibility

* fix tests

* Add more tests

* fix tests

* Make device explicit

* Add filter

* work on tests

* Add migration step

* clean out auto_uart

* Fix all tests

* Expose all device information

* small  improvment

* Fix loop over right devices

* Use migration for new device format

* Update rootfs/etc/cont-init.d/udev.sh

Co-authored-by: Franck Nijhof <git@frenck.dev>

* Fix old helper

* Fix API

* add helper for by-id

* fix tests

* Fix serial helper

* Fix hardware API schema

* Hide some virtual devices from tracking

* Apply suggestions from code review

Co-authored-by: Stefan Agner <stefan@agner.ch>

* Update supervisor/addons/validate.py

Co-authored-by: Stefan Agner <stefan@agner.ch>

* Update supervisor/addons/validate.py

Co-authored-by: Stefan Agner <stefan@agner.ch>

* fix lint

* Apply suggestions from code review

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Apply suggestions from code review

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* fix black

* fix lint

Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Stefan Agner <stefan@agner.ch>
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2021-01-28 15:26:56 +01:00
Joakim Sørensen
69a8a83528 Limit label check (#2475) 2021-01-28 12:07:42 +01:00
Joakim Sørensen
0307d700fa Add TypeError guard for docker stats (#2474) 2021-01-28 11:58:04 +01:00
Joakim Sørensen
919c383b41 Bump awesomeversion from 21.1.3 to 21.1.4 (#2473) 2021-01-28 11:41:11 +01:00
dependabot[bot]
d331af4d5a Bump pre-commit from 2.9.3 to 2.10.0 (#2472)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.9.3 to 2.10.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.9.3...v2.10.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-28 08:46:29 +01:00
Joakim Sørensen
b5467d3c23 Update frontend to 5ee0250b (#2471) 2021-01-28 08:45:33 +01:00
dependabot[bot]
3ef0040d66 Bump coverage from 5.3.1 to 5.4 (#2470)
Bumps [coverage](https://github.com/nedbat/coveragepy) from 5.3.1 to 5.4.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/coverage-5.3.1...coverage-5.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-27 08:41:22 +01:00
Joakim Sørensen
ec4dfd2172 Add action to check PR labels (#2469)
* Check PR labels

* update

* update

* update

* only use lable events

* remove env stuff

* add back types
2021-01-26 14:21:05 +01:00
Pascal Vizeli
8f54d7c8e9 New version logic NM (#2466) 2021-01-26 10:33:35 +01:00
dependabot[bot]
b59e709dc0 Bump home-assistant/builder from 2020.11.0 to 2021.01.1 (#2468)
Bumps [home-assistant/builder](https://github.com/home-assistant/builder) from 2020.11.0 to 2021.01.1.
- [Release notes](https://github.com/home-assistant/builder/releases)
- [Commits](https://github.com/home-assistant/builder/compare/2020.11.0...e33ea8af3ad98e9ed7513cad92cc88fb303b42ff)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-26 10:17:50 +01:00
dependabot[bot]
b236e6c886 Bump pytest from 6.2.1 to 6.2.2 (#2467)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.1 to 6.2.2.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.2.1...6.2.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-26 09:47:45 +01:00
Pascal Vizeli
8acbb7d6f0 Fix API info calls access (#2464) 2021-01-25 10:45:08 +01:00
dependabot[bot]
49e4bc9381 Bump actions/stale from v3.0.14 to v3.0.15 (#2463)
Bumps [actions/stale](https://github.com/actions/stale) from v3.0.14 to v3.0.15.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v3.0.14...86561461b92875de77a8b2d2e75f004c826e8f45)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-25 09:59:20 +01:00
Philip Allgaier
36106cc08d Small README tweaks (#2460) 2021-01-24 21:18:06 +01:00
Pascal Vizeli
8f1763abe2 Fix OSError with custom component check (#2458) 2021-01-24 16:46:49 +01:00
Joakim Sørensen
480eebc6cb Update alert notification (#2457) 2021-01-23 21:06:55 +01:00
Pascal Vizeli
dccfffd979 Improve fixups with Job condition checks (#2451) 2021-01-21 16:48:25 +01:00
dependabot[bot]
1a978f4762 Bump pytest-cov from 2.11.0 to 2.11.1 (#2455)
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.11.0 to 2.11.1.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.11.0...v2.11.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-21 09:29:47 +01:00
Pascal Vizeli
1fbc8f4060 Add discovery support for zwave_js (#2454)
* Add discovery support for zwave_js

* New schema

* hmm

* address comments
2021-01-20 16:51:51 +01:00
Pascal Vizeli
db3fc1421c Fix: stable issue with corrupt git repository / submodule (#2452) 2021-01-19 14:21:27 +01:00
dependabot[bot]
9ecd03db0e Bump pytest-cov from 2.10.1 to 2.11.0 (#2446)
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.10.1 to 2.11.0.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.10.1...v2.11.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-18 13:54:22 +01:00
dependabot[bot]
f111ccb1b6 Bump awesomeversion from 21.1.2 to 21.1.3 (#2445)
Bumps [awesomeversion](https://github.com/ludeeus/awesomeversion) from 21.1.2 to 21.1.3.
- [Release notes](https://github.com/ludeeus/awesomeversion/releases)
- [Commits](https://github.com/ludeeus/awesomeversion/compare/21.1.2...21.1.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-18 13:54:07 +01:00
Joakim Sørensen
a32341cc5d Update frontend to 08c1b864 (#2444) 2021-01-17 17:54:42 +01:00
Pascal Vizeli
f73e277230 Fix issues with awesomeversion and representation (#2443) 2021-01-17 16:39:34 +01:00
Joakim Sørensen
8d8587ca29 Update wording in notification (#2438)
* Update wording in notification

* Update notify.py
2021-01-15 21:49:52 +01:00
Joakim Sørensen
88eb9511bf Add core version check (#2436)
* Add core version check

* Fix version handling, rename and use correct paths

* simplify check

* wrap approve check
2021-01-15 21:13:42 +01:00
Pascal Vizeli
e1068997ea Fix submodule update (#2434) 2021-01-15 14:28:31 +01:00
dependabot[bot]
560e04c64a Bump colorlog from 4.6.2 to 4.7.2 (#2432)
Bumps [colorlog](https://github.com/borntyping/python-colorlog) from 4.6.2 to 4.7.2.
- [Release notes](https://github.com/borntyping/python-colorlog/releases)
- [Commits](https://github.com/borntyping/python-colorlog/compare/v4.6.2...v4.7.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-15 14:24:40 +01:00
Joakim Sørensen
621ec03971 Ignore wheels on release (#2428)
* Fix wheels on publish

* ignore wheels for publish

* test

* revert test
2021-01-12 15:45:35 +01:00
Pascal Vizeli
d14a47d3f7 Auth: Improve authorisation (#2427) 2021-01-12 14:49:53 +01:00
Pascal Vizeli
3e9de0c210 Fix submodules - check if it is needed or not (#2426) 2021-01-12 13:53:04 +01:00
Joakim Sørensen
01a6e074a5 Adjust development tasks (#2425)
* Adjust development tasks

* add development
2021-01-12 13:50:11 +01:00
Joakim Sørensen
1434077f4e Update frontend panel to edcb7e87 (#2422) 2021-01-11 15:22:10 +01:00
Fredrik Erlandsson
3922175af1 Update git to support updates of submodules (#2378)
* Update git to support updates of submodules

* Remove unnecessary-comprehension

* prefix with **
2021-01-11 15:21:09 +01:00
Franck Nijhof
ec6852a8d7 Set a default for add-on options and schema config (#2421) 2021-01-11 12:36:19 +01:00
Pascal Vizeli
b0b908b4ae Fix missing repository (#2420) 2021-01-11 12:17:53 +01:00
Franck Nijhof
5a00336ef1 Set a default for add-on startup config (#2419) 2021-01-11 12:10:23 +01:00
Stefan Agner
d53f5e21f4 Increases core container timeout to match core shutdown time (#2417)
Align the core container timeout with what the core container
uses as grace period.
2021-01-11 11:24:54 +01:00
Stefan Agner
bd173fa333 Shutdown using systemd-logind if available (#2416)
The Reboot() and PowerOff() methods of the systemd D-Bus API are not
meant to be called directly when logind is in use. Make sure to use the
logind APIs if available.

Since OS release 5.1 systemd-logind is enabled.
2021-01-11 11:21:45 +01:00
Franck Nijhof
6b32fa31b6 Set a default for add-on boot config (#2418) 2021-01-11 11:17:23 +01:00
Joakim Sørensen
d1dba89e39 Add GitHub Action to build wheels (#2186)
* Make GitHub Action to build wheels

* try new

* fix branch

* fix typo

* test arch

* waitfor

* add ref

* fix wait

* fix name

* quote

* add complete step

* Update .github/workflows/wheels.yml

Co-authored-by: Franck Nijhof <git@frenck.dev>

* fix typo

* use name

* test

* merge them

* move

* test with requirement change

* add wheels-user

* revert version change

* use master

* bump awesomeversion

* set user

Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-01-08 18:57:35 +01:00
dependabot[bot]
b2f2806465 Bump gitpython from 3.1.11 to 3.1.12 (#2404)
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.11 to 3.1.12.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/master/CHANGES)
- [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.11...3.1.12)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-07 21:03:01 +01:00
Sergio Oller
3b70cd58a3 Allow GET method on /auth with BasicAuth (#2407)
* Allow GET on /auth with BasicAuth

* Accept GET without further validation

As suggested on https://github.com/home-assistant/supervisor/pull/2407#pullrequestreview-563712080
2021-01-07 21:02:36 +01:00
Joakim Sørensen
6769bfd824 Fix typo in reference (#2409) 2021-01-07 19:05:31 +01:00
dependabot[bot]
bff4af2534 Bump codecov/codecov-action from v1.2.0 to v1.2.1 (#2405)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.2.0 to v1.2.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.2.0...e156083f13aff6830c92fc5faa23505779fbf649)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-06 14:04:37 +01:00
dependabot[bot]
aabf575ac5 Bump actions/upload-artifact from v2.2.1 to v2.2.2 (#2400)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from v2.2.1 to v2.2.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2.2.1...e448a9b857ee2131e752b06002bf0e093c65e571)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-05 09:50:24 +01:00
dependabot[bot]
4aacaf6bd6 Bump codecov/codecov-action from v1.1.1 to v1.2.0 (#2401)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.1.1 to v1.2.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.1.1...a92c414703a4bba586f6df7fcc885c9d0bdff772)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-05 09:49:32 +01:00
dependabot[bot]
268070e89c Bump dessant/lock-threads from v2.0.1 to v2.0.3 (#2398)
Bumps [dessant/lock-threads](https://github.com/dessant/lock-threads) from v2.0.1 to v2.0.3.
- [Release notes](https://github.com/dessant/lock-threads/releases)
- [Changelog](https://github.com/dessant/lock-threads/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dessant/lock-threads/compare/v2.0.1...486f7380c15596f92b724e4260e4981c68d6bde6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-04 09:37:26 +01:00
Joakim Sørensen
4fa2134cc6 Bump awesomeversion from 20.12.4 to 20.12.5 (#2394) 2021-01-02 22:13:35 +01:00
Pascal Vizeli
97c35de49a Refacture version handling with AwesomeVersion (#2392)
* Refacture version handling with AwesomeVersion

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* next

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* next

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* next

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* v20.12.3

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* next

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* next

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* fix exception

* fix schema

* cleanup plugins

* fix tests

* fix attach

* fix TypeError

* fix issue with compairing

* make lint happy

* Update supervisor/homeassistant/__init__.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update tests/test_validate.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update supervisor/docker/__init__.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update supervisor/supervisor.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-12-31 17:09:33 +01:00
Joakim Sørensen
32fb550969 Bump docker to 4.4.1 (#2390) 2020-12-29 16:38:20 +01:00
dependabot[bot]
3457441929 Bump pytz from 2020.4 to 2020.5 (#2386)
Bumps [pytz](https://github.com/stub42/pytz) from 2020.4 to 2020.5.
- [Release notes](https://github.com/stub42/pytz/releases)
- [Commits](https://github.com/stub42/pytz/compare/release_2020.4...release_2020.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-28 16:26:50 +01:00
dependabot[bot]
32f0fc7a46 Bump codecov/codecov-action from v1.1.0 to v1.1.1 (#2381)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.1.0 to v1.1.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.1.0...1fc7722ded4708880a5aea49f2bfafb9336f0c8d)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-22 13:27:04 +01:00
dependabot[bot]
c891a8f164 Bump coverage from 5.3 to 5.3.1 (#2379)
Bumps [coverage](https://github.com/nedbat/coveragepy) from 5.3 to 5.3.1.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/coverage-5.3...coverage-5.3.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-21 15:18:02 +01:00
dependabot[bot]
991764af94 Bump actions/setup-python from v2.2.0 to v2.2.1 (#2380)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from v2.2.0 to v2.2.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2.2.0...3105fb18c05ddd93efea5f9e0bef7a03a6e9e7df)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-21 15:17:25 +01:00
dependabot[bot]
1df447272e Bump codecov/codecov-action from v1.0.15 to v1.1.0 (#2375)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.0.15 to v1.1.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.0.15...7de43a7373de21874ae196a78f8eb633fcf7f0c4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-18 21:42:42 +01:00
dependabot[bot]
f032ae757b Bump actions/setup-python from v2.1.4 to v2.2.0 (#2376)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from v2.1.4 to v2.2.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2.1.4...8c5ea631b2b2d5d8840cf4a2b183a8a0edc1e40d)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-18 21:42:10 +01:00
dependabot[bot]
e529b2859e Bump codecov from 2.1.10 to 2.1.11 (#2377)
Bumps [codecov](https://github.com/codecov/codecov-python) from 2.1.10 to 2.1.11.
- [Release notes](https://github.com/codecov/codecov-python/releases)
- [Changelog](https://github.com/codecov/codecov-python/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-python/compare/v2.1.10...v2.1.11)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-18 21:40:42 +01:00
Casper
d1cb2368fa fix typo (#2372) 2020-12-16 10:13:20 +01:00
dependabot[bot]
7b812184d1 Bump pytest from 6.2.0 to 6.2.1 (#2373)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.0 to 6.2.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.2.0...6.2.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-16 10:12:57 +01:00
dependabot[bot]
4f7ce1c6ee Bump cryptography from 3.2.1 to 3.3.1 (#2360)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.2.1 to 3.3.1.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.2.1...3.3.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-15 12:52:47 +01:00
dependabot[bot]
44a5ac63db Bump pytest from 6.1.2 to 6.2.0 (#2365)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.1.2 to 6.2.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.1.2...6.2.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-15 12:52:22 +01:00
Joakim Sørensen
0989ee88cc Pin docker-py to commit (#2371)
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-12-15 12:48:50 +01:00
dependabot[bot]
ba8b72c2c8 Bump sentry-sdk from 0.19.4 to 0.19.5 (#2362)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.19.4 to 0.19.5.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.19.4...0.19.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-15 12:28:11 +01:00
dependabot[bot]
2dbb4583f4 Bump debugpy from 1.2.0 to 1.2.1 (#2370)
Bumps [debugpy](https://github.com/microsoft/debugpy) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/microsoft/debugpy/releases)
- [Commits](https://github.com/microsoft/debugpy/compare/v1.2.0...v1.2.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-15 12:26:45 +01:00
Robin
81ad42e029 Fix typo in log message when completing snapshot (#2367) 2020-12-15 10:49:40 +01:00
dependabot[bot]
5d3695f8ba Bump pre-commit from 2.9.2 to 2.9.3 (#2356)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.9.2 to 2.9.3.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.9.2...v2.9.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-08 08:35:18 +01:00
Pascal Vizeli
c771694aa0 Show link for help user with unsupported systems (#2354)
* Show link for help user with unsupported systems

* Update .github/ISSUE_TEMPLATE/config.yml

Co-authored-by: Franck Nijhof <git@frenck.dev>

Co-authored-by: Franck Nijhof <git@frenck.dev>
2020-12-07 11:45:46 +01:00
Pascal Vizeli
1ac0fd4c10 Add note for unsupported system (#2353) 2020-12-07 11:00:27 +01:00
dependabot[bot]
631ff8caef Bump voluptuous from 0.12.0 to 0.12.1 (#2352)
Bumps [voluptuous](https://github.com/alecthomas/voluptuous) from 0.12.0 to 0.12.1.
- [Release notes](https://github.com/alecthomas/voluptuous/releases)
- [Changelog](https://github.com/alecthomas/voluptuous/blob/master/CHANGELOG.md)
- [Commits](https://github.com/alecthomas/voluptuous/compare/0.12.0...0.12.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-07 10:39:49 +01:00
Joakim Sørensen
7382182132 Add changes to release drafter (#2349)
* Add changes to release drafter

* remove duplicate

* Add more labels

* add CI

* remove enhacement
2020-12-06 13:24:09 +01:00
Joakim Sørensen
4ff9da68ef Actually use the vlan_struct (#2347) 2020-12-05 13:04:37 +01:00
Pascal Vizeli
dee2998ee3 Fix issue with mark system wrong as rollback (#2345) 2020-12-05 11:19:27 +01:00
Pascal Vizeli
1d43236211 Upgrade json config handler logging to critical (#2344) 2020-12-05 10:57:20 +01:00
Pascal Vizeli
792bc610a3 Fix NM byte switch for ipv6 nameserver (#2342)
* Fix NM byte switch for ipv6 nameserver

* remove not needed code
2020-12-04 17:55:26 +01:00
Pascal Vizeli
7a51c828c2 Fix wrong exception handler 2020-12-04 15:26:13 +00:00
Pascal Vizeli
fab6fcd5ac Check NetworkManager Version if it is supported (#2340)
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-12-04 12:38:12 +01:00
Joakim Sørensen
c8e00ba160 Adds vlan_struct (#2337)
* Return VLAN ID instead of wifistruct for VLAN

* Use vlan_struct

* fix typing

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-12-04 11:37:55 +01:00
Joakim Sørensen
6245b6d823 Fix KeyError in connectivity_enabled (#2336) 2020-12-03 21:40:34 +01:00
Pascal Vizeli
0c55bf20fc Fix issue on store git clone (#2331) 2020-12-03 21:06:48 +01:00
Pascal Vizeli
f8fd7b5933 Improve error handling with job condition (#2322)
* Improve error handling with job condition

* fix

* first patch

* last patch

* Address comments

* Revert strange replace
2020-12-03 12:24:32 +01:00
Pascal Vizeli
6462eea2ef Fix sentry stdlib spam (#2326) 2020-12-02 17:24:40 +01:00
Pascal Vizeli
3d79891249 Make dbus connection more robust (#2325)
* Make dbus connection more robust

* move rauc down
2020-12-02 17:22:28 +01:00
Pascal Vizeli
80763c4bbf Support OTA url over version files (#2324)
* Support OTA url over version files

* Fix new schema
2020-12-02 14:59:42 +01:00
Pascal Vizeli
59102afd45 Fix sentry with sets (#2323) 2020-12-02 12:43:38 +01:00
Pascal Vizeli
0b085354db Send list of images to sentry (#2321) 2020-12-01 14:29:37 +01:00
Pascal Vizeli
e2a473baa3 Add network reload to api (#2319) 2020-12-01 14:03:59 +01:00
Pascal Vizeli
06e10fdd3c Fix NM naming schema (#2318)
* Fix NM naming schema

* Address comments

* Add test
2020-12-01 12:11:20 +01:00
Pascal Vizeli
fb4386a7ad Use persistent MAC address instead clone / don't touch default (#2317) 2020-12-01 09:27:49 +01:00
Pascal Vizeli
2d294f6841 Make evaluation of container better (#2316) 2020-11-30 18:00:12 +01:00
Pascal Vizeli
e09a839148 Fix byte order for network DNS settings (#2315) 2020-11-30 15:22:02 +01:00
Pascal Vizeli
d9c4dae739 Send error to sentry from update 2020-11-30 10:28:05 +00:00
Pascal Vizeli
49853e92a4 Fix sentry spam (#2313) 2020-11-30 11:01:10 +01:00
Pascal Vizeli
19620d6808 Fix: cleanup repository from list (#2310)
* Fix: cleanup repository from list

* Add repr

* Avoid not exists error message
2020-11-29 14:00:29 +01:00
Pascal Vizeli
f6bf44de1c Add tests for remove function (#2309) 2020-11-29 12:34:33 +01:00
Pascal Vizeli
06fae59fc8 Remove corrupt FS on store sentry report (#2308) 2020-11-28 18:11:56 +01:00
Pascal Vizeli
5c25fcd84c Reset on invalid filesystem (#2307) 2020-11-28 15:57:00 +01:00
Pascal Vizeli
aa5297026f Handle Store suggestion (#2306)
* Handle Store suggestion

* Add fixup

* Add more fixup & list

* Enable fixups

* Add tests

* fix index

* fix break

* fix import

* Load it anyway

* Run suFix ccestion on load too

* fix error message

* fix error message

* Fix remove

* Finishing

* Add tests

* Fix error

* fix cleanup stale stuff

* Fix source

* use source as url

* add test for url

* Apply suggestions from code review

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-11-28 15:03:44 +01:00
Joakim Sørensen
841520b75e Strip device names (#2303) 2020-11-26 22:40:54 +01:00
Pascal Vizeli
d9e20307de Allow check to cleanup issues (#2302) 2020-11-26 22:38:33 +01:00
Pascal Vizeli
fda1b523ba Extend resolution center (#2297)
* Extend resolution center

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* move forward

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* Rename it to fixups

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* Finish p1

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* Finish p1 - add files

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* Finishup

* Add more tests

* Add test for suggestion

* Add more tests

* fix tests & isort

* address comments

* address comments v2

* fix isort

* Change reference handling
2020-11-26 17:16:36 +01:00
dependabot[bot]
7cccbc682c Bump pre-commit from 2.9.0 to 2.9.2 (#2300)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.9.0 to 2.9.2.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.9.0...v2.9.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-26 08:30:35 +01:00
Pascal Vizeli
621eb4c4c0 Don't send DBusProgramError to sentry (#2294)
* Don't send DBusProgramError to sentry

* Add message
2020-11-24 14:18:00 +01:00
Pascal Vizeli
056926242f Fix sentry resoluton messages (#2295) 2020-11-24 14:17:47 +01:00
Pascal Vizeli
84294f286f Add unhealthy if update fails on startup 2020-11-24 12:51:16 +00:00
Joakim Sørensen
b6bc6b8498 Update frontend panel to 1d367eca (#2293) 2020-11-24 11:56:35 +01:00
Pascal Vizeli
845c935b39 Add JobManager API ignore (#2290)
* Disable job condition for unhealth & unsupported systems

* Add JobManager API ignore

* Apply suggestions from code review

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Update tests/resolution/evaluation/test_evaluate_job_conditions.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* fix names

* address comments

* Update decorator.py

* adjust security

* add reset

* Apply suggestions from code review

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-11-24 10:54:57 +01:00
dependabot[bot]
19d8de89df Bump docker from 4.3.1 to 4.4.0 (#2292)
Bumps [docker](https://github.com/docker/docker-py) from 4.3.1 to 4.4.0.
- [Release notes](https://github.com/docker/docker-py/releases)
- [Commits](https://github.com/docker/docker-py/compare/4.3.1...4.4.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-24 08:49:22 +01:00
Joakim Sørensen
cfae20a3ec Change snapshot create conditions (#2289) 2020-11-23 22:57:41 +01:00
Joakim Sørensen
6db6ab96e6 Update frontend panel to 0ef88816 (#2291) 2020-11-23 22:57:11 +01:00
dependabot[bot]
48695c6805 Bump actions/stale from v3.0.13 to v3.0.14 (#2286)
Bumps [actions/stale](https://github.com/actions/stale) from v3.0.13 to v3.0.14.
- [Release notes](https://github.com/actions/stale/releases)
- [Commits](https://github.com/actions/stale/compare/v3.0.13...87c2b794b9b47a9bec68ae03c01aeb572ffebdb1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-23 09:36:20 +01:00
dependabot[bot]
d74908e3b5 Bump pre-commit from 2.8.2 to 2.9.0 (#2287)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.8.2 to 2.9.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.8.2...v2.9.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-23 09:30:41 +01:00
Pascal Vizeli
7e94537e36 Soft restart supervisor (#2281)
* Add softrestart to supervisor

* decouble

* adjust logger

* make sure it need run

* Use job condition

* add more job running
2020-11-21 12:48:16 +01:00
Pascal Vizeli
1427e0ae96 Add jobs decorator to add-ons/snapshot/core and remove 404 hack (#2280)
* Add jobs decorator to add-ons/snapshot/core and remove 404 hack

* add to repair
2020-11-21 10:47:15 +01:00
Pascal Vizeli
01e27dfa2f Wifi mode old NM (#2279) 2020-11-21 10:20:31 +01:00
Joakim Sørensen
f48249c9d1 Remove HEALTHY from update_repositories (#2277) 2020-11-21 10:07:44 +01:00
Joakim Sørensen
e607d4feeb Fix missing primary interface after change (#2274)
* Fix missing primary interface after change

* Fix test
2020-11-20 12:01:59 +01:00
Joakim Sørensen
5367ac257e Update frontend panel to 46f55895 (#2275) 2020-11-20 11:51:43 +01:00
Joakim Sørensen
46dc6dc63b Add log about ratelimit (#2271)
* Add log about ratelimit

* Update wording

* create issue
2020-11-20 10:50:26 +01:00
dependabot[bot]
a59ea72c66 Bump sentry-sdk from 0.19.3 to 0.19.4 (#2273)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.19.3 to 0.19.4.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.19.3...0.19.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-20 09:44:28 +01:00
Pascal Vizeli
2daf46c444 Rename add-ons repository (#2272) 2020-11-19 21:10:37 +01:00
Pascal Vizeli
1bf38bdc99 Use Brotli instead of brotlipy (#2270) 2020-11-19 09:24:40 +01:00
dependabot[bot]
131909973c Bump aiohttp from 3.7.2 to 3.7.3 (#2269)
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.7.2 to 3.7.3.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.7.2...v3.7.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-19 08:35:04 +01:00
Pascal Vizeli
ecdf4e53b8 Use atomic writes to make it more stable again full disk (#2267) 2020-11-18 17:08:57 +01:00
Pascal Vizeli
7aa039d162 Missing log what going on (#2268) 2020-11-18 17:08:28 +01:00
Pascal Vizeli
3dd3340e35 Make host feature cheaper to call and relay on it (#2266) 2020-11-18 14:13:49 +01:00
Pascal Vizeli
2f9fc39b72 Check if connectivity check if available on host (#2265)
* Check if connectivity check if available on host

* fix get

* not needed

* Update const.py

* Use enabled
2020-11-18 12:40:55 +01:00
Pascal Vizeli
80f4309799 Enforce internet host/system (#2263) 2020-11-18 11:29:23 +01:00
Pascal Vizeli
550fca4bcd Remove coroutine from job update (#2264) 2020-11-18 11:25:04 +01:00
Pascal Vizeli
4b500ef873 JobManager should not touch our exceptions (#2261)
* JobManager should not touch our exceptions

* Add tests

* temporary allow su update all time

* Update supervisor/jobs/decorator.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-11-17 18:46:02 +01:00
dependabot[bot]
476f021fbf Bump debugpy from 1.1.0 to 1.2.0 (#2260)
Bumps [debugpy](https://github.com/microsoft/debugpy) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/microsoft/debugpy/releases)
- [Commits](https://github.com/microsoft/debugpy/compare/v1.1.0...v1.2.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-17 18:38:00 +01:00
dependabot[bot]
8393ca5b23 Bump codecov/codecov-action from v1.0.14 to v1.0.15 (#2259)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.0.14 to v1.0.15.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.0.14...239febf655bba88b16ff5dea1d3135ea8663a1f9)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-17 08:56:32 +01:00
dependabot[bot]
4eb7a60b88 Bump actions/upload-artifact from v2.2.0 to v2.2.1 (#2257)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from v2.2.0 to v2.2.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2.2.0...726a6dcd0199f578459862705eed35cda05af50b)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-16 12:34:50 +01:00
Pascal Vizeli
2040102e21 Handle Unhealthy like Unsupported (#2255)
* Handle Unhealthy like Unsupported

* Add tests

* Add unhealthy to sentry

* Add test
2020-11-14 16:16:00 +01:00
Joakim Sørensen
7ee5737f75 Activate new network settings after update (#2253) 2020-11-13 18:15:46 +01:00
Pascal Vizeli
8d499753a0 Fix auto interface method (#2252) 2020-11-13 16:58:28 +01:00
Pascal Vizeli
028ec277eb Enable support for mdns & llmnr for host (#2251) 2020-11-13 16:47:56 +01:00
Pascal Vizeli
5552b1da49 Optimize flow / reduce call time (#2250)
* Optimize flow / reduce call time

* rename

* freeze too

* add connectivity task

* use newstyle timeout

* Fix tests

Co-authored-by: Ludeeus <ludeeus@ludeeus.dev>
2020-11-13 12:19:10 +01:00
Joakim Sørensen
06ab7e904f Split check for internet connection to help troubleshooting (#2248)
* Split check for internet connection to help troubleshooting

* Siplify

* revert

* cleanup

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-11-13 08:58:07 +01:00
Pascal Vizeli
e4bf820038 Check & fix git repository integrity (#2245)
* Check & fix git repository integrity

* fix typing

* New style error handling

* Fix return

* tag more issue

* Fix black
2020-11-13 08:35:45 +01:00
dependabot[bot]
c209d2fa8d Bump sentry-sdk from 0.19.2 to 0.19.3 (#2249)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.19.2 to 0.19.3.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.19.2...0.19.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-13 08:27:31 +01:00
Joakim Sørensen
784c5d3b7c Use bool for host internet (#2247)
* Use bool for host internet

* Ignore host check if no network manager

* Update supervisor/host/network.py

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>

* Check dbus connection isntead of supported features

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-11-13 00:07:05 +01:00
Joakim Sørensen
a18b706f99 Add JobManager and Job decorator (#2225)
* Adds condition decorator to block execution that require internet

* Fix exsisting tests

* Add internet state to network info

* Add healthy condition

* Add tests

* It's all changed

* rename
2020-11-12 22:57:28 +01:00
Pascal Vizeli
cd34a40dd8 Send issues with sentry report (#2246) 2020-11-12 14:57:04 +01:00
Pascal Vizeli
ced72e1273 Fix show update if version is None (#2244) 2020-11-12 10:11:38 +01:00
Pascal Vizeli
5416eda1d6 Improve the error logging with new DBusProgramError (#2243) 2020-11-12 09:34:43 +01:00
Pascal Vizeli
c76a4ff422 Revert: psk is not readable and only exists on initial (#2242)
* Revert: psk is not readable and only exists on initial

* fix tests
2020-11-11 21:07:28 +01:00
Stefan Agner
d558ad2d76 Use technology neutral "auto" instead of "dhcp" for autoconfiguration (#2241)
* Use technology neutral "auto"  instead of "dhcp" for autoconfiguration

IPv6 is often run with SLAAC which does not use a DHCP server but still
does automatic address configuration. Follow wording of NetworkManager
and use "auto" instead.

* Use "auto" also in interface_update.tmpl

* Update interface_update.tmpl

* remove newline

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-11-11 18:23:04 +01:00
Pascal Vizeli
5f2d183b1d Fix wifi conversation (#2240)
* Fix wifi conversation

* Fix naming

* simple
2020-11-11 17:09:48 +01:00
Pascal Vizeli
46e92036ec Fix handling with open or wpa-psk (#2239) 2020-11-11 16:33:46 +01:00
Pascal Vizeli
280d423bfe Fix error if a wlan scan is allready running (#2238)
* Fix error if a wlan scan is allready running

* fix other messages too
2020-11-11 13:48:50 +01:00
Pascal Vizeli
c4847ad10d Handle dbus single byte (#2237) 2020-11-11 13:09:13 +01:00
dependabot[bot]
0a7c75830b Bump pyupgrade from 2.7.3 to 2.7.4 (#2236)
Bumps [pyupgrade](https://github.com/asottile/pyupgrade) from 2.7.3 to 2.7.4.
- [Release notes](https://github.com/asottile/pyupgrade/releases)
- [Commits](https://github.com/asottile/pyupgrade/compare/v2.7.3...v2.7.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-11 08:45:07 +01:00
Pascal Vizeli
7aceb21123 Fix auth mode WEP (#2235)
* Fix auth mode WEP

* fix mapping
2020-11-10 18:07:20 +01:00
Pascal Vizeli
9264d437b1 Fix network API default value & tests (#2234) 2020-11-10 15:08:35 +01:00
Franck Nijhof
edc8d8960f Replace stale bot with GitHub Action (#2232) 2020-11-10 09:15:34 +01:00
dependabot[bot]
0f4f196dc9 Bump colorlog from 4.5.0 to 4.6.2 (#2233)
Bumps [colorlog](https://github.com/borntyping/python-colorlog) from 4.5.0 to 4.6.2.
- [Release notes](https://github.com/borntyping/python-colorlog/releases)
- [Commits](https://github.com/borntyping/python-colorlog/compare/v4.5.0...v4.6.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-10 09:15:01 +01:00
Pascal Vizeli
a027f4b5fc Revert info back to debug 2020-11-09 15:11:57 +00:00
Franck Nijhof
f025d1df05 Replace lock bot with GitHub Action (#2231) 2020-11-09 13:07:23 +01:00
Pascal Vizeli
4c560d7c54 Fix gateway None on API (#2230)
* Fix gateway None on API

* fix tests
2020-11-09 10:00:39 +01:00
Pascal Vizeli
a976ef6e67 Cleanup some logger (#2229) 2020-11-09 09:56:01 +01:00
Pascal Vizeli
e1b9d754af Fix all interface are primary (#2228) 2020-11-09 09:27:16 +01:00
Pascal Vizeli
ee49935b7d Odroid-C4 (#2226)
* Add Odroid-C4

* add machine
2020-11-09 08:57:18 +01:00
dependabot[bot]
36694c9ef0 Bump colorlog from 4.4.0 to 4.5.0 (#2227)
Bumps [colorlog](https://github.com/borntyping/python-colorlog) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/borntyping/python-colorlog/releases)
- [Commits](https://github.com/borntyping/python-colorlog/compare/v4.4.0...v4.5.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-09 08:57:08 +01:00
Pascal Vizeli
bd786811a3 Network: abstract dbus and supervisor - ipv6/wifi/vlan (#2217)
* Abstract code between dbus - supervisor

* cleanup v2

* fix address vs interface

* fix API calls

* Fix methodnames

* add vlan type

* add vlan support

* Fix tests

* Add wifi support

* more OOO

* fix typing import

* typing part 2

* Fix profile

* fix test payload

* ignore powersafe

* support privancy

* fix property

* Fix tests

* full support all API

* Fix all

* more robust

* Update supervisor/dbus/network/connection.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Fix gateway

* fix empty gateway

* Allow no ipv6 or ipv4 kernel support

* Exclude device drivers

* Add wifi

* Use loop on api

* refactory p1

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* refactory p2

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* refactory p3

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* refactory p4

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* refactory p5

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* refactory p6

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* refactory p7

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* refactory p8

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* Fix lint

* update sup p1

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* update sup p2

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* fix tests

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* fix logging

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* improve mock handling

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* add fixtures

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>

* fix tests

* better testing

* Add more tests

* Fix API test

* Add test for vlan payload

* Support variation

* Fix doc string

* support remove & wifi scan

* make sure we ignore local-link on ipv6

* remove privancy - add vlan

* Fix tests

* fix isort

* Fixture dbus by commands

* Add dnsmanager fixture

* expose commands called by dbus

* Add wifi tests

* Update supervisor/plugins/dns.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Address comments & fix tests

* change url to be closer on others

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-11-09 08:56:42 +01:00
Paulus Schoutsen
ffaeb2b96d Add validate session API (#2223) 2020-11-06 11:52:11 +01:00
dependabot[bot]
517e6cb437 Bump attrs from 20.2.0 to 20.3.0 (#2222)
Bumps [attrs](https://github.com/python-attrs/attrs) from 20.2.0 to 20.3.0.
- [Release notes](https://github.com/python-attrs/attrs/releases)
- [Changelog](https://github.com/python-attrs/attrs/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/python-attrs/attrs/compare/20.2.0...20.3.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-06 11:45:42 +01:00
Joakim Sørensen
9479672b88 Create evaluation modules (#2220)
* Create evaluation modules

* Use sys_core
2020-11-05 17:36:02 +01:00
Joakim Sørensen
934e59596a Adds more logs to session validation (#2219)
* Adds more logs to session validation

* It's not there

* Use debug

* format

* Create new timestamp if OverflowError
2020-11-05 10:40:56 +01:00
Joakim Sørensen
8f4ac10361 Add login support for dockerhub (#2218)
* Add login support for dockerhub

* Remove registry
2020-11-05 10:39:53 +01:00
Pascal Vizeli
50e0fd159f Add process lock for update + fix timeout (#2215) 2020-11-03 18:12:57 +01:00
Pascal Vizeli
28344ff5f3 Supervisor container startup health function (#2214)
* Supervisor container startup health function

* better struct

* add test

* address comment

* rename file

* Update tests/test_main.py

Co-authored-by: Stefan Agner <stefan@agner.ch>

Co-authored-by: Stefan Agner <stefan@agner.ch>
2020-11-03 16:36:10 +01:00
dependabot[bot]
608ae14246 Bump sentry-sdk from 0.19.1 to 0.19.2 (#2211)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.19.1 to 0.19.2.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.19.1...0.19.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-03 09:58:43 +01:00
dependabot[bot]
c0c0d44c2d Bump home-assistant/builder from 2020.10.0 to 2020.11.0 (#2210)
Bumps [home-assistant/builder](https://github.com/home-assistant/builder) from 2020.10.0 to 2020.11.0.
- [Release notes](https://github.com/home-assistant/builder/releases)
- [Commits](https://github.com/home-assistant/builder/compare/2020.10.0...c60c59d1300ac720519bbf35026f6b6904214d71)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-03 09:58:12 +01:00
Pascal Vizeli
5e947348ae Fix pulse cookie error (#2212) 2020-11-03 09:54:31 +01:00
Joakim Sørensen
1f4032f56f Add the log stream from docker if build fails (#2207)
* Add the log stream from docker if build fails

* Check if dict
2020-11-02 11:44:11 +01:00
dependabot[bot]
336ab0d2b1 Bump pre-commit from 2.8.1 to 2.8.2 (#2206)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.8.1 to 2.8.2.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.8.1...v2.8.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-02 09:58:55 +01:00
dependabot[bot]
0f9d80dde4 Bump pytz from 2020.1 to 2020.4 (#2205)
Bumps [pytz](https://github.com/stub42/pytz) from 2020.1 to 2020.4.
- [Release notes](https://github.com/stub42/pytz/releases)
- [Commits](https://github.com/stub42/pytz/compare/release_2020.1...release_2020.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-02 09:58:36 +01:00
Joakim Sørensen
0fcab4d92b Fix missing metadata in the issue template (#2200) 2020-10-30 17:18:37 +01:00
Joakim Sørensen
abd35b62c8 Update issue template (#2199) 2020-10-30 17:11:51 +01:00
Pascal Vizeli
7b721ad8c6 Fix initialized state on dead/removing/pause containers (#2197) 2020-10-30 16:16:07 +01:00
Joakim Sørensen
37eaaf356d Add run_supervisor step to builder action (#2195)
* Add run_supervisor step to builder action

* split

* build it

* wording

* move so version push can depend on it
2020-10-30 13:42:45 +01:00
Pascal Vizeli
8cbb4b510b Init template sooner (#2194) 2020-10-30 10:37:34 +01:00
Pascal Vizeli
f71549e3df New fix for stale container on network (#2189)
* New fix for stale container on network

* fix core repair

* Clenaup before attach to network

* Fix reload

* Fix host network

* Fix prune network

* Remove refresh

* Fix unpack

* better name

* clean order

* Add comment why

* more comments

* Update supervisor/misc/tasks.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-10-30 10:03:05 +01:00
Joakim Sørensen
fe15bb6a30 Add workflow_dispatch for manual action run (#2192) 2020-10-29 18:31:52 +01:00
Pascal Vizeli
50d36b857a DNS plugin maintainance (#2179)
* DNS plugin maintainance

* cleanup old data

* move fallback to plugin

* smaller

* Allow plugin to write into config persistent

* Fix hosts

* create issue on dns loop
2020-10-29 15:48:57 +01:00
dependabot[bot]
db260dfbde Bump pre-commit from 2.7.1 to 2.8.1 (#2188)
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.7.1 to 2.8.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v2.7.1...v2.8.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-29 10:11:39 +01:00
dependabot[bot]
a0c99615aa Bump pytest from 6.1.1 to 6.1.2 (#2187)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.1.1 to 6.1.2.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.1.1...6.1.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-29 10:11:27 +01:00
dependabot[bot]
c66c806e6e Bump cchardet from 2.1.6 to 2.1.7 (#2182)
Bumps [cchardet](https://github.com/PyYoshi/cChardet) from 2.1.6 to 2.1.7.
- [Release notes](https://github.com/PyYoshi/cChardet/releases)
- [Changelog](https://github.com/PyYoshi/cChardet/blob/master/CHANGES.rst)
- [Commits](https://github.com/PyYoshi/cChardet/compare/2.1.6...2.1.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-28 09:43:37 +01:00
dependabot[bot]
a432d28ee3 Bump cryptography from 3.2 to 3.2.1 (#2181)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.2 to 3.2.1.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.2...3.2.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-28 09:43:17 +01:00
dependabot[bot]
742bc43500 Bump aiohttp from 3.7.1 to 3.7.2 (#2183)
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.7.1 to 3.7.2.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.7.1...v3.7.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-28 09:42:51 +01:00
Joakim Sørensen
223e2f1df5 Fix missing await (#2180) 2020-10-27 15:10:57 +01:00
dependabot[bot]
ed9aea6219 Bump debugpy from 1.0.0 to 1.1.0 (#2178)
Bumps [debugpy](https://github.com/microsoft/debugpy) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/microsoft/debugpy/releases)
- [Commits](https://github.com/microsoft/debugpy/compare/v1.0.0...v1.1.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-27 11:30:24 +01:00
Joakim Sørensen
aa7b68d4d5 Fix missing await (#2177)
* Fix missing await

* One more
2020-10-26 21:14:42 +01:00
Pascal Vizeli
8e57cd2751 Remove uvloop (#2176) 2020-10-26 11:45:12 +01:00
dependabot[bot]
64229a188e Bump aiohttp from 3.6.3 to 3.7.1 (#2175)
* Bump aiohttp from 3.6.3 to 3.7.1

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.6.3 to 3.7.1.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.6.3...v3.7.1)

Signed-off-by: dependabot[bot] <support@github.com>

* remove yarl pining

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-10-26 10:35:46 +01:00
dependabot[bot]
10cbbcc2de Bump gitpython from 3.1.10 to 3.1.11 (#2173)
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.10 to 3.1.11.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/master/CHANGES)
- [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.10...3.1.11)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-26 10:19:36 +01:00
dependabot[bot]
5318e4fbcd Bump cryptography from 3.1 to 3.2 (#2174)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.1 to 3.2.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.1...3.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-26 10:19:28 +01:00
Joakim Sørensen
007251a04c Use matrix builds (#2172) 2020-10-25 13:08:17 +01:00
Joakim Sørensen
fd4b3ee539 Move from azure pipelines to GitHub actions for build (#2170) 2020-10-24 13:57:51 +02:00
Pascal Vizeli
976ae96633 Revert dns restart logic (#2169) 2020-10-23 16:49:35 +02:00
Pascal Vizeli
042bdcdf37 Make startup more stable (#2167) 2020-10-23 16:48:03 +02:00
Pascal Vizeli
c423e9cf8e Fix plugin restart (#2166) 2020-10-23 14:57:42 +02:00
Joakim Sørensen
1f13d6aa91 Add build check to CI (#2165)
* Add build check to CI

* Use tag name
2020-10-23 14:30:41 +02:00
dependabot[bot]
78c09a0fa6 Bump pyupgrade from 2.7.2 to 2.7.3 (#2163)
Bumps [pyupgrade](https://github.com/asottile/pyupgrade) from 2.7.2 to 2.7.3.
- [Release notes](https://github.com/asottile/pyupgrade/releases)
- [Commits](https://github.com/asottile/pyupgrade/compare/v2.7.2...v2.7.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-23 10:12:21 +02:00
dependabot[bot]
e6d6f2ee8c Bump gitpython from 3.1.9 to 3.1.10 (#2164)
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.9 to 3.1.10.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/master/CHANGES)
- [Commits](https://github.com/gitpython-developers/GitPython/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-23 09:55:52 +02:00
Pascal Vizeli
2918ef6225 Update azure-pipelines-release.yml 2020-10-22 16:28:29 +02:00
Pascal Vizeli
35b626a1c5 Fix gvariant bytes array (#2162) 2020-10-22 15:56:32 +02:00
Pascal Vizeli
6f26536d97 update branch 2020-10-22 11:32:24 +00:00
Pascal Vizeli
01064564b4 Fix new version handling with Plugins (#2159) 2020-10-22 12:29:53 +02:00
Pascal Vizeli
0c6c6a6620 Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 20:55:16 +02:00
Joakim Sørensen
be166d533f Update frontend to c4ed7433 (#2157) 2020-10-21 20:52:02 +02:00
Pascal Vizeli
d3e5535221 Update azure-pipelines-release.yml 2020-10-21 20:32:40 +02:00
Pascal Vizeli
7206213cd8 Update azure-pipelines-release.yml 2020-10-21 17:27:11 +02:00
Pascal Vizeli
605782d707 Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 14:31:37 +02:00
Pascal Vizeli
2c387349c9 Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 14:20:46 +02:00
Pascal Vizeli
e9c9f98168 Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 14:14:04 +02:00
Pascal Vizeli
a98c7819b0 Fix version script 2020-10-21 12:02:43 +00:00
Pascal Vizeli
7c42c5758d Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 13:51:07 +02:00
Pascal Vizeli
c555146094 Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 13:48:09 +02:00
Pascal Vizeli
f48c9b5774 Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 13:45:40 +02:00
Pascal Vizeli
8d1732e5eb Update azure-pipelines-release.yml for Azure Pipelines 2020-10-21 13:42:19 +02:00
Pascal Vizeli
f2843db421 Streamline version handling (#2155)
* Streamline version handling

* guard detached add-on

* commit version

* fix version

* Update pipeline

* use su-version

* Handle core like before

* Fix dev

* Update supervisor/api/addons.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Cleanup

* Fix format

* fix import

* fix yml issue

* fix readme

* Update supervisor/api/addons.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update frontend

* Address comments

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
Co-authored-by: Ludeeus <ludeeus@ludeeus.dev>
2020-10-21 13:40:38 +02:00
Joakim Sørensen
b513512551 Normalize CPU stats (#2154)
* Normalize CPU stats

* Change fixture to make it clearer

* guard for 0

* Update supervisor/docker/stats.py

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>

* Update stats.py

* Update stats.py

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-10-20 22:26:09 +02:00
Joakim Sørensen
1a59839b1b Correct typo in log message (#2156)
* Correct typo in log message

* More typos
2020-10-20 20:30:20 +02:00
Pascal Vizeli
45861617b9 Add test for network docker (#2153) 2020-10-20 10:52:16 +02:00
Pascal Vizeli
353544085e Show internal network settings (#2152) 2020-10-20 10:42:51 +02:00
Pascal Vizeli
144d3921f7 Support preinstalled landingpage (#2137) 2020-10-20 10:13:39 +02:00
dependabot[bot]
e44d22880e Bump sentry-sdk from 0.18.0 to 0.19.1 (#2150)
* Bump sentry-sdk from 0.18.0 to 0.19.1

Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.18.0 to 0.19.1.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.18.0...0.19.1)

Signed-off-by: dependabot[bot] <support@github.com>

* Disable auto enabling integrations for now

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-10-20 10:10:24 +02:00
Pascal Vizeli
c7692b43e8 Bump version 250 2020-10-19 16:46:11 +02:00
Pascal Vizeli
9c53caae80 Speedup HA core auth (#2144)
* Speedup HA core auth

* Add reset API call

* use delete

* Add complexe cache logic

* Allow manage api to handle auth reset/cache

* revert to only cache

* add tests

* ignore protected-access for this tests

* fix comment
2020-10-19 16:38:28 +02:00
Pascal Vizeli
7a1d85ca2b Fix old issues attach to Issues list (#2148) 2020-10-19 16:38:14 +02:00
Joakim Sørensen
e684223f32 Update frontend to eec4a91 (#2147) 2020-10-19 16:02:59 +02:00
Joakim Sørensen
9744f3354b Overwrite snapshot if slug allready exsist (#2146) 2020-10-19 13:57:58 +02:00
dependabot[bot]
c6e3787681 Bump codecov/codecov-action from v1.0.13 to v1.0.14 (#2143)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.0.13 to v1.0.14.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.0.13...7d5dfa54903bd909319c580a00535b483d1efcf3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-19 10:14:26 +02:00
Pascal Vizeli
eab76a6d1d Bump version 249 2020-10-18 16:17:39 +02:00
Pascal Vizeli
6549a10935 Merge remote-tracking branch 'origin/master' into dev 2020-10-18 14:09:27 +00:00
Pascal Vizeli
530d40dbbd Bump cli min version to 2020.10.0 (#2140) 2020-10-18 15:41:58 +02:00
Joakim Sørensen
50f2d8e7d8 Update frontend to 713e057 (#2138) 2020-10-18 09:55:12 +02:00
Pascal Vizeli
7a9aac491e Use /info for resolution API (#2136) 2020-10-16 13:07:02 +02:00
Pascal Vizeli
7dcb609fd5 Add api access for resolution call (#2135) 2020-10-16 12:28:53 +02:00
Pascal Vizeli
d119e99001 Resolution: extend type and context (#2130)
* Resolution: extend type and context

* fix property

* add helper

* fix api

* fix tests

* Fix patch

* finish tests

* Update supervisor/resolution/const.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update supervisor/resolution/const.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Fix type

* fix lint

* Update supervisor/api/resolution.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update supervisor/resolution/__init__.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update API & add more tests

* Update supervisor/api/resolution.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update supervisor/resolution/__init__.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* Update supervisor/resolution/__init__.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* fix black

* remove azure ci

* fix test

* fix tests

* fix tests

* fix tests p2

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2020-10-16 12:22:32 +02:00
Joakim Sørensen
fe0e41adec Log messages cleanup (#2129)
* Log cleanup

* More logs
2020-10-15 14:50:43 +02:00
dependabot[bot]
034393bd42 Bump actions/setup-python from v2.1.3 to v2.1.4 (#2128)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from v2.1.3 to v2.1.4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2.1.3...41b7212b1668f5de9d65e9c82aa777e6bbedb3a8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-15 11:10:34 +02:00
Joakim Sørensen
02e72726a5 Add issues/suggestion to resolution center / start with diskspace (#2125)
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-10-14 17:14:25 +02:00
dependabot[bot]
d599c3ad76 Bump debugpy from 1.0.0rc2 to 1.0.0 (#2126)
Bumps [debugpy](https://github.com/microsoft/debugpy) from 1.0.0rc2 to 1.0.0.
- [Release notes](https://github.com/microsoft/debugpy/releases)
- [Commits](https://github.com/microsoft/debugpy/compare/v1.0.0rc2...v1.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-14 10:11:31 +02:00
Pascal Vizeli
b00f7c44df Observer: rebuild container if the application don't response (#2121)
* Observer: rebuild container if the application don't response

* add network mask

* Fix version
2020-10-13 15:01:31 +02:00
Joakim Sørensen
028b170cff Add resolution manager and unsupported flags (#2124)
* Add unsupported reason flags

* Restore test_network.py

* Add Resolution manager object

* fix import
2020-10-13 12:54:17 +02:00
Pascal Vizeli
8da686fc34 Fix corrupt container on startup (#2122) 2020-10-13 11:02:54 +02:00
dependabot[bot]
3f6453aa89 Bump aiohttp from 3.6.2 to 3.6.3 (#2123)
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.6.2 to 3.6.3.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.6.2...v3.6.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-13 10:27:34 +02:00
Pascal Vizeli
7967254673 CLI: remote latest tag, not needed anymore (#2120) 2020-10-12 21:56:19 +02:00
Pascal Vizeli
0f60fdd20b Make api soon available (#2119)
* Make api soon available

* add more tests
2020-10-12 15:56:29 +02:00
Joakim Sørensen
ccb8e5fe06 Add content-disposition header to snapshot download (#2116)
* Add content-disposition header to snapshot download

* compile it
2020-10-12 11:11:32 +02:00
dependabot[bot]
ba576d8748 Bump codecov from 2.1.9 to 2.1.10 (#2118)
Bumps [codecov](https://github.com/codecov/codecov-python) from 2.1.9 to 2.1.10.
- [Release notes](https://github.com/codecov/codecov-python/releases)
- [Changelog](https://github.com/codecov/codecov-python/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-python/compare/v2.1.9...v2.1.10)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-12 09:20:10 +02:00
dependabot[bot]
edcd9ca6e6 Bump getsentry/action-release from v1.0.2 to v1.1 (#2117)
Bumps [getsentry/action-release](https://github.com/getsentry/action-release) from v1.0.2 to v1.1.
- [Release notes](https://github.com/getsentry/action-release/releases)
- [Commits](https://github.com/getsentry/action-release/compare/v1.0.2...770b4a8dfd940faf96cd27e2004fda20bcdad5ea)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-12 09:19:04 +02:00
Pascal Vizeli
ac4277cd7b Return default network connection (#2115) 2020-10-12 09:13:27 +02:00
Pascal Vizeli
4c525de5e2 Mark system without using NetworkManager as unsupported (#2114)
* Mark system without using NetworkManager as unsupported

* Use feature style

* fix code
2020-10-10 18:30:34 +02:00
Pascal Vizeli
cb751e0397 Rename snapshot remove like other API calls (#2113) 2020-10-10 15:08:13 +02:00
Pascal Vizeli
ac457c1c28 Add brotlipy for ingress / like core (#2112) 2020-10-10 12:58:37 +02:00
Joakim Sørensen
caa77b9337 Remove API docs (#2088) 2020-10-09 14:39:39 +02:00
dependabot[bot]
96d8785349 Bump colorlog from 4.2.1 to 4.4.0 (#2110)
Bumps [colorlog](https://github.com/borntyping/python-colorlog) from 4.2.1 to 4.4.0.
- [Release notes](https://github.com/borntyping/python-colorlog/releases)
- [Commits](https://github.com/borntyping/python-colorlog/compare/v4.2.1...v4.4.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-09 11:27:34 +02:00
Joakim Sørensen
e4f57d2269 Update frontend to 892843b (#2111) 2020-10-09 11:27:06 +02:00
Ludeeus
f946de1e46 Bump version to 248 2020-10-07 12:03:20 +00:00
Joakim Sørensen
d588987b8b Merge pull request #2107 from home-assistant/247patch 2020-10-07 13:56:02 +02:00
Joakim Sørensen
4925b5fa97 Pin yarl to 1.5.1 (#2106) 2020-10-07 11:43:15 +00:00
Ludeeus
aa3f6390d3 Bump version to 247 2020-10-07 11:43:00 +00:00
Joakim Sørensen
6ba413f452 Pin yarl to 1.5.1 (#2106) 2020-10-07 13:41:46 +02:00
Pascal Vizeli
10b6706e4a Make docker API more Consistency to exists (#2102)
Co-authored-by: Ludeeus <ludeeus@ludeeus.dev>
2020-10-06 16:02:22 +02:00
Joakim Sørensen
17559bfc8e Extract exception message from chain for API errors (#2100)
* Get message from excepiton chain

* cleanup
2020-10-06 15:53:58 +02:00
Joakim Sørensen
9dc2f43ffb Handle both cases of bind failures (#2099) 2020-10-06 11:28:09 +02:00
Joakim Sørensen
38db375fea Add docker/info API (#2095) 2020-10-06 11:26:56 +02:00
Joakim Sørensen
f35b6d0b00 Set permissions on JSON files (#2093)
* Set 600 premissions on json files

* Add test

* Fix local tar tests

* Fix tar test in action

* Use pytest fixture for tmp_path in tests

* remove not needed things
2020-10-05 15:14:09 +02:00
Pascal Vizeli
8d75583a07 Update manager role for access docker api endpoint (#2091) 2020-10-05 13:18:46 +02:00
Joakim Sørensen
361fc51477 Add pull request template (#2092) 2020-10-05 13:18:19 +02:00
Halász Dávid
f6019b4e68 Support for installing add-ons from password protected registries (#2038) 2020-10-05 12:19:25 +02:00
dependabot[bot]
998dd5387b Bump flake8 from 3.8.3 to 3.8.4 (#2089)
Bumps [flake8](https://gitlab.com/pycqa/flake8) from 3.8.3 to 3.8.4.
- [Release notes](https://gitlab.com/pycqa/flake8/tags)
- [Commits](https://gitlab.com/pycqa/flake8/compare/3.8.3...3.8.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-05 09:32:44 +02:00
dependabot[bot]
3b7776ca01 Bump pytest from 6.1.0 to 6.1.1 (#2090)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.1.0 to 6.1.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.1.0...6.1.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-05 09:31:48 +02:00
dependabot[bot]
5788d1dd32 Bump actions/upload-artifact from v2.1.4 to v2.2.0 (#2086)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from v2.1.4 to v2.2.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2.1.4...27bce4eee761b5bc643f46a8dfb41b430c8d05f6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 09:52:15 +02:00
dependabot[bot]
ff04d339f4 Bump gitpython from 3.1.8 to 3.1.9 (#2083)
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.8 to 3.1.9.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/master/CHANGES)
- [Commits](https://github.com/gitpython-developers/GitPython/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-01 08:57:07 +02:00
dependabot[bot]
e9d03c5c8e Bump actions/setup-python from v2.1.2 to v2.1.3 (#2082)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from v2.1.2 to v2.1.3.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2.1.2...c181ffa198a1248f902bc2f7965d2f9a36c2d7f6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-01 08:55:27 +02:00
dependabot[bot]
ab4b98470e Bump sentry-sdk from 0.17.8 to 0.18.0 (#2080)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.17.8 to 0.18.0.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.17.8...0.18.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-30 10:26:44 +02:00
Ludeeus
c4f0702595 Bump version to 247 2020-09-30 07:39:19 +00:00
Paulus Schoutsen
736c9cb2bd Merge pull request #2081 from home-assistant/dev 2020-09-30 09:37:02 +02:00
Joakim Sørensen
f24e8535d3 Update frontend to 9dabce1 (#2079) 2020-09-29 17:30:48 +02:00
dependabot[bot]
8e4f3e0526 Bump pytest from 6.0.2 to 6.1.0 (#2078)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.0.2 to 6.1.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.0.2...6.1.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-28 09:18:44 +02:00
Joakim Sørensen
a9abd933b5 Use multipart for snapshot uploads (#2076)
* Use multipart for snapshot uploads

* Wrap I/O and run in executor

* revert 7f26b43

* remove cleanup
2020-09-24 13:09:53 +02:00
dependabot[bot]
f1121fe66f Bump sentry-sdk from 0.17.7 to 0.17.8 (#2077)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.17.7 to 0.17.8.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.17.7...0.17.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-24 10:43:38 +02:00
dependabot[bot]
c26a2e399c Bump sentry-sdk from 0.17.6 to 0.17.7 (#2075)
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 0.17.6 to 0.17.7.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGES.md)
- [Commits](https://github.com/getsentry/sentry-python/compare/0.17.6...0.17.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-23 14:26:34 +02:00
Joakim Sørensen
1af90721cc Addon repositories (#2071)
* stash

* Add test

* Use executor

* Make remove a coroutine

* Change logging and return
2020-09-22 23:40:36 +02:00
Joakim Sørensen
9274a0fa17 Add uuid to update payload (#2070)
* Add uuid to update payload

* Add it to test
2020-09-22 23:38:04 +02:00
dependabot[bot]
9443032c2a Bump voluptuous from 0.11.7 to 0.12.0 (#2073)
Bumps [voluptuous](https://github.com/alecthomas/voluptuous) from 0.11.7 to 0.12.0.
- [Release notes](https://github.com/alecthomas/voluptuous/releases)
- [Changelog](https://github.com/alecthomas/voluptuous/blob/master/CHANGELOG.md)
- [Commits](https://github.com/alecthomas/voluptuous/commits/v0.12.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-22 23:36:42 +02:00
Iulian Onofrei
8deb1cf2e6 Fix typo in logger method name (#2069) 2020-09-19 03:11:52 +02:00
Pascal Vizeli
13c7ce6a0a Merge branch 'dev' of https://github.com/home-assistant/supervisor into dev 2020-09-17 10:33:06 +00:00
Pascal Vizeli
0f54824cdb add one test more 2020-09-17 10:32:41 +00:00
Pascal Vizeli
10cd722806 Bump version to 246 2020-09-17 12:12:32 +02:00
540 changed files with 21882 additions and 10392 deletions

View File

@@ -2,6 +2,11 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.8
WORKDIR /workspaces
# Set Docker daemon config
RUN \
mkdir -p /etc/docker \
&& echo '{"storage-driver": "vfs"}' > /etc/docker/daemon.json
# Install Node/Yarn for Frontent
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \

View File

@@ -5,6 +5,7 @@
"appPort": "9123:8123",
"postCreateCommand": "pre-commit install",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
"containerEnv": {"NVM_DIR":"/usr/local/share/nvm"},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",

View File

@@ -1,28 +1,69 @@
---
name: Report a bug with the Supervisor on a supported System
about: Report an issue related to the Home Assistant Supervisor.
labels: bug
---
<!-- READ THIS FIRST:
- If you need additional help with this template please refer to https://www.home-assistant.io/help/reporting_issues/
- Make sure you are running the latest version of Home Assistant before reporting an issue: https://github.com/home-assistant/core/releases
- Do not report issues for integrations here, please refer to https://github.com/home-assistant/core/issues
- This is for bugs only. Feature and enhancement requests should go in our community forum: https://community.home-assistant.io/c/feature-requests
- Provide as many details as possible. Paste logs, configuration sample and code into the backticks. Do not delete any text from this template!
- If you have a problem with an add-on, make an issue in its repository.
- If you have a problem with an add-on, make an issue in it's repository.
-->
**Home Assistant release with the issue:**
<!--
- Frontend -> Configuration -> Info
- Or use this command: hass --version
Important: You can only fill a bug repport for an supported system! If you run an unsupported installation. This report would be closed without comment.
-->
**Operating environment (HassOS/Generic):**
<!--
Please provide details about your environment.
-->
### Describe the issue
**Supervisor logs:**
<!-- Provide as many details as possible. -->
### Steps to reproduce
<!-- What do you do to encounter the issue. -->
1. ...
2. ...
3. ...
### Enviroment details
<!-- You can find these details in the system tab of the supervisor panel, or by using the `ha` CLI. -->
- **Operating System:**: xxx
- **Supervisor version:**: xxx
- **Home Assistant version**: xxx
### Supervisor logs
<details>
<summary>Supervisor logs</summary>
<!--
- Frontend -> Supervisor -> System
- Or use this command: ha supervisor logs
- Logs are more than just errors, even if you don't think it's important, it is.
-->
```
Paste supervisor logs here
```
</details>
### System Information
<details>
<summary>System Information</summary>
<!--
- Use this command: ha info
-->
```
Paste system info here
```
</details>
**Description of problem:**

106
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,106 @@
name: Bug Report Form
about: Report an issue related to the Home Assistant Supervisor.
labels: bug
title: ""
issue_body: true
body:
- type: markdown
attributes:
value: |
This issue form is for reporting bugs with **supported** setups only!
If you have a feature or enhancement request, please use the [feature request][fr] section of our [Community Forum][fr].
[fr]: https://community.home-assistant.io/c/feature-requests
- type: textarea
validations:
required: true
attributes:
label: Describe the issue you are experiencing
description: Provide a clear and concise description of what the bug is.
- type: markdown
attributes:
value: |
## Environment
- type: input
validations:
required: true
attributes:
label: What is the used version of the Supervisor?
placeholder: supervisor-
description: >
Can be found in the Supervisor panel -> System tab. Starts with
`supervisor-....`.
- type: dropdown
validations:
required: true
attributes:
label: What type of installation are you running?
description: >
If you don't know, you can find it in: Configuration panel -> Info.
options:
- Home Assistant OS
- Home Assistant Supervised
- type: dropdown
validations:
required: true
attributes:
label: Which operating system are you running on?
options:
- Home Assistant Operating System
- Debian
- Other (e.g., Raspbian/Raspberry Pi OS/Fedora)
- type: input
validations:
required: true
attributes:
label: What is the version of your installed operating system?
placeholder: "5.11"
description: Can be found in the Supervisor panel -> System tab.
- type: input
validations:
required: true
attributes:
label: What version of Home Assistant Core is installed?
placeholder: core-
description: >
Can be found in the Supervisor panel -> System tab. Starts with
`core-....`.
- type: markdown
attributes:
value: |
# Details
- type: textarea
validations:
required: true
attributes:
label: Steps to reproduce the issue
description: |
Please tell us exactly how to reproduce your issue.
Provide clear and concise step by step instructions and add code snippets if needed.
value: |
1.
2.
3.
...
- type: textarea
validations:
required: true
attributes:
label: Anything in the Supervisor logs that might be useful for us?
description: >
The Supervisor logs can be found in the Supervisor panel -> System tab.
value: |
```txt
# Put your logs below this line
```
- type: markdown
attributes:
value: |
## Additional information
- type: markdown
attributes:
value: |
If you have any additional information for us, use the field below.
Please note, you can attach screenshots or screen recordings here.

25
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
blank_issues_enabled: false
contact_links:
- name: Report a bug/issues with an unsupported Supervisor
url: https://community.home-assistant.io
about: The Community guide can help or was updated to solve your issue
- name: Report a bug for the Supervisor panel
url: https://github.com/home-assistant/frontend/issues
about: The Supervisor panel is a part of the Home Assistant frontend
- name: Report incorrect or missing information on our developer documentation
url: https://github.com/home-assistant/developers.home-assistant.io/issues
about: Our documentation has its own issue tracker. Please report issues with the website there.
- name: Request a feature for the Supervisor
url: https://community.home-assistant.io/c/feature-requests
about: Request an new feature for the Supervisor.
- name: I have a question or need support
url: https://www.home-assistant.io/help
about: We use GitHub for tracking bugs, check our website for resources on getting help.
- name: I'm unsure where to go?
url: https://www.home-assistant.io/join-chat
about: If you are unsure where to go, then joining our chat is recommended; Just ask!

68
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,68 @@
<!--
You are amazing! Thanks for contributing to our project!
Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue in the
additional information section.
-->
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (which adds functionality to the supervisor)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. **Your PR cannot be merged unless tests pass**
- [ ] There is no commented out code in this PR.
- [ ] I have followed the [development checklist][dev-checklist]
- [ ] The code has been formatted using Black (`black --fast supervisor tests`)
- [ ] Tests have been added to verify that the new code works.
If API endpoints of add-on configuration are added/changed:
- [ ] Documentation added/updated for [developers.home-assistant.io][docs-repository]
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/en/development_checklist.html
[docs-repository]: https://github.com/home-assistant/developers.home-assistant

27
.github/lock.yml vendored
View File

@@ -1,27 +0,0 @@
# Configuration for Lock Threads - https://github.com/dessant/lock-threads
# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 1
# Skip issues and pull requests created before a given timestamp. Timestamp must
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
skipCreatedBefore: 2020-01-01
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
exemptLabels: []
# Label to add before locking, such as `outdated`. Set to `false` to disable
lockLabel: false
# Comment to post before locking. Set to `false` to disable
lockComment: false
# Assign `resolved` as the reason for locking. Set to `false` to disable
setLockReason: false
# Limit to only `issues` or `pulls`
only: pulls
# Optionally, specify configuration settings just for `issues` or `pulls`
issues:
daysUntilLock: 30

View File

@@ -1,4 +1,49 @@
change-template: "- #$NUMBER $TITLE @$AUTHOR"
sort-direction: ascending
categories:
- title: ":boom: Breaking Changes"
label: "breaking-change"
- title: ":wrench: Build"
label: "build"
- title: ":boar: Chore"
label: "chore"
- title: ":sparkles: New Features"
label: "new-feature"
- title: ":zap: Performance"
label: "performance"
- title: ":recycle: Refactor"
label: "refactor"
- title: ":green_heart: CI"
label: "ci"
- title: ":bug: Bug Fixes"
label: "bugfix"
- title: ":white_check_mark: Test"
label: "test"
- title: ":arrow_up: Dependency Updates"
label: "dependencies"
include-labels:
- "breaking-change"
- "build"
- "chore"
- "performance"
- "refactor"
- "new-feature"
- "bugfix"
- "dependencies"
- "test"
- "ci"
template: |
## What's Changed
$CHANGES

18
.github/stale.yml vendored
View File

@@ -1,18 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
- rfc
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

215
.github/workflows/builder.yml vendored Normal file
View File

@@ -0,0 +1,215 @@
name: Build supervisor
on:
workflow_dispatch:
inputs:
channel:
description: "Channel"
required: true
default: "dev"
version:
description: "Version"
required: true
publish:
description: "Publish"
required: true
default: "false"
stable:
description: "Stable"
required: true
default: "false"
pull_request:
branches: ["main"]
release:
types: ["published"]
push:
branches: ["main"]
paths:
- "rootfs/**"
- "supervisor/**"
- build.json
- Dockerfile
- requirements.txt
- setup.py
env:
BUILD_NAME: supervisor
BUILD_TYPE: supervisor
WHEELS_TAG: 3.8-alpine3.13
jobs:
init:
name: Initialize build
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.info.outputs.architectures }}
version: ${{ steps.version.outputs.version }}
channel: ${{ steps.version.outputs.channel }}
publish: ${{ steps.version.outputs.publish }}
requirements: ${{ steps.requirements.outputs.changed }}
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get information
id: info
uses: home-assistant/actions/helpers/info@master
- name: Get version
id: version
uses: home-assistant/actions/helpers/version@master
with:
type: ${{ env.BUILD_TYPE }}
- name: Get changed files
id: changed_files
if: steps.version.outputs.publish == 'false'
uses: jitterbit/get-changed-files@v1
- name: Check if requirements files changed
id: requirements
run: |
if [[ "${{ steps.changed_files.outputs.all }}" =~ requirements.txt ]]; then
echo "::set-output name=changed::true"
fi
build:
name: Build ${{ matrix.arch }} supervisor
needs: init
runs-on: ubuntu-latest
strategy:
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures) }}
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build wheels
if: needs.init.outputs.requirements == 'true'
uses: home-assistant/wheels@master
with:
tag: ${{ env.WHEELS_TAG }}
arch: ${{ matrix.arch }}
wheels-host: ${{ secrets.WHEELS_HOST }}
wheels-key: ${{ secrets.WHEELS_KEY }}
wheels-user: wheels
apk: "build-base;libffi-dev;openssl-dev;cargo"
skip-binary: aiohttp
requirements: "requirements.txt"
- name: Set version
if: needs.init.outputs.publish == 'true'
uses: home-assistant/actions/helpers/version@master
with:
type: ${{ env.BUILD_TYPE }}
- name: Login to DockerHub
if: needs.init.outputs.publish == 'true'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set build arguments
if: needs.init.outputs.publish == 'false'
run: echo "BUILD_ARGS=--test" >> $GITHUB_ENV
- name: Build supervisor
uses: home-assistant/builder@2021.02.0
with:
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--target /data \
--generic ${{ needs.init.outputs.version }}
version:
name: Update version
needs: ["init", "run_supervisor"]
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
if: needs.init.outputs.publish == 'true'
uses: actions/checkout@v2
- name: Initialize git
if: needs.init.outputs.publish == 'true'
uses: home-assistant/actions/helpers/git-init@master
with:
name: ${{ secrets.GIT_NAME }}
email: ${{ secrets.GIT_EMAIL }}
token: ${{ secrets.GIT_TOKEN }}
- name: Update version file
if: needs.init.outputs.publish == 'true'
uses: home-assistant/actions/helpers/version-push@master
with:
key: ${{ env.BUILD_NAME }}
version: ${{ needs.init.outputs.version }}
channel: ${{ needs.init.outputs.channel }}
run_supervisor:
runs-on: ubuntu-latest
name: Run the Supervisor
needs: ["build"]
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Build the Supervisor
uses: home-assistant/builder@2021.02.0
with:
args: |
--test \
--amd64 \
--target /data \
--generic runner
- name: Create the Supervisor
run: |
mkdir -p /tmp/supervisor/data
docker create --name hassio_supervisor \
--privileged \
--security-opt seccomp=unconfined \
--security-opt apparmor:unconfined \
-v /run/docker.sock:/run/docker.sock \
-v /run/dbus:/run/dbus \
-v /tmp/supervisor/data:/data \
-v /etc/machine-id:/etc/machine-id:ro \
-e SUPERVISOR_SHARE="/tmp/supervisor/data" \
-e SUPERVISOR_NAME=hassio_supervisor \
-e SUPERVISOR_DEV=1 \
-e SUPERVISOR_MACHINE="qemux86-64" \
homeassistant/amd64-hassio-supervisor:runner
- name: Start the Supervisor
run: docker start hassio_supervisor
- name: Wait for Supervisor to come up
run: |
SUPERVISOR=$(docker inspect --format='{{.NetworkSettings.IPAddress}}' hassio_supervisor)
ping="error"
while [ "$ping" != "ok" ]; do
ping=$(curl -sSL "http://$SUPERVISOR/supervisor/ping" | jq -r .result)
sleep 5
done
- name: Check the Supervisor
run: |
echo "Checking supervisor info"
test=$(docker exec hassio_cli ha supervisor info --no-progress --raw-json | jq -r .result)
if [ "$test" != "ok" ];then
docker logs hassio_supervisor
exit 1
fi
echo "Checking supervisor network info"
test=$(docker exec hassio_cli ha network info --no-progress --raw-json | jq -r .result)
if [ "$test" != "ok" ];then
docker logs hassio_supervisor
exit 1
fi

19
.github/workflows/check_pr_labels.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Check PR
on:
pull_request:
branches: ["main"]
types: [labeled, unlabeled, synchronize]
jobs:
init:
name: Check labels
runs-on: ubuntu-latest
steps:
- name: Check labels
run: |
labels=$(jq -r '.pull_request.labels[] | .name' ${{github.event_path }})
echo "$labels"
if [ "$labels" == "cla-signed" ]; then
exit 1
fi

View File

@@ -4,8 +4,7 @@ name: CI
on:
push:
branches:
- dev
- master
- main
pull_request: ~
env:
@@ -26,12 +25,12 @@ jobs:
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
with:
python-version: ${{ matrix.python-version }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -48,7 +47,7 @@ jobs:
pip install -r requirements.txt -r requirements_tests.txt
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: |
@@ -69,13 +68,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -113,13 +112,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -131,7 +130,7 @@ jobs:
exit 1
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: |
@@ -157,13 +156,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -189,13 +188,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -207,7 +206,7 @@ jobs:
exit 1
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: |
@@ -230,13 +229,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -248,7 +247,7 @@ jobs:
exit 1
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: |
@@ -274,13 +273,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -306,13 +305,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -324,7 +323,7 @@ jobs:
exit 1
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: |
@@ -350,13 +349,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ matrix.python-version }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -391,7 +390,7 @@ jobs:
-o console_output_style=count \
tests
- name: Upload coverage artifact
uses: actions/upload-artifact@v2.1.4
uses: actions/upload-artifact@v2.2.2
with:
name: coverage-${{ matrix.python-version }}
path: .coverage
@@ -404,13 +403,13 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v2.1.2
uses: actions/setup-python@v2.2.1
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: venv
key: |
@@ -429,4 +428,4 @@ jobs:
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.0.13
uses: codecov/codecov-action@v1.2.1

20
.github/workflows/lock.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Lock
# yamllint disable-line rule:truthy
on:
schedule:
- cron: "0 0 * * *"
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2.0.3
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: "30"
issue-exclude-created-before: "2020-10-01T00:00:00Z"
issue-lock-reason: ""
pr-lock-inactive-days: "1"
pr-exclude-created-before: "2020-11-01T00:00:00Z"
pr-lock-reason: ""

View File

@@ -2,14 +2,43 @@ name: Release Drafter
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- dev
- main
jobs:
update_release_draft:
runs-on: ubuntu-latest
name: Release Drafter
steps:
- uses: release-drafter/release-drafter@v5
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Find Next Version
id: version
run: |
declare -i newpost
latest=$(git describe --tags $(git rev-list --tags --max-count=1))
latestpre=$(echo "$latest" | awk '{split($0,a,"."); print a[1] "." a[2]}')
datepre=$(date --utc '+%Y.%m')
if [[ "$latestpre" == "$datepre" ]]; then
latestpost=$(echo "$latest" | awk '{split($0,a,"."); print a[3]}')
newpost=$latestpost+1
else
newpost=0
fi
echo Current version: $latest
echo New target version: $datepre.$newpost
echo "::set-output name=version::$datepre.$newpost"
- name: Run Release Drafter
uses: release-drafter/release-drafter@v5
with:
tag: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -12,7 +12,7 @@ jobs:
- name: Check out code from GitHub
uses: actions/checkout@v2
- name: Sentry Release
uses: getsentry/action-release@v1.0.2
uses: getsentry/action-release@v1.1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}

39
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: Stale
# yamllint disable-line rule:truthy
on:
schedule:
- cron: "0 * * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3.0.17
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 60
days-before-close: 7
stale-issue-label: "stale"
exempt-issue-labels: "no-stale,Help%20wanted,help-wanted,pinned,rfc,security"
stale-issue-message: >
There hasn't been any activity on this issue recently. Due to the
high number of incoming GitHub notifications, we have to clean some
of the old issues, as many of them have already been resolved with
the latest updates.
Please make sure to update to the latest version and check if that
solves the issue. Let us know if that works for you by
adding a comment 👍
This issue has now been marked as stale and will be closed if no
further activity occurs. Thank you for your contributions.
stale-pr-label: "stale"
exempt-pr-labels: "no-stale,pinned,rfc,security"
stale-pr-message: >
There hasn't been any activity on this pull request recently. This
pull request has been automatically marked as stale because of that
and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

22
.vscode/tasks.json vendored
View File

@@ -2,9 +2,9 @@
"version": "2.0.0",
"tasks": [
{
"label": "Run Testenv",
"label": "Run Supervisor",
"type": "shell",
"command": "./scripts/test_env.sh",
"command": "./scripts/run-supervisor.sh",
"group": {
"kind": "test",
"isDefault": true
@@ -16,7 +16,21 @@
"problemMatcher": []
},
{
"label": "Run Testenv CLI",
"label": "Build Supervisor",
"type": "shell",
"command": "./scripts/build-supervisor.sh",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Run Supervisor CLI",
"type": "shell",
"command": "docker exec -ti hassio_cli /usr/bin/cli.sh",
"group": {
@@ -30,7 +44,7 @@
"problemMatcher": []
},
{
"label": "Update UI",
"label": "Update Supervisor Panel",
"type": "shell",
"command": "./scripts/update-frontend.sh",
"group": {

1235
API.md

File diff suppressed because it is too large Load Diff

View File

@@ -10,17 +10,23 @@ network settings or installing and updating software.
## Installation
Installation instructions can be found at https://home-assistant.io/hassio.
Installation instructions can be found at https://home-assistant.io/getting-started.
## Development
The development of the Supervisor is not difficult but tricky.
For small changes and bugfixes you can just follow this, but for significant changes open a RFC first.
Development instructions can be found [here][development].
- You can use the builder to create your Supervisor: https://github.com/home-assistant/hassio-builder
- Access a HassOS device or VM and pull your Supervisor.
- Set the developer modus with the CLI tool: `ha supervisor options --channel=dev`
- Tag it as `homeassistant/xy-hassio-supervisor:latest`
- Restart the service with `systemctl restart hassos-supervisor | journalctl -fu hassos-supervisor`
- Test your changes
## Release
For small bugfixes or improvements, make a PR. For significant changes open a RFC first, please. Thanks.
Releases are done in 3 stages (channels) with this structure:
1. Pull requests are merged to the `main` branch.
2. A new build is pushed to the `dev` stage.
3. Releases are published.
4. A new build is pushed to the `beta` stage.
5. The [`stable.json`][stable] file is updated.
6. The build that was pushed to `beta` will now be pushed to `stable`.
[development]: https://developers.home-assistant.io/docs/supervisor/development
[stable]: https://github.com/home-assistant/version/blob/master/stable.json

View File

@@ -1,52 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
batch: true
branches:
include:
- master
- dev
pr:
- dev
variables:
- name: versionHadolint
value: "v1.16.3"
jobs:
- job: "Tox"
pool:
vmImage: "ubuntu-latest"
steps:
- script: |
sudo apt-get update
sudo apt-get install -y libpulse0 libudev1
displayName: "Install Host library"
- task: UsePythonVersion@0
displayName: "Use Python 3.8"
inputs:
versionSpec: "3.8"
- script: pip install tox
displayName: "Install Tox"
- script: tox
displayName: "Run Tox"
- job: "JQ"
pool:
vmImage: "ubuntu-latest"
steps:
- script: sudo apt-get install -y jq
displayName: "Install JQ"
- bash: |
shopt -s globstar
cat **/*.json | jq '.'
displayName: "Run JQ"
- job: "Hadolint"
pool:
vmImage: "ubuntu-latest"
steps:
- script: sudo docker pull hadolint/hadolint:$(versionHadolint)
displayName: "Install Hadolint"
- script: |
sudo docker run --rm -i \
-v $(pwd)/.hadolint.yaml:/.hadolint.yaml:ro \
hadolint/hadolint:$(versionHadolint) < Dockerfile
displayName: "Run Hadolint"

View File

@@ -1,53 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
batch: true
branches:
include:
- dev
tags:
include:
- "*"
pr: none
variables:
- name: versionBuilder
value: "7.0"
- group: docker
jobs:
- job: "VersionValidate"
pool:
vmImage: "ubuntu-latest"
steps:
- task: UsePythonVersion@0
displayName: "Use Python 3.8"
inputs:
versionSpec: "3.8"
- script: |
setup_version="$(python setup.py -V)"
branch_version="$(Build.SourceBranchName)"
if [ "${branch_version}" == "dev" ]; then
exit 0
elif [ "${setup_version}" != "${branch_version}" ]; then
echo "Version of tag ${branch_version} don't match with ${setup_version}!"
exit 1
fi
displayName: "Check version of branch/tag"
- job: "Release"
dependsOn:
- "VersionValidate"
pool:
vmImage: "ubuntu-latest"
steps:
- script: sudo docker login -u $(dockerUser) -p $(dockerPassword)
displayName: "Docker hub login"
- script: sudo docker pull homeassistant/amd64-builder:$(versionBuilder)
displayName: "Install Builder"
- script: |
sudo docker run --rm --privileged \
-v ~/.docker:/root/.docker \
-v /run/docker.sock:/run/docker.sock:rw -v $(pwd):/data:ro \
homeassistant/amd64-builder:$(versionBuilder) \
--generic $(Build.SourceBranchName) --all -t /data
displayName: "Build Release"

View File

@@ -1,27 +0,0 @@
# https://dev.azure.com/home-assistant
trigger:
batch: true
branches:
include:
- dev
pr: none
variables:
- name: versionWheels
value: '1.13.0-3.8-alpine3.12'
resources:
repositories:
- repository: azure
type: github
name: 'home-assistant/ci-azure'
endpoint: 'home-assistant'
jobs:
- template: templates/azp-job-wheels.yaml@azure
parameters:
builderVersion: '$(versionWheels)'
builderApk: 'build-base;libffi-dev;openssl-dev'
builderPip: 'Cython'
skipBinary: 'aiohttp'
wheelsRequirement: 'requirements.txt'

View File

@@ -1,11 +1,11 @@
{
"image": "homeassistant/{arch}-hassio-supervisor",
"build_from": {
"aarch64": "homeassistant/aarch64-base-python:3.8-alpine3.12",
"armhf": "homeassistant/armhf-base-python:3.8-alpine3.12",
"armv7": "homeassistant/armv7-base-python:3.8-alpine3.12",
"amd64": "homeassistant/amd64-base-python:3.8-alpine3.12",
"i386": "homeassistant/i386-base-python:3.8-alpine3.12"
"aarch64": "homeassistant/aarch64-base-python:3.8-alpine3.13",
"armhf": "homeassistant/armhf-base-python:3.8-alpine3.13",
"armv7": "homeassistant/armv7-base-python:3.8-alpine3.13",
"amd64": "homeassistant/amd64-base-python:3.8-alpine3.13",
"i386": "homeassistant/i386-base-python:3.8-alpine3.13"
},
"labels": {
"io.hass.type": "supervisor"

View File

@@ -1,19 +1,20 @@
aiohttp==3.6.2
aiohttp==3.7.4
async_timeout==3.0.1
attrs==20.2.0
cchardet==2.1.6
colorlog==4.2.1
atomicwrites==1.4.0
attrs==20.3.0
awesomeversion==21.2.3
brotli==1.0.9
cchardet==2.1.7
colorlog==4.7.2
cpe==1.2.1
cryptography==3.1
debugpy==1.0.0rc2
docker==4.3.1
gitpython==3.1.8
jinja2==2.11.2
packaging==20.4
pulsectl==20.5.1
pytz==2020.1
cryptography==3.4.6
debugpy==1.2.1
docker==4.4.4
gitpython==3.1.14
jinja2==2.11.3
pulsectl==21.2.0
pytz==2021.1
pyudev==0.22.0
ruamel.yaml==0.15.100
sentry-sdk==0.17.6
uvloop==0.14.0
voluptuous==0.11.7
sentry-sdk==0.20.3
voluptuous==0.12.1

View File

@@ -1,14 +1,14 @@
black==20.8b1
codecov==2.1.9
coverage==5.3
codecov==2.1.11
coverage==5.5
flake8-docstrings==1.5.0
flake8==3.8.3
pre-commit==2.7.1
flake8==3.8.4
pre-commit==2.10.1
pydocstyle==5.1.1
pylint==2.6.0
pylint==2.7.2
pytest-aiohttp==0.3.0
pytest-asyncio==0.12.0 # NB!: Versions over 0.12.0 breaks pytest-aiohttp (https://github.com/aio-libs/pytest-aiohttp/issues/16)
pytest-cov==2.10.1
pytest-cov==2.11.1
pytest-timeout==1.4.2
pytest==6.0.2
pyupgrade==2.7.2
pytest==6.2.2
pyupgrade==2.10.0

View File

@@ -2,9 +2,17 @@
# ==============================================================================
# Start udev service
# ==============================================================================
if bashio::fs.directory_exists /run/udev && ! bashio::fs.file_exists /run/.old_udev; then
bashio::log.info "Using udev information from host"
bashio::exit.ok
fi
bashio::log.info "Setup udev backend inside container"
udevd --daemon
bashio::log.info "Update udev information"
touch /run/.old_udev
if udevadm trigger; then
udevadm settle || true
else

View File

@@ -26,7 +26,7 @@ autospawn = no
; daemon-binary = /usr/bin/pulseaudio
; extra-arguments = --log-target=syslog
; cookie-file =
cookie-file = /run/pulse-cookie
; enable-shm = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB

View File

@@ -1,5 +1,8 @@
#!/usr/bin/execlineb -S0
#!/usr/bin/execlineb -S1
# ==============================================================================
# Take down the S6 supervision tree when Supervisor fails
# ==============================================================================
if { s6-test ${1} -ne 100 }
if { s6-test ${1} -ne 256 }
redirfd -w 2 /dev/null s6-svscanctl -t /var/run/s6/services

View File

@@ -5,7 +5,7 @@
declare failed_count=0
declare supervisor_state
bashio::log.info "Start local supervisor watchdog..."
bashio::log.info "Starting local supervisor watchdog..."
while [[ failed_count -lt 2 ]];
do
@@ -31,4 +31,4 @@ do
done
basio::exit.nok "Watchdog detect issue with Supervisor - take container down!"
basio::exit.nok "Watchdog detected issue with Supervisor - taking container down!"

28
scripts/build-supervisor.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
source "${BASH_SOURCE[0]%/*}/common.sh"
set -eE
DOCKER_TIMEOUT=30
DOCKER_PID=0
function build_supervisor() {
docker pull homeassistant/amd64-builder:dev
docker run --rm \
--privileged \
-v /run/docker.sock:/run/docker.sock \
-v "$(pwd):/data" \
homeassistant/amd64-builder:dev \
--generic latest \
--target /data \
--test \
--amd64 \
--no-cache
}
echo "Build Supervisor"
start_docker
trap "stop_docker" ERR
build_supervisor

75
scripts/test_env.sh → scripts/common.sh Executable file → Normal file
View File

@@ -1,9 +1,4 @@
#!/bin/bash
set -eE
DOCKER_TIMEOUT=30
DOCKER_PID=0
function start_docker() {
local starttime
@@ -28,7 +23,6 @@ function start_docker() {
echo "Docker was initialized"
}
function stop_docker() {
local starttime
local endtime
@@ -54,17 +48,6 @@ function stop_docker() {
fi
}
function build_supervisor() {
docker pull homeassistant/amd64-builder:dev
docker run --rm --privileged \
-v /run/docker.sock:/run/docker.sock -v "$(pwd):/data" \
homeassistant/amd64-builder:dev \
--generic dev -t /data --test --amd64 --no-cache
}
function cleanup_lastboot() {
if [[ -f /workspaces/test_supervisor/config.json ]]; then
echo "Cleaning up last boot"
@@ -73,61 +56,3 @@ function cleanup_lastboot() {
rm /tmp/config.json
fi
}
function cleanup_docker() {
echo "Cleaning up stopped containers..."
docker rm $(docker ps -a -q) || true
}
function setup_test_env() {
mkdir -p /workspaces/test_supervisor
echo "Start Supervisor"
docker run --rm --privileged \
--name hassio_supervisor \
--security-opt seccomp=unconfined \
--security-opt apparmor:unconfined \
-v /run/docker.sock:/run/docker.sock \
-v /run/dbus:/run/dbus \
-v "/workspaces/test_supervisor":/data \
-v /etc/machine-id:/etc/machine-id:ro \
-e SUPERVISOR_SHARE="/workspaces/test_supervisor" \
-e SUPERVISOR_NAME=hassio_supervisor \
-e SUPERVISOR_DEV=1 \
-e SUPERVISOR_MACHINE="qemux86-64" \
homeassistant/amd64-hassio-supervisor:latest
}
function init_dbus() {
if pgrep dbus-daemon; then
echo "Dbus is running"
return 0
fi
echo "Startup dbus"
mkdir -p /var/lib/dbus
cp -f /etc/machine-id /var/lib/dbus/machine-id
# cleanups
mkdir -p /run/dbus
rm -f /run/dbus/pid
# run
dbus-daemon --system --print-address
}
echo "Start Test-Env"
start_docker
trap "stop_docker" ERR
build_supervisor
cleanup_lastboot
cleanup_docker
init_dbus
setup_test_env
stop_docker

102
scripts/run-supervisor.sh Executable file
View File

@@ -0,0 +1,102 @@
#!/bin/bash
source "${BASH_SOURCE[0]%/*}/common.sh"
source "${BASH_SOURCE[0]%/*}/build-supervisor.sh"
set -eE
DOCKER_TIMEOUT=30
DOCKER_PID=0
function cleanup_docker() {
echo "Cleaning up stopped containers..."
docker rm $(docker ps -a -q) || true
}
function run_supervisor() {
mkdir -p /workspaces/test_supervisor
echo "Start Supervisor"
docker run --rm --privileged \
--name hassio_supervisor \
--privileged \
--security-opt seccomp=unconfined \
--security-opt apparmor:unconfined \
-v /run/docker.sock:/run/docker.sock:rw \
-v /run/dbus:/run/dbus:ro \
-v /run/udev:/run/udev:ro \
-v "/workspaces/test_supervisor":/data:rw \
-v /etc/machine-id:/etc/machine-id:ro \
-v /workspaces/supervisor:/usr/src/supervisor \
-e SUPERVISOR_SHARE="/workspaces/test_supervisor" \
-e SUPERVISOR_NAME=hassio_supervisor \
-e SUPERVISOR_DEV=1 \
-e SUPERVISOR_MACHINE="qemux86-64" \
homeassistant/amd64-hassio-supervisor:latest
}
function init_dbus() {
if pgrep dbus-daemon; then
echo "Dbus is running"
return 0
fi
echo "Startup dbus"
mkdir -p /var/lib/dbus
cp -f /etc/machine-id /var/lib/dbus/machine-id
# cleanups
mkdir -p /run/dbus
rm -f /run/dbus/pid
# run
dbus-daemon --system --print-address
}
function init_udev() {
if pgrep systemd-udevd; then
echo "udev is running"
return 0
fi
echo "Startup udev"
# cleanups
mkdir -p /run/udev
# run
/lib/systemd/systemd-udevd --daemon
sleep 3
udevadm trigger && udevadm settle
}
echo "Run Supervisor"
start_docker
trap "stop_docker" ERR
if [ "$( docker container inspect -f '{{.State.Status}}' hassio_supervisor )" == "running" ]; then
echo "Restarting Supervisor"
docker rm -f hassio_supervisor
init_dbus
init_udev
cleanup_lastboot
run_supervisor
stop_docker
else
echo "Starting Supervisor"
docker system prune -f
build_supervisor
cleanup_lastboot
cleanup_docker
init_dbus
init_udev
run_supervisor
stop_docker
fi

View File

@@ -31,24 +31,27 @@ setup(
zip_safe=False,
platforms="any",
packages=[
"supervisor",
"supervisor.docker",
"supervisor.addons",
"supervisor.api",
"supervisor.dbus",
"supervisor.dbus.payloads",
"supervisor.dbus.network",
"supervisor.discovery",
"supervisor.dbus.payloads",
"supervisor.dbus",
"supervisor.discovery.services",
"supervisor.services",
"supervisor.services.modules",
"supervisor.discovery",
"supervisor.docker",
"supervisor.homeassistant",
"supervisor.host",
"supervisor.jobs",
"supervisor.misc",
"supervisor.utils",
"supervisor.plugins",
"supervisor.resolution.evaluations",
"supervisor.resolution",
"supervisor.services.modules",
"supervisor.services",
"supervisor.snapshots",
"supervisor.store",
"supervisor.utils",
"supervisor",
],
include_package_data=True,
)

View File

@@ -2,24 +2,25 @@
import asyncio
from concurrent.futures import ThreadPoolExecutor
import logging
from pathlib import Path
import sys
from supervisor import bootstrap
_LOGGER: logging.Logger = logging.getLogger(__name__)
CONTAINER_OS_STARTUP_CHECK = Path("/run/os/startup-marker")
def run_os_startup_check_cleanup() -> None:
"""Cleanup OS startup check."""
if not CONTAINER_OS_STARTUP_CHECK.exists():
return
def initialize_event_loop():
"""Attempt to use uvloop."""
try:
# pylint: disable=import-outside-toplevel
import uvloop
uvloop.install()
except ImportError:
pass
return asyncio.get_event_loop()
CONTAINER_OS_STARTUP_CHECK.unlink()
except OSError as err:
_LOGGER.warning("Not able to remove the startup health file: %s", err)
# pylint: disable=invalid-name
@@ -27,7 +28,7 @@ if __name__ == "__main__":
bootstrap.initialize_logging()
# Init async event loop
loop = initialize_event_loop()
loop = asyncio.get_event_loop()
# Check if all information are available to setup Supervisor
bootstrap.check_environment()
@@ -36,24 +37,27 @@ if __name__ == "__main__":
executor = ThreadPoolExecutor(thread_name_prefix="SyncWorker")
loop.set_default_executor(executor)
_LOGGER.info("Initialize Supervisor setup")
_LOGGER.info("Initializing Supervisor setup")
coresys = loop.run_until_complete(bootstrap.initialize_coresys())
loop.run_until_complete(coresys.core.connect())
bootstrap.supervisor_debugger(coresys)
bootstrap.migrate_system_env(coresys)
_LOGGER.info("Setup Supervisor")
# Signal health startup for container
run_os_startup_check_cleanup()
_LOGGER.info("Setting up Supervisor")
loop.run_until_complete(coresys.core.setup())
loop.call_soon_threadsafe(loop.create_task, coresys.core.start())
loop.call_soon_threadsafe(bootstrap.reg_signal, loop, coresys)
try:
_LOGGER.info("Run Supervisor")
_LOGGER.info("Running Supervisor")
loop.run_forever()
finally:
loop.close()
_LOGGER.info("Close Supervisor")
sys.exit(0)
_LOGGER.info("Closing Supervisor")
sys.exit(coresys.core.exit_code)

View File

@@ -10,6 +10,7 @@ from ..coresys import CoreSys, CoreSysAttributes
from ..exceptions import (
AddonConfigurationError,
AddonsError,
AddonsJobError,
AddonsNotSupportedError,
CoreDNSError,
DockerAPIError,
@@ -18,6 +19,8 @@ from ..exceptions import (
HomeAssistantAPIError,
HostAppArmorError,
)
from ..jobs.decorator import Job, JobCondition
from ..resolution.const import ContextType, IssueType, SuggestionType
from ..store.addon import AddonStore
from ..utils import check_exception_chain
from .addon import Addon
@@ -93,7 +96,7 @@ class AddonManager(CoreSysAttributes):
tasks.append(addon)
# Evaluate add-ons which need to be started
_LOGGER.info("Phase '%s' start %d add-ons", stage, len(tasks))
_LOGGER.info("Phase '%s' starting %d add-ons", stage, len(tasks))
if not tasks:
return
@@ -127,7 +130,7 @@ class AddonManager(CoreSysAttributes):
tasks.append(addon)
# Evaluate add-ons which need to be stopped
_LOGGER.info("Phase '%s' stop %d add-ons", stage, len(tasks))
_LOGGER.info("Phase '%s' stopping %d add-ons", stage, len(tasks))
if not tasks:
return
@@ -140,6 +143,14 @@ class AddonManager(CoreSysAttributes):
_LOGGER.warning("Can't stop Add-on %s: %s", addon.slug, err)
self.sys_capture_exception(err)
@Job(
conditions=[
JobCondition.FREE_SPACE,
JobCondition.INTERNET_HOST,
JobCondition.HEALTHY,
],
on_condition=AddonsJobError,
)
async def install(self, slug: str) -> None:
"""Install an add-on."""
if slug in self.local:
@@ -159,7 +170,9 @@ class AddonManager(CoreSysAttributes):
addon = Addon(self.coresys, slug)
if not addon.path_data.is_dir():
_LOGGER.info("Create Home Assistant add-on data folder %s", addon.path_data)
_LOGGER.info(
"Creating Home Assistant add-on data folder %s", addon.path_data
)
addon.path_data.mkdir()
# Setup/Fix AppArmor profile
@@ -232,6 +245,14 @@ class AddonManager(CoreSysAttributes):
_LOGGER.info("Add-on '%s' successfully removed", slug)
@Job(
conditions=[
JobCondition.FREE_SPACE,
JobCondition.INTERNET_HOST,
JobCondition.HEALTHY,
],
on_condition=AddonsJobError,
)
async def update(self, slug: str) -> None:
"""Update add-on."""
if slug not in self.local:
@@ -255,17 +276,18 @@ class AddonManager(CoreSysAttributes):
# Update instance
last_state: AddonState = addon.state
old_image = addon.image
try:
await addon.instance.update(store.version, store.image)
# Cleanup
with suppress(DockerError):
await addon.instance.cleanup()
except DockerError as err:
raise AddonsError() from err
else:
self.data.update(store)
_LOGGER.info("Add-on '%s' successfully updated", slug)
_LOGGER.info("Add-on '%s' successfully updated", slug)
self.data.update(store)
# Cleanup
with suppress(DockerError):
await addon.instance.cleanup(old_image=old_image)
# Setup/Fix AppArmor profile
await addon.install_apparmor()
@@ -274,6 +296,14 @@ class AddonManager(CoreSysAttributes):
if last_state == AddonState.STARTED:
await addon.start()
@Job(
conditions=[
JobCondition.FREE_SPACE,
JobCondition.INTERNET_HOST,
JobCondition.HEALTHY,
],
on_condition=AddonsJobError,
)
async def rebuild(self, slug: str) -> None:
"""Perform a rebuild of local build add-on."""
if slug not in self.local:
@@ -309,6 +339,14 @@ class AddonManager(CoreSysAttributes):
if last_state == AddonState.STARTED:
await addon.start()
@Job(
conditions=[
JobCondition.FREE_SPACE,
JobCondition.INTERNET_HOST,
JobCondition.HEALTHY,
],
on_condition=AddonsJobError,
)
async def restore(self, slug: str, tar_file: tarfile.TarFile) -> None:
"""Restore state of an add-on."""
if slug not in self.local:
@@ -331,6 +369,7 @@ class AddonManager(CoreSysAttributes):
with suppress(HomeAssistantAPIError):
await self.sys_ingress.update_hass_panel(addon)
@Job(conditions=[JobCondition.FREE_SPACE, JobCondition.INTERNET_HOST])
async def repair(self) -> None:
"""Repair local add-ons."""
needs_repair: List[Addon] = []
@@ -346,11 +385,7 @@ class AddonManager(CoreSysAttributes):
return
for addon in needs_repair:
_LOGGER.info("Start repair for add-on: %s", addon.slug)
await self.sys_run_in_executor(
self.sys_docker.network.stale_cleanup, addon.instance.name
)
_LOGGER.info("Repairing for add-on: %s", addon.slug)
with suppress(DockerError, KeyError):
# Need pull a image again
if not addon.need_build:
@@ -378,7 +413,12 @@ class AddonManager(CoreSysAttributes):
continue
except DockerError as err:
_LOGGER.warning("Add-on %s is corrupt: %s", addon.slug, err)
self.sys_core.healthy = False
self.sys_resolution.create_issue(
IssueType.CORRUPT_DOCKER,
ContextType.ADDON,
reference=addon.slug,
suggestions=[SuggestionType.EXECUTE_REPAIR],
)
self.sys_capture_exception(err)
else:
self.sys_plugins.dns.add_host(

View File

@@ -10,7 +10,7 @@ import secrets
import shutil
import tarfile
from tempfile import TemporaryDirectory
from typing import Any, Awaitable, Dict, List, Optional
from typing import Any, Awaitable, Dict, List, Optional, Set
import aiohttp
import voluptuous as vol
@@ -22,6 +22,8 @@ from ..const import (
ATTR_AUDIO_OUTPUT,
ATTR_AUTO_UPDATE,
ATTR_BOOT,
ATTR_DATA,
ATTR_EVENT,
ATTR_IMAGE,
ATTR_INGRESS_ENTRY,
ATTR_INGRESS_PANEL,
@@ -32,8 +34,10 @@ from ..const import (
ATTR_PORTS,
ATTR_PROTECTED,
ATTR_SCHEMA,
ATTR_SLUG,
ATTR_STATE,
ATTR_SYSTEM,
ATTR_TYPE,
ATTR_USER,
ATTR_UUID,
ATTR_VERSION,
@@ -50,18 +54,21 @@ from ..exceptions import (
AddonConfigurationError,
AddonsError,
AddonsNotSupportedError,
ConfigurationFileError,
DockerError,
DockerRequestError,
HostAppArmorError,
JsonFileError,
)
from ..hardware.data import Device
from ..homeassistant.const import WSEvent, WSType
from ..utils import check_port
from ..utils.apparmor import adjust_profile
from ..utils.json import read_json_file, write_json_file
from ..utils.tar import atomic_contents_add, secure_path
from .model import AddonModel, Data
from .options import AddonOptions
from .utils import remove_data
from .validate import SCHEMA_ADDON_SNAPSHOT, validate_options
from .validate import SCHEMA_ADDON_SNAPSHOT
_LOGGER: logging.Logger = logging.getLogger(__name__)
@@ -72,7 +79,7 @@ RE_WEBUI = re.compile(
RE_WATCHDOG = re.compile(
r"^(?:(?P<s_prefix>https?|tcp)|\[PROTO:(?P<t_proto>\w+)\])"
r":\/\/\[HOST\]:\[PORT:(?P<t_port>\d+)\](?P<s_suffix>.*)$"
r":\/\/\[HOST\]:(?:\[PORT:)?(?P<t_port>\d+)\]?(?P<s_suffix>.*)$"
)
RE_OLD_AUDIO = re.compile(r"\d+,\d+")
@@ -87,12 +94,34 @@ class Addon(AddonModel):
"""Initialize data holder."""
super().__init__(coresys, slug)
self.instance: DockerAddon = DockerAddon(coresys, self)
self.state: AddonState = AddonState.UNKNOWN
self._state: AddonState = AddonState.UNKNOWN
def __repr__(self) -> str:
"""Return internal representation."""
return f"<Addon: {self.slug}>"
@property
def state(self) -> AddonState:
"""Return state of the add-on."""
return self._state
@state.setter
def state(self, new_state: AddonState) -> None:
"""Set the add-on into new state."""
if self._state == new_state:
return
self._state = new_state
self.sys_homeassistant.websocket.send_command(
{
ATTR_TYPE: WSType.SUPERVISOR_EVENT,
ATTR_DATA: {
ATTR_EVENT: WSEvent.ADDON,
ATTR_SLUG: self.slug,
ATTR_STATE: new_state,
},
}
)
@property
def in_progress(self) -> bool:
"""Return True if a task is in progress."""
@@ -101,7 +130,7 @@ class Addon(AddonModel):
async def load(self) -> None:
"""Async initialize of object."""
with suppress(DockerError):
await self.instance.attach(tag=self.version)
await self.instance.attach(version=self.version)
# Evaluate state
if await self.instance.is_running():
@@ -149,6 +178,13 @@ class Addon(AddonModel):
"""Return installed version."""
return self.persist[ATTR_VERSION]
@property
def need_update(self) -> bool:
"""Return True if an update is available."""
if self.is_detached:
return False
return self.version != self.latest_version
@property
def dns(self) -> List[str]:
"""Return list of DNS name for that add-on."""
@@ -387,6 +423,34 @@ class Addon(AddonModel):
"""Return path to asound config for Docker."""
return Path(self.sys_config.path_extern_tmp, f"{self.slug}_pulse")
@property
def devices(self) -> Set[Device]:
"""Extract devices from add-on options."""
raw_schema = self.data[ATTR_SCHEMA]
if isinstance(raw_schema, bool) or not raw_schema:
return set()
# Validate devices
options_validator = AddonOptions(self.coresys, raw_schema, self.name, self.slug)
with suppress(vol.Invalid):
options_validator(self.options)
return options_validator.devices
@property
def pwned(self) -> Set[str]:
"""Extract pwned data for add-on options."""
raw_schema = self.data[ATTR_SCHEMA]
if isinstance(raw_schema, bool) or not raw_schema:
return set()
# Validate devices
options_validator = AddonOptions(self.coresys, raw_schema, self.name, self.slug)
with suppress(vol.Invalid):
options_validator(self.options)
return options_validator.pwned
def save_persist(self) -> None:
"""Save data of add-on."""
self.sys_addons.data.save_data()
@@ -435,22 +499,19 @@ class Addon(AddonModel):
async def write_options(self) -> None:
"""Return True if add-on options is written to data."""
schema = self.schema
options = self.options
# Update secrets for validation
await self.sys_homeassistant.secrets.reload()
try:
options = schema(options)
options = self.schema(self.options)
write_json_file(self.path_options, options)
except vol.Invalid as ex:
_LOGGER.error(
"Add-on %s has invalid options: %s",
self.slug,
humanize_error(options, ex),
humanize_error(self.options, ex),
)
except JsonFileError:
except ConfigurationFileError:
_LOGGER.error("Add-on %s can't write options", self.slug)
else:
_LOGGER.debug("Add-on %s write options: %s", self.slug, options)
@@ -463,7 +524,7 @@ class Addon(AddonModel):
if not self.path_data.is_dir():
return
_LOGGER.info("Remove add-on data folder %s", self.path_data)
_LOGGER.info("Removing add-on data folder %s", self.path_data)
await remove_data(self.path_data)
def write_pulse(self) -> None:
@@ -531,7 +592,9 @@ class Addon(AddonModel):
# create voluptuous
new_schema = vol.Schema(
vol.All(dict, validate_options(self.coresys, new_raw_schema))
vol.All(
dict, AddonOptions(self.coresys, new_raw_schema, self.name, self.slug)
)
)
# validate
@@ -545,7 +608,7 @@ class Addon(AddonModel):
async def start(self) -> None:
"""Set options and start add-on."""
if await self.instance.is_running():
_LOGGER.warning("%s already running!", self.slug)
_LOGGER.warning("%s is already running!", self.slug)
return
# Access Token
@@ -563,19 +626,20 @@ class Addon(AddonModel):
try:
await self.instance.run()
except DockerRequestError as err:
self.state = AddonState.STOPPED
self.state = AddonState.ERROR
raise AddonsError() from err
except DockerError as err:
self.state = AddonState.ERROR
raise AddonsError(err) from err
raise AddonsError() from err
else:
self.state = AddonState.STARTED
async def stop(self) -> None:
"""Stop add-on."""
try:
return await self.instance.stop()
await self.instance.stop()
except DockerRequestError as err:
self.state = AddonState.ERROR
raise AddonsError() from err
except DockerError as err:
self.state = AddonState.ERROR
@@ -646,7 +710,7 @@ class Addon(AddonModel):
# Store local configs/state
try:
write_json_file(temp_path.joinpath("addon.json"), data)
except JsonFileError as err:
except ConfigurationFileError as err:
_LOGGER.error("Can't save meta for %s", self.slug)
raise AddonsError() from err
@@ -676,7 +740,7 @@ class Addon(AddonModel):
)
try:
_LOGGER.info("Build snapshot for add-on %s", self.slug)
_LOGGER.info("Building snapshot for add-on %s", self.slug)
await self.sys_run_in_executor(_write_tarfile)
except (tarfile.TarError, OSError) as err:
_LOGGER.error("Can't write tarfile %s: %s", tar_file, err)
@@ -702,7 +766,7 @@ class Addon(AddonModel):
# Read snapshot data
try:
data = read_json_file(Path(temp, "addon.json"))
except JsonFileError as err:
except ConfigurationFileError as err:
raise AddonsError() from err
# Validate
@@ -731,7 +795,7 @@ class Addon(AddonModel):
# Check version / restore image
version = data[ATTR_VERSION]
if not await self.instance.exists():
_LOGGER.info("Restore/Install image for addon %s", self.slug)
_LOGGER.info("Restore/Install of image for addon %s", self.slug)
image_file = Path(temp, "image.tar")
if image_file.is_file():
@@ -742,7 +806,7 @@ class Addon(AddonModel):
await self.instance.install(version, restore_image)
await self.instance.cleanup()
elif self.instance.version != version or self.legacy:
_LOGGER.info("Restore/Update image for addon %s", self.slug)
_LOGGER.info("Restore/Update of image for addon %s", self.slug)
with suppress(DockerError):
await self.instance.update(version, restore_image)
else:
@@ -754,7 +818,7 @@ class Addon(AddonModel):
"""Restore data."""
shutil.copytree(Path(temp, "data"), self.path_data, symlinks=True)
_LOGGER.info("Restore data for addon %s", self.slug)
_LOGGER.info("Restoring data for addon %s", self.slug)
if self.path_data.is_dir():
await remove_data(self.path_data)
try:
@@ -778,4 +842,4 @@ class Addon(AddonModel):
if data[ATTR_STATE] == AddonState.STARTED:
return await self.start()
_LOGGER.info("Finish restore for add-on %s", self.slug)
_LOGGER.info("Finished restore for add-on %s", self.slug)

View File

@@ -4,16 +4,25 @@ from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING, Dict
from ..const import ATTR_ARGS, ATTR_BUILD_FROM, ATTR_SQUASH, META_ADDON
from awesomeversion import AwesomeVersion
from ..const import (
ATTR_ARGS,
ATTR_BUILD_FROM,
ATTR_SQUASH,
FILE_SUFFIX_CONFIGURATION,
META_ADDON,
)
from ..coresys import CoreSys, CoreSysAttributes
from ..utils.json import JsonConfig
from ..exceptions import ConfigurationFileError
from ..utils.common import FileConfiguration, find_one_filetype
from .validate import SCHEMA_BUILD_CONFIG
if TYPE_CHECKING:
from . import AnyAddon
class AddonBuild(JsonConfig, CoreSysAttributes):
class AddonBuild(FileConfiguration, CoreSysAttributes):
"""Handle build options for add-ons."""
def __init__(self, coresys: CoreSys, addon: AnyAddon) -> None:
@@ -21,9 +30,14 @@ class AddonBuild(JsonConfig, CoreSysAttributes):
self.coresys: CoreSys = coresys
self.addon = addon
super().__init__(
Path(self.addon.path_location, "build.json"), SCHEMA_BUILD_CONFIG
)
try:
build_file = find_one_filetype(
self.addon.path_location, "build", FILE_SUFFIX_CONFIGURATION
)
except ConfigurationFileError:
build_file = self.addon.path_location / "build.json"
super().__init__(build_file, SCHEMA_BUILD_CONFIG)
def save_data(self):
"""Ignore save function."""
@@ -46,11 +60,21 @@ class AddonBuild(JsonConfig, CoreSysAttributes):
"""Return additional Docker build arguments."""
return self._data[ATTR_ARGS]
def get_docker_args(self, version):
@property
def is_valid(self) -> bool:
"""Return true if the build env is valid."""
return all(
[
self.addon.path_location.is_dir(),
Path(self.addon.path_location, "Dockerfile").is_file(),
]
)
def get_docker_args(self, version: AwesomeVersion):
"""Create a dict with Docker build arguments."""
args = {
"path": str(self.addon.path_location),
"tag": f"{self.addon.image}:{version}",
"tag": f"{self.addon.image}:{version!s}",
"pull": True,
"forcerm": True,
"squash": self.squash,

View File

@@ -1,6 +1,5 @@
"""Init file for Supervisor add-on data."""
from copy import deepcopy
import logging
from typing import Any, Dict
from ..const import (
@@ -13,16 +12,14 @@ from ..const import (
)
from ..coresys import CoreSys, CoreSysAttributes
from ..store.addon import AddonStore
from ..utils.json import JsonConfig
from ..utils.common import FileConfiguration
from .addon import Addon
from .validate import SCHEMA_ADDONS_FILE
_LOGGER: logging.Logger = logging.getLogger(__name__)
Config = Dict[str, Any]
class AddonsData(JsonConfig, CoreSysAttributes):
class AddonsData(FileConfiguration, CoreSysAttributes):
"""Hold data for installed Add-ons inside Supervisor."""
def __init__(self, coresys: CoreSys):

View File

@@ -3,7 +3,7 @@ from abc import ABC, abstractmethod
from pathlib import Path
from typing import Any, Awaitable, Dict, List, Optional
from packaging import version as pkg_version
from awesomeversion import AwesomeVersion, AwesomeVersionException
import voluptuous as vol
from ..const import (
@@ -12,7 +12,6 @@ from ..const import (
ATTR_ARCH,
ATTR_AUDIO,
ATTR_AUTH_API,
ATTR_AUTO_UART,
ATTR_BOOT,
ATTR_DESCRIPTON,
ATTR_DEVICES,
@@ -46,6 +45,7 @@ from ..const import (
ATTR_PORTS,
ATTR_PORTS_DESCRIPTION,
ATTR_PRIVILEGED,
ATTR_REALTIME,
ATTR_REPOSITORY,
ATTR_SCHEMA,
ATTR_SERVICES,
@@ -56,6 +56,8 @@ from ..const import (
ATTR_STDIN,
ATTR_TIMEOUT,
ATTR_TMPFS,
ATTR_TRANSLATIONS,
ATTR_UART,
ATTR_UDEV,
ATTR_URL,
ATTR_USB,
@@ -71,7 +73,9 @@ from ..const import (
AddonStartup,
)
from ..coresys import CoreSys, CoreSysAttributes
from .validate import RE_SERVICE, RE_VOLUME, schema_ui_options, validate_options
from ..docker.const import Capabilities
from .options import AddonOptions, UiOptions
from .validate import RE_SERVICE, RE_VOLUME
Data = Dict[str, Any]
@@ -183,12 +187,17 @@ class AddonModel(CoreSysAttributes, ABC):
return self.data[ATTR_REPOSITORY]
@property
def latest_version(self) -> str:
def translations(self) -> dict:
"""Return add-on translations."""
return self.data[ATTR_TRANSLATIONS]
@property
def latest_version(self) -> AwesomeVersion:
"""Return latest version of add-on."""
return self.data[ATTR_VERSION]
@property
def version(self) -> Optional[str]:
def version(self) -> AwesomeVersion:
"""Return version of add-on."""
return self.data[ATTR_VERSION]
@@ -296,14 +305,9 @@ class AddonModel(CoreSysAttributes, ABC):
return self.data[ATTR_HOST_DBUS]
@property
def devices(self) -> List[str]:
"""Return devices of add-on."""
return self.data.get(ATTR_DEVICES, [])
@property
def tmpfs(self) -> Optional[str]:
"""Return tmpfs of add-on."""
return self.data.get(ATTR_TMPFS)
def static_devices(self) -> List[Path]:
"""Return static devices of add-on."""
return [Path(node) for node in self.data.get(ATTR_DEVICES, [])]
@property
def environment(self) -> Optional[Dict[str, str]]:
@@ -311,7 +315,7 @@ class AddonModel(CoreSysAttributes, ABC):
return self.data.get(ATTR_ENVIRONMENT)
@property
def privileged(self) -> List[str]:
def privileged(self) -> List[Capabilities]:
"""Return list of privilege."""
return self.data.get(ATTR_PRIVILEGED, [])
@@ -387,7 +391,7 @@ class AddonModel(CoreSysAttributes, ABC):
@property
def with_uart(self) -> bool:
"""Return True if we should map all UART device."""
return self.data[ATTR_AUTO_UART]
return self.data[ATTR_UART]
@property
def with_udev(self) -> bool:
@@ -399,6 +403,11 @@ class AddonModel(CoreSysAttributes, ABC):
"""Return True if the add-on access to kernel modules."""
return self.data[ATTR_KERNEL_MODULES]
@property
def with_realtime(self) -> bool:
"""Return True if the add-on need realtime schedule functions."""
return self.data[ATTR_REALTIME]
@property
def with_full_access(self) -> bool:
"""Return True if the add-on want full access to hardware."""
@@ -409,6 +418,11 @@ class AddonModel(CoreSysAttributes, ABC):
"""Return True if the add-on read access to devicetree."""
return self.data[ATTR_DEVICETREE]
@property
def with_tmpfs(self) -> Optional[str]:
"""Return if tmp is in memory of add-on."""
return self.data[ATTR_TMPFS]
@property
def access_auth_api(self) -> bool:
"""Return True if the add-on access to login/auth backend."""
@@ -522,8 +536,10 @@ class AddonModel(CoreSysAttributes, ABC):
raw_schema = self.data[ATTR_SCHEMA]
if isinstance(raw_schema, bool):
return vol.Schema(dict)
return vol.Schema(vol.All(dict, validate_options(self.coresys, raw_schema)))
raw_schema = {}
return vol.Schema(
vol.All(dict, AddonOptions(self.coresys, raw_schema, self.name, self.slug))
)
@property
def schema_ui(self) -> Optional[List[Dict[str, Any]]]:
@@ -532,7 +548,7 @@ class AddonModel(CoreSysAttributes, ABC):
if isinstance(raw_schema, bool):
return None
return schema_ui_options(raw_schema)
return UiOptions(self.coresys)(raw_schema)
def __eq__(self, other):
"""Compaired add-on objects."""
@@ -554,15 +570,10 @@ class AddonModel(CoreSysAttributes, ABC):
return False
# Home Assistant
version = config.get(ATTR_HOMEASSISTANT)
if version is None or self.sys_homeassistant.version is None:
return True
version: Optional[AwesomeVersion] = config.get(ATTR_HOMEASSISTANT)
try:
return pkg_version.parse(
self.sys_homeassistant.version
) >= pkg_version.parse(version)
except pkg_version.InvalidVersion:
return self.sys_homeassistant.version >= version
except (AwesomeVersionException, TypeError):
return True
def _image(self, config) -> str:

View File

@@ -0,0 +1,410 @@
"""Add-on Options / UI rendering."""
import hashlib
import logging
from pathlib import Path
import re
from typing import Any, Dict, List, Set, Union
import voluptuous as vol
from ..coresys import CoreSys, CoreSysAttributes
from ..exceptions import HardwareNotFound
from ..hardware.const import UdevSubsystem
from ..hardware.data import Device
from ..validate import network_port
_LOGGER: logging.Logger = logging.getLogger(__name__)
_STR = "str"
_INT = "int"
_FLOAT = "float"
_BOOL = "bool"
_PASSWORD = "password"
_EMAIL = "email"
_URL = "url"
_PORT = "port"
_MATCH = "match"
_LIST = "list"
_DEVICE = "device"
RE_SCHEMA_ELEMENT = re.compile(
r"^(?:"
r"|bool"
r"|email"
r"|url"
r"|port"
r"|device(?:\((?P<filter>subsystem=[a-z]+)\))?"
r"|str(?:\((?P<s_min>\d+)?,(?P<s_max>\d+)?\))?"
r"|password(?:\((?P<p_min>\d+)?,(?P<p_max>\d+)?\))?"
r"|int(?:\((?P<i_min>\d+)?,(?P<i_max>\d+)?\))?"
r"|float(?:\((?P<f_min>[\d\.]+)?,(?P<f_max>[\d\.]+)?\))?"
r"|match\((?P<match>.*)\)"
r"|list\((?P<list>.+)\)"
r")\??$"
)
_SCHEMA_LENGTH_PARTS = (
"i_min",
"i_max",
"f_min",
"f_max",
"s_min",
"s_max",
"p_min",
"p_max",
)
class AddonOptions(CoreSysAttributes):
"""Validate Add-ons Options."""
def __init__(
self, coresys: CoreSys, raw_schema: Dict[str, Any], name: str, slug: str
):
"""Validate schema."""
self.coresys: CoreSys = coresys
self.raw_schema: Dict[str, Any] = raw_schema
self.devices: Set[Device] = set()
self.pwned: Set[str] = set()
self._name = name
self._slug = slug
def __call__(self, struct):
"""Create schema validator for add-ons options."""
options = {}
# read options
for key, value in struct.items():
# Ignore unknown options / remove from list
if key not in self.raw_schema:
_LOGGER.warning(
"Option '%s' does not exist in the schema for %s (%s)",
key,
self._name,
self._slug,
)
continue
typ = self.raw_schema[key]
try:
if isinstance(typ, list):
# nested value list
options[key] = self._nested_validate_list(typ[0], value, key)
elif isinstance(typ, dict):
# nested value dict
options[key] = self._nested_validate_dict(typ, value, key)
else:
# normal value
options[key] = self._single_validate(typ, value, key)
except (IndexError, KeyError):
raise vol.Invalid(
f"Type error for option '{key}' in {self._name} ({self._slug})"
) from None
self._check_missing_options(self.raw_schema, options, "root")
return options
# pylint: disable=no-value-for-parameter
def _single_validate(self, typ: str, value: Any, key: str):
"""Validate a single element."""
# if required argument
if value is None:
raise vol.Invalid(
f"Missing required option '{key}' in {self._name} ({self._slug})"
) from None
# Lookup secret
if str(value).startswith("!secret "):
secret: str = value.partition(" ")[2]
value = self.sys_homeassistant.secrets.get(secret)
if value is None:
raise vol.Invalid(
f"Unknown secret '{secret}' in {self._name} ({self._slug})"
) from None
# parse extend data from type
match = RE_SCHEMA_ELEMENT.match(typ)
if not match:
raise vol.Invalid(
f"Unknown type '{typ}' in {self._name} ({self._slug})"
) from None
# prepare range
range_args = {}
for group_name in _SCHEMA_LENGTH_PARTS:
group_value = match.group(group_name)
if group_value:
range_args[group_name[2:]] = float(group_value)
if typ.startswith(_STR) or typ.startswith(_PASSWORD):
if typ.startswith(_PASSWORD) and value:
self.pwned.add(hashlib.sha1(str(value).encode()).hexdigest())
return vol.All(str(value), vol.Range(**range_args))(value)
elif typ.startswith(_INT):
return vol.All(vol.Coerce(int), vol.Range(**range_args))(value)
elif typ.startswith(_FLOAT):
return vol.All(vol.Coerce(float), vol.Range(**range_args))(value)
elif typ.startswith(_BOOL):
return vol.Boolean()(value)
elif typ.startswith(_EMAIL):
return vol.Email()(value)
elif typ.startswith(_URL):
return vol.Url()(value)
elif typ.startswith(_PORT):
return network_port(value)
elif typ.startswith(_MATCH):
return vol.Match(match.group("match"))(str(value))
elif typ.startswith(_LIST):
return vol.In(match.group("list").split("|"))(str(value))
elif typ.startswith(_DEVICE):
try:
device = self.sys_hardware.get_by_path(Path(value))
except HardwareNotFound:
raise vol.Invalid(
f"Device '{value}' does not exists! in {self._name} ({self._slug})"
) from None
# Have filter
if match.group("filter"):
str_filter = match.group("filter")
device_filter = _create_device_filter(str_filter)
if device not in self.sys_hardware.filter_devices(**device_filter):
raise vol.Invalid(
f"Device '{value}' don't match the filter {str_filter}! in {self._name} ({self._slug})"
)
# Device valid
self.devices.add(device)
return str(device.path)
raise vol.Invalid(
f"Fatal error for option '{key}' with type '{typ}' in {self._name} ({self._slug})"
) from None
def _nested_validate_list(self, typ: Any, data_list: List[Any], key: str):
"""Validate nested items."""
options = []
# Make sure it is a list
if not isinstance(data_list, list):
raise vol.Invalid(
f"Invalid list for option '{key}' in {self._name} ({self._slug})"
) from None
# Process list
for element in data_list:
# Nested?
if isinstance(typ, dict):
c_options = self._nested_validate_dict(typ, element, key)
options.append(c_options)
else:
options.append(self._single_validate(typ, element, key))
return options
def _nested_validate_dict(
self, typ: Dict[Any, Any], data_dict: Dict[Any, Any], key: str
):
"""Validate nested items."""
options = {}
# Make sure it is a dict
if not isinstance(data_dict, dict):
raise vol.Invalid(
f"Invalid dict for option '{key}' in {self._name} ({self._slug})"
) from None
# Process dict
for c_key, c_value in data_dict.items():
# Ignore unknown options / remove from list
if c_key not in typ:
_LOGGER.warning(
"Unknown option '%s' for %s (%s)", c_key, self._name, self._slug
)
continue
# Nested?
if isinstance(typ[c_key], list):
options[c_key] = self._nested_validate_list(
typ[c_key][0], c_value, c_key
)
else:
options[c_key] = self._single_validate(typ[c_key], c_value, c_key)
self._check_missing_options(typ, options, key)
return options
def _check_missing_options(
self, origin: Dict[Any, Any], exists: Dict[Any, Any], root: str
) -> None:
"""Check if all options are exists."""
missing = set(origin) - set(exists)
for miss_opt in missing:
if isinstance(origin[miss_opt], str) and origin[miss_opt].endswith("?"):
continue
raise vol.Invalid(
f"Missing option '{miss_opt}' in {root} in {self._name} ({self._slug})"
) from None
class UiOptions(CoreSysAttributes):
"""Render UI Add-ons Options."""
def __init__(self, coresys: CoreSys) -> None:
"""Initialize UI option render."""
self.coresys = coresys
def __call__(self, raw_schema: Dict[str, Any]) -> List[Dict[str, Any]]:
"""Generate UI schema."""
ui_schema: List[Dict[str, Any]] = []
# read options
for key, value in raw_schema.items():
if isinstance(value, list):
# nested value list
self._nested_ui_list(ui_schema, value, key)
elif isinstance(value, dict):
# nested value dict
self._nested_ui_dict(ui_schema, value, key)
else:
# normal value
self._single_ui_option(ui_schema, value, key)
return ui_schema
def _single_ui_option(
self,
ui_schema: List[Dict[str, Any]],
value: str,
key: str,
multiple: bool = False,
) -> None:
"""Validate a single element."""
ui_node: Dict[str, Union[str, bool, float, List[str]]] = {"name": key}
# If multiple
if multiple:
ui_node["multiple"] = True
# Parse extend data from type
match = RE_SCHEMA_ELEMENT.match(value)
if not match:
return
# Prepare range
for group_name in _SCHEMA_LENGTH_PARTS:
group_value = match.group(group_name)
if not group_value:
continue
if group_name[2:] == "min":
ui_node["lengthMin"] = float(group_value)
elif group_name[2:] == "max":
ui_node["lengthMax"] = float(group_value)
# If required
if value.endswith("?"):
ui_node["optional"] = True
else:
ui_node["required"] = True
# Data types
if value.startswith(_STR):
ui_node["type"] = "string"
elif value.startswith(_PASSWORD):
ui_node["type"] = "string"
ui_node["format"] = "password"
elif value.startswith(_INT):
ui_node["type"] = "integer"
elif value.startswith(_FLOAT):
ui_node["type"] = "float"
elif value.startswith(_BOOL):
ui_node["type"] = "boolean"
elif value.startswith(_EMAIL):
ui_node["type"] = "string"
ui_node["format"] = "email"
elif value.startswith(_URL):
ui_node["type"] = "string"
ui_node["format"] = "url"
elif value.startswith(_PORT):
ui_node["type"] = "integer"
elif value.startswith(_MATCH):
ui_node["type"] = "string"
elif value.startswith(_LIST):
ui_node["type"] = "select"
ui_node["options"] = match.group("list").split("|")
elif value.startswith(_DEVICE):
ui_node["type"] = "select"
# Have filter
if match.group("filter"):
device_filter = _create_device_filter(match.group("filter"))
ui_node["options"] = [
(device.by_id or device.path).as_posix()
for device in self.sys_hardware.filter_devices(**device_filter)
]
else:
ui_node["options"] = [
(device.by_id or device.path).as_posix()
for device in self.sys_hardware.devices
]
ui_schema.append(ui_node)
def _nested_ui_list(
self,
ui_schema: List[Dict[str, Any]],
option_list: List[Any],
key: str,
) -> None:
"""UI nested list items."""
try:
element = option_list[0]
except IndexError:
_LOGGER.error("Invalid schema %s", key)
return
if isinstance(element, dict):
self._nested_ui_dict(ui_schema, element, key, multiple=True)
else:
self._single_ui_option(ui_schema, element, key, multiple=True)
def _nested_ui_dict(
self,
ui_schema: List[Dict[str, Any]],
option_dict: Dict[str, Any],
key: str,
multiple: bool = False,
) -> None:
"""UI nested dict items."""
ui_node = {
"name": key,
"type": "schema",
"optional": True,
"multiple": multiple,
}
nested_schema = []
for c_key, c_value in option_dict.items():
# Nested?
if isinstance(c_value, list):
self._nested_ui_list(nested_schema, c_value, c_key)
else:
self._single_ui_option(nested_schema, c_value, c_key)
ui_node["schema"] = nested_schema
ui_schema.append(ui_node)
def _create_device_filter(str_filter: str) -> Dict[str, Any]:
"""Generate device Filter."""
raw_filter = dict(value.split("=") for value in str_filter.split(";"))
clean_filter = {}
for key, value in raw_filter.items():
if key == "subsystem":
clean_filter[key] = UdevSubsystem(value)
else:
clean_filter[key] = value
return clean_filter

View File

@@ -6,18 +6,8 @@ import logging
from pathlib import Path
from typing import TYPE_CHECKING
from ..const import (
PRIVILEGED_DAC_READ_SEARCH,
PRIVILEGED_NET_ADMIN,
PRIVILEGED_SYS_ADMIN,
PRIVILEGED_SYS_MODULE,
PRIVILEGED_SYS_PTRACE,
PRIVILEGED_SYS_RAWIO,
ROLE_ADMIN,
ROLE_MANAGER,
SECURITY_DISABLE,
SECURITY_PROFILE,
)
from ..const import ROLE_ADMIN, ROLE_MANAGER, SECURITY_DISABLE, SECURITY_PROFILE
from ..docker.const import Capabilities
if TYPE_CHECKING:
from .model import AddonModel
@@ -46,16 +36,19 @@ def rating_security(addon: AddonModel) -> int:
rating += 1
# Privileged options
if any(
privilege in addon.privileged
for privilege in (
PRIVILEGED_NET_ADMIN,
PRIVILEGED_SYS_ADMIN,
PRIVILEGED_SYS_RAWIO,
PRIVILEGED_SYS_PTRACE,
PRIVILEGED_SYS_MODULE,
PRIVILEGED_DAC_READ_SEARCH,
if (
any(
privilege in addon.privileged
for privilege in (
Capabilities.NET_ADMIN,
Capabilities.SYS_ADMIN,
Capabilities.SYS_RAWIO,
Capabilities.SYS_PTRACE,
Capabilities.SYS_MODULE,
Capabilities.DAC_READ_SEARCH,
)
)
or addon.with_kernel_modules
):
rating += -1
@@ -73,12 +66,8 @@ def rating_security(addon: AddonModel) -> int:
if addon.host_pid:
rating += -2
# Full Access
if addon.with_full_access:
rating += -2
# Docker Access
if addon.access_docker_api:
# Docker Access & full Access
if addon.access_docker_api or addon.with_full_access:
rating = 1
return max(min(6, rating), 1)

View File

@@ -2,7 +2,7 @@
import logging
import re
import secrets
from typing import Any, Dict, List, Union
from typing import Any, Dict
import uuid
import voluptuous as vol
@@ -18,10 +18,10 @@ from ..const import (
ATTR_AUDIO_INPUT,
ATTR_AUDIO_OUTPUT,
ATTR_AUTH_API,
ATTR_AUTO_UART,
ATTR_AUTO_UPDATE,
ATTR_BOOT,
ATTR_BUILD_FROM,
ATTR_CONFIGURATION,
ATTR_DESCRIPTON,
ATTR_DEVICES,
ATTR_DEVICETREE,
@@ -60,6 +60,7 @@ from ..const import (
ATTR_PORTS_DESCRIPTION,
ATTR_PRIVILEGED,
ATTR_PROTECTED,
ATTR_REALTIME,
ATTR_REPOSITORY,
ATTR_SCHEMA,
ATTR_SERVICES,
@@ -73,6 +74,8 @@ from ..const import (
ATTR_SYSTEM,
ATTR_TIMEOUT,
ATTR_TMPFS,
ATTR_TRANSLATIONS,
ATTR_UART,
ATTR_UDEV,
ATTR_URL,
ATTR_USB,
@@ -82,7 +85,6 @@ from ..const import (
ATTR_VIDEO,
ATTR_WATCHDOG,
ATTR_WEBUI,
PRIVILEGED_ALL,
ROLE_ALL,
ROLE_DEFAULT,
AddonBoot,
@@ -90,9 +92,10 @@ from ..const import (
AddonStartup,
AddonState,
)
from ..coresys import CoreSys
from ..discovery.validate import valid_discovery_service
from ..docker.const import Capabilities
from ..validate import (
docker_image,
docker_ports,
docker_ports_description,
network_port,
@@ -100,51 +103,14 @@ from ..validate import (
uuid_match,
version_tag,
)
from .options import RE_SCHEMA_ELEMENT
_LOGGER: logging.Logger = logging.getLogger(__name__)
RE_VOLUME = re.compile(r"^(config|ssl|addons|backup|share|media)(?::(rw|ro))?$")
RE_SERVICE = re.compile(r"^(?P<service>mqtt|mysql):(?P<rights>provide|want|need)$")
V_STR = "str"
V_INT = "int"
V_FLOAT = "float"
V_BOOL = "bool"
V_PASSWORD = "password"
V_EMAIL = "email"
V_URL = "url"
V_PORT = "port"
V_MATCH = "match"
V_LIST = "list"
RE_SCHEMA_ELEMENT = re.compile(
r"^(?:"
r"|bool"
r"|email"
r"|url"
r"|port"
r"|str(?:\((?P<s_min>\d+)?,(?P<s_max>\d+)?\))?"
r"|password(?:\((?P<p_min>\d+)?,(?P<p_max>\d+)?\))?"
r"|int(?:\((?P<i_min>\d+)?,(?P<i_max>\d+)?\))?"
r"|float(?:\((?P<f_min>[\d\.]+)?,(?P<f_max>[\d\.]+)?\))?"
r"|match\((?P<match>.*)\)"
r"|list\((?P<list>.+)\)"
r")\??$"
)
_SCHEMA_LENGTH_PARTS = (
"i_min",
"i_max",
"f_min",
"f_max",
"s_min",
"s_max",
"p_min",
"p_max",
)
RE_DOCKER_IMAGE = re.compile(r"^([a-zA-Z\-\.:\d{}]+/)*?([\-\w{}]+)/([\-\w{}]+)$")
RE_DOCKER_IMAGE_BUILD = re.compile(
r"^([a-zA-Z\-\.:\d{}]+/)*?([\-\w{}]+)/([\-\w{}]+)(:[\.\-\w{}]+)?$"
)
@@ -155,6 +121,7 @@ RE_MACHINE = re.compile(
r"^!?(?:"
r"|intel-nuc"
r"|odroid-c2"
r"|odroid-c4"
r"|odroid-n2"
r"|odroid-xu"
r"|qemuarm-64"
@@ -172,34 +139,101 @@ RE_MACHINE = re.compile(
)
def _simple_startup(value) -> str:
"""Define startup schema."""
if value == "before":
return AddonStartup.SERVICES.value
if value == "after":
return AddonStartup.APPLICATION.value
return value
def _warn_addon_config(config: Dict[str, Any]):
"""Warn about miss configs."""
name = config.get(ATTR_NAME)
if not name:
raise vol.Invalid("Invalid Add-on config!")
if config.get(ATTR_FULL_ACCESS, False) and (
config.get(ATTR_DEVICES)
or config.get(ATTR_UART)
or config.get(ATTR_USB)
or config.get(ATTR_GPIO)
):
_LOGGER.warning(
"Add-on have full device access, and selective device access in the configuration. Please report this to the maintainer of %s",
name,
)
return config
def _migrate_addon_config(protocol=False):
"""Migrate addon config."""
def _migrate(config: Dict[str, Any]):
name = config.get(ATTR_NAME)
if not name:
raise vol.Invalid("Invalid Add-on config!")
# Startup 2018-03-30
if config.get(ATTR_STARTUP) in ("before", "after"):
value = config[ATTR_STARTUP]
if protocol:
_LOGGER.warning(
"Add-on config 'startup' with '%s' is deprecated. Please report this to the maintainer of %s",
value,
name,
)
if value == "before":
config[ATTR_STARTUP] = AddonStartup.SERVICES.value
elif value == "after":
config[ATTR_STARTUP] = AddonStartup.APPLICATION.value
# UART 2021-01-20
if "auto_uart" in config:
if protocol:
_LOGGER.warning(
"Add-on config 'auto_uart' is deprecated, use 'uart'. Please report this to the maintainer of %s",
name,
)
config[ATTR_UART] = config.pop("auto_uart")
# Device 2021-01-20
if ATTR_DEVICES in config and any(":" in line for line in config[ATTR_DEVICES]):
if protocol:
_LOGGER.warning(
"Add-on config 'devices' use a deprecated format, the new format uses a list of paths only. Please report this to the maintainer of %s",
name,
)
config[ATTR_DEVICES] = [line.split(":")[0] for line in config[ATTR_DEVICES]]
# TMPFS 2021-02-01
if ATTR_TMPFS in config and not isinstance(config[ATTR_TMPFS], bool):
if protocol:
_LOGGER.warning(
"Add-on config 'tmpfs' use a deprecated format, new it's only a boolean. Please report this to the maintainer of %s",
name,
)
config[ATTR_TMPFS] = True
return config
return _migrate
# pylint: disable=no-value-for-parameter
SCHEMA_ADDON_CONFIG = vol.Schema(
_SCHEMA_ADDON_CONFIG = vol.Schema(
{
vol.Required(ATTR_NAME): vol.Coerce(str),
vol.Required(ATTR_VERSION): vol.All(version_tag, str),
vol.Required(ATTR_SLUG): vol.Coerce(str),
vol.Required(ATTR_DESCRIPTON): vol.Coerce(str),
vol.Required(ATTR_NAME): str,
vol.Required(ATTR_VERSION): version_tag,
vol.Required(ATTR_SLUG): str,
vol.Required(ATTR_DESCRIPTON): str,
vol.Required(ATTR_ARCH): [vol.In(ARCH_ALL)],
vol.Optional(ATTR_MACHINE): vol.All([vol.Match(RE_MACHINE)], vol.Unique()),
vol.Optional(ATTR_URL): vol.Url(),
vol.Required(ATTR_STARTUP): vol.All(_simple_startup, vol.Coerce(AddonStartup)),
vol.Required(ATTR_BOOT): vol.Coerce(AddonBoot),
vol.Optional(ATTR_STARTUP, default=AddonStartup.APPLICATION): vol.Coerce(
AddonStartup
),
vol.Optional(ATTR_BOOT, default=AddonBoot.AUTO): vol.Coerce(AddonBoot),
vol.Optional(ATTR_INIT, default=True): vol.Boolean(),
vol.Optional(ATTR_ADVANCED, default=False): vol.Boolean(),
vol.Optional(ATTR_STAGE, default=AddonStage.STABLE): vol.Coerce(AddonStage),
vol.Optional(ATTR_PORTS): docker_ports,
vol.Optional(ATTR_PORTS_DESCRIPTION): docker_ports_description,
vol.Optional(ATTR_WATCHDOG): vol.Match(
r"^(?:https?|\[PROTO:\w+\]|tcp):\/\/\[HOST\]:\[PORT:\d+\].*$"
r"^(?:https?|\[PROTO:\w+\]|tcp):\/\/\[HOST\]:(\[PORT:\d+\]|\d+).*$"
),
vol.Optional(ATTR_WEBUI): vol.Match(
r"^(?:https?|\[PROTO:\w+\]):\/\/\[HOST\]:\[PORT:\d+\].*$"
@@ -208,30 +242,31 @@ SCHEMA_ADDON_CONFIG = vol.Schema(
vol.Optional(ATTR_INGRESS_PORT, default=8099): vol.Any(
network_port, vol.Equal(0)
),
vol.Optional(ATTR_INGRESS_ENTRY): vol.Coerce(str),
vol.Optional(ATTR_PANEL_ICON, default="mdi:puzzle"): vol.Coerce(str),
vol.Optional(ATTR_PANEL_TITLE): vol.Coerce(str),
vol.Optional(ATTR_INGRESS_ENTRY): str,
vol.Optional(ATTR_PANEL_ICON, default="mdi:puzzle"): str,
vol.Optional(ATTR_PANEL_TITLE): str,
vol.Optional(ATTR_PANEL_ADMIN, default=True): vol.Boolean(),
vol.Optional(ATTR_HOMEASSISTANT): vol.Maybe(vol.Coerce(str)),
vol.Optional(ATTR_HOMEASSISTANT): vol.Maybe(version_tag),
vol.Optional(ATTR_HOST_NETWORK, default=False): vol.Boolean(),
vol.Optional(ATTR_HOST_PID, default=False): vol.Boolean(),
vol.Optional(ATTR_HOST_IPC, default=False): vol.Boolean(),
vol.Optional(ATTR_HOST_DBUS, default=False): vol.Boolean(),
vol.Optional(ATTR_DEVICES): [vol.Match(r"^(.*):(.*):([rwm]{1,3})$")],
vol.Optional(ATTR_AUTO_UART, default=False): vol.Boolean(),
vol.Optional(ATTR_DEVICES): [str],
vol.Optional(ATTR_UDEV, default=False): vol.Boolean(),
vol.Optional(ATTR_TMPFS): vol.Match(r"^size=(\d)*[kmg](,uid=\d{1,4})?(,rw)?$"),
vol.Optional(ATTR_TMPFS, default=False): vol.Boolean(),
vol.Optional(ATTR_MAP, default=list): [vol.Match(RE_VOLUME)],
vol.Optional(ATTR_ENVIRONMENT): {vol.Match(r"\w*"): vol.Coerce(str)},
vol.Optional(ATTR_PRIVILEGED): [vol.In(PRIVILEGED_ALL)],
vol.Optional(ATTR_ENVIRONMENT): {vol.Match(r"\w*"): str},
vol.Optional(ATTR_PRIVILEGED): [vol.Coerce(Capabilities)],
vol.Optional(ATTR_APPARMOR, default=True): vol.Boolean(),
vol.Optional(ATTR_FULL_ACCESS, default=False): vol.Boolean(),
vol.Optional(ATTR_AUDIO, default=False): vol.Boolean(),
vol.Optional(ATTR_VIDEO, default=False): vol.Boolean(),
vol.Optional(ATTR_GPIO, default=False): vol.Boolean(),
vol.Optional(ATTR_USB, default=False): vol.Boolean(),
vol.Optional(ATTR_UART, default=False): vol.Boolean(),
vol.Optional(ATTR_DEVICETREE, default=False): vol.Boolean(),
vol.Optional(ATTR_KERNEL_MODULES, default=False): vol.Boolean(),
vol.Optional(ATTR_REALTIME, default=False): vol.Boolean(),
vol.Optional(ATTR_HASSIO_API, default=False): vol.Boolean(),
vol.Optional(ATTR_HASSIO_ROLE, default=ROLE_DEFAULT): vol.In(ROLE_ALL),
vol.Optional(ATTR_HOMEASSISTANT_API, default=False): vol.Boolean(),
@@ -241,32 +276,26 @@ SCHEMA_ADDON_CONFIG = vol.Schema(
vol.Optional(ATTR_AUTH_API, default=False): vol.Boolean(),
vol.Optional(ATTR_SERVICES): [vol.Match(RE_SERVICE)],
vol.Optional(ATTR_DISCOVERY): [valid_discovery_service],
vol.Optional(ATTR_SNAPSHOT_EXCLUDE): [vol.Coerce(str)],
vol.Required(ATTR_OPTIONS): dict,
vol.Required(ATTR_SCHEMA): vol.Any(
vol.Optional(ATTR_SNAPSHOT_EXCLUDE): [str],
vol.Optional(ATTR_OPTIONS, default={}): dict,
vol.Optional(ATTR_SCHEMA, default={}): vol.Any(
vol.Schema(
{
vol.Coerce(str): vol.Any(
str: vol.Any(
SCHEMA_ELEMENT,
[
vol.Any(
SCHEMA_ELEMENT,
{
vol.Coerce(str): vol.Any(
SCHEMA_ELEMENT, [SCHEMA_ELEMENT]
)
},
{str: vol.Any(SCHEMA_ELEMENT, [SCHEMA_ELEMENT])},
)
],
vol.Schema(
{vol.Coerce(str): vol.Any(SCHEMA_ELEMENT, [SCHEMA_ELEMENT])}
),
vol.Schema({str: vol.Any(SCHEMA_ELEMENT, [SCHEMA_ELEMENT])}),
)
}
),
False,
),
vol.Optional(ATTR_IMAGE): vol.Match(RE_DOCKER_IMAGE),
vol.Optional(ATTR_IMAGE): docker_image,
vol.Optional(ATTR_TIMEOUT, default=10): vol.All(
vol.Coerce(int), vol.Range(min=10, max=300)
),
@@ -274,6 +303,10 @@ SCHEMA_ADDON_CONFIG = vol.Schema(
extra=vol.REMOVE_EXTRA,
)
SCHEMA_ADDON_CONFIG = vol.All(
_migrate_addon_config(True), _warn_addon_config, _SCHEMA_ADDON_CONFIG
)
# pylint: disable=no-value-for-parameter
SCHEMA_BUILD_CONFIG = vol.Schema(
@@ -289,23 +322,38 @@ SCHEMA_BUILD_CONFIG = vol.Schema(
extra=vol.REMOVE_EXTRA,
)
SCHEMA_TRANSLATION_CONFIGURATION = vol.Schema(
{
vol.Required(ATTR_NAME): str,
vol.Optional(ATTR_DESCRIPTON): vol.Maybe(str),
},
extra=vol.REMOVE_EXTRA,
)
SCHEMA_ADDON_TRANSLATIONS = vol.Schema(
{
vol.Optional(ATTR_CONFIGURATION): {str: SCHEMA_TRANSLATION_CONFIGURATION},
vol.Optional(ATTR_NETWORK): {str: str},
},
extra=vol.REMOVE_EXTRA,
)
# pylint: disable=no-value-for-parameter
SCHEMA_ADDON_USER = vol.Schema(
{
vol.Required(ATTR_VERSION): vol.Coerce(str),
vol.Optional(ATTR_IMAGE): vol.Coerce(str),
vol.Required(ATTR_VERSION): version_tag,
vol.Optional(ATTR_IMAGE): docker_image,
vol.Optional(ATTR_UUID, default=lambda: uuid.uuid4().hex): uuid_match,
vol.Optional(ATTR_ACCESS_TOKEN): token,
vol.Optional(ATTR_INGRESS_TOKEN, default=secrets.token_urlsafe): vol.Coerce(
str
),
vol.Optional(ATTR_INGRESS_TOKEN, default=secrets.token_urlsafe): str,
vol.Optional(ATTR_OPTIONS, default=dict): dict,
vol.Optional(ATTR_AUTO_UPDATE, default=False): vol.Boolean(),
vol.Optional(ATTR_BOOT): vol.Coerce(AddonBoot),
vol.Optional(ATTR_NETWORK): docker_ports,
vol.Optional(ATTR_AUDIO_OUTPUT): vol.Maybe(vol.Coerce(str)),
vol.Optional(ATTR_AUDIO_INPUT): vol.Maybe(vol.Coerce(str)),
vol.Optional(ATTR_AUDIO_OUTPUT): vol.Maybe(str),
vol.Optional(ATTR_AUDIO_INPUT): vol.Maybe(str),
vol.Optional(ATTR_PROTECTED, default=True): vol.Boolean(),
vol.Optional(ATTR_INGRESS_PANEL, default=False): vol.Boolean(),
vol.Optional(ATTR_WATCHDOG, default=False): vol.Boolean(),
@@ -313,20 +361,26 @@ SCHEMA_ADDON_USER = vol.Schema(
extra=vol.REMOVE_EXTRA,
)
SCHEMA_ADDON_SYSTEM = SCHEMA_ADDON_CONFIG.extend(
{
vol.Required(ATTR_LOCATON): vol.Coerce(str),
vol.Required(ATTR_REPOSITORY): vol.Coerce(str),
}
SCHEMA_ADDON_SYSTEM = vol.All(
_migrate_addon_config(),
_SCHEMA_ADDON_CONFIG.extend(
{
vol.Required(ATTR_LOCATON): str,
vol.Required(ATTR_REPOSITORY): str,
vol.Required(ATTR_TRANSLATIONS, default=dict): {
str: SCHEMA_ADDON_TRANSLATIONS
},
}
),
)
SCHEMA_ADDONS_FILE = vol.Schema(
{
vol.Optional(ATTR_USER, default=dict): {vol.Coerce(str): SCHEMA_ADDON_USER},
vol.Optional(ATTR_SYSTEM, default=dict): {vol.Coerce(str): SCHEMA_ADDON_SYSTEM},
}
vol.Optional(ATTR_USER, default=dict): {str: SCHEMA_ADDON_USER},
vol.Optional(ATTR_SYSTEM, default=dict): {str: SCHEMA_ADDON_SYSTEM},
},
extra=vol.REMOVE_EXTRA,
)
@@ -335,263 +389,7 @@ SCHEMA_ADDON_SNAPSHOT = vol.Schema(
vol.Required(ATTR_USER): SCHEMA_ADDON_USER,
vol.Required(ATTR_SYSTEM): SCHEMA_ADDON_SYSTEM,
vol.Required(ATTR_STATE): vol.Coerce(AddonState),
vol.Required(ATTR_VERSION): vol.Coerce(str),
vol.Required(ATTR_VERSION): version_tag,
},
extra=vol.REMOVE_EXTRA,
)
def validate_options(coresys: CoreSys, raw_schema: Dict[str, Any]):
"""Validate schema."""
def validate(struct):
"""Create schema validator for add-ons options."""
options = {}
# read options
for key, value in struct.items():
# Ignore unknown options / remove from list
if key not in raw_schema:
_LOGGER.warning("Unknown options %s", key)
continue
typ = raw_schema[key]
try:
if isinstance(typ, list):
# nested value list
options[key] = _nested_validate_list(coresys, typ[0], value, key)
elif isinstance(typ, dict):
# nested value dict
options[key] = _nested_validate_dict(coresys, typ, value, key)
else:
# normal value
options[key] = _single_validate(coresys, typ, value, key)
except (IndexError, KeyError):
raise vol.Invalid(f"Type error for {key}") from None
_check_missing_options(raw_schema, options, "root")
return options
return validate
# pylint: disable=no-value-for-parameter
# pylint: disable=inconsistent-return-statements
def _single_validate(coresys: CoreSys, typ: str, value: Any, key: str):
"""Validate a single element."""
# if required argument
if value is None:
raise vol.Invalid(f"Missing required option '{key}'") from None
# Lookup secret
if str(value).startswith("!secret "):
secret: str = value.partition(" ")[2]
value = coresys.homeassistant.secrets.get(secret)
if value is None:
raise vol.Invalid(f"Unknown secret {secret}") from None
# parse extend data from type
match = RE_SCHEMA_ELEMENT.match(typ)
if not match:
raise vol.Invalid(f"Unknown type {typ}") from None
# prepare range
range_args = {}
for group_name in _SCHEMA_LENGTH_PARTS:
group_value = match.group(group_name)
if group_value:
range_args[group_name[2:]] = float(group_value)
if typ.startswith(V_STR) or typ.startswith(V_PASSWORD):
return vol.All(str(value), vol.Range(**range_args))(value)
elif typ.startswith(V_INT):
return vol.All(vol.Coerce(int), vol.Range(**range_args))(value)
elif typ.startswith(V_FLOAT):
return vol.All(vol.Coerce(float), vol.Range(**range_args))(value)
elif typ.startswith(V_BOOL):
return vol.Boolean()(value)
elif typ.startswith(V_EMAIL):
return vol.Email()(value)
elif typ.startswith(V_URL):
return vol.Url()(value)
elif typ.startswith(V_PORT):
return network_port(value)
elif typ.startswith(V_MATCH):
return vol.Match(match.group("match"))(str(value))
elif typ.startswith(V_LIST):
return vol.In(match.group("list").split("|"))(str(value))
raise vol.Invalid(f"Fatal error for {key} type {typ}") from None
def _nested_validate_list(coresys, typ, data_list, key):
"""Validate nested items."""
options = []
# Make sure it is a list
if not isinstance(data_list, list):
raise vol.Invalid(f"Invalid list for {key}") from None
# Process list
for element in data_list:
# Nested?
if isinstance(typ, dict):
c_options = _nested_validate_dict(coresys, typ, element, key)
options.append(c_options)
else:
options.append(_single_validate(coresys, typ, element, key))
return options
def _nested_validate_dict(coresys, typ, data_dict, key):
"""Validate nested items."""
options = {}
# Make sure it is a dict
if not isinstance(data_dict, dict):
raise vol.Invalid(f"Invalid dict for {key}") from None
# Process dict
for c_key, c_value in data_dict.items():
# Ignore unknown options / remove from list
if c_key not in typ:
_LOGGER.warning("Unknown options %s", c_key)
continue
# Nested?
if isinstance(typ[c_key], list):
options[c_key] = _nested_validate_list(
coresys, typ[c_key][0], c_value, c_key
)
else:
options[c_key] = _single_validate(coresys, typ[c_key], c_value, c_key)
_check_missing_options(typ, options, key)
return options
def _check_missing_options(origin, exists, root):
"""Check if all options are exists."""
missing = set(origin) - set(exists)
for miss_opt in missing:
if isinstance(origin[miss_opt], str) and origin[miss_opt].endswith("?"):
continue
raise vol.Invalid(f"Missing option {miss_opt} in {root}") from None
def schema_ui_options(raw_schema: Dict[str, Any]) -> List[Dict[str, Any]]:
"""Generate UI schema."""
ui_schema: List[Dict[str, Any]] = []
# read options
for key, value in raw_schema.items():
if isinstance(value, list):
# nested value list
_nested_ui_list(ui_schema, value, key)
elif isinstance(value, dict):
# nested value dict
_nested_ui_dict(ui_schema, value, key)
else:
# normal value
_single_ui_option(ui_schema, value, key)
return ui_schema
def _single_ui_option(
ui_schema: List[Dict[str, Any]], value: str, key: str, multiple: bool = False
) -> None:
"""Validate a single element."""
ui_node: Dict[str, Union[str, bool, float, List[str]]] = {"name": key}
# If multiple
if multiple:
ui_node["multiple"] = True
# Parse extend data from type
match = RE_SCHEMA_ELEMENT.match(value)
if not match:
return
# Prepare range
for group_name in _SCHEMA_LENGTH_PARTS:
group_value = match.group(group_name)
if not group_value:
continue
if group_name[2:] == "min":
ui_node["lengthMin"] = float(group_value)
elif group_name[2:] == "max":
ui_node["lengthMax"] = float(group_value)
# If required
if value.endswith("?"):
ui_node["optional"] = True
else:
ui_node["required"] = True
# Data types
if value.startswith(V_STR):
ui_node["type"] = "string"
elif value.startswith(V_PASSWORD):
ui_node["type"] = "string"
ui_node["format"] = "password"
elif value.startswith(V_INT):
ui_node["type"] = "integer"
elif value.startswith(V_FLOAT):
ui_node["type"] = "float"
elif value.startswith(V_BOOL):
ui_node["type"] = "boolean"
elif value.startswith(V_EMAIL):
ui_node["type"] = "string"
ui_node["format"] = "email"
elif value.startswith(V_URL):
ui_node["type"] = "string"
ui_node["format"] = "url"
elif value.startswith(V_PORT):
ui_node["type"] = "integer"
elif value.startswith(V_MATCH):
ui_node["type"] = "string"
elif value.startswith(V_LIST):
ui_node["type"] = "select"
ui_node["options"] = match.group("list").split("|")
ui_schema.append(ui_node)
def _nested_ui_list(
ui_schema: List[Dict[str, Any]], option_list: List[Any], key: str
) -> None:
"""UI nested list items."""
try:
element = option_list[0]
except IndexError:
_LOGGER.error("Invalid schema %s", key)
return
if isinstance(element, dict):
_nested_ui_dict(ui_schema, element, key, multiple=True)
else:
_single_ui_option(ui_schema, element, key, multiple=True)
def _nested_ui_dict(
ui_schema: List[Dict[str, Any]],
option_dict: Dict[str, Any],
key: str,
multiple: bool = False,
) -> None:
"""UI nested dict items."""
ui_node = {"name": key, "type": "schema", "optional": True, "multiple": multiple}
nested_schema = []
for c_key, c_value in option_dict.items():
# Nested?
if isinstance(c_value, list):
_nested_ui_list(nested_schema, c_value, c_key)
else:
_single_ui_option(nested_schema, c_value, c_key)
ui_node["schema"] = nested_schema
ui_schema.append(ui_node)

View File

@@ -12,19 +12,23 @@ from .auth import APIAuth
from .cli import APICli
from .discovery import APIDiscovery
from .dns import APICoreDNS
from .docker import APIDocker
from .hardware import APIHardware
from .homeassistant import APIHomeAssistant
from .host import APIHost
from .info import APIInfo
from .ingress import APIIngress
from .jobs import APIJobs
from .multicast import APIMulticast
from .network import APINetwork
from .observer import APIObserver
from .os import APIOS
from .proxy import APIProxy
from .resolution import APIResoulution
from .security import SecurityMiddleware
from .services import APIServices
from .snapshots import APISnapshots
from .store import APIStore
from .supervisor import APISupervisor
_LOGGER: logging.Logger = logging.getLogger(__name__)
@@ -42,7 +46,10 @@ class RestAPI(CoreSysAttributes):
self.security: SecurityMiddleware = SecurityMiddleware(coresys)
self.webapp: web.Application = web.Application(
client_max_size=MAX_CLIENT_SIZE,
middlewares=[self.security.token_validation],
middlewares=[
self.security.system_validation,
self.security.token_validation,
],
)
# service stuff
@@ -51,26 +58,32 @@ class RestAPI(CoreSysAttributes):
async def load(self) -> None:
"""Register REST API Calls."""
self._register_supervisor()
self._register_host()
self._register_os()
self._register_addons()
self._register_audio()
self._register_auth()
self._register_cli()
self._register_observer()
self._register_multicast()
self._register_network()
self._register_discovery()
self._register_dns()
self._register_docker()
self._register_hardware()
self._register_homeassistant()
self._register_proxy()
self._register_panel()
self._register_addons()
self._register_ingress()
self._register_snapshots()
self._register_discovery()
self._register_services()
self._register_host()
self._register_info()
self._register_auth()
self._register_dns()
self._register_audio()
self._register_ingress()
self._register_multicast()
self._register_network()
self._register_observer()
self._register_os()
self._register_jobs()
self._register_panel()
self._register_proxy()
self._register_resolution()
self._register_services()
self._register_snapshots()
self._register_supervisor()
self._register_store()
await self.start()
def _register_host(self) -> None:
"""Register hostcontrol functions."""
@@ -101,6 +114,7 @@ class RestAPI(CoreSysAttributes):
self.webapp.add_routes(
[
web.get("/network/info", api_network.info),
web.post("/network/reload", api_network.reload),
web.get(
"/network/interface/{interface}/info", api_network.interface_info
),
@@ -108,6 +122,14 @@ class RestAPI(CoreSysAttributes):
"/network/interface/{interface}/update",
api_network.interface_update,
),
web.get(
"/network/interface/{interface}/accesspoints",
api_network.scan_accesspoints,
),
web.post(
"/network/interface/{interface}/vlan/{vlan}",
api_network.create_vlan,
),
]
)
@@ -124,6 +146,19 @@ class RestAPI(CoreSysAttributes):
]
)
def _register_jobs(self) -> None:
"""Register Jobs functions."""
api_jobs = APIJobs()
api_jobs.coresys = self.coresys
self.webapp.add_routes(
[
web.get("/jobs/info", api_jobs.info),
web.post("/jobs/options", api_jobs.options),
web.post("/jobs/reset", api_jobs.reset),
]
)
def _register_cli(self) -> None:
"""Register HA cli functions."""
api_cli = APICli()
@@ -185,13 +220,42 @@ class RestAPI(CoreSysAttributes):
self.webapp.add_routes([web.get("/info", api_info.info)])
def _register_resolution(self) -> None:
"""Register info functions."""
api_resolution = APIResoulution()
api_resolution.coresys = self.coresys
self.webapp.add_routes(
[
web.get("/resolution/info", api_resolution.info),
web.post(
"/resolution/suggestion/{suggestion}",
api_resolution.apply_suggestion,
),
web.delete(
"/resolution/suggestion/{suggestion}",
api_resolution.dismiss_suggestion,
),
web.delete(
"/resolution/issue/{issue}",
api_resolution.dismiss_issue,
),
web.post("/resolution/healthcheck", api_resolution.healthcheck),
]
)
def _register_auth(self) -> None:
"""Register auth functions."""
api_auth = APIAuth()
api_auth.coresys = self.coresys
self.webapp.add_routes(
[web.post("/auth", api_auth.auth), web.post("/auth/reset", api_auth.reset)]
[
web.get("/auth", api_auth.auth),
web.post("/auth", api_auth.auth),
web.post("/auth/reset", api_auth.reset),
web.delete("/auth/cache", api_auth.cache),
]
)
def _register_supervisor(self) -> None:
@@ -207,6 +271,7 @@ class RestAPI(CoreSysAttributes):
web.get("/supervisor/logs", api_supervisor.logs),
web.post("/supervisor/update", api_supervisor.update),
web.post("/supervisor/reload", api_supervisor.reload),
web.post("/supervisor/restart", api_supervisor.restart),
web.post("/supervisor/options", api_supervisor.options),
web.post("/supervisor/repair", api_supervisor.repair),
]
@@ -276,16 +341,15 @@ class RestAPI(CoreSysAttributes):
web.get("/addons", api_addons.list),
web.post("/addons/reload", api_addons.reload),
web.get("/addons/{addon}/info", api_addons.info),
web.post("/addons/{addon}/install", api_addons.install),
web.post("/addons/{addon}/uninstall", api_addons.uninstall),
web.post("/addons/{addon}/start", api_addons.start),
web.post("/addons/{addon}/stop", api_addons.stop),
web.post("/addons/{addon}/restart", api_addons.restart),
web.post("/addons/{addon}/update", api_addons.update),
web.post("/addons/{addon}/options", api_addons.options),
web.post(
"/addons/{addon}/options/validate", api_addons.options_validate
),
web.get("/addons/{addon}/options/config", api_addons.options_config),
web.post("/addons/{addon}/rebuild", api_addons.rebuild),
web.get("/addons/{addon}/logs", api_addons.logs),
web.get("/addons/{addon}/icon", api_addons.icon),
@@ -306,6 +370,7 @@ class RestAPI(CoreSysAttributes):
self.webapp.add_routes(
[
web.post("/ingress/session", api_ingress.create_session),
web.post("/ingress/validate_session", api_ingress.validate_session),
web.get("/ingress/panels", api_ingress.panels),
web.view("/ingress/{token}/{path:.*}", api_ingress.handler),
]
@@ -324,7 +389,7 @@ class RestAPI(CoreSysAttributes):
web.post("/snapshots/new/partial", api_snapshots.snapshot_partial),
web.post("/snapshots/new/upload", api_snapshots.upload),
web.get("/snapshots/{snapshot}/info", api_snapshots.info),
web.post("/snapshots/{snapshot}/remove", api_snapshots.remove),
web.delete("/snapshots/{snapshot}", api_snapshots.remove),
web.post(
"/snapshots/{snapshot}/restore/full", api_snapshots.restore_full
),
@@ -333,6 +398,8 @@ class RestAPI(CoreSysAttributes):
api_snapshots.restore_partial,
),
web.get("/snapshots/{snapshot}/download", api_snapshots.download),
# Old, remove at end of 2020
web.post("/snapshots/{snapshot}/remove", api_snapshots.remove),
]
)
@@ -403,11 +470,65 @@ class RestAPI(CoreSysAttributes):
]
)
def _register_store(self) -> None:
"""Register store endpoints."""
api_store = APIStore()
api_store.coresys = self.coresys
self.webapp.add_routes(
[
web.get("/store", api_store.store_info),
web.get("/store/addons", api_store.addons_list),
web.get("/store/addons/{addon}", api_store.addons_addon_info),
web.get("/store/addons/{addon}/{version}", api_store.addons_addon_info),
web.post(
"/store/addons/{addon}/install", api_store.addons_addon_install
),
web.post(
"/store/addons/{addon}/install/{version}",
api_store.addons_addon_install,
),
web.post("/store/addons/{addon}/update", api_store.addons_addon_update),
web.post(
"/store/addons/{addon}/update/{version}",
api_store.addons_addon_update,
),
web.post("/store/reload", api_store.reload),
web.get("/store/repositories", api_store.repositories_list),
web.get(
"/store/repositories/{repository}",
api_store.repositories_repository_info,
),
]
)
# Reroute from legacy
self.webapp.add_routes(
[
web.post("/addons/{addon}/install", api_store.addons_addon_install),
web.post("/addons/{addon}/update", api_store.addons_addon_update),
]
)
def _register_panel(self) -> None:
"""Register panel for Home Assistant."""
panel_dir = Path(__file__).parent.joinpath("panel")
self.webapp.add_routes([web.static("/app", panel_dir)])
def _register_docker(self) -> None:
"""Register docker configuration functions."""
api_docker = APIDocker()
api_docker.coresys = self.coresys
self.webapp.add_routes(
[
web.get("/docker/info", api_docker.info),
web.get("/docker/registries", api_docker.registries),
web.post("/docker/registries", api_docker.create_registry),
web.delete("/docker/registries/{hostname}", api_docker.remove_registry),
]
)
async def start(self) -> None:
"""Run RESTful API webserver."""
await self._runner.setup()
@@ -420,7 +541,7 @@ class RestAPI(CoreSysAttributes):
except OSError as err:
_LOGGER.critical("Failed to create HTTP server at 0.0.0.0:80 -> %s", err)
else:
_LOGGER.info("Start API on %s", self.sys_docker.network.supervisor)
_LOGGER.info("Starting API on %s", self.sys_docker.network.supervisor)
async def stop(self) -> None:
"""Stop RESTful API webserver."""
@@ -431,4 +552,4 @@ class RestAPI(CoreSysAttributes):
await self._site.stop()
await self._runner.cleanup()
_LOGGER.info("Stop API on %s", self.sys_docker.network.supervisor)
_LOGGER.info("Stopping API on %s", self.sys_docker.network.supervisor)

View File

@@ -82,7 +82,10 @@ from ..const import (
ATTR_STARTUP,
ATTR_STATE,
ATTR_STDIN,
ATTR_TRANSLATIONS,
ATTR_UART,
ATTR_UDEV,
ATTR_UPDATE_AVAILABLE,
ATTR_URL,
ATTR_USB,
ATTR_VALID,
@@ -100,7 +103,7 @@ from ..const import (
)
from ..coresys import CoreSysAttributes
from ..docker.stats import DockerStats
from ..exceptions import APIError
from ..exceptions import APIError, APIForbidden
from ..validate import docker_ports
from .utils import api_process, api_process_raw, api_validate
@@ -161,10 +164,15 @@ class APIAddons(CoreSysAttributes):
ATTR_DESCRIPTON: addon.description,
ATTR_ADVANCED: addon.advanced,
ATTR_STAGE: addon.stage,
ATTR_VERSION: addon.latest_version,
ATTR_INSTALLED: addon.version if addon.is_installed else None,
ATTR_VERSION: addon.version if addon.is_installed else None,
ATTR_VERSION_LATEST: addon.latest_version,
ATTR_UPDATE_AVAILABLE: addon.need_update
if addon.is_installed
else False,
ATTR_INSTALLED: addon.is_installed,
ATTR_AVAILABLE: addon.available,
ATTR_DETACHED: addon.is_detached,
ATTR_HOMEASSISTANT: addon.homeassistant_version,
ATTR_REPOSITORY: addon.repository,
ATTR_BUILD: addon.need_build,
ATTR_URL: addon.url,
@@ -209,6 +217,7 @@ class APIAddons(CoreSysAttributes):
ATTR_REPOSITORY: addon.repository,
ATTR_VERSION: None,
ATTR_VERSION_LATEST: addon.latest_version,
ATTR_UPDATE_AVAILABLE: False,
ATTR_PROTECTED: addon.protected,
ATTR_RATING: rating_security(addon),
ATTR_BOOT: addon.boot,
@@ -231,7 +240,7 @@ class APIAddons(CoreSysAttributes):
ATTR_PRIVILEGED: addon.privileged,
ATTR_FULL_ACCESS: addon.with_full_access,
ATTR_APPARMOR: addon.apparmor,
ATTR_DEVICES: _pretty_devices(addon),
ATTR_DEVICES: addon.static_devices,
ATTR_ICON: addon.with_icon,
ATTR_LOGO: addon.with_logo,
ATTR_CHANGELOG: addon.with_changelog,
@@ -244,6 +253,7 @@ class APIAddons(CoreSysAttributes):
ATTR_HOMEASSISTANT_API: addon.access_homeassistant_api,
ATTR_GPIO: addon.with_gpio,
ATTR_USB: addon.with_usb,
ATTR_UART: addon.with_uart,
ATTR_KERNEL_MODULES: addon.with_kernel_modules,
ATTR_DEVICETREE: addon.with_devicetree,
ATTR_UDEV: addon.with_udev,
@@ -256,6 +266,7 @@ class APIAddons(CoreSysAttributes):
ATTR_SERVICES: _pretty_services(addon),
ATTR_DISCOVERY: addon.discovery,
ATTR_IP_ADDRESS: None,
ATTR_TRANSLATIONS: addon.translations,
ATTR_INGRESS: addon.with_ingress,
ATTR_INGRESS_ENTRY: None,
ATTR_INGRESS_URL: None,
@@ -278,7 +289,10 @@ class APIAddons(CoreSysAttributes):
ATTR_AUTO_UPDATE: addon.auto_update,
ATTR_IP_ADDRESS: str(addon.ip_address),
ATTR_VERSION: addon.version,
ATTR_UPDATE_AVAILABLE: addon.need_update,
ATTR_WATCHDOG: addon.watchdog,
ATTR_DEVICES: addon.static_devices
+ [device.path for device in addon.devices],
}
)
@@ -332,6 +346,19 @@ class APIAddons(CoreSysAttributes):
return data
@api_process
async def options_config(self, request: web.Request) -> None:
"""Validate user options for add-on."""
slug: str = request.match_info.get("addon")
if slug != "self":
raise APIForbidden("This can be only read by the Add-on itself!")
addon = self._extract_addon_installed(request)
try:
return addon.schema(addon.options)
except vol.Invalid:
raise APIError("Invalid configuration data for the add-on") from None
@api_process
async def security(self, request: web.Request) -> None:
"""Store security options for add-on."""
@@ -339,7 +366,7 @@ class APIAddons(CoreSysAttributes):
body: Dict[str, Any] = await api_validate(SCHEMA_SECURITY, request)
if ATTR_PROTECTED in body:
_LOGGER.warning("Protected flag changing for %s!", addon.slug)
_LOGGER.warning("Changing protected flag for %s!", addon.slug)
addon.protected = body[ATTR_PROTECTED]
addon.save_persist()
@@ -362,12 +389,6 @@ class APIAddons(CoreSysAttributes):
ATTR_BLK_WRITE: stats.blk_write,
}
@api_process
def install(self, request: web.Request) -> Awaitable[None]:
"""Install add-on."""
addon = self._extract_addon(request)
return asyncio.shield(addon.install())
@api_process
def uninstall(self, request: web.Request) -> Awaitable[None]:
"""Uninstall add-on."""
@@ -386,12 +407,6 @@ class APIAddons(CoreSysAttributes):
addon = self._extract_addon_installed(request)
return asyncio.shield(addon.stop())
@api_process
def update(self, request: web.Request) -> Awaitable[None]:
"""Update add-on."""
addon: Addon = self._extract_addon_installed(request)
return asyncio.shield(addon.update())
@api_process
def restart(self, request: web.Request) -> Awaitable[None]:
"""Restart add-on."""
@@ -461,14 +476,6 @@ class APIAddons(CoreSysAttributes):
await asyncio.shield(addon.write_stdin(data))
def _pretty_devices(addon: AnyAddon) -> List[str]:
"""Return a simplified device list."""
dev_list = addon.devices
if not dev_list:
return []
return [row.split(":")[0] for row in dev_list]
def _pretty_services(addon: AnyAddon) -> List[str]:
"""Return a simplified services role list."""
return [f"{name}:{access}" for name, access in addon.services_role.items()]

View File

@@ -25,6 +25,7 @@ from ..const import (
ATTR_NETWORK_RX,
ATTR_NETWORK_TX,
ATTR_OUTPUT,
ATTR_UPDATE_AVAILABLE,
ATTR_VERSION,
ATTR_VERSION_LATEST,
ATTR_VOLUME,
@@ -71,6 +72,7 @@ class APIAudio(CoreSysAttributes):
return {
ATTR_VERSION: self.sys_plugins.audio.version,
ATTR_VERSION_LATEST: self.sys_plugins.audio.latest_version,
ATTR_UPDATE_AVAILABLE: self.sys_plugins.audio.need_update,
ATTR_HOST: str(self.sys_docker.network.audio),
ATTR_AUDIO: {
ATTR_CARD: [attr.asdict(card) for card in self.sys_host.sound.cards],

View File

@@ -29,6 +29,10 @@ SCHEMA_PASSWORD_RESET = vol.Schema(
}
)
REALM_HEADER: Dict[str, str] = {
WWW_AUTHENTICATE: 'Basic realm="Home Assistant Authentication"'
}
class APIAuth(CoreSysAttributes):
"""Handle RESTful API for auth functions."""
@@ -63,7 +67,9 @@ class APIAuth(CoreSysAttributes):
# BasicAuth
if AUTHORIZATION in request.headers:
return await self._process_basic(request, addon)
if not await self._process_basic(request, addon):
raise HTTPUnauthorized(headers=REALM_HEADER)
return True
# Json
if request.headers.get(CONTENT_TYPE) == CONTENT_TYPE_JSON:
@@ -75,9 +81,7 @@ class APIAuth(CoreSysAttributes):
data = await request.post()
return await self._process_dict(request, addon, data)
raise HTTPUnauthorized(
headers={WWW_AUTHENTICATE: 'Basic realm="Home Assistant Authentication"'}
)
raise HTTPUnauthorized(headers=REALM_HEADER)
@api_process
async def reset(self, request: web.Request) -> None:
@@ -86,3 +90,8 @@ class APIAuth(CoreSysAttributes):
await asyncio.shield(
self.sys_auth.change_password(body[ATTR_USERNAME], body[ATTR_PASSWORD])
)
@api_process
async def cache(self, request: web.Request) -> None:
"""Process cache reset request."""
self.sys_auth.reset_data()

View File

@@ -15,6 +15,7 @@ from ..const import (
ATTR_MEMORY_USAGE,
ATTR_NETWORK_RX,
ATTR_NETWORK_TX,
ATTR_UPDATE_AVAILABLE,
ATTR_VERSION,
ATTR_VERSION_LATEST,
)
@@ -36,6 +37,7 @@ class APICli(CoreSysAttributes):
return {
ATTR_VERSION: self.sys_plugins.cli.version,
ATTR_VERSION_LATEST: self.sys_plugins.cli.latest_version,
ATTR_UPDATE_AVAILABLE: self.sys_plugins.cli.need_update,
}
@api_process

View File

@@ -18,6 +18,7 @@ from ..const import (
ATTR_NETWORK_RX,
ATTR_NETWORK_TX,
ATTR_SERVERS,
ATTR_UPDATE_AVAILABLE,
ATTR_VERSION,
ATTR_VERSION_LATEST,
CONTENT_TYPE_BINARY,
@@ -44,9 +45,10 @@ class APICoreDNS(CoreSysAttributes):
return {
ATTR_VERSION: self.sys_plugins.dns.version,
ATTR_VERSION_LATEST: self.sys_plugins.dns.latest_version,
ATTR_UPDATE_AVAILABLE: self.sys_plugins.dns.need_update,
ATTR_HOST: str(self.sys_docker.network.dns),
ATTR_SERVERS: self.sys_plugins.dns.servers,
ATTR_LOCALS: self.sys_host.network.dns_servers,
ATTR_LOCALS: self.sys_plugins.dns.locals,
}
@api_process

76
supervisor/api/docker.py Normal file
View File

@@ -0,0 +1,76 @@
"""Init file for Supervisor Home Assistant RESTful API."""
import logging
from typing import Any, Dict
from aiohttp import web
import voluptuous as vol
from ..const import (
ATTR_HOSTNAME,
ATTR_LOGGING,
ATTR_PASSWORD,
ATTR_REGISTRIES,
ATTR_STORAGE,
ATTR_USERNAME,
ATTR_VERSION,
)
from ..coresys import CoreSysAttributes
from .utils import api_process, api_validate
_LOGGER: logging.Logger = logging.getLogger(__name__)
SCHEMA_DOCKER_REGISTRY = vol.Schema(
{
vol.Coerce(str): {
vol.Required(ATTR_USERNAME): str,
vol.Required(ATTR_PASSWORD): str,
}
}
)
class APIDocker(CoreSysAttributes):
"""Handle RESTful API for Docker configuration."""
@api_process
async def registries(self, request) -> Dict[str, Any]:
"""Return the list of registries."""
data_registries = {}
for hostname, registry in self.sys_docker.config.registries.items():
data_registries[hostname] = {
ATTR_USERNAME: registry[ATTR_USERNAME],
}
return {ATTR_REGISTRIES: data_registries}
@api_process
async def create_registry(self, request: web.Request):
"""Create a new docker registry."""
body = await api_validate(SCHEMA_DOCKER_REGISTRY, request)
for hostname, registry in body.items():
self.sys_docker.config.registries[hostname] = registry
self.sys_docker.config.save_data()
@api_process
async def remove_registry(self, request: web.Request):
"""Delete a docker registry."""
hostname = request.match_info.get(ATTR_HOSTNAME)
del self.sys_docker.config.registries[hostname]
self.sys_docker.config.save_data()
@api_process
async def info(self, request: web.Request):
"""Get docker info."""
data_registries = {}
for hostname, registry in self.sys_docker.config.registries.items():
data_registries[hostname] = {
ATTR_USERNAME: registry[ATTR_USERNAME],
}
return {
ATTR_VERSION: self.sys_docker.info.version,
ATTR_STORAGE: self.sys_docker.info.storage,
ATTR_LOGGING: self.sys_docker.info.logging,
ATTR_REGISTRIES: data_registries,
}

View File

@@ -1,50 +1,46 @@
"""Init file for Supervisor hardware RESTful API."""
import asyncio
import logging
from typing import Any, Awaitable, Dict, List
from typing import Any, Awaitable, Dict
from aiohttp import web
from ..const import (
ATTR_AUDIO,
ATTR_DISK,
ATTR_GPIO,
ATTR_INPUT,
ATTR_OUTPUT,
ATTR_SERIAL,
ATTR_USB,
)
from ..const import ATTR_AUDIO, ATTR_DEVICES, ATTR_INPUT, ATTR_NAME, ATTR_OUTPUT
from ..coresys import CoreSysAttributes
from ..hardware.const import (
ATTR_ATTRIBUTES,
ATTR_BY_ID,
ATTR_DEV_PATH,
ATTR_SUBSYSTEM,
ATTR_SYSFS,
)
from ..hardware.data import Device
from .utils import api_process
_LOGGER: logging.Logger = logging.getLogger(__name__)
def device_struct(device: Device) -> Dict[str, Any]:
"""Return a dict with information of a interface to be used in th API."""
return {
ATTR_NAME: device.name,
ATTR_SYSFS: device.sysfs,
ATTR_DEV_PATH: device.path,
ATTR_SUBSYSTEM: device.subsystem,
ATTR_BY_ID: device.by_id,
ATTR_ATTRIBUTES: device.attributes,
}
class APIHardware(CoreSysAttributes):
"""Handle RESTful API for hardware functions."""
@api_process
async def info(self, request: web.Request) -> Dict[str, Any]:
"""Show hardware info."""
serial: List[str] = []
# Create Serial list with device links
for device in self.sys_hardware.serial_devices:
serial.append(device.path.as_posix())
for link in device.links:
serial.append(link.as_posix())
return {
ATTR_SERIAL: serial,
ATTR_INPUT: list(self.sys_hardware.input_devices),
ATTR_DISK: [
device.path.as_posix() for device in self.sys_hardware.disk_devices
],
ATTR_GPIO: list(self.sys_hardware.gpio_devices),
ATTR_USB: [
device.path.as_posix() for device in self.sys_hardware.usb_devices
],
ATTR_AUDIO: self.sys_hardware.audio_devices,
ATTR_DEVICES: [
device_struct(device) for device in self.sys_hardware.devices
]
}
@api_process
@@ -64,6 +60,6 @@ class APIHardware(CoreSysAttributes):
}
@api_process
def trigger(self, request: web.Request) -> Awaitable[None]:
async def trigger(self, request: web.Request) -> Awaitable[None]:
"""Trigger a udev device reload."""
return asyncio.shield(self.sys_hardware.udev_trigger())
_LOGGER.debug("Ignoring DEPRECATED hardware trigger function call.")

View File

@@ -25,6 +25,7 @@ from ..const import (
ATTR_PORT,
ATTR_REFRESH_TOKEN,
ATTR_SSL,
ATTR_UPDATE_AVAILABLE,
ATTR_VERSION,
ATTR_VERSION_LATEST,
ATTR_WAIT_BOOT,
@@ -65,6 +66,7 @@ class APIHomeAssistant(CoreSysAttributes):
return {
ATTR_VERSION: self.sys_homeassistant.version,
ATTR_VERSION_LATEST: self.sys_homeassistant.latest_version,
ATTR_UPDATE_AVAILABLE: self.sys_homeassistant.need_update,
ATTR_MACHINE: self.sys_homeassistant.machine,
ATTR_IP_ADDRESS: str(self.sys_homeassistant.ip_address),
ATTR_ARCH: self.sys_homeassistant.arch,

View File

@@ -11,6 +11,7 @@ from ..const import (
ATTR_DEPLOYMENT,
ATTR_DESCRIPTON,
ATTR_DISK_FREE,
ATTR_DISK_LIFE_TIME,
ATTR_DISK_TOTAL,
ATTR_DISK_USED,
ATTR_FEATURES,
@@ -43,7 +44,8 @@ class APIHost(CoreSysAttributes):
ATTR_DISK_FREE: self.sys_host.info.free_space,
ATTR_DISK_TOTAL: self.sys_host.info.total_space,
ATTR_DISK_USED: self.sys_host.info.used_space,
ATTR_FEATURES: self.sys_host.supported_features,
ATTR_DISK_LIFE_TIME: self.sys_host.info.disk_life_time,
ATTR_FEATURES: self.sys_host.features,
ATTR_HOSTNAME: self.sys_host.info.hostname,
ATTR_KERNEL: self.sys_host.info.kernel,
ATTR_OPERATING_SYSTEM: self.sys_host.info.operating_system,
@@ -73,7 +75,11 @@ class APIHost(CoreSysAttributes):
@api_process
def reload(self, request):
"""Reload host data."""
return asyncio.shield(self.sys_host.reload())
return asyncio.shield(
asyncio.wait(
[self.sys_host.reload(), self.sys_resolution.evaluate.evaluate_system()]
)
)
@api_process
async def services(self, request):

View File

@@ -15,6 +15,7 @@ from ..const import (
ATTR_LOGGING,
ATTR_MACHINE,
ATTR_OPERATING_SYSTEM,
ATTR_STATE,
ATTR_SUPERVISOR,
ATTR_SUPPORTED,
ATTR_SUPPORTED_ARCH,
@@ -39,9 +40,10 @@ class APIInfo(CoreSysAttributes):
ATTR_DOCKER: self.sys_docker.info.version,
ATTR_HOSTNAME: self.sys_host.info.hostname,
ATTR_OPERATING_SYSTEM: self.sys_host.info.operating_system,
ATTR_FEATURES: self.sys_host.supported_features,
ATTR_FEATURES: self.sys_host.features,
ATTR_MACHINE: self.sys_machine,
ATTR_ARCH: self.sys_arch.default,
ATTR_STATE: self.sys_core.state,
ATTR_SUPPORTED_ARCH: self.sys_arch.supported,
ATTR_SUPPORTED: self.sys_core.supported,
ATTR_CHANNEL: self.sys_updater.channel,

View File

@@ -12,6 +12,7 @@ from aiohttp.web_exceptions import (
HTTPUnauthorized,
)
from multidict import CIMultiDict, istr
import voluptuous as vol
from ..addons.addon import Addon
from ..const import (
@@ -27,10 +28,12 @@ from ..const import (
REQUEST_FROM,
)
from ..coresys import CoreSysAttributes
from .utils import api_process
from .utils import api_process, api_validate
_LOGGER: logging.Logger = logging.getLogger(__name__)
VALIDATE_SESSION_DATA = vol.Schema({ATTR_SESSION: str})
class APIIngress(CoreSysAttributes):
"""Ingress view to handle add-on webui routing."""
@@ -78,6 +81,18 @@ class APIIngress(CoreSysAttributes):
session = self.sys_ingress.create_session()
return {ATTR_SESSION: session}
@api_process
async def validate_session(self, request: web.Request) -> Dict[str, Any]:
"""Validate session and extending how long it's valid for."""
self._check_ha_access(request)
data = await api_validate(VALIDATE_SESSION_DATA, request)
# Check Ingress Session
if not self.sys_ingress.validate_session(data[ATTR_SESSION]):
_LOGGER.warning("No valid ingress session %s", data[ATTR_SESSION])
raise HTTPUnauthorized()
async def handler(
self, request: web.Request
) -> Union[web.Response, web.StreamResponse, web.WebSocketResponse]:

42
supervisor/api/jobs.py Normal file
View File

@@ -0,0 +1,42 @@
"""Init file for Supervisor Jobs RESTful API."""
import logging
from typing import Any, Dict
from aiohttp import web
import voluptuous as vol
from ..coresys import CoreSysAttributes
from ..jobs.const import ATTR_IGNORE_CONDITIONS, JobCondition
from .utils import api_process, api_validate
_LOGGER: logging.Logger = logging.getLogger(__name__)
SCHEMA_OPTIONS = vol.Schema(
{vol.Optional(ATTR_IGNORE_CONDITIONS): [vol.Coerce(JobCondition)]}
)
class APIJobs(CoreSysAttributes):
"""Handle RESTful API for OS functions."""
@api_process
async def info(self, request: web.Request) -> Dict[str, Any]:
"""Return JobManager information."""
return {
ATTR_IGNORE_CONDITIONS: self.sys_jobs.ignore_conditions,
}
@api_process
async def options(self, request: web.Request) -> None:
"""Set options for JobManager."""
body = await api_validate(SCHEMA_OPTIONS, request)
if ATTR_IGNORE_CONDITIONS in body:
self.sys_jobs.ignore_conditions = body[ATTR_IGNORE_CONDITIONS]
self.sys_jobs.save_data()
@api_process
async def reset(self, request: web.Request) -> None:
"""Reset options for JobManager."""
self.sys_jobs.reset_data()

View File

@@ -15,6 +15,7 @@ from ..const import (
ATTR_MEMORY_USAGE,
ATTR_NETWORK_RX,
ATTR_NETWORK_TX,
ATTR_UPDATE_AVAILABLE,
ATTR_VERSION,
ATTR_VERSION_LATEST,
CONTENT_TYPE_BINARY,
@@ -38,6 +39,7 @@ class APIMulticast(CoreSysAttributes):
return {
ATTR_VERSION: self.sys_plugins.multicast.version,
ATTR_VERSION_LATEST: self.sys_plugins.multicast.latest_version,
ATTR_UPDATE_AVAILABLE: self.sys_plugins.multicast.need_update,
}
@api_process

View File

@@ -1,98 +1,282 @@
"""REST API for network."""
import asyncio
from typing import Any, Dict
from ipaddress import ip_address, ip_interface
from typing import Any, Awaitable, Dict
from aiohttp import web
import attr
import voluptuous as vol
from ..const import (
ATTR_ACCESSPOINTS,
ATTR_ADDRESS,
ATTR_AUTH,
ATTR_CONNECTED,
ATTR_DNS,
ATTR_DOCKER,
ATTR_ENABLED,
ATTR_FREQUENCY,
ATTR_GATEWAY,
ATTR_HOST_INTERNET,
ATTR_ID,
ATTR_INTERFACE,
ATTR_INTERFACES,
ATTR_IP_ADDRESS,
ATTR_IPV4,
ATTR_IPV6,
ATTR_MAC,
ATTR_METHOD,
ATTR_METHODS,
ATTR_MODE,
ATTR_NAMESERVERS,
ATTR_PARENT,
ATTR_PRIMARY,
ATTR_PSK,
ATTR_SIGNAL,
ATTR_SSID,
ATTR_SUPERVISOR_INTERNET,
ATTR_TYPE,
ATTR_VLAN,
ATTR_WIFI,
DOCKER_NETWORK,
DOCKER_NETWORK_MASK,
)
from ..coresys import CoreSysAttributes
from ..dbus.const import InterfaceMethodSimple
from ..dbus.network.interface import NetworkInterface
from ..dbus.network.utils import int2ip
from ..exceptions import APIError
from ..exceptions import APIError, HostNetworkNotFound
from ..host.const import AuthMethod, InterfaceType, WifiMode
from ..host.network import (
AccessPoint,
Interface,
InterfaceMethod,
IpConfig,
VlanConfig,
WifiConfig,
)
from .utils import api_process, api_validate
SCHEMA_UPDATE = vol.Schema(
_SCHEMA_IP_CONFIG = vol.Schema(
{
vol.Optional(ATTR_ADDRESS): vol.Coerce(str),
vol.Optional(ATTR_METHOD): vol.In(ATTR_METHODS),
vol.Optional(ATTR_GATEWAY): vol.Coerce(str),
vol.Optional(ATTR_DNS): [str],
vol.Optional(ATTR_ADDRESS): [vol.Coerce(ip_interface)],
vol.Optional(ATTR_METHOD): vol.Coerce(InterfaceMethod),
vol.Optional(ATTR_GATEWAY): vol.Coerce(ip_address),
vol.Optional(ATTR_NAMESERVERS): [vol.Coerce(ip_address)],
}
)
_SCHEMA_WIFI_CONFIG = vol.Schema(
{
vol.Optional(ATTR_MODE): vol.Coerce(WifiMode),
vol.Optional(ATTR_AUTH): vol.Coerce(AuthMethod),
vol.Optional(ATTR_SSID): str,
vol.Optional(ATTR_PSK): str,
}
)
def interface_information(interface: NetworkInterface) -> dict:
# pylint: disable=no-value-for-parameter
SCHEMA_UPDATE = vol.Schema(
{
vol.Optional(ATTR_IPV4): _SCHEMA_IP_CONFIG,
vol.Optional(ATTR_IPV6): _SCHEMA_IP_CONFIG,
vol.Optional(ATTR_WIFI): _SCHEMA_WIFI_CONFIG,
vol.Optional(ATTR_ENABLED): vol.Boolean(),
}
)
def ipconfig_struct(config: IpConfig) -> Dict[str, Any]:
"""Return a dict with information about ip configuration."""
return {
ATTR_METHOD: config.method,
ATTR_ADDRESS: [address.with_prefixlen for address in config.address],
ATTR_NAMESERVERS: [str(address) for address in config.nameservers],
ATTR_GATEWAY: str(config.gateway) if config.gateway else None,
}
def wifi_struct(config: WifiConfig) -> Dict[str, Any]:
"""Return a dict with information about wifi configuration."""
return {
ATTR_MODE: config.mode,
ATTR_AUTH: config.auth,
ATTR_SSID: config.ssid,
ATTR_SIGNAL: config.signal,
}
def vlan_struct(config: VlanConfig) -> Dict[str, Any]:
"""Return a dict with information about VLAN configuration."""
return {
ATTR_ID: config.id,
ATTR_PARENT: config.interface,
}
def interface_struct(interface: Interface) -> Dict[str, Any]:
"""Return a dict with information of a interface to be used in th API."""
return {
ATTR_IP_ADDRESS: f"{interface.ip_address}/{interface.prefix}",
ATTR_GATEWAY: interface.gateway,
ATTR_ID: interface.id,
ATTR_INTERFACE: interface.name,
ATTR_TYPE: interface.type,
ATTR_NAMESERVERS: [int2ip(x) for x in interface.nameservers],
ATTR_METHOD: InterfaceMethodSimple.DHCP
if interface.method == "auto"
else InterfaceMethodSimple.STATIC,
ATTR_ENABLED: interface.enabled,
ATTR_CONNECTED: interface.connected,
ATTR_PRIMARY: interface.primary,
ATTR_IPV4: ipconfig_struct(interface.ipv4) if interface.ipv4 else None,
ATTR_IPV6: ipconfig_struct(interface.ipv6) if interface.ipv6 else None,
ATTR_WIFI: wifi_struct(interface.wifi) if interface.wifi else None,
ATTR_VLAN: vlan_struct(interface.vlan) if interface.vlan else None,
}
def accesspoint_struct(accesspoint: AccessPoint) -> Dict[str, Any]:
"""Return a dict for AccessPoint."""
return {
ATTR_MODE: accesspoint.mode,
ATTR_SSID: accesspoint.ssid,
ATTR_FREQUENCY: accesspoint.frequency,
ATTR_SIGNAL: accesspoint.signal,
ATTR_MAC: accesspoint.mac,
}
class APINetwork(CoreSysAttributes):
"""Handle REST API for network."""
def _get_interface(self, name: str) -> Interface:
"""Get Interface by name or default."""
name = name.lower()
if name == "default":
for interface in self.sys_host.network.interfaces:
if not interface.primary:
continue
return interface
else:
try:
return self.sys_host.network.get(name)
except HostNetworkNotFound:
pass
raise APIError(f"Interface {name} does not exist") from None
@api_process
async def info(self, request: web.Request) -> Dict[str, Any]:
"""Return network information."""
interfaces = {}
for interface in self.sys_host.network.interfaces:
interfaces[
self.sys_host.network.interfaces[interface].name
] = interface_information(self.sys_host.network.interfaces[interface])
return {ATTR_INTERFACES: interfaces}
return {
ATTR_INTERFACES: [
interface_struct(interface)
for interface in self.sys_host.network.interfaces
],
ATTR_DOCKER: {
ATTR_INTERFACE: DOCKER_NETWORK,
ATTR_ADDRESS: str(DOCKER_NETWORK_MASK),
ATTR_GATEWAY: str(self.sys_docker.network.gateway),
ATTR_DNS: str(self.sys_docker.network.dns),
},
ATTR_HOST_INTERNET: self.sys_host.network.connectivity,
ATTR_SUPERVISOR_INTERNET: self.sys_supervisor.connectivity,
}
@api_process
async def interface_info(self, request: web.Request) -> Dict[str, Any]:
"""Return network information for a interface."""
req_interface = request.match_info.get(ATTR_INTERFACE)
for interface in self.sys_host.network.interfaces:
if req_interface == self.sys_host.network.interfaces[interface].name:
return interface_information(
self.sys_host.network.interfaces[interface]
)
interface = self._get_interface(request.match_info.get(ATTR_INTERFACE))
return {}
return interface_struct(interface)
@api_process
async def interface_update(self, request: web.Request) -> Dict[str, Any]:
async def interface_update(self, request: web.Request) -> None:
"""Update the configuration of an interface."""
req_interface = request.match_info.get(ATTR_INTERFACE)
interface = self._get_interface(request.match_info.get(ATTR_INTERFACE))
if not self.sys_host.network.interfaces.get(req_interface):
raise APIError(f"Interface {req_interface} does not exsist")
args = await api_validate(SCHEMA_UPDATE, request)
if not args:
# Validate data
body = await api_validate(SCHEMA_UPDATE, request)
if not body:
raise APIError("You need to supply at least one option to update")
await asyncio.shield(
self.sys_host.network.interfaces[req_interface].update_settings(**args)
# Apply config
for key, config in body.items():
if key == ATTR_IPV4:
interface.ipv4 = attr.evolve(
interface.ipv4 or IpConfig(InterfaceMethod.STATIC, [], None, []),
**config,
)
elif key == ATTR_IPV6:
interface.ipv6 = attr.evolve(
interface.ipv6 or IpConfig(InterfaceMethod.STATIC, [], None, []),
**config,
)
elif key == ATTR_WIFI:
interface.wifi = attr.evolve(
interface.wifi
or WifiConfig(
WifiMode.INFRASTRUCTURE, "", AuthMethod.OPEN, None, None
),
**config,
)
elif key == ATTR_ENABLED:
interface.enabled = config
await asyncio.shield(self.sys_host.network.apply_changes(interface))
@api_process
def reload(self, request: web.Request) -> Awaitable[None]:
"""Reload network data."""
return asyncio.shield(self.sys_host.network.update())
@api_process
async def scan_accesspoints(self, request: web.Request) -> Dict[str, Any]:
"""Scan and return a list of available networks."""
interface = self._get_interface(request.match_info.get(ATTR_INTERFACE))
# Only wlan is supported
if interface.type != InterfaceType.WIRELESS:
raise APIError(f"Interface {interface.name} is not a valid wireless card!")
ap_list = await self.sys_host.network.scan_wifi(interface)
return {ATTR_ACCESSPOINTS: [accesspoint_struct(ap) for ap in ap_list]}
@api_process
async def create_vlan(self, request: web.Request) -> None:
"""Create a new vlan."""
interface = self._get_interface(request.match_info.get(ATTR_INTERFACE))
vlan = int(request.match_info.get(ATTR_VLAN))
# Only ethernet is supported
if interface.type != InterfaceType.ETHERNET:
raise APIError(
f"Interface {interface.name} is not a valid ethernet card for vlan!"
)
body = await api_validate(SCHEMA_UPDATE, request)
vlan_config = VlanConfig(vlan, interface.name)
ipv4_config = None
if ATTR_IPV4 in body:
ipv4_config = IpConfig(
body[ATTR_IPV4].get(ATTR_METHOD, InterfaceMethod.AUTO),
body[ATTR_IPV4].get(ATTR_ADDRESS, []),
body[ATTR_IPV4].get(ATTR_GATEWAY, None),
body[ATTR_IPV4].get(ATTR_NAMESERVERS, []),
)
ipv6_config = None
if ATTR_IPV6 in body:
ipv6_config = IpConfig(
body[ATTR_IPV6].get(ATTR_METHOD, InterfaceMethod.AUTO),
body[ATTR_IPV6].get(ATTR_ADDRESS, []),
body[ATTR_IPV6].get(ATTR_GATEWAY, None),
body[ATTR_IPV6].get(ATTR_NAMESERVERS, []),
)
vlan_interface = Interface(
"",
True,
True,
False,
InterfaceType.VLAN,
ipv4_config,
ipv6_config,
None,
vlan_config,
)
await asyncio.shield(self.sys_host.reload())
return await asyncio.shield(self.interface_info(request))
await asyncio.shield(self.sys_host.network.apply_changes(vlan_interface))

View File

@@ -16,6 +16,7 @@ from ..const import (
ATTR_MEMORY_USAGE,
ATTR_NETWORK_RX,
ATTR_NETWORK_TX,
ATTR_UPDATE_AVAILABLE,
ATTR_VERSION,
ATTR_VERSION_LATEST,
)
@@ -38,6 +39,7 @@ class APIObserver(CoreSysAttributes):
ATTR_HOST: str(self.sys_docker.network.observer),
ATTR_VERSION: self.sys_plugins.observer.version,
ATTR_VERSION_LATEST: self.sys_plugins.observer.latest_version,
ATTR_UPDATE_AVAILABLE: self.sys_plugins.observer.need_update,
}
@api_process

View File

@@ -6,7 +6,13 @@ from typing import Any, Awaitable, Dict
from aiohttp import web
import voluptuous as vol
from ..const import ATTR_BOARD, ATTR_BOOT, ATTR_VERSION, ATTR_VERSION_LATEST
from ..const import (
ATTR_BOARD,
ATTR_BOOT,
ATTR_UPDATE_AVAILABLE,
ATTR_VERSION,
ATTR_VERSION_LATEST,
)
from ..coresys import CoreSysAttributes
from ..validate import version_tag
from .utils import api_process, api_validate
@@ -25,6 +31,7 @@ class APIOS(CoreSysAttributes):
return {
ATTR_VERSION: self.sys_hassos.version,
ATTR_VERSION_LATEST: self.sys_hassos.latest_version,
ATTR_UPDATE_AVAILABLE: self.sys_hassos.need_update,
ATTR_BOARD: self.sys_hassos.board,
ATTR_BOOT: self.sys_dbus.rauc.boot_slot,
}

View File

@@ -1,9 +1,9 @@
try {
new Function("import('/api/hassio/app/frontend_latest/entrypoint.4fa1b377.js')")();
new Function("import('/api/hassio/app/frontend_latest/entrypoint.639ed35e.js')")();
} catch (err) {
var el = document.createElement('script');
el.src = '/api/hassio/app/frontend_es5/entrypoint.3608315c.js';
el.src = '/api/hassio/app/frontend_es5/entrypoint.054b9d8c.js';
document.body.appendChild(el);
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
{"version":3,"file":"chunk.02b49ce508473d982594.js","sources":["webpack:///chunk.02b49ce508473d982594.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
{"version":3,"file":"chunk.07342fc3f773b069bbb2.js","sources":["webpack:///chunk.07342fc3f773b069bbb2.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.114930542eafd429baaa.js","sources":["webpack://home-assistant-frontend/chunk.114930542eafd429baaa.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.1274df0d4f9b61110840.js","sources":["webpack://home-assistant-frontend/chunk.1274df0d4f9b61110840.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.23709353009814f6ec3d.js","sources":["webpack://home-assistant-frontend/chunk.23709353009814f6ec3d.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.3a2a2f6b4ddd0c4883f8.js","sources":["webpack://home-assistant-frontend/chunk.3a2a2f6b4ddd0c4883f8.js"],"mappings":";AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.3daef259cd4ead95b329.js","sources":["webpack://home-assistant-frontend/chunk.3daef259cd4ead95b329.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.42d4a155d238b5760bd6.js","sources":["webpack://home-assistant-frontend/chunk.42d4a155d238b5760bd6.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
{"version":3,"file":"chunk.446a0fe8bcfde43ba5b8.js","sources":["webpack:///chunk.446a0fe8bcfde43ba5b8.js"],"mappings":"AAAA","sourceRoot":""}

View File

@@ -1,2 +0,0 @@
(self.webpackJsonp=self.webpackJsonp||[]).push([[1],{176:function(e,r,n){"use strict";n.r(r),n.d(r,"codeMirror",(function(){return c})),n.d(r,"codeMirrorCss",(function(){return i}));var a=n(165),o=n.n(a),s=n(172),t=(n(173),n(174),n(11));o.a.commands.save=function(e){Object(t.a)(e.getWrapperElement(),"editor-save")};var c=o.a,i=s.a}}]);
//# sourceMappingURL=chunk.4d5a693ebe9a164ef588.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"chunk.4d5a693ebe9a164ef588.js","sources":["webpack:///chunk.4d5a693ebe9a164ef588.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.66a403e06c27cd823e0b.js","sources":["webpack://home-assistant-frontend/chunk.66a403e06c27cd823e0b.js"],"mappings":"AAAA","sourceRoot":""}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

View File

@@ -0,0 +1 @@
{"version":3,"file":"chunk.69339833f81fc6a02f8b.js","sources":["webpack://home-assistant-frontend/chunk.69339833f81fc6a02f8b.js"],"mappings":";AAAA","sourceRoot":""}

Some files were not shown because too many files have changed in this diff Show More