Add reload api call to supervisor (#8)

* Add reload api call to supervisor

* Pump version
This commit is contained in:
Pascal Vizeli 2017-04-21 11:30:22 +02:00 committed by GitHub
parent f056d175b7
commit 03c3c9b6a1
5 changed files with 59 additions and 40 deletions

76
API.md
View File

@ -1,41 +1,5 @@
# HassIO Server
## Host Controll
Communicate over unix socket with a host daemon.
- commands
```
# info
-> {'os', 'version', 'current', 'level', 'hostname'}
# reboot
# shutdown
# host-update [v]
# network info
# network hostname xy
# network wlan ssd xy
# network wlan password xy
# network int ip xy
# network int netmask xy
# network int route xy
```
level:
- 1: power functions
- 2: host update
- 4: network functions
Answer:
```
{}|OK|ERROR|WRONG
```
- {}: json
- OK: call was successfully
- ERROR: error on call
- WRONG: not supported
## HassIO REST API
Interface for HomeAssistant to controll things from supervisor.
@ -94,6 +58,10 @@ Optional:
}
```
- `/supervisor/reload`
Reload addons/version.
### Host
- `/host/shutdown`
@ -194,3 +162,39 @@ Optional:
"version": "VERSION"
}
```
## Host Controll
Communicate over unix socket with a host daemon.
- commands
```
# info
-> {'os', 'version', 'current', 'level', 'hostname'}
# reboot
# shutdown
# host-update [v]
# network info
# network hostname xy
# network wlan ssd xy
# network wlan password xy
# network int ip xy
# network int netmask xy
# network int route xy
```
level:
- 1: power functions
- 2: host update
- 4: network functions
Answer:
```
{}|OK|ERROR|WRONG
```
- {}: json
- OK: call was successfully
- ERROR: error on call
- WRONG: not supported

View File

@ -49,6 +49,7 @@ class RestAPI(object):
self.webapp.router.add_get('/supervisor/ping', api_supervisor.ping)
self.webapp.router.add_get('/supervisor/info', api_supervisor.info)
self.webapp.router.add_get('/supervisor/update', api_supervisor.update)
self.webapp.router.add_get('/supervisor/reload', api_supervisor.reload)
self.webapp.router.add_get(
'/supervisor/options', api_supervisor.options)

View File

@ -65,4 +65,18 @@ class APISupervisor(object):
if version == self.supervisor.version:
raise RuntimeError("Version is already in use")
return await asyncio.shield(self.supervisor.update(version))
return await asyncio.shield(
self.supervisor.update(version), loop=self.loop)
@api_process
async def reload(self, request):
"""Reload addons, config ect."""
tasks = [self.addons.reaload(), self.config.fetch_update_infos()]
results, _ = await asyncio.shield(
asyncio.wait(tasks, loop=self.loop), loop=self.loop)
for result in results:
if result.exception() is not None:
raise RuntimeError("Some reload task fails!")
return True

View File

@ -1,5 +1,5 @@
"""Const file for HassIO."""
HASSIO_VERSION = '0.9'
HASSIO_VERSION = '0.10'
URL_HASSIO_VERSION = \
'https://raw.githubusercontent.com/pvizeli/hassio/master/version.json'

View File

@ -165,7 +165,7 @@ class DockerBase(object):
if not self.container:
return
_LOGGER.info("Stop %s docker application.", self.image)
_LOGGER.info("Stop %s docker application", self.image)
self.container.reload()
if self.container.status == 'running':
@ -230,7 +230,7 @@ class DockerBase(object):
# update docker image
if self._install(tag):
_LOGGER.info("Cleanup old %s docker.", old_image)
_LOGGER.info("Cleanup old %s docker", old_image)
self._stop()
try:
self.dock.images.remove(image=old_image, force=True)