mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-25 18:16:32 +00:00
commit
6aad966c52
39
API.md
39
API.md
@ -368,7 +368,6 @@ Trigger an udev reload
|
|||||||
"machine": "Image machine type",
|
"machine": "Image machine type",
|
||||||
"ip_address": "ip address",
|
"ip_address": "ip address",
|
||||||
"image": "str",
|
"image": "str",
|
||||||
"custom": "bool -> if custom image",
|
|
||||||
"boot": "bool",
|
"boot": "bool",
|
||||||
"port": 8123,
|
"port": 8123,
|
||||||
"ssl": "bool",
|
"ssl": "bool",
|
||||||
@ -936,6 +935,44 @@ return:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Multicast
|
||||||
|
|
||||||
|
- GET `/multicast/info`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "1",
|
||||||
|
"version_latest": "2"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- POST `/multicast/update`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "VERSION"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- POST `/multicast/restart`
|
||||||
|
|
||||||
|
- GET `/multicast/logs`
|
||||||
|
|
||||||
|
- GET `/multicast/stats`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"cpu_percent": 0.0,
|
||||||
|
"memory_usage": 283123,
|
||||||
|
"memory_limit": 329392,
|
||||||
|
"memory_percent": 1.4,
|
||||||
|
"network_tx": 0,
|
||||||
|
"network_rx": 0,
|
||||||
|
"blk_read": 0,
|
||||||
|
"blk_write": 0
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Auth / SSO API
|
### Auth / SSO API
|
||||||
|
|
||||||
You can use the user system on homeassistant. We handle this auth system on
|
You can use the user system on homeassistant. We handle this auth system on
|
||||||
|
811
LICENSE
811
LICENSE
@ -1,201 +1,674 @@
|
|||||||
Apache License
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2.0, January 2004
|
Version 3, 29 June 2007
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
1. Definitions.
|
Preamble
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
The GNU General Public License is a free, copyleft license for
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
software and other kinds of works.
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
The licenses for most software and other practical works are designed
|
||||||
the copyright owner that is granting the License.
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
When we speak of free software, we are referring to freedom, not
|
||||||
other entities that control, are controlled by, or are under common
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
control with that entity. For the purposes of this definition,
|
have the freedom to distribute copies of free software (and charge for
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
them if you wish), that you receive source code or can get it if you
|
||||||
direction or management of such entity, whether by contract or
|
want it, that you can change the software or use pieces of it in new
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
free programs, and that you know you can do these things.
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
To protect your rights, we need to prevent others from denying you
|
||||||
exercising permissions granted by this License.
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
For example, if you distribute copies of such a program, whether
|
||||||
including but not limited to software source code, documentation
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
source, and configuration files.
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
transformation or translation of a Source form, including but
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
not limited to compiled object code, generated documentation,
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
Object form, made available under the License, as indicated by a
|
that there is no warranty for this free software. For both users' and
|
||||||
copyright notice that is included in or attached to the work
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
(an example is provided in the Appendix below).
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
Some devices are designed to deny users access to install or run
|
||||||
form, that is based on (or derived from) the Work and for which the
|
modified versions of the software inside them, although the manufacturer
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
protecting users' freedom to change the software. The systematic
|
||||||
of this License, Derivative Works shall not include works that remain
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
the Work and Derivative Works thereof.
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
Finally, every program is threatened constantly by software patents.
|
||||||
the original version of the Work and any modifications or additions
|
States should not allow patents to restrict development and use of
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
avoid the special danger that patents applied to a free program could
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
patents cannot be used to render the program non-free.
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
The precise terms and conditions for copying, distribution and
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
modification follow.
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
TERMS AND CONDITIONS
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
0. Definitions.
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
Derivative Works a copy of this License; and
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
stating that You changed the files; and
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
that You distribute, all copyright, patent, trademark, and
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
attribution notices from the Source form of the Work,
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
excluding those notices that do not pertain to any part of
|
earlier work or a work "based on" the earlier work.
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
A "covered work" means either the unmodified Program or a work based
|
||||||
distribution, then any Derivative Works that You distribute must
|
on the Program.
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
To "propagate" a work means to do anything with it that, without
|
||||||
may provide additional or different license terms and conditions
|
permission, would make you directly or secondarily liable for
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
infringement under applicable copyright law, except executing it on a
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
distribution (with or without modification), making available to the
|
||||||
the conditions stated in this License.
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
To "convey" a work means any kind of propagation that enables other
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
to the extent that it includes a convenient and prominently visible
|
||||||
except as required for reasonable and customary use in describing the
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
1. Source Code.
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
The "source code" for a work means the preferred form of the work
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
for making modifications to it. "Object code" means any non-source
|
||||||
unless required by applicable law (such as deliberate and grossly
|
form of a work.
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
A "Standard Interface" means an interface that either is an official
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
standard defined by a recognized standards body, or, in the case of
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
interfaces specified for a particular programming language, one that
|
||||||
or other liability obligations and/or rights consistent with this
|
is widely used among developers working in that language.
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
The Corresponding Source need not include anything that users
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
can regenerate automatically from other parts of the Corresponding
|
||||||
replaced with your own identifying information. (Don't include
|
Source.
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright 2017 Pascal Vizeli
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
2. Basic Permissions.
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
You may make, run and propagate covered works that you do not
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
convey, without conditions so long as your license otherwise remains
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
in force. You may convey covered works to others for the sole purpose
|
||||||
See the License for the specific language governing permissions and
|
of having them make modifications exclusively for you, or provide you
|
||||||
limitations under the License.
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit ddb525f6cdee0206b7d82c3133f888b1a383f90c
|
Subproject commit ebb20abee0b3b227974684116ea2207d9ad33856
|
@ -4,7 +4,7 @@ attrs==19.3.0
|
|||||||
cchardet==2.1.6
|
cchardet==2.1.6
|
||||||
colorlog==4.1.0
|
colorlog==4.1.0
|
||||||
cpe==1.2.1
|
cpe==1.2.1
|
||||||
cryptography==2.8
|
cryptography==2.9
|
||||||
docker==4.2.0
|
docker==4.2.0
|
||||||
gitpython==3.1.0
|
gitpython==3.1.0
|
||||||
jinja2==2.11.1
|
jinja2==2.11.1
|
||||||
|
@ -96,7 +96,7 @@ function setup_test_env() {
|
|||||||
-e SUPERVISOR_SHARE="/workspaces/test_supervisor" \
|
-e SUPERVISOR_SHARE="/workspaces/test_supervisor" \
|
||||||
-e SUPERVISOR_NAME=hassio_supervisor \
|
-e SUPERVISOR_NAME=hassio_supervisor \
|
||||||
-e SUPERVISOR_DEV=1 \
|
-e SUPERVISOR_DEV=1 \
|
||||||
-e HOMEASSISTANT_REPOSITORY="homeassistant/qemux86-64-homeassistant" \
|
-e SUPERVISOR_MACHINE="qemux86-64" \
|
||||||
homeassistant/amd64-hassio-supervisor:latest
|
homeassistant/amd64-hassio-supervisor:latest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1
setup.py
1
setup.py
@ -37,6 +37,7 @@ setup(
|
|||||||
"supervisor.api",
|
"supervisor.api",
|
||||||
"supervisor.misc",
|
"supervisor.misc",
|
||||||
"supervisor.utils",
|
"supervisor.utils",
|
||||||
|
"supervisor.plugins",
|
||||||
"supervisor.snapshots",
|
"supervisor.snapshots",
|
||||||
],
|
],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
@ -325,10 +325,10 @@ class AddonManager(CoreSysAttributes):
|
|||||||
for addon in self.installed:
|
for addon in self.installed:
|
||||||
if not await addon.instance.is_running():
|
if not await addon.instance.is_running():
|
||||||
continue
|
continue
|
||||||
self.sys_dns.add_host(
|
self.sys_plugins.dns.add_host(
|
||||||
ipv4=addon.ip_address, names=[addon.hostname], write=False
|
ipv4=addon.ip_address, names=[addon.hostname], write=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# Write hosts files
|
# Write hosts files
|
||||||
with suppress(CoreDNSError):
|
with suppress(CoreDNSError):
|
||||||
self.sys_dns.write_hosts()
|
self.sys_plugins.dns.write_hosts()
|
||||||
|
@ -389,7 +389,7 @@ class Addon(AddonModel):
|
|||||||
|
|
||||||
def write_pulse(self):
|
def write_pulse(self):
|
||||||
"""Write asound config to file and return True on success."""
|
"""Write asound config to file and return True on success."""
|
||||||
pulse_config = self.sys_audio.pulse_client(
|
pulse_config = self.sys_plugins.audio.pulse_client(
|
||||||
input_profile=self.audio_input, output_profile=self.audio_output
|
input_profile=self.audio_input, output_profile=self.audio_output
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ from .security import SecurityMiddleware
|
|||||||
from .services import APIServices
|
from .services import APIServices
|
||||||
from .snapshots import APISnapshots
|
from .snapshots import APISnapshots
|
||||||
from .supervisor import APISupervisor
|
from .supervisor import APISupervisor
|
||||||
|
from .multicast import APIMulticast
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ class RestAPI(CoreSysAttributes):
|
|||||||
self._register_host()
|
self._register_host()
|
||||||
self._register_os()
|
self._register_os()
|
||||||
self._register_cli()
|
self._register_cli()
|
||||||
|
self._register_multicast()
|
||||||
self._register_hardware()
|
self._register_hardware()
|
||||||
self._register_homeassistant()
|
self._register_homeassistant()
|
||||||
self._register_proxy()
|
self._register_proxy()
|
||||||
@ -113,6 +115,21 @@ class RestAPI(CoreSysAttributes):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _register_multicast(self) -> None:
|
||||||
|
"""Register Multicast functions."""
|
||||||
|
api_multicast = APIMulticast()
|
||||||
|
api_multicast.coresys = self.coresys
|
||||||
|
|
||||||
|
self.webapp.add_routes(
|
||||||
|
[
|
||||||
|
web.get("/multicast/info", api_multicast.info),
|
||||||
|
web.get("/multicast/stats", api_multicast.stats),
|
||||||
|
web.get("/multicast/logs", api_multicast.logs),
|
||||||
|
web.post("/multicast/update", api_multicast.update),
|
||||||
|
web.post("/multicast/restart", api_multicast.restart),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
def _register_hardware(self) -> None:
|
def _register_hardware(self) -> None:
|
||||||
"""Register hardware functions."""
|
"""Register hardware functions."""
|
||||||
api_hardware = APIHardware()
|
api_hardware = APIHardware()
|
||||||
|
@ -68,8 +68,8 @@ class APIAudio(CoreSysAttributes):
|
|||||||
async def info(self, request: web.Request) -> Dict[str, Any]:
|
async def info(self, request: web.Request) -> Dict[str, Any]:
|
||||||
"""Return Audio information."""
|
"""Return Audio information."""
|
||||||
return {
|
return {
|
||||||
ATTR_VERSION: self.sys_audio.version,
|
ATTR_VERSION: self.sys_plugins.audio.version,
|
||||||
ATTR_VERSION_LATEST: self.sys_audio.latest_version,
|
ATTR_VERSION_LATEST: self.sys_plugins.audio.latest_version,
|
||||||
ATTR_HOST: str(self.sys_docker.network.audio),
|
ATTR_HOST: str(self.sys_docker.network.audio),
|
||||||
ATTR_AUDIO: {
|
ATTR_AUDIO: {
|
||||||
ATTR_CARD: [attr.asdict(card) for card in self.sys_host.sound.cards],
|
ATTR_CARD: [attr.asdict(card) for card in self.sys_host.sound.cards],
|
||||||
@ -88,7 +88,7 @@ class APIAudio(CoreSysAttributes):
|
|||||||
@api_process
|
@api_process
|
||||||
async def stats(self, request: web.Request) -> Dict[str, Any]:
|
async def stats(self, request: web.Request) -> Dict[str, Any]:
|
||||||
"""Return resource information."""
|
"""Return resource information."""
|
||||||
stats = await self.sys_audio.stats()
|
stats = await self.sys_plugins.audio.stats()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ATTR_CPU_PERCENT: stats.cpu_percent,
|
ATTR_CPU_PERCENT: stats.cpu_percent,
|
||||||
@ -105,21 +105,21 @@ class APIAudio(CoreSysAttributes):
|
|||||||
async def update(self, request: web.Request) -> None:
|
async def update(self, request: web.Request) -> None:
|
||||||
"""Update Audio plugin."""
|
"""Update Audio plugin."""
|
||||||
body = await api_validate(SCHEMA_VERSION, request)
|
body = await api_validate(SCHEMA_VERSION, request)
|
||||||
version = body.get(ATTR_VERSION, self.sys_audio.latest_version)
|
version = body.get(ATTR_VERSION, self.sys_plugins.audio.latest_version)
|
||||||
|
|
||||||
if version == self.sys_audio.version:
|
if version == self.sys_plugins.audio.version:
|
||||||
raise APIError("Version {} is already in use".format(version))
|
raise APIError("Version {} is already in use".format(version))
|
||||||
await asyncio.shield(self.sys_audio.update(version))
|
await asyncio.shield(self.sys_plugins.audio.update(version))
|
||||||
|
|
||||||
@api_process_raw(CONTENT_TYPE_BINARY)
|
@api_process_raw(CONTENT_TYPE_BINARY)
|
||||||
def logs(self, request: web.Request) -> Awaitable[bytes]:
|
def logs(self, request: web.Request) -> Awaitable[bytes]:
|
||||||
"""Return Audio Docker logs."""
|
"""Return Audio Docker logs."""
|
||||||
return self.sys_audio.logs()
|
return self.sys_plugins.audio.logs()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
def restart(self, request: web.Request) -> Awaitable[None]:
|
def restart(self, request: web.Request) -> Awaitable[None]:
|
||||||
"""Restart Audio plugin."""
|
"""Restart Audio plugin."""
|
||||||
return asyncio.shield(self.sys_audio.restart())
|
return asyncio.shield(self.sys_plugins.audio.restart())
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
def reload(self, request: web.Request) -> Awaitable[None]:
|
def reload(self, request: web.Request) -> Awaitable[None]:
|
||||||
|
@ -33,14 +33,14 @@ class APICli(CoreSysAttributes):
|
|||||||
async def info(self, request: web.Request) -> Dict[str, Any]:
|
async def info(self, request: web.Request) -> Dict[str, Any]:
|
||||||
"""Return HA cli information."""
|
"""Return HA cli information."""
|
||||||
return {
|
return {
|
||||||
ATTR_VERSION: self.sys_cli.version,
|
ATTR_VERSION: self.sys_plugins.cli.version,
|
||||||
ATTR_VERSION_LATEST: self.sys_cli.latest_version,
|
ATTR_VERSION_LATEST: self.sys_plugins.cli.latest_version,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def stats(self, request: web.Request) -> Dict[str, Any]:
|
async def stats(self, request: web.Request) -> Dict[str, Any]:
|
||||||
"""Return resource information."""
|
"""Return resource information."""
|
||||||
stats = await self.sys_cli.stats()
|
stats = await self.sys_plugins.cli.stats()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ATTR_CPU_PERCENT: stats.cpu_percent,
|
ATTR_CPU_PERCENT: stats.cpu_percent,
|
||||||
@ -57,6 +57,6 @@ class APICli(CoreSysAttributes):
|
|||||||
async def update(self, request: web.Request) -> None:
|
async def update(self, request: web.Request) -> None:
|
||||||
"""Update HA CLI."""
|
"""Update HA CLI."""
|
||||||
body = await api_validate(SCHEMA_VERSION, request)
|
body = await api_validate(SCHEMA_VERSION, request)
|
||||||
version = body.get(ATTR_VERSION, self.sys_cli.latest_version)
|
version = body.get(ATTR_VERSION, self.sys_plugins.cli.latest_version)
|
||||||
|
|
||||||
await asyncio.shield(self.sys_cli.update(version))
|
await asyncio.shield(self.sys_plugins.cli.update(version))
|
||||||
|
@ -42,10 +42,10 @@ class APICoreDNS(CoreSysAttributes):
|
|||||||
async def info(self, request: web.Request) -> Dict[str, Any]:
|
async def info(self, request: web.Request) -> Dict[str, Any]:
|
||||||
"""Return DNS information."""
|
"""Return DNS information."""
|
||||||
return {
|
return {
|
||||||
ATTR_VERSION: self.sys_dns.version,
|
ATTR_VERSION: self.sys_plugins.dns.version,
|
||||||
ATTR_VERSION_LATEST: self.sys_dns.latest_version,
|
ATTR_VERSION_LATEST: self.sys_plugins.dns.latest_version,
|
||||||
ATTR_HOST: str(self.sys_docker.network.dns),
|
ATTR_HOST: str(self.sys_docker.network.dns),
|
||||||
ATTR_SERVERS: self.sys_dns.servers,
|
ATTR_SERVERS: self.sys_plugins.dns.servers,
|
||||||
ATTR_LOCALS: self.sys_host.network.dns_servers,
|
ATTR_LOCALS: self.sys_host.network.dns_servers,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,15 +55,15 @@ class APICoreDNS(CoreSysAttributes):
|
|||||||
body = await api_validate(SCHEMA_OPTIONS, request)
|
body = await api_validate(SCHEMA_OPTIONS, request)
|
||||||
|
|
||||||
if ATTR_SERVERS in body:
|
if ATTR_SERVERS in body:
|
||||||
self.sys_dns.servers = body[ATTR_SERVERS]
|
self.sys_plugins.dns.servers = body[ATTR_SERVERS]
|
||||||
self.sys_create_task(self.sys_dns.restart())
|
self.sys_create_task(self.sys_plugins.dns.restart())
|
||||||
|
|
||||||
self.sys_dns.save_data()
|
self.sys_plugins.dns.save_data()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def stats(self, request: web.Request) -> Dict[str, Any]:
|
async def stats(self, request: web.Request) -> Dict[str, Any]:
|
||||||
"""Return resource information."""
|
"""Return resource information."""
|
||||||
stats = await self.sys_dns.stats()
|
stats = await self.sys_plugins.dns.stats()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ATTR_CPU_PERCENT: stats.cpu_percent,
|
ATTR_CPU_PERCENT: stats.cpu_percent,
|
||||||
@ -80,23 +80,23 @@ class APICoreDNS(CoreSysAttributes):
|
|||||||
async def update(self, request: web.Request) -> None:
|
async def update(self, request: web.Request) -> None:
|
||||||
"""Update DNS plugin."""
|
"""Update DNS plugin."""
|
||||||
body = await api_validate(SCHEMA_VERSION, request)
|
body = await api_validate(SCHEMA_VERSION, request)
|
||||||
version = body.get(ATTR_VERSION, self.sys_dns.latest_version)
|
version = body.get(ATTR_VERSION, self.sys_plugins.dns.latest_version)
|
||||||
|
|
||||||
if version == self.sys_dns.version:
|
if version == self.sys_plugins.dns.version:
|
||||||
raise APIError("Version {} is already in use".format(version))
|
raise APIError("Version {} is already in use".format(version))
|
||||||
await asyncio.shield(self.sys_dns.update(version))
|
await asyncio.shield(self.sys_plugins.dns.update(version))
|
||||||
|
|
||||||
@api_process_raw(CONTENT_TYPE_BINARY)
|
@api_process_raw(CONTENT_TYPE_BINARY)
|
||||||
def logs(self, request: web.Request) -> Awaitable[bytes]:
|
def logs(self, request: web.Request) -> Awaitable[bytes]:
|
||||||
"""Return DNS Docker logs."""
|
"""Return DNS Docker logs."""
|
||||||
return self.sys_dns.logs()
|
return self.sys_plugins.dns.logs()
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
def restart(self, request: web.Request) -> Awaitable[None]:
|
def restart(self, request: web.Request) -> Awaitable[None]:
|
||||||
"""Restart CoreDNS plugin."""
|
"""Restart CoreDNS plugin."""
|
||||||
return asyncio.shield(self.sys_dns.restart())
|
return asyncio.shield(self.sys_plugins.dns.restart())
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
def reset(self, request: web.Request) -> Awaitable[None]:
|
def reset(self, request: web.Request) -> Awaitable[None]:
|
||||||
"""Reset CoreDNS plugin."""
|
"""Reset CoreDNS plugin."""
|
||||||
return asyncio.shield(self.sys_dns.reset())
|
return asyncio.shield(self.sys_plugins.dns.reset())
|
||||||
|
@ -14,10 +14,8 @@ from ..const import (
|
|||||||
ATTR_BLK_WRITE,
|
ATTR_BLK_WRITE,
|
||||||
ATTR_BOOT,
|
ATTR_BOOT,
|
||||||
ATTR_CPU_PERCENT,
|
ATTR_CPU_PERCENT,
|
||||||
ATTR_CUSTOM,
|
|
||||||
ATTR_IMAGE,
|
ATTR_IMAGE,
|
||||||
ATTR_IP_ADDRESS,
|
ATTR_IP_ADDRESS,
|
||||||
ATTR_VERSION_LATEST,
|
|
||||||
ATTR_MACHINE,
|
ATTR_MACHINE,
|
||||||
ATTR_MEMORY_LIMIT,
|
ATTR_MEMORY_LIMIT,
|
||||||
ATTR_MEMORY_PERCENT,
|
ATTR_MEMORY_PERCENT,
|
||||||
@ -28,6 +26,7 @@ from ..const import (
|
|||||||
ATTR_REFRESH_TOKEN,
|
ATTR_REFRESH_TOKEN,
|
||||||
ATTR_SSL,
|
ATTR_SSL,
|
||||||
ATTR_VERSION,
|
ATTR_VERSION,
|
||||||
|
ATTR_VERSION_LATEST,
|
||||||
ATTR_WAIT_BOOT,
|
ATTR_WAIT_BOOT,
|
||||||
ATTR_WATCHDOG,
|
ATTR_WATCHDOG,
|
||||||
CONTENT_TYPE_BINARY,
|
CONTENT_TYPE_BINARY,
|
||||||
@ -43,8 +42,7 @@ _LOGGER: logging.Logger = logging.getLogger(__name__)
|
|||||||
SCHEMA_OPTIONS = vol.Schema(
|
SCHEMA_OPTIONS = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(ATTR_BOOT): vol.Boolean(),
|
vol.Optional(ATTR_BOOT): vol.Boolean(),
|
||||||
vol.Inclusive(ATTR_IMAGE, "custom_hass"): vol.Maybe(docker_image),
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
vol.Inclusive(ATTR_VERSION_LATEST, "custom_hass"): vol.Maybe(vol.Coerce(str)),
|
|
||||||
vol.Optional(ATTR_PORT): network_port,
|
vol.Optional(ATTR_PORT): network_port,
|
||||||
vol.Optional(ATTR_SSL): vol.Boolean(),
|
vol.Optional(ATTR_SSL): vol.Boolean(),
|
||||||
vol.Optional(ATTR_WATCHDOG): vol.Boolean(),
|
vol.Optional(ATTR_WATCHDOG): vol.Boolean(),
|
||||||
@ -71,7 +69,6 @@ class APIHomeAssistant(CoreSysAttributes):
|
|||||||
ATTR_IP_ADDRESS: str(self.sys_homeassistant.ip_address),
|
ATTR_IP_ADDRESS: str(self.sys_homeassistant.ip_address),
|
||||||
ATTR_ARCH: self.sys_homeassistant.arch,
|
ATTR_ARCH: self.sys_homeassistant.arch,
|
||||||
ATTR_IMAGE: self.sys_homeassistant.image,
|
ATTR_IMAGE: self.sys_homeassistant.image,
|
||||||
ATTR_CUSTOM: self.sys_homeassistant.is_custom_image,
|
|
||||||
ATTR_BOOT: self.sys_homeassistant.boot,
|
ATTR_BOOT: self.sys_homeassistant.boot,
|
||||||
ATTR_PORT: self.sys_homeassistant.api_port,
|
ATTR_PORT: self.sys_homeassistant.api_port,
|
||||||
ATTR_SSL: self.sys_homeassistant.api_ssl,
|
ATTR_SSL: self.sys_homeassistant.api_ssl,
|
||||||
@ -88,9 +85,8 @@ class APIHomeAssistant(CoreSysAttributes):
|
|||||||
"""Set Home Assistant options."""
|
"""Set Home Assistant options."""
|
||||||
body = await api_validate(SCHEMA_OPTIONS, request)
|
body = await api_validate(SCHEMA_OPTIONS, request)
|
||||||
|
|
||||||
if ATTR_IMAGE in body and ATTR_VERSION_LATEST in body:
|
if ATTR_IMAGE in body:
|
||||||
self.sys_homeassistant.image = body[ATTR_IMAGE]
|
self.sys_homeassistant.image = body[ATTR_IMAGE]
|
||||||
self.sys_homeassistant.latest_version = body[ATTR_VERSION_LATEST]
|
|
||||||
|
|
||||||
if ATTR_BOOT in body:
|
if ATTR_BOOT in body:
|
||||||
self.sys_homeassistant.boot = body[ATTR_BOOT]
|
self.sys_homeassistant.boot = body[ATTR_BOOT]
|
||||||
|
76
supervisor/api/multicast.py
Normal file
76
supervisor/api/multicast.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
"""Init file for Supervisor Multicast RESTful API."""
|
||||||
|
import asyncio
|
||||||
|
import logging
|
||||||
|
from typing import Any, Awaitable, Dict
|
||||||
|
|
||||||
|
from aiohttp import web
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from ..const import (
|
||||||
|
ATTR_BLK_READ,
|
||||||
|
ATTR_BLK_WRITE,
|
||||||
|
ATTR_CPU_PERCENT,
|
||||||
|
ATTR_VERSION_LATEST,
|
||||||
|
ATTR_MEMORY_LIMIT,
|
||||||
|
ATTR_MEMORY_PERCENT,
|
||||||
|
ATTR_MEMORY_USAGE,
|
||||||
|
ATTR_NETWORK_RX,
|
||||||
|
ATTR_NETWORK_TX,
|
||||||
|
ATTR_VERSION,
|
||||||
|
CONTENT_TYPE_BINARY,
|
||||||
|
)
|
||||||
|
from ..coresys import CoreSysAttributes
|
||||||
|
from ..exceptions import APIError
|
||||||
|
from .utils import api_process, api_process_raw, api_validate
|
||||||
|
|
||||||
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
SCHEMA_VERSION = vol.Schema({vol.Optional(ATTR_VERSION): vol.Coerce(str)})
|
||||||
|
|
||||||
|
|
||||||
|
class APIMulticast(CoreSysAttributes):
|
||||||
|
"""Handle RESTful API for Multicast functions."""
|
||||||
|
|
||||||
|
@api_process
|
||||||
|
async def info(self, request: web.Request) -> Dict[str, Any]:
|
||||||
|
"""Return Multicast information."""
|
||||||
|
return {
|
||||||
|
ATTR_VERSION: self.sys_plugins.multicast.version,
|
||||||
|
ATTR_VERSION_LATEST: self.sys_plugins.multicast.latest_version,
|
||||||
|
}
|
||||||
|
|
||||||
|
@api_process
|
||||||
|
async def stats(self, request: web.Request) -> Dict[str, Any]:
|
||||||
|
"""Return resource information."""
|
||||||
|
stats = await self.sys_plugins.multicast.stats()
|
||||||
|
|
||||||
|
return {
|
||||||
|
ATTR_CPU_PERCENT: stats.cpu_percent,
|
||||||
|
ATTR_MEMORY_USAGE: stats.memory_usage,
|
||||||
|
ATTR_MEMORY_LIMIT: stats.memory_limit,
|
||||||
|
ATTR_MEMORY_PERCENT: stats.memory_percent,
|
||||||
|
ATTR_NETWORK_RX: stats.network_rx,
|
||||||
|
ATTR_NETWORK_TX: stats.network_tx,
|
||||||
|
ATTR_BLK_READ: stats.blk_read,
|
||||||
|
ATTR_BLK_WRITE: stats.blk_write,
|
||||||
|
}
|
||||||
|
|
||||||
|
@api_process
|
||||||
|
async def update(self, request: web.Request) -> None:
|
||||||
|
"""Update Multicast plugin."""
|
||||||
|
body = await api_validate(SCHEMA_VERSION, request)
|
||||||
|
version = body.get(ATTR_VERSION, self.sys_plugins.multicast.latest_version)
|
||||||
|
|
||||||
|
if version == self.sys_plugins.multicast.version:
|
||||||
|
raise APIError("Version {} is already in use".format(version))
|
||||||
|
await asyncio.shield(self.sys_plugins.multicast.update(version))
|
||||||
|
|
||||||
|
@api_process_raw(CONTENT_TYPE_BINARY)
|
||||||
|
def logs(self, request: web.Request) -> Awaitable[bytes]:
|
||||||
|
"""Return Multicast Docker logs."""
|
||||||
|
return self.sys_plugins.multicast.logs()
|
||||||
|
|
||||||
|
@api_process
|
||||||
|
def restart(self, request: web.Request) -> Awaitable[None]:
|
||||||
|
"""Restart Multicast plugin."""
|
||||||
|
return asyncio.shield(self.sys_plugins.multicast.restart())
|
2
supervisor/api/panel/chunk.05403bc1774dc39117f6.js
Normal file
2
supervisor/api/panel/chunk.05403bc1774dc39117f6.js
Normal file
File diff suppressed because one or more lines are too long
BIN
supervisor/api/panel/chunk.05403bc1774dc39117f6.js.gz
Normal file
BIN
supervisor/api/panel/chunk.05403bc1774dc39117f6.js.gz
Normal file
Binary file not shown.
1
supervisor/api/panel/chunk.05403bc1774dc39117f6.js.map
Normal file
1
supervisor/api/panel/chunk.05403bc1774dc39117f6.js.map
Normal file
File diff suppressed because one or more lines are too long
3
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js
Normal file
3
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js
Normal file
File diff suppressed because one or more lines are too long
10
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js.LICENSE
Normal file
10
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js.LICENSE
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
@license
|
||||||
|
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||||
|
This code may only be used under the BSD style license found at
|
||||||
|
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
||||||
|
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
||||||
|
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
||||||
|
part of the polymer project is also subject to an additional IP rights grant
|
||||||
|
found at http://polymer.github.io/PATENTS.txt
|
||||||
|
*/
|
BIN
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js.gz
Normal file
BIN
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js.gz
Normal file
Binary file not shown.
1
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js.map
Normal file
1
supervisor/api/panel/chunk.d9ebbcff54094bd6592a.js.map
Normal file
File diff suppressed because one or more lines are too long
3
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js
Normal file
3
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js
Normal file
File diff suppressed because one or more lines are too long
10
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js.LICENSE
Normal file
10
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js.LICENSE
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
@license
|
||||||
|
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||||
|
This code may only be used under the BSD style license found at
|
||||||
|
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
||||||
|
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
||||||
|
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
||||||
|
part of the polymer project is also subject to an additional IP rights grant
|
||||||
|
found at http://polymer.github.io/PATENTS.txt
|
||||||
|
*/
|
BIN
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js.gz
Normal file
BIN
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js.gz
Normal file
Binary file not shown.
1
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js.map
Normal file
1
supervisor/api/panel/chunk.ec48cf4e7f87d6417353.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
|||||||
!function(e){function n(n){for(var t,o,a=n[0],i=n[1],f=0,u=[];f<a.length;f++)o=a[f],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&u.push(r[o][0]),r[o]=0;for(t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t]);for(c&&c(n);u.length;)u.shift()()}var t={},r={6:0};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.e=function(e){var n=[],t=r[e];if(0!==t)if(t)n.push(t[2]);else{var a=new Promise(function(n,o){t=r[e]=[n,o]});n.push(t[2]=a);var i,f=document.createElement("script");f.charset="utf-8",f.timeout=120,o.nc&&f.setAttribute("nonce",o.nc),f.src=function(e){return o.p+"chunk."+{0:"7ab69340d9bb40dda79e",1:"610423483939ffdbfb92",2:"ece210525014eb36073b",3:"a947da09b1ace1352383",4:"d402ad0de6ea5da0f9fc",5:"05d0c315f85f2fc8c34a",7:"b38bff4d0774d202dcad",8:"af76a4db9eb1e2862aae",9:"54be96e339b8c82764a0",10:"045f3417b78f858fff44",11:"381907f8b6a21cec010f",12:"b2dce600432c76a53d8c",13:"70a435e100109291f210",14:"594ef9f33131c4d33409",15:"7ac9df67ea34d63f8998"}[e]+".js"}(e);var c=new Error;i=function(n){f.onerror=f.onload=null,clearTimeout(u);var t=r[e];if(0!==t){if(t){var o=n&&("load"===n.type?"missing":n.type),a=n&&n.target&&n.target.src;c.message="Loading chunk "+e+" failed.\n("+o+": "+a+")",c.name="ChunkLoadError",c.type=o,c.request=a,t[1](c)}r[e]=void 0}};var u=setTimeout(function(){i({type:"timeout",target:f})},12e4);f.onerror=f.onload=i,document.head.appendChild(f)}return Promise.all(n)},o.m=e,o.c=t,o.d=function(e,n,t){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,n){if(1&n&&(e=o(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)o.d(t,r,function(n){return e[n]}.bind(null,r));return t},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="/api/hassio/app/",o.oe=function(e){throw console.error(e),e};var a=self.webpackJsonp=self.webpackJsonp||[],i=a.push.bind(a);a.push=n,a=a.slice();for(var f=0;f<a.length;f++)n(a[f]);var c=i;o(o.s=0)}([function(e,n,t){window.loadES5Adapter().then(function(){t.e(12).then(t.t.bind(null,1,7)),Promise.all([t.e(1),t.e(8)]).then(t.bind(null,3)),Promise.all([t.e(1),t.e(15),t.e(10)]).then(t.bind(null,2))});var r=document.createElement("style");r.innerHTML="\nbody {\n font-family: Roboto, sans-serif;\n -moz-osx-font-smoothing: grayscale;\n -webkit-font-smoothing: antialiased;\n font-weight: 400;\n margin: 0;\n padding: 0;\n height: 100vh;\n}\n",document.head.appendChild(r)}]);
|
!function(e){function n(n){for(var t,o,a=n[0],i=n[1],f=0,u=[];f<a.length;f++)o=a[f],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&u.push(r[o][0]),r[o]=0;for(t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t]);for(c&&c(n);u.length;)u.shift()()}var t={},r={6:0};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.e=function(e){var n=[],t=r[e];if(0!==t)if(t)n.push(t[2]);else{var a=new Promise(function(n,o){t=r[e]=[n,o]});n.push(t[2]=a);var i,f=document.createElement("script");f.charset="utf-8",f.timeout=120,o.nc&&f.setAttribute("nonce",o.nc),f.src=function(e){return o.p+"chunk."+{0:"7ab69340d9bb40dda79e",1:"610423483939ffdbfb92",2:"ece210525014eb36073b",3:"d9ebbcff54094bd6592a",4:"d402ad0de6ea5da0f9fc",5:"ec48cf4e7f87d6417353",7:"b38bff4d0774d202dcad",8:"af76a4db9eb1e2862aae",9:"54be96e339b8c82764a0",10:"05403bc1774dc39117f6",11:"381907f8b6a21cec010f",12:"b2dce600432c76a53d8c",13:"70a435e100109291f210",14:"594ef9f33131c4d33409",15:"7ac9df67ea34d63f8998"}[e]+".js"}(e);var c=new Error;i=function(n){f.onerror=f.onload=null,clearTimeout(u);var t=r[e];if(0!==t){if(t){var o=n&&("load"===n.type?"missing":n.type),a=n&&n.target&&n.target.src;c.message="Loading chunk "+e+" failed.\n("+o+": "+a+")",c.name="ChunkLoadError",c.type=o,c.request=a,t[1](c)}r[e]=void 0}};var u=setTimeout(function(){i({type:"timeout",target:f})},12e4);f.onerror=f.onload=i,document.head.appendChild(f)}return Promise.all(n)},o.m=e,o.c=t,o.d=function(e,n,t){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,n){if(1&n&&(e=o(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)o.d(t,r,function(n){return e[n]}.bind(null,r));return t},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="/api/hassio/app/",o.oe=function(e){throw console.error(e),e};var a=self.webpackJsonp=self.webpackJsonp||[],i=a.push.bind(a);a.push=n,a=a.slice();for(var f=0;f<a.length;f++)n(a[f]);var c=i;o(o.s=0)}([function(e,n,t){window.loadES5Adapter().then(function(){t.e(12).then(t.t.bind(null,1,7)),Promise.all([t.e(1),t.e(8)]).then(t.bind(null,3)),Promise.all([t.e(1),t.e(15),t.e(10)]).then(t.bind(null,2))});var r=document.createElement("style");r.innerHTML="\nbody {\n font-family: Roboto, sans-serif;\n -moz-osx-font-smoothing: grayscale;\n -webkit-font-smoothing: antialiased;\n font-weight: 400;\n margin: 0;\n padding: 0;\n height: 100vh;\n}\n",document.head.appendChild(r)}]);
|
||||||
//# sourceMappingURL=entrypoint.js.map
|
//# sourceMappingURL=entrypoint.js.map
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -5,12 +5,12 @@
|
|||||||
"vendors~hassio-icons~hassio-main.js.map": "/api/hassio/app/chunk.610423483939ffdbfb92.js.map",
|
"vendors~hassio-icons~hassio-main.js.map": "/api/hassio/app/chunk.610423483939ffdbfb92.js.map",
|
||||||
"codemirror.js": "/api/hassio/app/chunk.ece210525014eb36073b.js",
|
"codemirror.js": "/api/hassio/app/chunk.ece210525014eb36073b.js",
|
||||||
"codemirror.js.map": "/api/hassio/app/chunk.ece210525014eb36073b.js.map",
|
"codemirror.js.map": "/api/hassio/app/chunk.ece210525014eb36073b.js.map",
|
||||||
"confirmation.js": "/api/hassio/app/chunk.a947da09b1ace1352383.js",
|
"confirmation.js": "/api/hassio/app/chunk.d9ebbcff54094bd6592a.js",
|
||||||
"confirmation.js.map": "/api/hassio/app/chunk.a947da09b1ace1352383.js.map",
|
"confirmation.js.map": "/api/hassio/app/chunk.d9ebbcff54094bd6592a.js.map",
|
||||||
"dialog-hassio-markdown.js": "/api/hassio/app/chunk.d402ad0de6ea5da0f9fc.js",
|
"dialog-hassio-markdown.js": "/api/hassio/app/chunk.d402ad0de6ea5da0f9fc.js",
|
||||||
"dialog-hassio-markdown.js.map": "/api/hassio/app/chunk.d402ad0de6ea5da0f9fc.js.map",
|
"dialog-hassio-markdown.js.map": "/api/hassio/app/chunk.d402ad0de6ea5da0f9fc.js.map",
|
||||||
"dialog-hassio-snapshot.js": "/api/hassio/app/chunk.05d0c315f85f2fc8c34a.js",
|
"dialog-hassio-snapshot.js": "/api/hassio/app/chunk.ec48cf4e7f87d6417353.js",
|
||||||
"dialog-hassio-snapshot.js.map": "/api/hassio/app/chunk.05d0c315f85f2fc8c34a.js.map",
|
"dialog-hassio-snapshot.js.map": "/api/hassio/app/chunk.ec48cf4e7f87d6417353.js.map",
|
||||||
"entrypoint.js": "/api/hassio/app/entrypoint.js",
|
"entrypoint.js": "/api/hassio/app/entrypoint.js",
|
||||||
"entrypoint.js.map": "/api/hassio/app/entrypoint.js.map",
|
"entrypoint.js.map": "/api/hassio/app/entrypoint.js.map",
|
||||||
"hassio-addon-view.js": "/api/hassio/app/chunk.b38bff4d0774d202dcad.js",
|
"hassio-addon-view.js": "/api/hassio/app/chunk.b38bff4d0774d202dcad.js",
|
||||||
@ -19,8 +19,8 @@
|
|||||||
"hassio-icons.js.map": "/api/hassio/app/chunk.af76a4db9eb1e2862aae.js.map",
|
"hassio-icons.js.map": "/api/hassio/app/chunk.af76a4db9eb1e2862aae.js.map",
|
||||||
"hassio-ingress-view.js": "/api/hassio/app/chunk.54be96e339b8c82764a0.js",
|
"hassio-ingress-view.js": "/api/hassio/app/chunk.54be96e339b8c82764a0.js",
|
||||||
"hassio-ingress-view.js.map": "/api/hassio/app/chunk.54be96e339b8c82764a0.js.map",
|
"hassio-ingress-view.js.map": "/api/hassio/app/chunk.54be96e339b8c82764a0.js.map",
|
||||||
"hassio-main.js": "/api/hassio/app/chunk.045f3417b78f858fff44.js",
|
"hassio-main.js": "/api/hassio/app/chunk.05403bc1774dc39117f6.js",
|
||||||
"hassio-main.js.map": "/api/hassio/app/chunk.045f3417b78f858fff44.js.map",
|
"hassio-main.js.map": "/api/hassio/app/chunk.05403bc1774dc39117f6.js.map",
|
||||||
"mdi-icons.js": "/api/hassio/app/chunk.381907f8b6a21cec010f.js",
|
"mdi-icons.js": "/api/hassio/app/chunk.381907f8b6a21cec010f.js",
|
||||||
"mdi-icons.js.map": "/api/hassio/app/chunk.381907f8b6a21cec010f.js.map",
|
"mdi-icons.js.map": "/api/hassio/app/chunk.381907f8b6a21cec010f.js.map",
|
||||||
"roboto.js": "/api/hassio/app/chunk.b2dce600432c76a53d8c.js",
|
"roboto.js": "/api/hassio/app/chunk.b2dce600432c76a53d8c.js",
|
||||||
@ -33,11 +33,11 @@
|
|||||||
"vendors~hassio-main.js.map": "/api/hassio/app/chunk.7ac9df67ea34d63f8998.js.map",
|
"vendors~hassio-main.js.map": "/api/hassio/app/chunk.7ac9df67ea34d63f8998.js.map",
|
||||||
"a1ebfa0a88593a3b571c.worker.js": "/api/hassio/app/a1ebfa0a88593a3b571c.worker.js",
|
"a1ebfa0a88593a3b571c.worker.js": "/api/hassio/app/a1ebfa0a88593a3b571c.worker.js",
|
||||||
"a1ebfa0a88593a3b571c.worker.js.map": "/api/hassio/app/a1ebfa0a88593a3b571c.worker.js.map",
|
"a1ebfa0a88593a3b571c.worker.js.map": "/api/hassio/app/a1ebfa0a88593a3b571c.worker.js.map",
|
||||||
"chunk.05d0c315f85f2fc8c34a.js.LICENSE": "/api/hassio/app/chunk.05d0c315f85f2fc8c34a.js.LICENSE",
|
|
||||||
"chunk.594ef9f33131c4d33409.js.LICENSE": "/api/hassio/app/chunk.594ef9f33131c4d33409.js.LICENSE",
|
"chunk.594ef9f33131c4d33409.js.LICENSE": "/api/hassio/app/chunk.594ef9f33131c4d33409.js.LICENSE",
|
||||||
"chunk.610423483939ffdbfb92.js.LICENSE": "/api/hassio/app/chunk.610423483939ffdbfb92.js.LICENSE",
|
"chunk.610423483939ffdbfb92.js.LICENSE": "/api/hassio/app/chunk.610423483939ffdbfb92.js.LICENSE",
|
||||||
"chunk.7ab69340d9bb40dda79e.js.LICENSE": "/api/hassio/app/chunk.7ab69340d9bb40dda79e.js.LICENSE",
|
"chunk.7ab69340d9bb40dda79e.js.LICENSE": "/api/hassio/app/chunk.7ab69340d9bb40dda79e.js.LICENSE",
|
||||||
"chunk.7ac9df67ea34d63f8998.js.LICENSE": "/api/hassio/app/chunk.7ac9df67ea34d63f8998.js.LICENSE",
|
"chunk.7ac9df67ea34d63f8998.js.LICENSE": "/api/hassio/app/chunk.7ac9df67ea34d63f8998.js.LICENSE",
|
||||||
"chunk.a947da09b1ace1352383.js.LICENSE": "/api/hassio/app/chunk.a947da09b1ace1352383.js.LICENSE",
|
"chunk.d402ad0de6ea5da0f9fc.js.LICENSE": "/api/hassio/app/chunk.d402ad0de6ea5da0f9fc.js.LICENSE",
|
||||||
"chunk.d402ad0de6ea5da0f9fc.js.LICENSE": "/api/hassio/app/chunk.d402ad0de6ea5da0f9fc.js.LICENSE"
|
"chunk.d9ebbcff54094bd6592a.js.LICENSE": "/api/hassio/app/chunk.d9ebbcff54094bd6592a.js.LICENSE",
|
||||||
|
"chunk.ec48cf4e7f87d6417353.js.LICENSE": "/api/hassio/app/chunk.ec48cf4e7f87d6417353.js.LICENSE"
|
||||||
}
|
}
|
@ -123,21 +123,11 @@ class APIProxy(CoreSysAttributes):
|
|||||||
_LOGGER.error("Got unexpected response from HA WebSocket: %s", data)
|
_LOGGER.error("Got unexpected response from HA WebSocket: %s", data)
|
||||||
raise APIError()
|
raise APIError()
|
||||||
|
|
||||||
if self.sys_homeassistant.refresh_token:
|
# Auth session
|
||||||
await self.sys_homeassistant.ensure_access_token()
|
await self.sys_homeassistant.ensure_access_token()
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
{
|
{"type": "auth", "access_token": self.sys_homeassistant.access_token}
|
||||||
"type": "auth",
|
)
|
||||||
"access_token": self.sys_homeassistant.access_token,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
await client.send_json(
|
|
||||||
{
|
|
||||||
"type": "auth",
|
|
||||||
"api_password": self.sys_homeassistant.api_password,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
data = await client.receive_json()
|
data = await client.receive_json()
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ ADDONS_ROLE_ACCESS = {
|
|||||||
r"|/audio/.*"
|
r"|/audio/.*"
|
||||||
r"|/dns/.*"
|
r"|/dns/.*"
|
||||||
r"|/cli/.*"
|
r"|/cli/.*"
|
||||||
|
r"|/multicast/.*"
|
||||||
r"|/core/.+"
|
r"|/core/.+"
|
||||||
r"|/homeassistant/.+"
|
r"|/homeassistant/.+"
|
||||||
r"|/host/.+"
|
r"|/host/.+"
|
||||||
@ -130,7 +131,7 @@ class SecurityMiddleware(CoreSysAttributes):
|
|||||||
|
|
||||||
# Host
|
# Host
|
||||||
# Remove machine_id handling later if all use new CLI
|
# Remove machine_id handling later if all use new CLI
|
||||||
if supervisor_token in (self.sys_machine_id, self.sys_cli.supervisor_token):
|
if supervisor_token in (self.sys_machine_id, self.sys_plugins.cli.supervisor_token):
|
||||||
_LOGGER.debug("%s access from Host", request.path)
|
_LOGGER.debug("%s access from Host", request.path)
|
||||||
request_from = self.sys_host
|
request_from = self.sys_host
|
||||||
|
|
||||||
|
@ -38,11 +38,12 @@ from ..const import (
|
|||||||
CONTENT_TYPE_BINARY,
|
CONTENT_TYPE_BINARY,
|
||||||
SUPERVISOR_VERSION,
|
SUPERVISOR_VERSION,
|
||||||
UpdateChannels,
|
UpdateChannels,
|
||||||
|
LogLevel,
|
||||||
)
|
)
|
||||||
from ..coresys import CoreSysAttributes
|
from ..coresys import CoreSysAttributes
|
||||||
from ..exceptions import APIError
|
from ..exceptions import APIError
|
||||||
from ..utils.validate import validate_timezone
|
from ..utils.validate import validate_timezone
|
||||||
from ..validate import log_level, repositories, wait_boot
|
from ..validate import repositories, wait_boot
|
||||||
from .utils import api_process, api_process_raw, api_validate
|
from .utils import api_process, api_process_raw, api_validate
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
@ -54,7 +55,7 @@ SCHEMA_OPTIONS = vol.Schema(
|
|||||||
vol.Optional(ATTR_ADDONS_REPOSITORIES): repositories,
|
vol.Optional(ATTR_ADDONS_REPOSITORIES): repositories,
|
||||||
vol.Optional(ATTR_TIMEZONE): validate_timezone,
|
vol.Optional(ATTR_TIMEZONE): validate_timezone,
|
||||||
vol.Optional(ATTR_WAIT_BOOT): wait_boot,
|
vol.Optional(ATTR_WAIT_BOOT): wait_boot,
|
||||||
vol.Optional(ATTR_LOGGING): log_level,
|
vol.Optional(ATTR_LOGGING): vol.Coerce(LogLevel),
|
||||||
vol.Optional(ATTR_DEBUG): vol.Boolean(),
|
vol.Optional(ATTR_DEBUG): vol.Boolean(),
|
||||||
vol.Optional(ATTR_DEBUG_BLOCK): vol.Boolean(),
|
vol.Optional(ATTR_DEBUG_BLOCK): vol.Boolean(),
|
||||||
}
|
}
|
||||||
@ -92,7 +93,7 @@ class APISupervisor(CoreSysAttributes):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
ATTR_VERSION: SUPERVISOR_VERSION,
|
ATTR_VERSION: SUPERVISOR_VERSION,
|
||||||
ATTR_VERSION_LATEST: self.sys_updater.version_hassio,
|
ATTR_VERSION_LATEST: self.sys_updater.version_supervisor,
|
||||||
ATTR_CHANNEL: self.sys_updater.channel,
|
ATTR_CHANNEL: self.sys_updater.channel,
|
||||||
ATTR_ARCH: self.sys_supervisor.arch,
|
ATTR_ARCH: self.sys_supervisor.arch,
|
||||||
ATTR_IP_ADDRESS: str(self.sys_supervisor.ip_address),
|
ATTR_IP_ADDRESS: str(self.sys_supervisor.ip_address),
|
||||||
@ -153,7 +154,7 @@ class APISupervisor(CoreSysAttributes):
|
|||||||
async def update(self, request: web.Request) -> None:
|
async def update(self, request: web.Request) -> None:
|
||||||
"""Update Supervisor OS."""
|
"""Update Supervisor OS."""
|
||||||
body = await api_validate(SCHEMA_VERSION, request)
|
body = await api_validate(SCHEMA_VERSION, request)
|
||||||
version = body.get(ATTR_VERSION, self.sys_updater.version_hassio)
|
version = body.get(ATTR_VERSION, self.sys_updater.version_supervisor)
|
||||||
|
|
||||||
if version == self.sys_supervisor.version:
|
if version == self.sys_supervisor.version:
|
||||||
raise APIError("Version {} is already in use".format(version))
|
raise APIError("Version {} is already in use".format(version))
|
||||||
|
@ -11,33 +11,36 @@ from .addons import AddonManager
|
|||||||
from .api import RestAPI
|
from .api import RestAPI
|
||||||
from .arch import CpuArch
|
from .arch import CpuArch
|
||||||
from .auth import Auth
|
from .auth import Auth
|
||||||
from .audio import Audio
|
from .const import (
|
||||||
from .const import SOCKET_DOCKER, UpdateChannels
|
ENV_HOMEASSISTANT_REPOSITORY,
|
||||||
|
ENV_SUPERVISOR_MACHINE,
|
||||||
|
ENV_SUPERVISOR_NAME,
|
||||||
|
ENV_SUPERVISOR_SHARE,
|
||||||
|
SOCKET_DOCKER,
|
||||||
|
LogLevel,
|
||||||
|
UpdateChannels,
|
||||||
|
)
|
||||||
from .core import Core
|
from .core import Core
|
||||||
from .cli import HaCli
|
|
||||||
from .coresys import CoreSys
|
from .coresys import CoreSys
|
||||||
from .dbus import DBusManager
|
from .dbus import DBusManager
|
||||||
from .discovery import Discovery
|
from .discovery import Discovery
|
||||||
from .dns import CoreDNS
|
|
||||||
from .hassos import HassOS
|
from .hassos import HassOS
|
||||||
from .homeassistant import HomeAssistant
|
from .homeassistant import HomeAssistant
|
||||||
from .host import HostManager
|
from .host import HostManager
|
||||||
from .hwmon import HwMonitor
|
from .hwmon import HwMonitor
|
||||||
from .ingress import Ingress
|
from .ingress import Ingress
|
||||||
|
from .plugins import PluginManager
|
||||||
|
from .secrets import SecretsManager
|
||||||
from .services import ServiceManager
|
from .services import ServiceManager
|
||||||
from .snapshots import SnapshotManager
|
from .snapshots import SnapshotManager
|
||||||
from .store import StoreManager
|
from .store import StoreManager
|
||||||
from .supervisor import Supervisor
|
from .supervisor import Supervisor
|
||||||
from .tasks import Tasks
|
from .tasks import Tasks
|
||||||
from .updater import Updater
|
from .updater import Updater
|
||||||
from .secrets import SecretsManager
|
|
||||||
from .utils.dt import fetch_timezone
|
from .utils.dt import fetch_timezone
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
ENV_SHARE = "SUPERVISOR_SHARE"
|
|
||||||
ENV_NAME = "SUPERVISOR_NAME"
|
|
||||||
ENV_REPO = "HOMEASSISTANT_REPOSITORY"
|
|
||||||
|
|
||||||
MACHINE_ID = Path("/etc/machine-id")
|
MACHINE_ID = Path("/etc/machine-id")
|
||||||
|
|
||||||
@ -48,9 +51,8 @@ async def initialize_coresys():
|
|||||||
|
|
||||||
# Initialize core objects
|
# Initialize core objects
|
||||||
coresys.core = Core(coresys)
|
coresys.core = Core(coresys)
|
||||||
coresys.dns = CoreDNS(coresys)
|
coresys.plugins = PluginManager(coresys)
|
||||||
coresys.arch = CpuArch(coresys)
|
coresys.arch = CpuArch(coresys)
|
||||||
coresys.audio = Audio(coresys)
|
|
||||||
coresys.auth = Auth(coresys)
|
coresys.auth = Auth(coresys)
|
||||||
coresys.updater = Updater(coresys)
|
coresys.updater = Updater(coresys)
|
||||||
coresys.api = RestAPI(coresys)
|
coresys.api = RestAPI(coresys)
|
||||||
@ -68,7 +70,6 @@ async def initialize_coresys():
|
|||||||
coresys.dbus = DBusManager(coresys)
|
coresys.dbus = DBusManager(coresys)
|
||||||
coresys.hassos = HassOS(coresys)
|
coresys.hassos = HassOS(coresys)
|
||||||
coresys.secrets = SecretsManager(coresys)
|
coresys.secrets = SecretsManager(coresys)
|
||||||
coresys.cli = HaCli(coresys)
|
|
||||||
|
|
||||||
# bootstrap config
|
# bootstrap config
|
||||||
initialize_system_data(coresys)
|
initialize_system_data(coresys)
|
||||||
@ -81,6 +82,13 @@ async def initialize_coresys():
|
|||||||
if coresys.config.timezone == "UTC":
|
if coresys.config.timezone == "UTC":
|
||||||
coresys.config.timezone = await fetch_timezone(coresys.websession)
|
coresys.config.timezone = await fetch_timezone(coresys.websession)
|
||||||
|
|
||||||
|
# Set machine type
|
||||||
|
if os.environ.get(ENV_SUPERVISOR_MACHINE):
|
||||||
|
coresys.machine = os.environ[ENV_SUPERVISOR_MACHINE]
|
||||||
|
elif os.environ.get(ENV_HOMEASSISTANT_REPOSITORY):
|
||||||
|
coresys.machine = os.environ[ENV_HOMEASSISTANT_REPOSITORY][14:-14]
|
||||||
|
_LOGGER.info("Setup coresys for machine: %s", coresys.machine)
|
||||||
|
|
||||||
return coresys
|
return coresys
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +164,7 @@ def initialize_system_data(coresys: CoreSys):
|
|||||||
if bool(os.environ.get("SUPERVISOR_DEV", 0)):
|
if bool(os.environ.get("SUPERVISOR_DEV", 0)):
|
||||||
_LOGGER.warning("SUPERVISOR_DEV is set")
|
_LOGGER.warning("SUPERVISOR_DEV is set")
|
||||||
coresys.updater.channel = UpdateChannels.DEV
|
coresys.updater.channel = UpdateChannels.DEV
|
||||||
coresys.config.logging = "debug"
|
coresys.config.logging = LogLevel.DEBUG
|
||||||
coresys.config.debug = True
|
coresys.config.debug = True
|
||||||
|
|
||||||
|
|
||||||
@ -165,7 +173,7 @@ def migrate_system_env(coresys: CoreSys):
|
|||||||
config = coresys.config
|
config = coresys.config
|
||||||
|
|
||||||
# hass.io 0.37 -> 0.38
|
# hass.io 0.37 -> 0.38
|
||||||
old_build = Path(config.path_hassio, "addons/build")
|
old_build = Path(config.path_supervisor, "addons/build")
|
||||||
if old_build.is_dir():
|
if old_build.is_dir():
|
||||||
try:
|
try:
|
||||||
old_build.rmdir()
|
old_build.rmdir()
|
||||||
@ -202,12 +210,20 @@ def initialize_logging():
|
|||||||
def check_environment() -> None:
|
def check_environment() -> None:
|
||||||
"""Check if all environment are exists."""
|
"""Check if all environment are exists."""
|
||||||
# check environment variables
|
# check environment variables
|
||||||
for key in (ENV_SHARE, ENV_NAME, ENV_REPO):
|
for key in (ENV_SUPERVISOR_SHARE, ENV_SUPERVISOR_NAME):
|
||||||
try:
|
try:
|
||||||
os.environ[key]
|
os.environ[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_LOGGER.fatal("Can't find %s in env!", key)
|
_LOGGER.fatal("Can't find %s in env!", key)
|
||||||
|
|
||||||
|
# Check Machine info
|
||||||
|
if not os.environ.get(ENV_HOMEASSISTANT_REPOSITORY) and not os.environ.get(
|
||||||
|
ENV_SUPERVISOR_MACHINE
|
||||||
|
):
|
||||||
|
_LOGGER.fatal("Can't find any kind of machine/homeassistant details!")
|
||||||
|
elif not os.environ.get(ENV_SUPERVISOR_MACHINE):
|
||||||
|
_LOGGER.info("Use the old homeassistant repository for machine extraction")
|
||||||
|
|
||||||
# check docker socket
|
# check docker socket
|
||||||
if not SOCKET_DOCKER.is_socket():
|
if not SOCKET_DOCKER.is_socket():
|
||||||
_LOGGER.fatal("Can't find Docker socket!")
|
_LOGGER.fatal("Can't find Docker socket!")
|
||||||
|
@ -12,12 +12,14 @@ from .const import (
|
|||||||
ATTR_LOGGING,
|
ATTR_LOGGING,
|
||||||
ATTR_TIMEZONE,
|
ATTR_TIMEZONE,
|
||||||
ATTR_WAIT_BOOT,
|
ATTR_WAIT_BOOT,
|
||||||
|
ENV_SUPERVISOR_SHARE,
|
||||||
FILE_HASSIO_CONFIG,
|
FILE_HASSIO_CONFIG,
|
||||||
SUPERVISOR_DATA,
|
SUPERVISOR_DATA,
|
||||||
|
LogLevel,
|
||||||
)
|
)
|
||||||
from .utils.dt import parse_datetime
|
from .utils.dt import parse_datetime
|
||||||
from .utils.json import JsonConfig
|
from .utils.json import JsonConfig
|
||||||
from .validate import SCHEMA_HASSIO_CONFIG
|
from .validate import SCHEMA_SUPERVISOR_CONFIG
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ class CoreConfig(JsonConfig):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize config object."""
|
"""Initialize config object."""
|
||||||
super().__init__(FILE_HASSIO_CONFIG, SCHEMA_HASSIO_CONFIG)
|
super().__init__(FILE_HASSIO_CONFIG, SCHEMA_SUPERVISOR_CONFIG)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def timezone(self):
|
def timezone(self):
|
||||||
@ -88,19 +90,19 @@ class CoreConfig(JsonConfig):
|
|||||||
self._data[ATTR_DEBUG_BLOCK] = value
|
self._data[ATTR_DEBUG_BLOCK] = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def logging(self) -> str:
|
def logging(self) -> LogLevel:
|
||||||
"""Return log level of system."""
|
"""Return log level of system."""
|
||||||
return self._data[ATTR_LOGGING]
|
return self._data[ATTR_LOGGING]
|
||||||
|
|
||||||
@logging.setter
|
@logging.setter
|
||||||
def logging(self, value: str):
|
def logging(self, value: LogLevel):
|
||||||
"""Set system log level."""
|
"""Set system log level."""
|
||||||
self._data[ATTR_LOGGING] = value
|
self._data[ATTR_LOGGING] = value
|
||||||
self.modify_log_level()
|
self.modify_log_level()
|
||||||
|
|
||||||
def modify_log_level(self) -> None:
|
def modify_log_level(self) -> None:
|
||||||
"""Change log level."""
|
"""Change log level."""
|
||||||
lvl = getattr(logging, self.logging.upper())
|
lvl = getattr(logging, str(self.logging.value).upper())
|
||||||
logging.getLogger("supervisor").setLevel(lvl)
|
logging.getLogger("supervisor").setLevel(lvl)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -119,19 +121,19 @@ class CoreConfig(JsonConfig):
|
|||||||
self._data[ATTR_LAST_BOOT] = value.isoformat()
|
self._data[ATTR_LAST_BOOT] = value.isoformat()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_hassio(self):
|
def path_supervisor(self):
|
||||||
"""Return Supervisor data path."""
|
"""Return Supervisor data path."""
|
||||||
return SUPERVISOR_DATA
|
return SUPERVISOR_DATA
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_extern_hassio(self):
|
def path_extern_supervisor(self):
|
||||||
"""Return Supervisor data path external for Docker."""
|
"""Return Supervisor data path external for Docker."""
|
||||||
return PurePath(os.environ["SUPERVISOR_SHARE"])
|
return PurePath(os.environ[ENV_SUPERVISOR_SHARE])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_extern_homeassistant(self):
|
def path_extern_homeassistant(self):
|
||||||
"""Return config path external for Docker."""
|
"""Return config path external for Docker."""
|
||||||
return str(PurePath(self.path_extern_hassio, HOMEASSISTANT_CONFIG))
|
return str(PurePath(self.path_extern_supervisor, HOMEASSISTANT_CONFIG))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_homeassistant(self):
|
def path_homeassistant(self):
|
||||||
@ -141,7 +143,7 @@ class CoreConfig(JsonConfig):
|
|||||||
@property
|
@property
|
||||||
def path_extern_ssl(self):
|
def path_extern_ssl(self):
|
||||||
"""Return SSL path external for Docker."""
|
"""Return SSL path external for Docker."""
|
||||||
return str(PurePath(self.path_extern_hassio, HASSIO_SSL))
|
return str(PurePath(self.path_extern_supervisor, HASSIO_SSL))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_ssl(self):
|
def path_ssl(self):
|
||||||
@ -166,7 +168,7 @@ class CoreConfig(JsonConfig):
|
|||||||
@property
|
@property
|
||||||
def path_extern_addons_local(self):
|
def path_extern_addons_local(self):
|
||||||
"""Return path for custom Add-ons."""
|
"""Return path for custom Add-ons."""
|
||||||
return PurePath(self.path_extern_hassio, ADDONS_LOCAL)
|
return PurePath(self.path_extern_supervisor, ADDONS_LOCAL)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_addons_data(self):
|
def path_addons_data(self):
|
||||||
@ -176,7 +178,7 @@ class CoreConfig(JsonConfig):
|
|||||||
@property
|
@property
|
||||||
def path_extern_addons_data(self):
|
def path_extern_addons_data(self):
|
||||||
"""Return root add-on data folder external for Docker."""
|
"""Return root add-on data folder external for Docker."""
|
||||||
return PurePath(self.path_extern_hassio, ADDONS_DATA)
|
return PurePath(self.path_extern_supervisor, ADDONS_DATA)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_audio(self):
|
def path_audio(self):
|
||||||
@ -186,7 +188,7 @@ class CoreConfig(JsonConfig):
|
|||||||
@property
|
@property
|
||||||
def path_extern_audio(self):
|
def path_extern_audio(self):
|
||||||
"""Return root audio data folder external for Docker."""
|
"""Return root audio data folder external for Docker."""
|
||||||
return PurePath(self.path_extern_hassio, AUDIO_DATA)
|
return PurePath(self.path_extern_supervisor, AUDIO_DATA)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_tmp(self):
|
def path_tmp(self):
|
||||||
@ -196,7 +198,7 @@ class CoreConfig(JsonConfig):
|
|||||||
@property
|
@property
|
||||||
def path_extern_tmp(self):
|
def path_extern_tmp(self):
|
||||||
"""Return Supervisor temp folder for Docker."""
|
"""Return Supervisor temp folder for Docker."""
|
||||||
return PurePath(self.path_extern_hassio, TMP_DATA)
|
return PurePath(self.path_extern_supervisor, TMP_DATA)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_backup(self):
|
def path_backup(self):
|
||||||
@ -206,7 +208,7 @@ class CoreConfig(JsonConfig):
|
|||||||
@property
|
@property
|
||||||
def path_extern_backup(self):
|
def path_extern_backup(self):
|
||||||
"""Return root backup data folder external for Docker."""
|
"""Return root backup data folder external for Docker."""
|
||||||
return PurePath(self.path_extern_hassio, BACKUP_DATA)
|
return PurePath(self.path_extern_supervisor, BACKUP_DATA)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_share(self):
|
def path_share(self):
|
||||||
@ -221,12 +223,12 @@ class CoreConfig(JsonConfig):
|
|||||||
@property
|
@property
|
||||||
def path_extern_share(self):
|
def path_extern_share(self):
|
||||||
"""Return root share data folder external for Docker."""
|
"""Return root share data folder external for Docker."""
|
||||||
return PurePath(self.path_extern_hassio, SHARE_DATA)
|
return PurePath(self.path_extern_supervisor, SHARE_DATA)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_extern_dns(self):
|
def path_extern_dns(self):
|
||||||
"""Return dns path external for Docker."""
|
"""Return dns path external for Docker."""
|
||||||
return str(PurePath(self.path_extern_hassio, DNS_DATA))
|
return str(PurePath(self.path_extern_supervisor, DNS_DATA))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_dns(self):
|
def path_dns(self):
|
||||||
|
@ -3,7 +3,7 @@ from enum import Enum
|
|||||||
from ipaddress import ip_network
|
from ipaddress import ip_network
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
SUPERVISOR_VERSION = "214"
|
SUPERVISOR_VERSION = "215"
|
||||||
|
|
||||||
|
|
||||||
URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons"
|
URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons"
|
||||||
@ -28,6 +28,7 @@ FILE_HASSIO_INGRESS = Path(SUPERVISOR_DATA, "ingress.json")
|
|||||||
FILE_HASSIO_DNS = Path(SUPERVISOR_DATA, "dns.json")
|
FILE_HASSIO_DNS = Path(SUPERVISOR_DATA, "dns.json")
|
||||||
FILE_HASSIO_AUDIO = Path(SUPERVISOR_DATA, "audio.json")
|
FILE_HASSIO_AUDIO = Path(SUPERVISOR_DATA, "audio.json")
|
||||||
FILE_HASSIO_CLI = Path(SUPERVISOR_DATA, "cli.json")
|
FILE_HASSIO_CLI = Path(SUPERVISOR_DATA, "cli.json")
|
||||||
|
FILE_HASSIO_MULTICAST = Path(SUPERVISOR_DATA, "multicast.json")
|
||||||
|
|
||||||
SOCKET_DOCKER = Path("/run/docker.sock")
|
SOCKET_DOCKER = Path("/run/docker.sock")
|
||||||
|
|
||||||
@ -68,9 +69,16 @@ ENV_TOKEN_OLD = "HASSIO_TOKEN"
|
|||||||
ENV_TOKEN = "SUPERVISOR_TOKEN"
|
ENV_TOKEN = "SUPERVISOR_TOKEN"
|
||||||
ENV_TIME = "TZ"
|
ENV_TIME = "TZ"
|
||||||
|
|
||||||
|
ENV_HOMEASSISTANT_REPOSITORY = "HOMEASSISTANT_REPOSITORY"
|
||||||
|
ENV_SUPERVISOR_SHARE = "SUPERVISOR_SHARE"
|
||||||
|
ENV_SUPERVISOR_NAME = "SUPERVISOR_NAME"
|
||||||
|
ENV_SUPERVISOR_MACHINE = "SUPERVISOR_MACHINE"
|
||||||
|
|
||||||
REQUEST_FROM = "HASSIO_FROM"
|
REQUEST_FROM = "HASSIO_FROM"
|
||||||
|
|
||||||
|
ATTR_SUPERVISOR = "supervisor"
|
||||||
ATTR_MACHINE = "machine"
|
ATTR_MACHINE = "machine"
|
||||||
|
ATTR_MULTICAST = "multicast"
|
||||||
ATTR_WAIT_BOOT = "wait_boot"
|
ATTR_WAIT_BOOT = "wait_boot"
|
||||||
ATTR_DEPLOYMENT = "deployment"
|
ATTR_DEPLOYMENT = "deployment"
|
||||||
ATTR_WATCHDOG = "watchdog"
|
ATTR_WATCHDOG = "watchdog"
|
||||||
@ -138,7 +146,6 @@ ATTR_USER = "user"
|
|||||||
ATTR_SYSTEM = "system"
|
ATTR_SYSTEM = "system"
|
||||||
ATTR_SNAPSHOTS = "snapshots"
|
ATTR_SNAPSHOTS = "snapshots"
|
||||||
ATTR_HOMEASSISTANT = "homeassistant"
|
ATTR_HOMEASSISTANT = "homeassistant"
|
||||||
ATTR_HASSIO = "hassio"
|
|
||||||
ATTR_HASSIO_API = "hassio_api"
|
ATTR_HASSIO_API = "hassio_api"
|
||||||
ATTR_HOMEASSISTANT_API = "homeassistant_api"
|
ATTR_HOMEASSISTANT_API = "homeassistant_api"
|
||||||
ATTR_UUID = "uuid"
|
ATTR_UUID = "uuid"
|
||||||
@ -147,7 +154,6 @@ ATTR_SIZE = "size"
|
|||||||
ATTR_TYPE = "type"
|
ATTR_TYPE = "type"
|
||||||
ATTR_TIMEOUT = "timeout"
|
ATTR_TIMEOUT = "timeout"
|
||||||
ATTR_AUTO_UPDATE = "auto_update"
|
ATTR_AUTO_UPDATE = "auto_update"
|
||||||
ATTR_CUSTOM = "custom"
|
|
||||||
ATTR_VIDEO = "video"
|
ATTR_VIDEO = "video"
|
||||||
ATTR_AUDIO = "audio"
|
ATTR_AUDIO = "audio"
|
||||||
ATTR_AUDIO_INPUT = "audio_input"
|
ATTR_AUDIO_INPUT = "audio_input"
|
||||||
@ -355,3 +361,13 @@ class CoreStates(str, Enum):
|
|||||||
STARTUP = "startup"
|
STARTUP = "startup"
|
||||||
RUNNING = "running"
|
RUNNING = "running"
|
||||||
FREEZE = "freeze"
|
FREEZE = "freeze"
|
||||||
|
|
||||||
|
|
||||||
|
class LogLevel(str, Enum):
|
||||||
|
"""Logging level of system."""
|
||||||
|
|
||||||
|
DEBUG = "debug"
|
||||||
|
INFO = "info"
|
||||||
|
WARNING = "warning"
|
||||||
|
ERROR = "error"
|
||||||
|
CRITICAL = "critical"
|
||||||
|
@ -41,9 +41,7 @@ class Core(CoreSysAttributes):
|
|||||||
await self.sys_host.load()
|
await self.sys_host.load()
|
||||||
|
|
||||||
# Load Plugins container
|
# Load Plugins container
|
||||||
await asyncio.wait(
|
await self.sys_plugins.load()
|
||||||
[self.sys_dns.load(), self.sys_audio.load(), self.sys_cli.load()]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Load Home Assistant
|
# Load Home Assistant
|
||||||
await self.sys_homeassistant.load()
|
await self.sys_homeassistant.load()
|
||||||
@ -172,7 +170,7 @@ class Core(CoreSysAttributes):
|
|||||||
self.sys_websession.close(),
|
self.sys_websession.close(),
|
||||||
self.sys_websession_ssl.close(),
|
self.sys_websession_ssl.close(),
|
||||||
self.sys_ingress.unload(),
|
self.sys_ingress.unload(),
|
||||||
self.sys_dns.unload(),
|
self.sys_plugins.unload(),
|
||||||
self.sys_hwmonitor.unload(),
|
self.sys_hwmonitor.unload(),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -193,6 +191,9 @@ class Core(CoreSysAttributes):
|
|||||||
await self.sys_addons.shutdown(STARTUP_SYSTEM)
|
await self.sys_addons.shutdown(STARTUP_SYSTEM)
|
||||||
await self.sys_addons.shutdown(STARTUP_INITIALIZE)
|
await self.sys_addons.shutdown(STARTUP_INITIALIZE)
|
||||||
|
|
||||||
|
# Shutdown all Plugins
|
||||||
|
await self.sys_plugins.shutdown()
|
||||||
|
|
||||||
def _update_last_boot(self):
|
def _update_last_boot(self):
|
||||||
"""Update last boot time."""
|
"""Update last boot time."""
|
||||||
self.sys_config.last_boot = self.sys_hardware.last_boot
|
self.sys_config.last_boot = self.sys_hardware.last_boot
|
||||||
@ -203,10 +204,10 @@ class Core(CoreSysAttributes):
|
|||||||
_LOGGER.info("Start repairing of Supervisor Environment")
|
_LOGGER.info("Start repairing of Supervisor Environment")
|
||||||
await self.sys_run_in_executor(self.sys_docker.repair)
|
await self.sys_run_in_executor(self.sys_docker.repair)
|
||||||
|
|
||||||
|
# Fix plugins
|
||||||
|
await self.sys_plugins.repair()
|
||||||
|
|
||||||
# Restore core functionality
|
# Restore core functionality
|
||||||
await self.sys_dns.repair()
|
|
||||||
await self.sys_audio.repair()
|
|
||||||
await self.sys_cli.repair()
|
|
||||||
await self.sys_addons.repair()
|
await self.sys_addons.repair()
|
||||||
await self.sys_homeassistant.repair()
|
await self.sys_homeassistant.repair()
|
||||||
|
|
||||||
|
@ -15,13 +15,10 @@ if TYPE_CHECKING:
|
|||||||
from .addons import AddonManager
|
from .addons import AddonManager
|
||||||
from .api import RestAPI
|
from .api import RestAPI
|
||||||
from .arch import CpuArch
|
from .arch import CpuArch
|
||||||
from .audio import Audio
|
|
||||||
from .auth import Auth
|
from .auth import Auth
|
||||||
from .core import Core
|
from .core import Core
|
||||||
from .cli import HaCli
|
|
||||||
from .dbus import DBusManager
|
from .dbus import DBusManager
|
||||||
from .discovery import Discovery
|
from .discovery import Discovery
|
||||||
from .dns import CoreDNS
|
|
||||||
from .hassos import HassOS
|
from .hassos import HassOS
|
||||||
from .hwmon import HwMonitor
|
from .hwmon import HwMonitor
|
||||||
from .homeassistant import HomeAssistant
|
from .homeassistant import HomeAssistant
|
||||||
@ -34,6 +31,7 @@ if TYPE_CHECKING:
|
|||||||
from .store import StoreManager
|
from .store import StoreManager
|
||||||
from .tasks import Tasks
|
from .tasks import Tasks
|
||||||
from .updater import Updater
|
from .updater import Updater
|
||||||
|
from .plugins import PluginManager
|
||||||
|
|
||||||
|
|
||||||
class CoreSys:
|
class CoreSys:
|
||||||
@ -42,7 +40,8 @@ class CoreSys:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize coresys."""
|
"""Initialize coresys."""
|
||||||
# Static attributes
|
# Static attributes
|
||||||
self.machine_id: Optional[str] = None
|
self._machine_id: Optional[str] = None
|
||||||
|
self._machine: Optional[str] = None
|
||||||
|
|
||||||
# External objects
|
# External objects
|
||||||
self._loop: asyncio.BaseEventLoop = asyncio.get_running_loop()
|
self._loop: asyncio.BaseEventLoop = asyncio.get_running_loop()
|
||||||
@ -60,10 +59,7 @@ class CoreSys:
|
|||||||
# Internal objects pointers
|
# Internal objects pointers
|
||||||
self._core: Optional[Core] = None
|
self._core: Optional[Core] = None
|
||||||
self._arch: Optional[CpuArch] = None
|
self._arch: Optional[CpuArch] = None
|
||||||
self._audio: Optional[Audio] = None
|
|
||||||
self._auth: Optional[Auth] = None
|
self._auth: Optional[Auth] = None
|
||||||
self._dns: Optional[CoreDNS] = None
|
|
||||||
self._cli: Optional[HaCli] = None
|
|
||||||
self._homeassistant: Optional[HomeAssistant] = None
|
self._homeassistant: Optional[HomeAssistant] = None
|
||||||
self._supervisor: Optional[Supervisor] = None
|
self._supervisor: Optional[Supervisor] = None
|
||||||
self._addons: Optional[AddonManager] = None
|
self._addons: Optional[AddonManager] = None
|
||||||
@ -80,13 +76,7 @@ class CoreSys:
|
|||||||
self._store: Optional[StoreManager] = None
|
self._store: Optional[StoreManager] = None
|
||||||
self._discovery: Optional[Discovery] = None
|
self._discovery: Optional[Discovery] = None
|
||||||
self._hwmonitor: Optional[HwMonitor] = None
|
self._hwmonitor: Optional[HwMonitor] = None
|
||||||
|
self._plugins: Optional[PluginManager] = None
|
||||||
@property
|
|
||||||
def machine(self) -> str:
|
|
||||||
"""Return running machine type of the Supervisor system."""
|
|
||||||
if self._homeassistant:
|
|
||||||
return self._homeassistant.machine
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dev(self) -> bool:
|
def dev(self) -> bool:
|
||||||
@ -146,16 +136,16 @@ class CoreSys:
|
|||||||
self._core = value
|
self._core = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cli(self) -> HaCli:
|
def plugins(self) -> PluginManager:
|
||||||
"""Return HaCli object."""
|
"""Return PluginManager object."""
|
||||||
return self._cli
|
return self._plugins
|
||||||
|
|
||||||
@cli.setter
|
@plugins.setter
|
||||||
def cli(self, value: HaCli):
|
def plugins(self, value: PluginManager):
|
||||||
"""Set a HaCli object."""
|
"""Set a PluginManager object."""
|
||||||
if self._cli:
|
if self._plugins:
|
||||||
raise RuntimeError("HaCli already set!")
|
raise RuntimeError("PluginManager already set!")
|
||||||
self._cli = value
|
self._plugins = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def arch(self) -> CpuArch:
|
def arch(self) -> CpuArch:
|
||||||
@ -181,18 +171,6 @@ class CoreSys:
|
|||||||
raise RuntimeError("Auth already set!")
|
raise RuntimeError("Auth already set!")
|
||||||
self._auth = value
|
self._auth = value
|
||||||
|
|
||||||
@property
|
|
||||||
def audio(self) -> Audio:
|
|
||||||
"""Return Audio object."""
|
|
||||||
return self._audio
|
|
||||||
|
|
||||||
@audio.setter
|
|
||||||
def audio(self, value: Audio):
|
|
||||||
"""Set a Audio object."""
|
|
||||||
if self._audio:
|
|
||||||
raise RuntimeError("Audio already set!")
|
|
||||||
self._audio = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def homeassistant(self) -> HomeAssistant:
|
def homeassistant(self) -> HomeAssistant:
|
||||||
"""Return Home Assistant object."""
|
"""Return Home Assistant object."""
|
||||||
@ -337,18 +315,6 @@ class CoreSys:
|
|||||||
raise RuntimeError("DBusManager already set!")
|
raise RuntimeError("DBusManager already set!")
|
||||||
self._dbus = value
|
self._dbus = value
|
||||||
|
|
||||||
@property
|
|
||||||
def dns(self) -> CoreDNS:
|
|
||||||
"""Return CoreDNS object."""
|
|
||||||
return self._dns
|
|
||||||
|
|
||||||
@dns.setter
|
|
||||||
def dns(self, value: CoreDNS):
|
|
||||||
"""Set a CoreDNS object."""
|
|
||||||
if self._dns:
|
|
||||||
raise RuntimeError("CoreDNS already set!")
|
|
||||||
self._dns = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self) -> HostManager:
|
def host(self) -> HostManager:
|
||||||
"""Return HostManager object."""
|
"""Return HostManager object."""
|
||||||
@ -397,6 +363,30 @@ class CoreSys:
|
|||||||
raise RuntimeError("HassOS already set!")
|
raise RuntimeError("HassOS already set!")
|
||||||
self._hassos = value
|
self._hassos = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def machine(self) -> Optional[str]:
|
||||||
|
"""Return machine type string."""
|
||||||
|
return self._machine
|
||||||
|
|
||||||
|
@machine.setter
|
||||||
|
def machine(self, value: str):
|
||||||
|
"""Set a machine type string."""
|
||||||
|
if self._machine:
|
||||||
|
raise RuntimeError("Machine type already set!")
|
||||||
|
self._machine = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def machine_id(self) -> Optional[str]:
|
||||||
|
"""Return machine-id type string."""
|
||||||
|
return self._machine_id
|
||||||
|
|
||||||
|
@machine_id.setter
|
||||||
|
def machine_id(self, value: str):
|
||||||
|
"""Set a machine-id type string."""
|
||||||
|
if self._machine_id:
|
||||||
|
raise RuntimeError("Machine-ID type already set!")
|
||||||
|
self._machine_id = value
|
||||||
|
|
||||||
|
|
||||||
class CoreSysAttributes:
|
class CoreSysAttributes:
|
||||||
"""Inheret basic CoreSysAttributes."""
|
"""Inheret basic CoreSysAttributes."""
|
||||||
@ -464,9 +454,9 @@ class CoreSysAttributes:
|
|||||||
return self.coresys.core
|
return self.coresys.core
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sys_cli(self) -> HaCli:
|
def sys_plugins(self) -> PluginManager:
|
||||||
"""Return HaCli object."""
|
"""Return PluginManager object."""
|
||||||
return self.coresys.cli
|
return self.coresys.plugins
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sys_arch(self) -> CpuArch:
|
def sys_arch(self) -> CpuArch:
|
||||||
@ -478,11 +468,6 @@ class CoreSysAttributes:
|
|||||||
"""Return Auth object."""
|
"""Return Auth object."""
|
||||||
return self.coresys.auth
|
return self.coresys.auth
|
||||||
|
|
||||||
@property
|
|
||||||
def sys_audio(self) -> Audio:
|
|
||||||
"""Return Audio object."""
|
|
||||||
return self.coresys.audio
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sys_homeassistant(self) -> HomeAssistant:
|
def sys_homeassistant(self) -> HomeAssistant:
|
||||||
"""Return Home Assistant object."""
|
"""Return Home Assistant object."""
|
||||||
@ -543,11 +528,6 @@ class CoreSysAttributes:
|
|||||||
"""Return DBusManager object."""
|
"""Return DBusManager object."""
|
||||||
return self.coresys.dbus
|
return self.coresys.dbus
|
||||||
|
|
||||||
@property
|
|
||||||
def sys_dns(self) -> CoreDNS:
|
|
||||||
"""Return CoreDNS object."""
|
|
||||||
return self.coresys.dns
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sys_host(self) -> HostManager:
|
def sys_host(self) -> HostManager:
|
||||||
"""Return HostManager object."""
|
"""Return HostManager object."""
|
||||||
|
@ -2,26 +2,29 @@
|
|||||||
log
|
log
|
||||||
errors
|
errors
|
||||||
loop
|
loop
|
||||||
|
{% if debug %}debug{% endif %}
|
||||||
hosts /config/hosts {
|
hosts /config/hosts {
|
||||||
fallthrough
|
fallthrough
|
||||||
}
|
}
|
||||||
template ANY AAAA local.hass.io hassio {
|
template ANY AAAA local.hass.io hassio {
|
||||||
rcode NOERROR
|
rcode NOERROR
|
||||||
}
|
}
|
||||||
forward . {{ locals | join(" ") }} dns://127.0.0.1:5353 {
|
mdns
|
||||||
|
forward . {{ locals | join(" ") }} dns://127.0.0.1:5553 {
|
||||||
except local.hass.io
|
except local.hass.io
|
||||||
policy sequential
|
policy sequential
|
||||||
health_check 5s
|
health_check 5s
|
||||||
}
|
}
|
||||||
fallback REFUSED . dns://127.0.0.1:5353
|
fallback REFUSED . dns://127.0.0.1:5553
|
||||||
fallback SERVFAIL . dns://127.0.0.1:5353
|
fallback SERVFAIL . dns://127.0.0.1:5553
|
||||||
fallback NXDOMAIN . dns://127.0.0.1:5353
|
fallback NXDOMAIN . dns://127.0.0.1:5553
|
||||||
cache 10
|
cache 10
|
||||||
}
|
}
|
||||||
|
|
||||||
.:5353 {
|
.:5553 {
|
||||||
log
|
log
|
||||||
errors
|
errors
|
||||||
|
{% if debug %}debug{% endif %}
|
||||||
forward . tls://1.1.1.1 tls://1.0.0.1 {
|
forward . tls://1.1.1.1 tls://1.0.0.1 {
|
||||||
tls_servername cloudflare-dns.com
|
tls_servername cloudflare-dns.com
|
||||||
except local.hass.io
|
except local.hass.io
|
||||||
|
@ -308,11 +308,11 @@ class DockerAddon(DockerInterface):
|
|||||||
"bind": "/etc/pulse/client.conf",
|
"bind": "/etc/pulse/client.conf",
|
||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
str(self.sys_audio.path_extern_pulse): {
|
str(self.sys_plugins.audio.path_extern_pulse): {
|
||||||
"bind": "/run/audio",
|
"bind": "/run/audio",
|
||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
str(self.sys_audio.path_extern_asound): {
|
str(self.sys_plugins.audio.path_extern_asound): {
|
||||||
"bind": "/etc/asound.conf",
|
"bind": "/etc/asound.conf",
|
||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
@ -364,7 +364,7 @@ class DockerAddon(DockerInterface):
|
|||||||
_LOGGER.info("Start Docker add-on %s with version %s", self.image, self.version)
|
_LOGGER.info("Start Docker add-on %s with version %s", self.image, self.version)
|
||||||
|
|
||||||
# Write data to DNS server
|
# Write data to DNS server
|
||||||
self.sys_dns.add_host(ipv4=self.ip_address, names=[self.addon.hostname])
|
self.sys_plugins.dns.add_host(ipv4=self.ip_address, names=[self.addon.hostname])
|
||||||
|
|
||||||
def _install(
|
def _install(
|
||||||
self, tag: str, image: Optional[str] = None, latest: bool = False
|
self, tag: str, image: Optional[str] = None, latest: bool = False
|
||||||
@ -490,5 +490,5 @@ class DockerAddon(DockerInterface):
|
|||||||
Need run inside executor.
|
Need run inside executor.
|
||||||
"""
|
"""
|
||||||
if self.ip_address != NO_ADDDRESS:
|
if self.ip_address != NO_ADDDRESS:
|
||||||
self.sys_dns.delete_host(self.addon.hostname)
|
self.sys_plugins.dns.delete_host(self.addon.hostname)
|
||||||
super()._stop(remove_container)
|
super()._stop(remove_container)
|
||||||
|
@ -20,7 +20,7 @@ class DockerAudio(DockerInterface, CoreSysAttributes):
|
|||||||
@property
|
@property
|
||||||
def image(self) -> str:
|
def image(self) -> str:
|
||||||
"""Return name of Supervisor Audio image."""
|
"""Return name of Supervisor Audio image."""
|
||||||
return f"homeassistant/{self.sys_arch.supervisor}-hassio-audio"
|
return self.sys_plugins.audio.image
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
@ -32,7 +32,7 @@ class DockerAudio(DockerInterface, CoreSysAttributes):
|
|||||||
"""Return Volumes for the mount."""
|
"""Return Volumes for the mount."""
|
||||||
volumes = {
|
volumes = {
|
||||||
str(self.sys_config.path_extern_audio): {"bind": "/data", "mode": "rw"},
|
str(self.sys_config.path_extern_audio): {"bind": "/data", "mode": "rw"},
|
||||||
"/etc/group": {"bind": "/host/group", "mode": "ro"},
|
"/run/dbus": {"bind": "/run/dbus", "mode": "ro"},
|
||||||
}
|
}
|
||||||
|
|
||||||
# SND support
|
# SND support
|
||||||
@ -58,7 +58,7 @@ class DockerAudio(DockerInterface, CoreSysAttributes):
|
|||||||
# Create & Run container
|
# Create & Run container
|
||||||
docker_container = self.sys_docker.run(
|
docker_container = self.sys_docker.run(
|
||||||
self.image,
|
self.image,
|
||||||
version=self.sys_audio.version,
|
version=self.sys_plugins.audio.version,
|
||||||
init=False,
|
init=False,
|
||||||
ipv4=self.sys_docker.network.audio,
|
ipv4=self.sys_docker.network.audio,
|
||||||
name=self.name,
|
name=self.name,
|
||||||
|
@ -18,7 +18,7 @@ class DockerCli(DockerInterface, CoreSysAttributes):
|
|||||||
@property
|
@property
|
||||||
def image(self):
|
def image(self):
|
||||||
"""Return name of HA cli image."""
|
"""Return name of HA cli image."""
|
||||||
return f"homeassistant/{self.sys_arch.supervisor}-hassio-cli"
|
return self.sys_plugins.cli.image
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
@ -42,7 +42,7 @@ class DockerCli(DockerInterface, CoreSysAttributes):
|
|||||||
self.image,
|
self.image,
|
||||||
entrypoint=["/init"],
|
entrypoint=["/init"],
|
||||||
command=["/bin/bash", "-c", "sleep infinity"],
|
command=["/bin/bash", "-c", "sleep infinity"],
|
||||||
version=self.sys_cli.version,
|
version=self.sys_plugins.cli.version,
|
||||||
init=False,
|
init=False,
|
||||||
ipv4=self.sys_docker.network.cli,
|
ipv4=self.sys_docker.network.cli,
|
||||||
name=self.name,
|
name=self.name,
|
||||||
@ -51,7 +51,7 @@ class DockerCli(DockerInterface, CoreSysAttributes):
|
|||||||
extra_hosts={"supervisor": self.sys_docker.network.supervisor},
|
extra_hosts={"supervisor": self.sys_docker.network.supervisor},
|
||||||
environment={
|
environment={
|
||||||
ENV_TIME: self.sys_timezone,
|
ENV_TIME: self.sys_timezone,
|
||||||
ENV_TOKEN: self.sys_cli.supervisor_token,
|
ENV_TOKEN: self.sys_plugins.cli.supervisor_token,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,5 +60,5 @@ class DockerCli(DockerInterface, CoreSysAttributes):
|
|||||||
"Start CLI %s with version %s - %s",
|
"Start CLI %s with version %s - %s",
|
||||||
self.image,
|
self.image,
|
||||||
self.version,
|
self.version,
|
||||||
self.sys_docker.network.audio,
|
self.sys_docker.network.cli,
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@ class DockerDNS(DockerInterface, CoreSysAttributes):
|
|||||||
@property
|
@property
|
||||||
def image(self) -> str:
|
def image(self) -> str:
|
||||||
"""Return name of Supervisor DNS image."""
|
"""Return name of Supervisor DNS image."""
|
||||||
return f"homeassistant/{self.sys_arch.supervisor}-hassio-dns"
|
return self.sys_plugins.dns.image
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
@ -40,7 +40,7 @@ class DockerDNS(DockerInterface, CoreSysAttributes):
|
|||||||
# Create & Run container
|
# Create & Run container
|
||||||
docker_container = self.sys_docker.run(
|
docker_container = self.sys_docker.run(
|
||||||
self.image,
|
self.image,
|
||||||
version=self.sys_dns.version,
|
version=self.sys_plugins.dns.version,
|
||||||
init=False,
|
init=False,
|
||||||
dns=False,
|
dns=False,
|
||||||
ipv4=self.sys_docker.network.dns,
|
ipv4=self.sys_docker.network.dns,
|
||||||
|
@ -72,11 +72,11 @@ class DockerHomeAssistant(DockerInterface):
|
|||||||
"bind": "/etc/pulse/client.conf",
|
"bind": "/etc/pulse/client.conf",
|
||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
str(self.sys_audio.path_extern_pulse): {
|
str(self.sys_plugins.audio.path_extern_pulse): {
|
||||||
"bind": "/run/audio",
|
"bind": "/run/audio",
|
||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
str(self.sys_audio.path_extern_asound): {
|
str(self.sys_plugins.audio.path_extern_asound): {
|
||||||
"bind": "/etc/asound.conf",
|
"bind": "/etc/asound.conf",
|
||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
},
|
},
|
||||||
|
@ -302,11 +302,11 @@ class DockerInterface(CoreSysAttributes):
|
|||||||
_LOGGER.warning("Can't grep logs from %s: %s", self.image, err)
|
_LOGGER.warning("Can't grep logs from %s: %s", self.image, err)
|
||||||
|
|
||||||
@process_lock
|
@process_lock
|
||||||
def cleanup(self) -> Awaitable[None]:
|
def cleanup(self, old_image: Optional[str] = None) -> Awaitable[None]:
|
||||||
"""Check if old version exists and cleanup."""
|
"""Check if old version exists and cleanup."""
|
||||||
return self.sys_run_in_executor(self._cleanup)
|
return self.sys_run_in_executor(self._cleanup, old_image)
|
||||||
|
|
||||||
def _cleanup(self) -> None:
|
def _cleanup(self, old_image: Optional[str] = None) -> None:
|
||||||
"""Check if old version exists and cleanup.
|
"""Check if old version exists and cleanup.
|
||||||
|
|
||||||
Need run inside executor.
|
Need run inside executor.
|
||||||
@ -317,6 +317,7 @@ class DockerInterface(CoreSysAttributes):
|
|||||||
_LOGGER.warning("Can't find %s for cleanup", self.image)
|
_LOGGER.warning("Can't find %s for cleanup", self.image)
|
||||||
raise DockerAPIError() from None
|
raise DockerAPIError() from None
|
||||||
|
|
||||||
|
# Cleanup Current
|
||||||
for image in self.sys_docker.images.list(name=self.image):
|
for image in self.sys_docker.images.list(name=self.image):
|
||||||
if origin.id == image.id:
|
if origin.id == image.id:
|
||||||
continue
|
continue
|
||||||
@ -325,6 +326,15 @@ class DockerInterface(CoreSysAttributes):
|
|||||||
_LOGGER.info("Cleanup images: %s", image.tags)
|
_LOGGER.info("Cleanup images: %s", image.tags)
|
||||||
self.sys_docker.images.remove(image.id, force=True)
|
self.sys_docker.images.remove(image.id, force=True)
|
||||||
|
|
||||||
|
# Cleanup Old
|
||||||
|
if not old_image or self.image == old_image:
|
||||||
|
return
|
||||||
|
|
||||||
|
for image in self.sys_docker.images.list(name=old_image):
|
||||||
|
with suppress(docker.errors.DockerException):
|
||||||
|
_LOGGER.info("Cleanup images: %s", image.tags)
|
||||||
|
self.sys_docker.images.remove(image.id, force=True)
|
||||||
|
|
||||||
@process_lock
|
@process_lock
|
||||||
def restart(self) -> Awaitable[None]:
|
def restart(self) -> Awaitable[None]:
|
||||||
"""Restart docker container."""
|
"""Restart docker container."""
|
||||||
|
56
supervisor/docker/multicast.py
Normal file
56
supervisor/docker/multicast.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
"""HA Cli docker object."""
|
||||||
|
from contextlib import suppress
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from ..const import ENV_TIME
|
||||||
|
from ..coresys import CoreSysAttributes
|
||||||
|
from ..exceptions import DockerAPIError
|
||||||
|
from .interface import DockerInterface
|
||||||
|
|
||||||
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
MULTICAST_DOCKER_NAME: str = "hassio_multicast"
|
||||||
|
|
||||||
|
|
||||||
|
class DockerMulticast(DockerInterface, CoreSysAttributes):
|
||||||
|
"""Docker Supervisor wrapper for HA multicast."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image(self):
|
||||||
|
"""Return name of HA multicast image."""
|
||||||
|
return self.sys_plugins.multicast.image
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
"""Return name of Docker container."""
|
||||||
|
return MULTICAST_DOCKER_NAME
|
||||||
|
|
||||||
|
def _run(self) -> None:
|
||||||
|
"""Run Docker image.
|
||||||
|
|
||||||
|
Need run inside executor.
|
||||||
|
"""
|
||||||
|
if self._is_running():
|
||||||
|
return
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
with suppress(DockerAPIError):
|
||||||
|
self._stop()
|
||||||
|
|
||||||
|
# Create & Run container
|
||||||
|
docker_container = self.sys_docker.run(
|
||||||
|
self.image,
|
||||||
|
version=self.sys_plugins.multicast.version,
|
||||||
|
init=False,
|
||||||
|
name=self.name,
|
||||||
|
hostname=self.name.replace("_", "-"),
|
||||||
|
network_mode="host",
|
||||||
|
detach=True,
|
||||||
|
extra_hosts={"supervisor": self.sys_docker.network.supervisor},
|
||||||
|
environment={ENV_TIME: self.sys_timezone},
|
||||||
|
)
|
||||||
|
|
||||||
|
self._meta = docker_container.attrs
|
||||||
|
_LOGGER.info(
|
||||||
|
"Start Multicast %s with version %s - Host", self.image, self.version
|
||||||
|
)
|
@ -61,10 +61,21 @@ class CliError(HassioError):
|
|||||||
"""HA cli exception."""
|
"""HA cli exception."""
|
||||||
|
|
||||||
|
|
||||||
class CliUpdateError(HassOSError):
|
class CliUpdateError(CliError):
|
||||||
"""Error on update of a HA cli."""
|
"""Error on update of a HA cli."""
|
||||||
|
|
||||||
|
|
||||||
|
# Multicast
|
||||||
|
|
||||||
|
|
||||||
|
class MulticastError(HassioError):
|
||||||
|
"""Multicast exception."""
|
||||||
|
|
||||||
|
|
||||||
|
class MulticastUpdateError(MulticastError):
|
||||||
|
"""Error on update of a multicast."""
|
||||||
|
|
||||||
|
|
||||||
# DNS
|
# DNS
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ from contextlib import asynccontextmanager, suppress
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
@ -24,7 +23,6 @@ from .const import (
|
|||||||
ATTR_AUDIO_OUTPUT,
|
ATTR_AUDIO_OUTPUT,
|
||||||
ATTR_BOOT,
|
ATTR_BOOT,
|
||||||
ATTR_IMAGE,
|
ATTR_IMAGE,
|
||||||
ATTR_VERSION_LATEST,
|
|
||||||
ATTR_PORT,
|
ATTR_PORT,
|
||||||
ATTR_REFRESH_TOKEN,
|
ATTR_REFRESH_TOKEN,
|
||||||
ATTR_SSL,
|
ATTR_SSL,
|
||||||
@ -91,6 +89,7 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
await self.install_landingpage()
|
await self.install_landingpage()
|
||||||
else:
|
else:
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.instance.image
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -163,37 +162,19 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
@property
|
@property
|
||||||
def latest_version(self) -> str:
|
def latest_version(self) -> str:
|
||||||
"""Return last available version of Home Assistant."""
|
"""Return last available version of Home Assistant."""
|
||||||
if self.is_custom_image:
|
|
||||||
return self._data.get(ATTR_VERSION_LATEST)
|
|
||||||
return self.sys_updater.version_homeassistant
|
return self.sys_updater.version_homeassistant
|
||||||
|
|
||||||
@latest_version.setter
|
|
||||||
def latest_version(self, value: str):
|
|
||||||
"""Set last available version of Home Assistant."""
|
|
||||||
if value:
|
|
||||||
self._data[ATTR_VERSION_LATEST] = value
|
|
||||||
else:
|
|
||||||
self._data.pop(ATTR_VERSION_LATEST, None)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image(self) -> str:
|
def image(self) -> str:
|
||||||
"""Return image name of the Home Assistant container."""
|
"""Return image name of the Home Assistant container."""
|
||||||
if self._data.get(ATTR_IMAGE):
|
if self._data.get(ATTR_IMAGE):
|
||||||
return self._data[ATTR_IMAGE]
|
return self._data[ATTR_IMAGE]
|
||||||
return os.environ["HOMEASSISTANT_REPOSITORY"]
|
return f"homeassistant/{self.sys_machine}-homeassistant"
|
||||||
|
|
||||||
@image.setter
|
@image.setter
|
||||||
def image(self, value: str):
|
def image(self, value: str) -> None:
|
||||||
"""Set image name of Home Assistant container."""
|
"""Set image name of Home Assistant container."""
|
||||||
if value:
|
self._data[ATTR_IMAGE] = value
|
||||||
self._data[ATTR_IMAGE] = value
|
|
||||||
else:
|
|
||||||
self._data.pop(ATTR_IMAGE, None)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_custom_image(self) -> bool:
|
|
||||||
"""Return True if a custom image is used."""
|
|
||||||
return all(attr in self._data for attr in (ATTR_IMAGE, ATTR_VERSION_LATEST))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def version(self) -> Optional[str]:
|
def version(self) -> Optional[str]:
|
||||||
@ -271,12 +252,15 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
_LOGGER.info("Setup HomeAssistant landingpage")
|
_LOGGER.info("Setup HomeAssistant landingpage")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
await self.instance.install("landingpage")
|
await self.instance.install(
|
||||||
|
"landingpage", image=self.sys_updater.image_homeassistant
|
||||||
|
)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.warning("Fails install landingpage, retry after 30sec")
|
_LOGGER.warning("Fails install landingpage, retry after 30sec")
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
else:
|
else:
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.sys_updater.image_homeassistant
|
||||||
self.save_data()
|
self.save_data()
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -297,13 +281,16 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
tag = self.latest_version
|
tag = self.latest_version
|
||||||
if tag:
|
if tag:
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.update(tag)
|
await self.instance.update(
|
||||||
|
tag, image=self.sys_updater.image_homeassistant
|
||||||
|
)
|
||||||
break
|
break
|
||||||
_LOGGER.warning("Error on install Home Assistant. Retry in 30sec")
|
_LOGGER.warning("Error on install Home Assistant. Retry in 30sec")
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
_LOGGER.info("Home Assistant docker now installed")
|
_LOGGER.info("Home Assistant docker now installed")
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.sys_updater.image_homeassistant
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
# finishing
|
# finishing
|
||||||
@ -321,6 +308,7 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
async def update(self, version: Optional[str] = None) -> None:
|
async def update(self, version: Optional[str] = None) -> None:
|
||||||
"""Update HomeAssistant version."""
|
"""Update HomeAssistant version."""
|
||||||
version = version or self.latest_version
|
version = version or self.latest_version
|
||||||
|
old_image = self.image
|
||||||
rollback = self.version if not self.error_state else None
|
rollback = self.version if not self.error_state else None
|
||||||
running = await self.instance.is_running()
|
running = await self.instance.is_running()
|
||||||
exists = await self.instance.exists()
|
exists = await self.instance.exists()
|
||||||
@ -334,20 +322,24 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
"""Run Home Assistant update."""
|
"""Run Home Assistant update."""
|
||||||
_LOGGER.info("Update Home Assistant to version %s", to_version)
|
_LOGGER.info("Update Home Assistant to version %s", to_version)
|
||||||
try:
|
try:
|
||||||
await self.instance.update(to_version)
|
await self.instance.update(
|
||||||
|
to_version, image=self.sys_updater.image_homeassistant
|
||||||
|
)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.warning("Update Home Assistant image fails")
|
_LOGGER.warning("Update Home Assistant image fails")
|
||||||
raise HomeAssistantUpdateError() from None
|
raise HomeAssistantUpdateError() from None
|
||||||
else:
|
else:
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.sys_updater.image_homeassistant
|
||||||
|
|
||||||
if running:
|
if running:
|
||||||
await self._start()
|
await self._start()
|
||||||
|
|
||||||
_LOGGER.info("Successful run Home Assistant %s", to_version)
|
_LOGGER.info("Successful run Home Assistant %s", to_version)
|
||||||
|
|
||||||
|
# Successfull - last step
|
||||||
self.save_data()
|
self.save_data()
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.cleanup()
|
await self.instance.cleanup(old_image=old_image)
|
||||||
|
|
||||||
# Update Home Assistant
|
# Update Home Assistant
|
||||||
with suppress(HomeAssistantError):
|
with suppress(HomeAssistantError):
|
||||||
@ -644,7 +636,7 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
def write_pulse(self):
|
def write_pulse(self):
|
||||||
"""Write asound config to file and return True on success."""
|
"""Write asound config to file and return True on success."""
|
||||||
pulse_config = self.sys_audio.pulse_client(
|
pulse_config = self.sys_plugins.audio.pulse_client(
|
||||||
input_profile=self.audio_input, output_profile=self.audio_output
|
input_profile=self.audio_input, output_profile=self.audio_output
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -127,6 +127,11 @@ class Ingress(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
async def update_hass_panel(self, addon: Addon):
|
async def update_hass_panel(self, addon: Addon):
|
||||||
"""Return True if Home Assistant up and running."""
|
"""Return True if Home Assistant up and running."""
|
||||||
|
if not await self.sys_homeassistant.is_running():
|
||||||
|
_LOGGER.debug("Ignore panel update on Core")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Update UI
|
||||||
method = "post" if addon.ingress_panel else "delete"
|
method = "post" if addon.ingress_panel else "delete"
|
||||||
async with self.sys_homeassistant.make_request(
|
async with self.sys_homeassistant.make_request(
|
||||||
method, f"api/hassio_push/panel/{addon.slug}"
|
method, f"api/hassio_push/panel/{addon.slug}"
|
||||||
|
113
supervisor/plugins/__init__.py
Normal file
113
supervisor/plugins/__init__.py
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
"""Plugin for Supervisor backend."""
|
||||||
|
import asyncio
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
|
from ..exceptions import HassioError
|
||||||
|
from .audio import Audio
|
||||||
|
from .cli import HaCli
|
||||||
|
from .dns import CoreDNS
|
||||||
|
from .multicast import Multicast
|
||||||
|
|
||||||
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class PluginManager(CoreSysAttributes):
|
||||||
|
"""Manage supported function for plugins."""
|
||||||
|
|
||||||
|
required_cli: int = 25
|
||||||
|
required_dns: int = 6
|
||||||
|
required_audio: int = 14
|
||||||
|
required_multicast: int = 2
|
||||||
|
|
||||||
|
def __init__(self, coresys: CoreSys):
|
||||||
|
"""Initialize plugin manager."""
|
||||||
|
self.coresys: CoreSys = coresys
|
||||||
|
|
||||||
|
self._cli: HaCli = HaCli(coresys)
|
||||||
|
self._dns: CoreDNS = CoreDNS(coresys)
|
||||||
|
self._audio: Audio = Audio(coresys)
|
||||||
|
self._multicast: Multicast = Multicast(coresys)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cli(self) -> HaCli:
|
||||||
|
"""Return cli handler."""
|
||||||
|
return self._cli
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dns(self) -> CoreDNS:
|
||||||
|
"""Return dns handler."""
|
||||||
|
return self._dns
|
||||||
|
|
||||||
|
@property
|
||||||
|
def audio(self) -> Audio:
|
||||||
|
"""Return audio handler."""
|
||||||
|
return self._audio
|
||||||
|
|
||||||
|
@property
|
||||||
|
def multicast(self) -> Multicast:
|
||||||
|
"""Return multicast handler."""
|
||||||
|
return self._multicast
|
||||||
|
|
||||||
|
async def load(self):
|
||||||
|
"""Load Supervisor plugins."""
|
||||||
|
await asyncio.wait(
|
||||||
|
[self.dns.load(), self.audio.load(), self.cli.load(), self.multicast.load()]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check requirements
|
||||||
|
for plugin, required_version in (
|
||||||
|
(self._audio, self.required_audio),
|
||||||
|
(self._dns, self.required_dns),
|
||||||
|
(self._cli, self.required_cli),
|
||||||
|
(self._multicast, self.required_multicast),
|
||||||
|
):
|
||||||
|
# Check if need an update
|
||||||
|
try:
|
||||||
|
if int(plugin.version) >= required_version:
|
||||||
|
continue
|
||||||
|
except TypeError:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Somethings going wrong with requirements on %s",
|
||||||
|
type(plugin).__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
_LOGGER.info(
|
||||||
|
"Requirement need update for %s - %i",
|
||||||
|
type(plugin).__name__,
|
||||||
|
required_version,
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
await plugin.update(version=str(required_version))
|
||||||
|
except HassioError:
|
||||||
|
_LOGGER.error(
|
||||||
|
"Can't update %s to %i but it's a reuirement, the Supervisor is not health now!",
|
||||||
|
type(plugin).__name__,
|
||||||
|
required_version,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def repair(self):
|
||||||
|
"""Repair Supervisor plugins."""
|
||||||
|
await asyncio.wait(
|
||||||
|
[
|
||||||
|
self.dns.repair(),
|
||||||
|
self.audio.repair(),
|
||||||
|
self.cli.repair(),
|
||||||
|
self.multicast.repair(),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
async def unload(self) -> None:
|
||||||
|
"""Unload Supervisor plugin."""
|
||||||
|
await asyncio.wait([self.dns.unload()])
|
||||||
|
|
||||||
|
async def shutdown(self) -> None:
|
||||||
|
"""Shutdown Supervisor plugin."""
|
||||||
|
await asyncio.wait(
|
||||||
|
[
|
||||||
|
self.dns.stop(),
|
||||||
|
self.audio.stop(),
|
||||||
|
self.cli.stop(),
|
||||||
|
self.multicast.stop(),
|
||||||
|
]
|
||||||
|
)
|
@ -1,4 +1,7 @@
|
|||||||
"""Home Assistant control object."""
|
"""Home Assistant audio plugin.
|
||||||
|
|
||||||
|
Code: https://github.com/home-assistant/plugin-audio
|
||||||
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import logging
|
import logging
|
||||||
@ -8,18 +11,18 @@ from typing import Awaitable, Optional
|
|||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
from .const import ATTR_VERSION, FILE_HASSIO_AUDIO
|
from ..const import ATTR_IMAGE, ATTR_VERSION, FILE_HASSIO_AUDIO
|
||||||
from .coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
from .docker.audio import DockerAudio
|
from ..docker.audio import DockerAudio
|
||||||
from .docker.stats import DockerStats
|
from ..docker.stats import DockerStats
|
||||||
from .exceptions import AudioError, AudioUpdateError, DockerAPIError
|
from ..exceptions import AudioError, AudioUpdateError, DockerAPIError
|
||||||
from .utils.json import JsonConfig
|
from ..utils.json import JsonConfig
|
||||||
from .validate import SCHEMA_AUDIO_CONFIG
|
from .validate import SCHEMA_AUDIO_CONFIG
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
PULSE_CLIENT_TMPL: Path = Path(__file__).parents[0].joinpath("data/pulse-client.tmpl")
|
PULSE_CLIENT_TMPL: Path = Path(__file__).parents[1].joinpath("data/pulse-client.tmpl")
|
||||||
ASOUND_TMPL: Path = Path(__file__).parents[0].joinpath("data/asound.tmpl")
|
ASOUND_TMPL: Path = Path(__file__).parents[1].joinpath("data/asound.tmpl")
|
||||||
|
|
||||||
|
|
||||||
class Audio(JsonConfig, CoreSysAttributes):
|
class Audio(JsonConfig, CoreSysAttributes):
|
||||||
@ -52,6 +55,18 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
"""Set current version of Audio."""
|
"""Set current version of Audio."""
|
||||||
self._data[ATTR_VERSION] = value
|
self._data[ATTR_VERSION] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image(self) -> str:
|
||||||
|
"""Return current image of Audio."""
|
||||||
|
if self._data.get(ATTR_IMAGE):
|
||||||
|
return self._data[ATTR_IMAGE]
|
||||||
|
return f"homeassistant/{self.sys_arch.supervisor}-hassio-audio"
|
||||||
|
|
||||||
|
@image.setter
|
||||||
|
def image(self, value: str) -> None:
|
||||||
|
"""Return current image of Audio."""
|
||||||
|
self._data[ATTR_IMAGE] = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def latest_version(self) -> Optional[str]:
|
def latest_version(self) -> Optional[str]:
|
||||||
"""Return latest version of Audio."""
|
"""Return latest version of Audio."""
|
||||||
@ -84,6 +99,7 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
await self.install()
|
await self.install()
|
||||||
else:
|
else:
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.instance.image
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
# Run PulseAudio
|
# Run PulseAudio
|
||||||
@ -115,35 +131,40 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
if self.latest_version:
|
if self.latest_version:
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.install(self.latest_version)
|
await self.instance.install(
|
||||||
|
self.latest_version, image=self.sys_updater.image_audio
|
||||||
|
)
|
||||||
break
|
break
|
||||||
_LOGGER.warning("Error on install Audio plugin. Retry in 30sec")
|
_LOGGER.warning("Error on install Audio plugin. Retry in 30sec")
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
_LOGGER.info("Audio plugin now installed")
|
_LOGGER.info("Audio plugin now installed")
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.sys_updater.image_audio
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
async def update(self, version: Optional[str] = None) -> None:
|
async def update(self, version: Optional[str] = None) -> None:
|
||||||
"""Update Audio plugin."""
|
"""Update Audio plugin."""
|
||||||
version = version or self.latest_version
|
version = version or self.latest_version
|
||||||
|
old_image = self.image
|
||||||
|
|
||||||
if version == self.version:
|
if version == self.version:
|
||||||
_LOGGER.warning("Version %s is already installed for Audio", version)
|
_LOGGER.warning("Version %s is already installed for Audio", version)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.instance.update(version)
|
await self.instance.update(version, image=self.sys_updater.image_audio)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.error("Audio update fails")
|
_LOGGER.error("Audio update fails")
|
||||||
raise AudioUpdateError() from None
|
raise AudioUpdateError() from None
|
||||||
else:
|
else:
|
||||||
# Cleanup
|
self.version = version
|
||||||
with suppress(DockerAPIError):
|
self.image = self.sys_updater.image_audio
|
||||||
await self.instance.cleanup()
|
self.save_data()
|
||||||
|
|
||||||
self.version = version
|
# Cleanup
|
||||||
self.save_data()
|
with suppress(DockerAPIError):
|
||||||
|
await self.instance.cleanup(old_image=old_image)
|
||||||
|
|
||||||
# Start Audio
|
# Start Audio
|
||||||
await self.start()
|
await self.start()
|
||||||
@ -159,7 +180,6 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
async def start(self) -> None:
|
async def start(self) -> None:
|
||||||
"""Run CoreDNS."""
|
"""Run CoreDNS."""
|
||||||
# Start Instance
|
|
||||||
_LOGGER.info("Start Audio plugin")
|
_LOGGER.info("Start Audio plugin")
|
||||||
try:
|
try:
|
||||||
await self.instance.run()
|
await self.instance.run()
|
||||||
@ -167,6 +187,15 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
_LOGGER.error("Can't start Audio plugin")
|
_LOGGER.error("Can't start Audio plugin")
|
||||||
raise AudioError() from None
|
raise AudioError() from None
|
||||||
|
|
||||||
|
async def stop(self) -> None:
|
||||||
|
"""Stop CoreDNS."""
|
||||||
|
_LOGGER.info("Stop Audio plugin")
|
||||||
|
try:
|
||||||
|
await self.instance.stop()
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Can't stop Audio plugin")
|
||||||
|
raise AudioError() from None
|
||||||
|
|
||||||
def logs(self) -> Awaitable[bytes]:
|
def logs(self) -> Awaitable[bytes]:
|
||||||
"""Get CoreDNS docker logs.
|
"""Get CoreDNS docker logs.
|
||||||
|
|
@ -1,16 +1,19 @@
|
|||||||
"""CLI support on supervisor."""
|
"""Home Assistant cli plugin.
|
||||||
|
|
||||||
|
Code: https://github.com/home-assistant/plugin-cli
|
||||||
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import logging
|
import logging
|
||||||
import secrets
|
import secrets
|
||||||
from typing import Awaitable, Optional
|
from typing import Awaitable, Optional
|
||||||
|
|
||||||
from .const import ATTR_ACCESS_TOKEN, ATTR_VERSION, FILE_HASSIO_CLI
|
from ..const import ATTR_ACCESS_TOKEN, ATTR_IMAGE, ATTR_VERSION, FILE_HASSIO_CLI
|
||||||
from .coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
from .docker.cli import DockerCli
|
from ..docker.cli import DockerCli
|
||||||
from .docker.stats import DockerStats
|
from ..docker.stats import DockerStats
|
||||||
from .exceptions import CliError, CliUpdateError, DockerAPIError
|
from ..exceptions import CliError, CliUpdateError, DockerAPIError
|
||||||
from .utils.json import JsonConfig
|
from ..utils.json import JsonConfig
|
||||||
from .validate import SCHEMA_CLI_CONFIG
|
from .validate import SCHEMA_CLI_CONFIG
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
@ -35,6 +38,18 @@ class HaCli(CoreSysAttributes, JsonConfig):
|
|||||||
"""Set current version of cli."""
|
"""Set current version of cli."""
|
||||||
self._data[ATTR_VERSION] = value
|
self._data[ATTR_VERSION] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image(self) -> str:
|
||||||
|
"""Return current image of cli."""
|
||||||
|
if self._data.get(ATTR_IMAGE):
|
||||||
|
return self._data[ATTR_IMAGE]
|
||||||
|
return f"homeassistant/{self.sys_arch.supervisor}-hassio-cli"
|
||||||
|
|
||||||
|
@image.setter
|
||||||
|
def image(self, value: str) -> None:
|
||||||
|
"""Return current image of cli."""
|
||||||
|
self._data[ATTR_IMAGE] = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def latest_version(self) -> str:
|
def latest_version(self) -> str:
|
||||||
"""Return version of latest cli."""
|
"""Return version of latest cli."""
|
||||||
@ -72,6 +87,7 @@ class HaCli(CoreSysAttributes, JsonConfig):
|
|||||||
await self.install()
|
await self.install()
|
||||||
else:
|
else:
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.instance.image
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
# Run PulseAudio
|
# Run PulseAudio
|
||||||
@ -89,35 +105,44 @@ class HaCli(CoreSysAttributes, JsonConfig):
|
|||||||
|
|
||||||
if self.latest_version:
|
if self.latest_version:
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.install(self.latest_version, latest=True)
|
await self.instance.install(
|
||||||
|
self.latest_version,
|
||||||
|
image=self.sys_updater.image_cli,
|
||||||
|
latest=True,
|
||||||
|
)
|
||||||
break
|
break
|
||||||
_LOGGER.warning("Error on install cli plugin. Retry in 30sec")
|
_LOGGER.warning("Error on install cli plugin. Retry in 30sec")
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
_LOGGER.info("cli plugin now installed")
|
_LOGGER.info("cli plugin now installed")
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.sys_updater.image_cli
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
async def update(self, version: Optional[str] = None) -> None:
|
async def update(self, version: Optional[str] = None) -> None:
|
||||||
"""Update local HA cli."""
|
"""Update local HA cli."""
|
||||||
version = version or self.latest_version
|
version = version or self.latest_version
|
||||||
|
old_image = self.image
|
||||||
|
|
||||||
if version == self.version:
|
if version == self.version:
|
||||||
_LOGGER.warning("Version %s is already installed for cli", version)
|
_LOGGER.warning("Version %s is already installed for cli", version)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.instance.update(version, latest=True)
|
await self.instance.update(
|
||||||
|
version, image=self.sys_updater.image_cli, latest=True
|
||||||
|
)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.error("HA cli update fails")
|
_LOGGER.error("HA cli update fails")
|
||||||
raise CliUpdateError() from None
|
raise CliUpdateError() from None
|
||||||
|
else:
|
||||||
|
self.version = version
|
||||||
|
self.image = self.sys_updater.image_cli
|
||||||
|
self.save_data()
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.cleanup()
|
await self.instance.cleanup(old_image=old_image)
|
||||||
|
|
||||||
self.version = version
|
|
||||||
self.save_data()
|
|
||||||
|
|
||||||
# Start cli
|
# Start cli
|
||||||
await self.start()
|
await self.start()
|
||||||
@ -136,6 +161,15 @@ class HaCli(CoreSysAttributes, JsonConfig):
|
|||||||
_LOGGER.error("Can't start cli plugin")
|
_LOGGER.error("Can't start cli plugin")
|
||||||
raise CliError() from None
|
raise CliError() from None
|
||||||
|
|
||||||
|
async def stop(self) -> None:
|
||||||
|
"""Stop cli."""
|
||||||
|
_LOGGER.info("Stop cli plugin")
|
||||||
|
try:
|
||||||
|
await self.instance.stop()
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Can't stop cli plugin")
|
||||||
|
raise CliError() from None
|
||||||
|
|
||||||
async def stats(self) -> DockerStats:
|
async def stats(self) -> DockerStats:
|
||||||
"""Return stats of cli."""
|
"""Return stats of cli."""
|
||||||
try:
|
try:
|
@ -1,4 +1,7 @@
|
|||||||
"""Home Assistant control object."""
|
"""Home Assistant dns plugin.
|
||||||
|
|
||||||
|
Code: https://github.com/home-assistant/plugin-dns
|
||||||
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
@ -10,19 +13,27 @@ import attr
|
|||||||
import jinja2
|
import jinja2
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from .const import ATTR_SERVERS, ATTR_VERSION, DNS_SUFFIX, FILE_HASSIO_DNS
|
from ..const import (
|
||||||
from .coresys import CoreSys, CoreSysAttributes
|
ATTR_IMAGE,
|
||||||
from .docker.dns import DockerDNS
|
ATTR_SERVERS,
|
||||||
from .docker.stats import DockerStats
|
ATTR_VERSION,
|
||||||
from .exceptions import CoreDNSError, CoreDNSUpdateError, DockerAPIError
|
DNS_SUFFIX,
|
||||||
from .misc.forwarder import DNSForward
|
FILE_HASSIO_DNS,
|
||||||
from .utils.json import JsonConfig
|
LogLevel,
|
||||||
from .validate import dns_url, SCHEMA_DNS_CONFIG
|
)
|
||||||
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
|
from ..docker.dns import DockerDNS
|
||||||
|
from ..docker.stats import DockerStats
|
||||||
|
from ..exceptions import CoreDNSError, CoreDNSUpdateError, DockerAPIError
|
||||||
|
from ..misc.forwarder import DNSForward
|
||||||
|
from ..utils.json import JsonConfig
|
||||||
|
from ..validate import dns_url
|
||||||
|
from .validate import SCHEMA_DNS_CONFIG
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
COREDNS_TMPL: Path = Path(__file__).parents[0].joinpath("data/coredns.tmpl")
|
COREDNS_TMPL: Path = Path(__file__).parents[1].joinpath("data/coredns.tmpl")
|
||||||
RESOLV_TMPL: Path = Path(__file__).parents[0].joinpath("data/resolv.tmpl")
|
RESOLV_TMPL: Path = Path(__file__).parents[1].joinpath("data/resolv.tmpl")
|
||||||
HOST_RESOLV: Path = Path("/etc/resolv.conf")
|
HOST_RESOLV: Path = Path("/etc/resolv.conf")
|
||||||
|
|
||||||
|
|
||||||
@ -79,6 +90,18 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
"""Return current version of DNS."""
|
"""Return current version of DNS."""
|
||||||
self._data[ATTR_VERSION] = value
|
self._data[ATTR_VERSION] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image(self) -> str:
|
||||||
|
"""Return current image of DNS."""
|
||||||
|
if self._data.get(ATTR_IMAGE):
|
||||||
|
return self._data[ATTR_IMAGE]
|
||||||
|
return f"homeassistant/{self.sys_arch.supervisor}-hassio-dns"
|
||||||
|
|
||||||
|
@image.setter
|
||||||
|
def image(self, value: str) -> None:
|
||||||
|
"""Return current image of DNS."""
|
||||||
|
self._data[ATTR_IMAGE] = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def latest_version(self) -> Optional[str]:
|
def latest_version(self) -> Optional[str]:
|
||||||
"""Return latest version of CoreDNS."""
|
"""Return latest version of CoreDNS."""
|
||||||
@ -115,6 +138,7 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
await self.install()
|
await self.install()
|
||||||
else:
|
else:
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.instance.image
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
# Start DNS forwarder
|
# Start DNS forwarder
|
||||||
@ -154,13 +178,16 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
if self.latest_version:
|
if self.latest_version:
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.install(self.latest_version)
|
await self.instance.install(
|
||||||
|
self.latest_version, image=self.sys_updater.image_dns
|
||||||
|
)
|
||||||
break
|
break
|
||||||
_LOGGER.warning("Error on install CoreDNS plugin. Retry in 30sec")
|
_LOGGER.warning("Error on install CoreDNS plugin. Retry in 30sec")
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
_LOGGER.info("CoreDNS plugin now installed")
|
_LOGGER.info("CoreDNS plugin now installed")
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
|
self.image = self.sys_updater.image_dns
|
||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
# Init Hosts
|
# Init Hosts
|
||||||
@ -169,6 +196,7 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
async def update(self, version: Optional[str] = None) -> None:
|
async def update(self, version: Optional[str] = None) -> None:
|
||||||
"""Update CoreDNS plugin."""
|
"""Update CoreDNS plugin."""
|
||||||
version = version or self.latest_version
|
version = version or self.latest_version
|
||||||
|
old_image = self.image
|
||||||
|
|
||||||
if version == self.version:
|
if version == self.version:
|
||||||
_LOGGER.warning("Version %s is already installed for CoreDNS", version)
|
_LOGGER.warning("Version %s is already installed for CoreDNS", version)
|
||||||
@ -176,17 +204,18 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
# Update
|
# Update
|
||||||
try:
|
try:
|
||||||
await self.instance.update(version)
|
await self.instance.update(version, image=self.sys_updater.image_dns)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.error("CoreDNS update fails")
|
_LOGGER.error("CoreDNS update fails")
|
||||||
raise CoreDNSUpdateError() from None
|
raise CoreDNSUpdateError() from None
|
||||||
|
else:
|
||||||
|
self.version = version
|
||||||
|
self.image = self.sys_updater.image_dns
|
||||||
|
self.save_data()
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.cleanup()
|
await self.instance.cleanup(old_image=old_image)
|
||||||
|
|
||||||
self.version = version
|
|
||||||
self.save_data()
|
|
||||||
|
|
||||||
# Start CoreDNS
|
# Start CoreDNS
|
||||||
await self.start()
|
await self.start()
|
||||||
@ -194,8 +223,12 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
async def restart(self) -> None:
|
async def restart(self) -> None:
|
||||||
"""Restart CoreDNS plugin."""
|
"""Restart CoreDNS plugin."""
|
||||||
self._write_corefile()
|
self._write_corefile()
|
||||||
with suppress(DockerAPIError):
|
_LOGGER.info("Restart CoreDNS plugin")
|
||||||
|
try:
|
||||||
await self.instance.restart()
|
await self.instance.restart()
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Can't start CoreDNS plugin")
|
||||||
|
raise CoreDNSError()
|
||||||
|
|
||||||
async def start(self) -> None:
|
async def start(self) -> None:
|
||||||
"""Run CoreDNS."""
|
"""Run CoreDNS."""
|
||||||
@ -209,6 +242,15 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
_LOGGER.error("Can't start CoreDNS plugin")
|
_LOGGER.error("Can't start CoreDNS plugin")
|
||||||
raise CoreDNSError() from None
|
raise CoreDNSError() from None
|
||||||
|
|
||||||
|
async def stop(self) -> None:
|
||||||
|
"""Stop CoreDNS."""
|
||||||
|
_LOGGER.info("Stop CoreDNS plugin")
|
||||||
|
try:
|
||||||
|
await self.instance.stop()
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Can't stop CoreDNS plugin")
|
||||||
|
raise CoreDNSError() from None
|
||||||
|
|
||||||
async def reset(self) -> None:
|
async def reset(self) -> None:
|
||||||
"""Reset DNS and hosts."""
|
"""Reset DNS and hosts."""
|
||||||
# Reset manually defined DNS
|
# Reset manually defined DNS
|
||||||
@ -266,7 +308,9 @@ class CoreDNS(JsonConfig, CoreSysAttributes):
|
|||||||
_LOGGER.warning("Ignore invalid DNS Server: %s", server)
|
_LOGGER.warning("Ignore invalid DNS Server: %s", server)
|
||||||
|
|
||||||
# Generate config file
|
# Generate config file
|
||||||
data = self.coredns_template.render(locals=dns_servers)
|
data = self.coredns_template.render(
|
||||||
|
locals=dns_servers, debug=self.sys_config.logging == LogLevel.DEBUG
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.corefile.write_text(data)
|
self.corefile.write_text(data)
|
208
supervisor/plugins/multicast.py
Normal file
208
supervisor/plugins/multicast.py
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
"""Home Assistant multicast plugin.
|
||||||
|
|
||||||
|
Code: https://github.com/home-assistant/plugin-multicast
|
||||||
|
"""
|
||||||
|
import asyncio
|
||||||
|
from contextlib import suppress
|
||||||
|
import logging
|
||||||
|
from typing import Awaitable, Optional
|
||||||
|
|
||||||
|
from ..const import ATTR_IMAGE, ATTR_VERSION, FILE_HASSIO_MULTICAST
|
||||||
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
|
from ..docker.multicast import DockerMulticast
|
||||||
|
from ..docker.stats import DockerStats
|
||||||
|
from ..exceptions import DockerAPIError, MulticastError, MulticastUpdateError
|
||||||
|
from ..utils.json import JsonConfig
|
||||||
|
from .validate import SCHEMA_MULTICAST_CONFIG
|
||||||
|
|
||||||
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Multicast(JsonConfig, CoreSysAttributes):
|
||||||
|
"""Home Assistant core object for handle it."""
|
||||||
|
|
||||||
|
def __init__(self, coresys: CoreSys):
|
||||||
|
"""Initialize hass object."""
|
||||||
|
super().__init__(FILE_HASSIO_MULTICAST, SCHEMA_MULTICAST_CONFIG)
|
||||||
|
self.coresys: CoreSys = coresys
|
||||||
|
self.instance: DockerMulticast = DockerMulticast(coresys)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def version(self) -> Optional[str]:
|
||||||
|
"""Return current version of Multicast."""
|
||||||
|
return self._data.get(ATTR_VERSION)
|
||||||
|
|
||||||
|
@version.setter
|
||||||
|
def version(self, value: str) -> None:
|
||||||
|
"""Return current version of Multicast."""
|
||||||
|
self._data[ATTR_VERSION] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image(self) -> str:
|
||||||
|
"""Return current image of Multicast."""
|
||||||
|
if self._data.get(ATTR_IMAGE):
|
||||||
|
return self._data[ATTR_IMAGE]
|
||||||
|
return f"homeassistant/{self.sys_arch.supervisor}-hassio-multicast"
|
||||||
|
|
||||||
|
@image.setter
|
||||||
|
def image(self, value: str) -> None:
|
||||||
|
"""Return current image of Multicast."""
|
||||||
|
self._data[ATTR_IMAGE] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def latest_version(self) -> Optional[str]:
|
||||||
|
"""Return latest version of Multicast."""
|
||||||
|
return self.sys_updater.version_multicast
|
||||||
|
|
||||||
|
@property
|
||||||
|
def in_progress(self) -> bool:
|
||||||
|
"""Return True if a task is in progress."""
|
||||||
|
return self.instance.in_progress
|
||||||
|
|
||||||
|
@property
|
||||||
|
def need_update(self) -> bool:
|
||||||
|
"""Return True if an update is available."""
|
||||||
|
return self.version != self.latest_version
|
||||||
|
|
||||||
|
async def load(self) -> None:
|
||||||
|
"""Load multicast setup."""
|
||||||
|
# Check Multicast state
|
||||||
|
try:
|
||||||
|
# Evaluate Version if we lost this information
|
||||||
|
if not self.version:
|
||||||
|
self.version = await self.instance.get_latest_version(key=int)
|
||||||
|
|
||||||
|
await self.instance.attach(tag=self.version)
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.info(
|
||||||
|
"No Multicast plugin Docker image %s found.", self.instance.image
|
||||||
|
)
|
||||||
|
|
||||||
|
# Install Multicast plugin
|
||||||
|
with suppress(MulticastError):
|
||||||
|
await self.install()
|
||||||
|
else:
|
||||||
|
self.version = self.instance.version
|
||||||
|
self.image = self.instance.image
|
||||||
|
self.save_data()
|
||||||
|
|
||||||
|
# Run Multicast plugin
|
||||||
|
with suppress(MulticastError):
|
||||||
|
if await self.instance.is_running():
|
||||||
|
await self.restart()
|
||||||
|
else:
|
||||||
|
await self.start()
|
||||||
|
|
||||||
|
async def install(self) -> None:
|
||||||
|
"""Install Multicast."""
|
||||||
|
_LOGGER.info("Setup Multicast plugin")
|
||||||
|
while True:
|
||||||
|
# read homeassistant tag and install it
|
||||||
|
if not self.latest_version:
|
||||||
|
await self.sys_updater.reload()
|
||||||
|
|
||||||
|
if self.latest_version:
|
||||||
|
with suppress(DockerAPIError):
|
||||||
|
await self.instance.install(
|
||||||
|
self.latest_version, image=self.sys_updater.image_multicast
|
||||||
|
)
|
||||||
|
break
|
||||||
|
_LOGGER.warning("Error on install Multicast plugin. Retry in 30sec")
|
||||||
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
|
_LOGGER.info("Multicast plugin now installed")
|
||||||
|
self.version = self.instance.version
|
||||||
|
self.image = self.sys_updater.image_multicast
|
||||||
|
self.save_data()
|
||||||
|
|
||||||
|
async def update(self, version: Optional[str] = None) -> None:
|
||||||
|
"""Update Multicast plugin."""
|
||||||
|
version = version or self.latest_version
|
||||||
|
old_image = self.image
|
||||||
|
|
||||||
|
if version == self.version:
|
||||||
|
_LOGGER.warning("Version %s is already installed for Multicast", version)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Update
|
||||||
|
try:
|
||||||
|
await self.instance.update(version, image=self.sys_updater.image_multicast)
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Multicast update fails")
|
||||||
|
raise MulticastUpdateError() from None
|
||||||
|
else:
|
||||||
|
self.version = version
|
||||||
|
self.image = self.sys_updater.image_multicast
|
||||||
|
self.save_data()
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
with suppress(DockerAPIError):
|
||||||
|
await self.instance.cleanup(old_image=old_image)
|
||||||
|
|
||||||
|
# Start Multicast plugin
|
||||||
|
await self.start()
|
||||||
|
|
||||||
|
async def restart(self) -> None:
|
||||||
|
"""Restart Multicast plugin."""
|
||||||
|
_LOGGER.info("Restart Multicast plugin")
|
||||||
|
try:
|
||||||
|
await self.instance.restart()
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Can't start Multicast plugin")
|
||||||
|
raise MulticastError()
|
||||||
|
|
||||||
|
async def start(self) -> None:
|
||||||
|
"""Run Multicast."""
|
||||||
|
_LOGGER.info("Start Multicast plugin")
|
||||||
|
try:
|
||||||
|
await self.instance.run()
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Can't start Multicast plugin")
|
||||||
|
raise MulticastError()
|
||||||
|
|
||||||
|
async def stop(self) -> None:
|
||||||
|
"""Stop Multicast."""
|
||||||
|
_LOGGER.info("Stop Multicast plugin")
|
||||||
|
try:
|
||||||
|
await self.instance.stop()
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Can't stop Multicast plugin")
|
||||||
|
raise MulticastError()
|
||||||
|
|
||||||
|
def logs(self) -> Awaitable[bytes]:
|
||||||
|
"""Get Multicast docker logs.
|
||||||
|
|
||||||
|
Return Coroutine.
|
||||||
|
"""
|
||||||
|
return self.instance.logs()
|
||||||
|
|
||||||
|
async def stats(self) -> DockerStats:
|
||||||
|
"""Return stats of Multicast."""
|
||||||
|
try:
|
||||||
|
return await self.instance.stats()
|
||||||
|
except DockerAPIError:
|
||||||
|
raise MulticastError() from None
|
||||||
|
|
||||||
|
def is_running(self) -> Awaitable[bool]:
|
||||||
|
"""Return True if Docker container is running.
|
||||||
|
|
||||||
|
Return a coroutine.
|
||||||
|
"""
|
||||||
|
return self.instance.is_running()
|
||||||
|
|
||||||
|
def is_fails(self) -> Awaitable[bool]:
|
||||||
|
"""Return True if a Docker container is fails state.
|
||||||
|
Return a coroutine.
|
||||||
|
"""
|
||||||
|
return self.instance.is_fails()
|
||||||
|
|
||||||
|
async def repair(self) -> None:
|
||||||
|
"""Repair Multicast plugin."""
|
||||||
|
if await self.instance.exists():
|
||||||
|
return
|
||||||
|
|
||||||
|
_LOGGER.info("Repair Multicast %s", self.version)
|
||||||
|
try:
|
||||||
|
await self.instance.install(self.version)
|
||||||
|
except DockerAPIError:
|
||||||
|
_LOGGER.error("Repairing of Multicast fails")
|
44
supervisor/plugins/validate.py
Normal file
44
supervisor/plugins/validate.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
"""Validate functions."""
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from ..const import ATTR_ACCESS_TOKEN, ATTR_IMAGE, ATTR_SERVERS, ATTR_VERSION
|
||||||
|
from ..validate import dns_server_list, docker_image, token
|
||||||
|
|
||||||
|
|
||||||
|
SCHEMA_DNS_CONFIG = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
||||||
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
|
vol.Optional(ATTR_SERVERS, default=list): dns_server_list,
|
||||||
|
},
|
||||||
|
extra=vol.REMOVE_EXTRA,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
SCHEMA_AUDIO_CONFIG = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
||||||
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
|
},
|
||||||
|
extra=vol.REMOVE_EXTRA,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
SCHEMA_CLI_CONFIG = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
||||||
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
|
vol.Optional(ATTR_ACCESS_TOKEN): token,
|
||||||
|
},
|
||||||
|
extra=vol.REMOVE_EXTRA,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
SCHEMA_MULTICAST_CONFIG = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
||||||
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
|
},
|
||||||
|
extra=vol.REMOVE_EXTRA,
|
||||||
|
)
|
@ -310,6 +310,9 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if addons:
|
if addons:
|
||||||
|
_LOGGER.info("Restore %s run Repositories", snapshot.slug)
|
||||||
|
await snapshot.restore_repositories()
|
||||||
|
|
||||||
_LOGGER.info("Restore %s old add-ons", snapshot.slug)
|
_LOGGER.info("Restore %s old add-ons", snapshot.slug)
|
||||||
await snapshot.restore_addons(addons)
|
await snapshot.restore_addons(addons)
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ from ..const import (
|
|||||||
ATTR_FOLDERS,
|
ATTR_FOLDERS,
|
||||||
ATTR_HOMEASSISTANT,
|
ATTR_HOMEASSISTANT,
|
||||||
ATTR_IMAGE,
|
ATTR_IMAGE,
|
||||||
ATTR_VERSION_LATEST,
|
|
||||||
ATTR_NAME,
|
ATTR_NAME,
|
||||||
ATTR_PORT,
|
ATTR_PORT,
|
||||||
ATTR_PROTECTED,
|
ATTR_PROTECTED,
|
||||||
@ -360,7 +359,7 @@ class Snapshot(CoreSysAttributes):
|
|||||||
"""Internal function to snapshot a folder."""
|
"""Internal function to snapshot a folder."""
|
||||||
slug_name = name.replace("/", "_")
|
slug_name = name.replace("/", "_")
|
||||||
tar_name = Path(self._tmp.name, f"{slug_name}.tar.gz")
|
tar_name = Path(self._tmp.name, f"{slug_name}.tar.gz")
|
||||||
origin_dir = Path(self.sys_config.path_hassio, name)
|
origin_dir = Path(self.sys_config.path_supervisor, name)
|
||||||
|
|
||||||
# Check if exists
|
# Check if exists
|
||||||
if not origin_dir.is_dir():
|
if not origin_dir.is_dir():
|
||||||
@ -397,7 +396,7 @@ class Snapshot(CoreSysAttributes):
|
|||||||
"""Intenal function to restore a folder."""
|
"""Intenal function to restore a folder."""
|
||||||
slug_name = name.replace("/", "_")
|
slug_name = name.replace("/", "_")
|
||||||
tar_name = Path(self._tmp.name, f"{slug_name}.tar.gz")
|
tar_name = Path(self._tmp.name, f"{slug_name}.tar.gz")
|
||||||
origin_dir = Path(self.sys_config.path_hassio, name)
|
origin_dir = Path(self.sys_config.path_supervisor, name)
|
||||||
|
|
||||||
# Check if exists inside snapshot
|
# Check if exists inside snapshot
|
||||||
if not tar_name.exists():
|
if not tar_name.exists():
|
||||||
@ -430,13 +429,7 @@ class Snapshot(CoreSysAttributes):
|
|||||||
self.homeassistant[ATTR_WATCHDOG] = self.sys_homeassistant.watchdog
|
self.homeassistant[ATTR_WATCHDOG] = self.sys_homeassistant.watchdog
|
||||||
self.homeassistant[ATTR_BOOT] = self.sys_homeassistant.boot
|
self.homeassistant[ATTR_BOOT] = self.sys_homeassistant.boot
|
||||||
self.homeassistant[ATTR_WAIT_BOOT] = self.sys_homeassistant.wait_boot
|
self.homeassistant[ATTR_WAIT_BOOT] = self.sys_homeassistant.wait_boot
|
||||||
|
self.homeassistant[ATTR_IMAGE] = self.sys_homeassistant.image
|
||||||
# Custom image
|
|
||||||
if self.sys_homeassistant.is_custom_image:
|
|
||||||
self.homeassistant[ATTR_IMAGE] = self.sys_homeassistant.image
|
|
||||||
self.homeassistant[
|
|
||||||
ATTR_VERSION_LATEST
|
|
||||||
] = self.sys_homeassistant.latest_version
|
|
||||||
|
|
||||||
# API/Proxy
|
# API/Proxy
|
||||||
self.homeassistant[ATTR_PORT] = self.sys_homeassistant.api_port
|
self.homeassistant[ATTR_PORT] = self.sys_homeassistant.api_port
|
||||||
@ -455,12 +448,9 @@ class Snapshot(CoreSysAttributes):
|
|||||||
self.sys_homeassistant.boot = self.homeassistant[ATTR_BOOT]
|
self.sys_homeassistant.boot = self.homeassistant[ATTR_BOOT]
|
||||||
self.sys_homeassistant.wait_boot = self.homeassistant[ATTR_WAIT_BOOT]
|
self.sys_homeassistant.wait_boot = self.homeassistant[ATTR_WAIT_BOOT]
|
||||||
|
|
||||||
# Custom image
|
# Was not needed before
|
||||||
if self.homeassistant.get(ATTR_IMAGE):
|
if self.homeassistant[ATTR_IMAGE]:
|
||||||
self.sys_homeassistant.image = self.homeassistant[ATTR_IMAGE]
|
self.sys_homeassistant.image = self.homeassistant[ATTR_IMAGE]
|
||||||
self.sys_homeassistant.latest_version = self.homeassistant[
|
|
||||||
ATTR_VERSION_LATEST
|
|
||||||
]
|
|
||||||
|
|
||||||
# API/Proxy
|
# API/Proxy
|
||||||
self.sys_homeassistant.api_port = self.homeassistant[ATTR_PORT]
|
self.sys_homeassistant.api_port = self.homeassistant[ATTR_PORT]
|
||||||
|
@ -11,7 +11,6 @@ from ..const import (
|
|||||||
ATTR_FOLDERS,
|
ATTR_FOLDERS,
|
||||||
ATTR_HOMEASSISTANT,
|
ATTR_HOMEASSISTANT,
|
||||||
ATTR_IMAGE,
|
ATTR_IMAGE,
|
||||||
ATTR_VERSION_LATEST,
|
|
||||||
ATTR_NAME,
|
ATTR_NAME,
|
||||||
ATTR_PORT,
|
ATTR_PORT,
|
||||||
ATTR_PROTECTED,
|
ATTR_PROTECTED,
|
||||||
@ -60,8 +59,7 @@ SCHEMA_SNAPSHOT = vol.Schema(
|
|||||||
vol.Optional(ATTR_HOMEASSISTANT, default=dict): vol.Schema(
|
vol.Optional(ATTR_HOMEASSISTANT, default=dict): vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(ATTR_VERSION): vol.Coerce(str),
|
vol.Optional(ATTR_VERSION): vol.Coerce(str),
|
||||||
vol.Inclusive(ATTR_IMAGE, "custom_hass"): docker_image,
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
vol.Inclusive(ATTR_VERSION_LATEST, "custom_hass"): vol.Coerce(str),
|
|
||||||
vol.Optional(ATTR_BOOT, default=True): vol.Boolean(),
|
vol.Optional(ATTR_BOOT, default=True): vol.Boolean(),
|
||||||
vol.Optional(ATTR_SSL, default=False): vol.Boolean(),
|
vol.Optional(ATTR_SSL, default=False): vol.Boolean(),
|
||||||
vol.Optional(ATTR_PORT, default=8123): network_port,
|
vol.Optional(ATTR_PORT, default=8123): network_port,
|
||||||
|
@ -65,7 +65,7 @@ class Supervisor(CoreSysAttributes):
|
|||||||
@property
|
@property
|
||||||
def latest_version(self) -> str:
|
def latest_version(self) -> str:
|
||||||
"""Return last available version of Home Assistant."""
|
"""Return last available version of Home Assistant."""
|
||||||
return self.sys_updater.version_hassio
|
return self.sys_updater.version_supervisor
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image(self) -> str:
|
def image(self) -> str:
|
||||||
@ -115,7 +115,9 @@ class Supervisor(CoreSysAttributes):
|
|||||||
|
|
||||||
_LOGGER.info("Update Supervisor to version %s", version)
|
_LOGGER.info("Update Supervisor to version %s", version)
|
||||||
try:
|
try:
|
||||||
await self.instance.install(version, image=None, latest=True)
|
await self.instance.install(
|
||||||
|
version, image=self.sys_updater.image_supervisor, latest=True
|
||||||
|
)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.error("Update of Supervisor fails!")
|
_LOGGER.error("Update of Supervisor fails!")
|
||||||
raise SupervisorUpdateError() from None
|
raise SupervisorUpdateError() from None
|
||||||
|
@ -3,7 +3,13 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .coresys import CoreSysAttributes
|
from .coresys import CoreSysAttributes
|
||||||
from .exceptions import AudioError, CliError, CoreDNSError, HomeAssistantError
|
from .exceptions import (
|
||||||
|
AudioError,
|
||||||
|
CliError,
|
||||||
|
CoreDNSError,
|
||||||
|
HomeAssistantError,
|
||||||
|
MulticastError,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -14,6 +20,7 @@ RUN_UPDATE_ADDONS = 57600
|
|||||||
RUN_UPDATE_CLI = 28100
|
RUN_UPDATE_CLI = 28100
|
||||||
RUN_UPDATE_DNS = 30100
|
RUN_UPDATE_DNS = 30100
|
||||||
RUN_UPDATE_AUDIO = 30200
|
RUN_UPDATE_AUDIO = 30200
|
||||||
|
RUN_UPDATE_MULTICAST = 30300
|
||||||
|
|
||||||
RUN_RELOAD_ADDONS = 10800
|
RUN_RELOAD_ADDONS = 10800
|
||||||
RUN_RELOAD_SNAPSHOTS = 72000
|
RUN_RELOAD_SNAPSHOTS = 72000
|
||||||
@ -27,6 +34,7 @@ RUN_WATCHDOG_HOMEASSISTANT_API = 300
|
|||||||
RUN_WATCHDOG_DNS_DOCKER = 20
|
RUN_WATCHDOG_DNS_DOCKER = 20
|
||||||
RUN_WATCHDOG_AUDIO_DOCKER = 30
|
RUN_WATCHDOG_AUDIO_DOCKER = 30
|
||||||
RUN_WATCHDOG_CLI_DOCKER = 40
|
RUN_WATCHDOG_CLI_DOCKER = 40
|
||||||
|
RUN_WATCHDOG_MULTICAST_DOCKER = 50
|
||||||
|
|
||||||
|
|
||||||
class Tasks(CoreSysAttributes):
|
class Tasks(CoreSysAttributes):
|
||||||
@ -58,6 +66,11 @@ class Tasks(CoreSysAttributes):
|
|||||||
self.jobs.add(
|
self.jobs.add(
|
||||||
self.sys_scheduler.register_task(self._update_audio, RUN_UPDATE_AUDIO)
|
self.sys_scheduler.register_task(self._update_audio, RUN_UPDATE_AUDIO)
|
||||||
)
|
)
|
||||||
|
self.jobs.add(
|
||||||
|
self.sys_scheduler.register_task(
|
||||||
|
self._update_multicast, RUN_UPDATE_MULTICAST
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Reload
|
# Reload
|
||||||
self.jobs.add(
|
self.jobs.add(
|
||||||
@ -108,6 +121,11 @@ class Tasks(CoreSysAttributes):
|
|||||||
self._watchdog_cli_docker, RUN_WATCHDOG_CLI_DOCKER
|
self._watchdog_cli_docker, RUN_WATCHDOG_CLI_DOCKER
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self.jobs.add(
|
||||||
|
self.sys_scheduler.register_task(
|
||||||
|
self._watchdog_multicast_docker, RUN_WATCHDOG_MULTICAST_DOCKER
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER.info("All core tasks are scheduled")
|
_LOGGER.info("All core tasks are scheduled")
|
||||||
|
|
||||||
@ -209,66 +227,92 @@ class Tasks(CoreSysAttributes):
|
|||||||
|
|
||||||
async def _update_cli(self):
|
async def _update_cli(self):
|
||||||
"""Check and run update of cli."""
|
"""Check and run update of cli."""
|
||||||
if not self.sys_cli.need_update:
|
if not self.sys_plugins.cli.need_update:
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.info("Found new cli version")
|
_LOGGER.info("Found new cli version")
|
||||||
await self.sys_cli.update()
|
await self.sys_plugins.cli.update()
|
||||||
|
|
||||||
async def _update_dns(self):
|
async def _update_dns(self):
|
||||||
"""Check and run update of CoreDNS plugin."""
|
"""Check and run update of CoreDNS plugin."""
|
||||||
if not self.sys_dns.need_update:
|
if not self.sys_plugins.dns.need_update:
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.info("Found new CoreDNS plugin version")
|
_LOGGER.info("Found new CoreDNS plugin version")
|
||||||
await self.sys_dns.update()
|
await self.sys_plugins.dns.update()
|
||||||
|
|
||||||
async def _update_audio(self):
|
async def _update_audio(self):
|
||||||
"""Check and run update of PulseAudio plugin."""
|
"""Check and run update of PulseAudio plugin."""
|
||||||
if not self.sys_audio.need_update:
|
if not self.sys_plugins.audio.need_update:
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.info("Found new PulseAudio plugin version")
|
_LOGGER.info("Found new PulseAudio plugin version")
|
||||||
await self.sys_audio.update()
|
await self.sys_plugins.audio.update()
|
||||||
|
|
||||||
|
async def _update_multicast(self):
|
||||||
|
"""Check and run update of multicast."""
|
||||||
|
if not self.sys_plugins.multicast.need_update:
|
||||||
|
return
|
||||||
|
|
||||||
|
_LOGGER.info("Found new Multicast version")
|
||||||
|
await self.sys_plugins.multicast.update()
|
||||||
|
|
||||||
async def _watchdog_dns_docker(self):
|
async def _watchdog_dns_docker(self):
|
||||||
"""Check running state of Docker and start if they is close."""
|
"""Check running state of Docker and start if they is close."""
|
||||||
# if CoreDNS is active
|
# if CoreDNS is active
|
||||||
if await self.sys_dns.is_running() or self.sys_dns.in_progress:
|
if await self.sys_plugins.dns.is_running() or self.sys_plugins.dns.in_progress:
|
||||||
return
|
return
|
||||||
_LOGGER.warning("Watchdog found a problem with CoreDNS plugin!")
|
_LOGGER.warning("Watchdog found a problem with CoreDNS plugin!")
|
||||||
|
|
||||||
# Reset of fails
|
# Reset of fails
|
||||||
if await self.sys_dns.is_fails():
|
if await self.sys_plugins.dns.is_fails():
|
||||||
_LOGGER.error("CoreDNS plugin is in fails state / Reset config")
|
_LOGGER.error("CoreDNS plugin is in fails state / Reset config")
|
||||||
await self.sys_dns.reset()
|
await self.sys_plugins.dns.reset()
|
||||||
await self.sys_dns.loop_detection()
|
await self.sys_plugins.dns.loop_detection()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.sys_dns.start()
|
await self.sys_plugins.dns.start()
|
||||||
except CoreDNSError:
|
except CoreDNSError:
|
||||||
_LOGGER.error("Watchdog CoreDNS reanimation fails!")
|
_LOGGER.error("Watchdog CoreDNS reanimation fails!")
|
||||||
|
|
||||||
async def _watchdog_audio_docker(self):
|
async def _watchdog_audio_docker(self):
|
||||||
"""Check running state of Docker and start if they is close."""
|
"""Check running state of Docker and start if they is close."""
|
||||||
# if PulseAudio plugin is active
|
# if PulseAudio plugin is active
|
||||||
if await self.sys_audio.is_running() or self.sys_audio.in_progress:
|
if (
|
||||||
|
await self.sys_plugins.audio.is_running()
|
||||||
|
or self.sys_plugins.audio.in_progress
|
||||||
|
):
|
||||||
return
|
return
|
||||||
_LOGGER.warning("Watchdog found a problem with PulseAudio plugin!")
|
_LOGGER.warning("Watchdog found a problem with PulseAudio plugin!")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.sys_audio.start()
|
await self.sys_plugins.audio.start()
|
||||||
except AudioError:
|
except AudioError:
|
||||||
_LOGGER.error("Watchdog PulseAudio reanimation fails!")
|
_LOGGER.error("Watchdog PulseAudio reanimation fails!")
|
||||||
|
|
||||||
async def _watchdog_cli_docker(self):
|
async def _watchdog_cli_docker(self):
|
||||||
"""Check running state of Docker and start if they is close."""
|
"""Check running state of Docker and start if they is close."""
|
||||||
# if cli plugin is active
|
# if cli plugin is active
|
||||||
if await self.sys_cli.is_running() or self.sys_cli.in_progress:
|
if await self.sys_plugins.cli.is_running() or self.sys_plugins.cli.in_progress:
|
||||||
return
|
return
|
||||||
_LOGGER.warning("Watchdog found a problem with cli plugin!")
|
_LOGGER.warning("Watchdog found a problem with cli plugin!")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.sys_cli.start()
|
await self.sys_plugins.cli.start()
|
||||||
except CliError:
|
except CliError:
|
||||||
_LOGGER.error("Watchdog cli reanimation fails!")
|
_LOGGER.error("Watchdog cli reanimation fails!")
|
||||||
|
|
||||||
|
async def _watchdog_multicast_docker(self):
|
||||||
|
"""Check running state of Docker and start if they is close."""
|
||||||
|
# if multicast plugin is active
|
||||||
|
if (
|
||||||
|
await self.sys_plugins.multicast.is_running()
|
||||||
|
or self.sys_plugins.multicast.in_progress
|
||||||
|
):
|
||||||
|
return
|
||||||
|
_LOGGER.warning("Watchdog found a problem with Multicast plugin!")
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self.sys_plugins.multicast.start()
|
||||||
|
except MulticastError:
|
||||||
|
_LOGGER.error("Watchdog Multicast reanimation fails!")
|
||||||
|
@ -13,9 +13,11 @@ from .const import (
|
|||||||
ATTR_CHANNEL,
|
ATTR_CHANNEL,
|
||||||
ATTR_CLI,
|
ATTR_CLI,
|
||||||
ATTR_DNS,
|
ATTR_DNS,
|
||||||
ATTR_HASSIO,
|
|
||||||
ATTR_HASSOS,
|
ATTR_HASSOS,
|
||||||
ATTR_HOMEASSISTANT,
|
ATTR_HOMEASSISTANT,
|
||||||
|
ATTR_IMAGE,
|
||||||
|
ATTR_MULTICAST,
|
||||||
|
ATTR_SUPERVISOR,
|
||||||
FILE_HASSIO_UPDATER,
|
FILE_HASSIO_UPDATER,
|
||||||
URL_HASSIO_VERSION,
|
URL_HASSIO_VERSION,
|
||||||
UpdateChannels,
|
UpdateChannels,
|
||||||
@ -53,9 +55,9 @@ class Updater(JsonConfig, CoreSysAttributes):
|
|||||||
return self._data.get(ATTR_HOMEASSISTANT)
|
return self._data.get(ATTR_HOMEASSISTANT)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def version_hassio(self) -> Optional[str]:
|
def version_supervisor(self) -> Optional[str]:
|
||||||
"""Return latest version of Supervisor."""
|
"""Return latest version of Supervisor."""
|
||||||
return self._data.get(ATTR_HASSIO)
|
return self._data.get(ATTR_SUPERVISOR)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def version_hassos(self) -> Optional[str]:
|
def version_hassos(self) -> Optional[str]:
|
||||||
@ -77,6 +79,65 @@ class Updater(JsonConfig, CoreSysAttributes):
|
|||||||
"""Return latest version of Audio."""
|
"""Return latest version of Audio."""
|
||||||
return self._data.get(ATTR_AUDIO)
|
return self._data.get(ATTR_AUDIO)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def version_multicast(self) -> Optional[str]:
|
||||||
|
"""Return latest version of Multicast."""
|
||||||
|
return self._data.get(ATTR_MULTICAST)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_homeassistant(self) -> Optional[str]:
|
||||||
|
"""Return latest version of Home Assistant."""
|
||||||
|
return (
|
||||||
|
self._data[ATTR_IMAGE]
|
||||||
|
.get(ATTR_HOMEASSISTANT, "")
|
||||||
|
.format(machine=self.sys_machine)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_supervisor(self) -> Optional[str]:
|
||||||
|
"""Return latest version of Supervisor."""
|
||||||
|
return (
|
||||||
|
self._data[ATTR_IMAGE]
|
||||||
|
.get(ATTR_SUPERVISOR, "")
|
||||||
|
.format(arch=self.sys_arch.supervisor)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_cli(self) -> Optional[str]:
|
||||||
|
"""Return latest version of CLI."""
|
||||||
|
return (
|
||||||
|
self._data[ATTR_IMAGE]
|
||||||
|
.get(ATTR_CLI, "")
|
||||||
|
.format(arch=self.sys_arch.supervisor)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_dns(self) -> Optional[str]:
|
||||||
|
"""Return latest version of DNS."""
|
||||||
|
return (
|
||||||
|
self._data[ATTR_IMAGE]
|
||||||
|
.get(ATTR_DNS, "")
|
||||||
|
.format(arch=self.sys_arch.supervisor)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_audio(self) -> Optional[str]:
|
||||||
|
"""Return latest version of Audio."""
|
||||||
|
return (
|
||||||
|
self._data[ATTR_IMAGE]
|
||||||
|
.get(ATTR_AUDIO, "")
|
||||||
|
.format(arch=self.sys_arch.supervisor)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_multicast(self) -> Optional[str]:
|
||||||
|
"""Return latest version of Multicast."""
|
||||||
|
return (
|
||||||
|
self._data[ATTR_IMAGE]
|
||||||
|
.get(ATTR_MULTICAST, "")
|
||||||
|
.format(arch=self.sys_arch.supervisor)
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def channel(self) -> UpdateChannels:
|
def channel(self) -> UpdateChannels:
|
||||||
"""Return upstream channel of Supervisor instance."""
|
"""Return upstream channel of Supervisor instance."""
|
||||||
@ -116,7 +177,7 @@ class Updater(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Update supervisor version
|
# Update supervisor version
|
||||||
self._data[ATTR_HASSIO] = data["supervisor"]
|
self._data[ATTR_SUPERVISOR] = data["supervisor"]
|
||||||
|
|
||||||
# Update Home Assistant core version
|
# Update Home Assistant core version
|
||||||
self._data[ATTR_HOMEASSISTANT] = data["homeassistant"][machine]
|
self._data[ATTR_HOMEASSISTANT] = data["homeassistant"][machine]
|
||||||
@ -125,10 +186,19 @@ class Updater(JsonConfig, CoreSysAttributes):
|
|||||||
if self.sys_hassos.board:
|
if self.sys_hassos.board:
|
||||||
self._data[ATTR_HASSOS] = data["hassos"][self.sys_hassos.board]
|
self._data[ATTR_HASSOS] = data["hassos"][self.sys_hassos.board]
|
||||||
|
|
||||||
# Update Home Assistant services
|
# Update Home Assistant plugins
|
||||||
self._data[ATTR_CLI] = data["cli"]
|
self._data[ATTR_CLI] = data["cli"]
|
||||||
self._data[ATTR_DNS] = data["dns"]
|
self._data[ATTR_DNS] = data["dns"]
|
||||||
self._data[ATTR_AUDIO] = data["audio"]
|
self._data[ATTR_AUDIO] = data["audio"]
|
||||||
|
self._data[ATTR_MULTICAST] = data["multicast"]
|
||||||
|
|
||||||
|
# Update images for that versions
|
||||||
|
self._data[ATTR_IMAGE][ATTR_HOMEASSISTANT] = data["image"]["core"]
|
||||||
|
self._data[ATTR_IMAGE][ATTR_SUPERVISOR] = data["image"]["supervisor"]
|
||||||
|
self._data[ATTR_IMAGE][ATTR_AUDIO] = data["image"]["audio"]
|
||||||
|
self._data[ATTR_IMAGE][ATTR_CLI] = data["image"]["cli"]
|
||||||
|
self._data[ATTR_IMAGE][ATTR_DNS] = data["image"]["dns"]
|
||||||
|
self._data[ATTR_IMAGE][ATTR_MULTICAST] = data["image"]["multicast"]
|
||||||
|
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
_LOGGER.warning("Can't process version data: %s", err)
|
_LOGGER.warning("Can't process version data: %s", err)
|
||||||
|
@ -17,24 +17,24 @@ from .const import (
|
|||||||
ATTR_DEBUG,
|
ATTR_DEBUG,
|
||||||
ATTR_DEBUG_BLOCK,
|
ATTR_DEBUG_BLOCK,
|
||||||
ATTR_DNS,
|
ATTR_DNS,
|
||||||
ATTR_HASSIO,
|
|
||||||
ATTR_HASSOS,
|
ATTR_HASSOS,
|
||||||
ATTR_HOMEASSISTANT,
|
ATTR_HOMEASSISTANT,
|
||||||
ATTR_IMAGE,
|
ATTR_IMAGE,
|
||||||
ATTR_LAST_BOOT,
|
ATTR_LAST_BOOT,
|
||||||
ATTR_VERSION_LATEST,
|
|
||||||
ATTR_LOGGING,
|
ATTR_LOGGING,
|
||||||
|
ATTR_MULTICAST,
|
||||||
ATTR_PORT,
|
ATTR_PORT,
|
||||||
ATTR_PORTS,
|
ATTR_PORTS,
|
||||||
ATTR_REFRESH_TOKEN,
|
ATTR_REFRESH_TOKEN,
|
||||||
ATTR_SERVERS,
|
|
||||||
ATTR_SESSION,
|
ATTR_SESSION,
|
||||||
ATTR_SSL,
|
ATTR_SSL,
|
||||||
|
ATTR_SUPERVISOR,
|
||||||
ATTR_TIMEZONE,
|
ATTR_TIMEZONE,
|
||||||
ATTR_UUID,
|
ATTR_UUID,
|
||||||
ATTR_VERSION,
|
ATTR_VERSION,
|
||||||
ATTR_WAIT_BOOT,
|
ATTR_WAIT_BOOT,
|
||||||
ATTR_WATCHDOG,
|
ATTR_WATCHDOG,
|
||||||
|
LogLevel,
|
||||||
UpdateChannels,
|
UpdateChannels,
|
||||||
)
|
)
|
||||||
from .utils.validate import validate_timezone
|
from .utils.validate import validate_timezone
|
||||||
@ -49,7 +49,6 @@ docker_image = vol.Match(r"^[\w{}]+/[\-\w{}]+$")
|
|||||||
uuid_match = vol.Match(r"^[0-9a-f]{32}$")
|
uuid_match = vol.Match(r"^[0-9a-f]{32}$")
|
||||||
sha256 = vol.Match(r"^[0-9a-f]{64}$")
|
sha256 = vol.Match(r"^[0-9a-f]{64}$")
|
||||||
token = vol.Match(r"^[0-9a-f]{32,256}$")
|
token = vol.Match(r"^[0-9a-f]{32,256}$")
|
||||||
log_level = vol.In(["debug", "info", "warning", "error", "critical"])
|
|
||||||
|
|
||||||
|
|
||||||
def dns_url(url: str) -> str:
|
def dns_url(url: str) -> str:
|
||||||
@ -102,10 +101,9 @@ SCHEMA_HASS_CONFIG = vol.Schema(
|
|||||||
{
|
{
|
||||||
vol.Optional(ATTR_UUID, default=lambda: uuid.uuid4().hex): uuid_match,
|
vol.Optional(ATTR_UUID, default=lambda: uuid.uuid4().hex): uuid_match,
|
||||||
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
||||||
|
vol.Optional(ATTR_IMAGE): docker_image,
|
||||||
vol.Optional(ATTR_ACCESS_TOKEN): token,
|
vol.Optional(ATTR_ACCESS_TOKEN): token,
|
||||||
vol.Optional(ATTR_BOOT, default=True): vol.Boolean(),
|
vol.Optional(ATTR_BOOT, default=True): vol.Boolean(),
|
||||||
vol.Inclusive(ATTR_IMAGE, "custom_hass"): docker_image,
|
|
||||||
vol.Inclusive(ATTR_VERSION_LATEST, "custom_hass"): vol.Coerce(str),
|
|
||||||
vol.Optional(ATTR_PORT, default=8123): network_port,
|
vol.Optional(ATTR_PORT, default=8123): network_port,
|
||||||
vol.Optional(ATTR_REFRESH_TOKEN): vol.Maybe(vol.Coerce(str)),
|
vol.Optional(ATTR_REFRESH_TOKEN): vol.Maybe(vol.Coerce(str)),
|
||||||
vol.Optional(ATTR_SSL, default=False): vol.Boolean(),
|
vol.Optional(ATTR_SSL, default=False): vol.Boolean(),
|
||||||
@ -126,18 +124,30 @@ SCHEMA_UPDATER_CONFIG = vol.Schema(
|
|||||||
UpdateChannels
|
UpdateChannels
|
||||||
),
|
),
|
||||||
vol.Optional(ATTR_HOMEASSISTANT): vol.Coerce(str),
|
vol.Optional(ATTR_HOMEASSISTANT): vol.Coerce(str),
|
||||||
vol.Optional(ATTR_HASSIO): vol.Coerce(str),
|
vol.Optional(ATTR_SUPERVISOR): vol.Coerce(str),
|
||||||
vol.Optional(ATTR_HASSOS): vol.Coerce(str),
|
vol.Optional(ATTR_HASSOS): vol.Coerce(str),
|
||||||
vol.Optional(ATTR_CLI): vol.Coerce(str),
|
vol.Optional(ATTR_CLI): vol.Coerce(str),
|
||||||
vol.Optional(ATTR_DNS): vol.Coerce(str),
|
vol.Optional(ATTR_DNS): vol.Coerce(str),
|
||||||
vol.Optional(ATTR_AUDIO): vol.Coerce(str),
|
vol.Optional(ATTR_AUDIO): vol.Coerce(str),
|
||||||
|
vol.Optional(ATTR_MULTICAST): vol.Coerce(str),
|
||||||
|
vol.Optional(ATTR_IMAGE, default=dict): vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Optional(ATTR_HOMEASSISTANT): docker_image,
|
||||||
|
vol.Optional(ATTR_SUPERVISOR): docker_image,
|
||||||
|
vol.Optional(ATTR_CLI): docker_image,
|
||||||
|
vol.Optional(ATTR_DNS): docker_image,
|
||||||
|
vol.Optional(ATTR_AUDIO): docker_image,
|
||||||
|
vol.Optional(ATTR_MULTICAST): docker_image,
|
||||||
|
},
|
||||||
|
extra=vol.REMOVE_EXTRA,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
extra=vol.REMOVE_EXTRA,
|
extra=vol.REMOVE_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
SCHEMA_HASSIO_CONFIG = vol.Schema(
|
SCHEMA_SUPERVISOR_CONFIG = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(ATTR_TIMEZONE, default="UTC"): validate_timezone,
|
vol.Optional(ATTR_TIMEZONE, default="UTC"): validate_timezone,
|
||||||
vol.Optional(ATTR_LAST_BOOT): vol.Coerce(str),
|
vol.Optional(ATTR_LAST_BOOT): vol.Coerce(str),
|
||||||
@ -146,7 +156,7 @@ SCHEMA_HASSIO_CONFIG = vol.Schema(
|
|||||||
default=["https://github.com/hassio-addons/repository"],
|
default=["https://github.com/hassio-addons/repository"],
|
||||||
): repositories,
|
): repositories,
|
||||||
vol.Optional(ATTR_WAIT_BOOT, default=5): wait_boot,
|
vol.Optional(ATTR_WAIT_BOOT, default=5): wait_boot,
|
||||||
vol.Optional(ATTR_LOGGING, default="info"): log_level,
|
vol.Optional(ATTR_LOGGING, default=LogLevel.INFO): vol.Coerce(LogLevel),
|
||||||
vol.Optional(ATTR_DEBUG, default=False): vol.Boolean(),
|
vol.Optional(ATTR_DEBUG, default=False): vol.Boolean(),
|
||||||
vol.Optional(ATTR_DEBUG_BLOCK, default=False): vol.Boolean(),
|
vol.Optional(ATTR_DEBUG_BLOCK, default=False): vol.Boolean(),
|
||||||
},
|
},
|
||||||
@ -168,26 +178,3 @@ SCHEMA_INGRESS_CONFIG = vol.Schema(
|
|||||||
},
|
},
|
||||||
extra=vol.REMOVE_EXTRA,
|
extra=vol.REMOVE_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
SCHEMA_DNS_CONFIG = vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
|
||||||
vol.Optional(ATTR_SERVERS, default=list): dns_server_list,
|
|
||||||
},
|
|
||||||
extra=vol.REMOVE_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
SCHEMA_AUDIO_CONFIG = vol.Schema(
|
|
||||||
{vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str))}, extra=vol.REMOVE_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
SCHEMA_CLI_CONFIG = vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Optional(ATTR_VERSION): vol.Maybe(vol.Coerce(str)),
|
|
||||||
vol.Optional(ATTR_ACCESS_TOKEN): token,
|
|
||||||
},
|
|
||||||
extra=vol.REMOVE_EXTRA,
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user