diff --git a/API.md b/API.md index 2fb3e549a..3c31bffa7 100644 --- a/API.md +++ b/API.md @@ -124,6 +124,13 @@ Output is the raw docker log. - POST `/snapshots/new/upload` +return: +```json +{ + "slug": "" +} +``` + - POST `/snapshots/new/full` ```json @@ -133,6 +140,13 @@ Output is the raw docker log. } ``` +return: +```json +{ + "slug": "" +} +``` + - POST `/snapshots/new/partial` ```json @@ -144,6 +158,13 @@ Output is the raw docker log. } ``` +return: +```json +{ + "slug": "" +} +``` + - POST `/snapshots/reload` - GET `/snapshots/{slug}/info` diff --git a/hassio/api/panel/hassio-app.html b/hassio/api/panel/hassio-app.html index 8b54d560a..4b8f733ee 100644 --- a/hassio/api/panel/hassio-app.html +++ b/hassio/api/panel/hassio-app.html @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/hassio/api/panel/hassio-app.html.gz b/hassio/api/panel/hassio-app.html.gz index e83ef8235..c2f7af788 100644 Binary files a/hassio/api/panel/hassio-app.html.gz and b/hassio/api/panel/hassio-app.html.gz differ diff --git a/hassio/api/panel/index.html.gz b/hassio/api/panel/index.html.gz index 4bfaa0206..14b943d7e 100644 Binary files a/hassio/api/panel/index.html.gz and b/hassio/api/panel/index.html.gz differ diff --git a/hassio/api/snapshots.py b/hassio/api/snapshots.py index 9df56908d..46396adbf 100644 --- a/hassio/api/snapshots.py +++ b/hassio/api/snapshots.py @@ -109,16 +109,24 @@ class APISnapshots(CoreSysAttributes): async def snapshot_full(self, request): """Full-Snapshot a snapshot.""" body = await api_validate(SCHEMA_SNAPSHOT_FULL, request) - return await asyncio.shield( + snapshot = await asyncio.shield( self._snapshots.do_snapshot_full(**body), loop=self._loop) + if snapshot: + return {ATTR_SLUG: snapshot.slug} + return False + @api_process async def snapshot_partial(self, request): """Partial-Snapshot a snapshot.""" body = await api_validate(SCHEMA_SNAPSHOT_PARTIAL, request) - return await asyncio.shield( + snapshot = await asyncio.shield( self._snapshots.do_snapshot_partial(**body), loop=self._loop) + if snapshot: + return {ATTR_SLUG: snapshot.slug} + return False + @api_process async def restore_full(self, request): """Full-Restore a snapshot.""" @@ -174,5 +182,9 @@ class APISnapshots(CoreSysAttributes): except asyncio.CancelledError: return False - return await asyncio.shield( + snapshot = await asyncio.shield( self._snapshots.import_snapshot(tar_file), loop=self._loop) + + if snapshot: + return {ATTR_SLUG: snapshot.slug} + return False diff --git a/hassio/const.py b/hassio/const.py index 4a5ea4e96..156114786 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -2,7 +2,7 @@ from pathlib import Path from ipaddress import ip_network -HASSIO_VERSION = '0.91' +HASSIO_VERSION = '0.92' URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/' 'hassio/{}/version.json') diff --git a/hassio/snapshots/__init__.py b/hassio/snapshots/__init__.py index dd8808b7c..02aabe67f 100644 --- a/hassio/snapshots/__init__.py +++ b/hassio/snapshots/__init__.py @@ -90,30 +90,36 @@ class SnapshotManager(CoreSysAttributes): # Read meta data if not await snapshot.load(): - return False + return None # Allready exists? if snapshot.slug in self.snapshots_obj: _LOGGER.error("Snapshot %s allready exists!", snapshot.slug) - return False + return None # Move snapshot to backup + tar_origin = Path(self._config.path_backup, f"{snapshot.slug}.tar") try: - snapshot.tarfile.rename( - Path(self._config.path_backup, f"{snapshot.slug}.tar")) + snapshot.tarfile.rename(tar_origin) except OSError as err: _LOGGER.error("Can't move snapshot file to storage: %s", err) - return False + return None - await self.reload() - return True + # Load new snapshot + snapshot = Snapshot(self.coresys, tar_origin) + if not await snapshot.load(): + return None + _LOGGER.info("Success import %s", snapshot.slug) + + self.snapshots_obj[snapshot.slug] = snapshot + return snapshot async def do_snapshot_full(self, name="", password=None): """Create a full snapshot.""" if self.lock.locked(): _LOGGER.error("It is already a snapshot/restore process running") - return False + return None snapshot = self._create_snapshot(name, SNAPSHOT_FULL, password) _LOGGER.info("Full-Snapshot %s start", snapshot.slug) @@ -132,12 +138,12 @@ class SnapshotManager(CoreSysAttributes): except Exception: # pylint: disable=broad-except _LOGGER.exception("Snapshot %s error", snapshot.slug) - return False + return None else: _LOGGER.info("Full-Snapshot %s done", snapshot.slug) self.snapshots_obj[snapshot.slug] = snapshot - return True + return snapshot finally: self._scheduler.suspend = False @@ -148,7 +154,7 @@ class SnapshotManager(CoreSysAttributes): """Create a partial snapshot.""" if self.lock.locked(): _LOGGER.error("It is already a snapshot/restore process running") - return False + return None addons = addons or [] folders = folders or [] @@ -178,12 +184,12 @@ class SnapshotManager(CoreSysAttributes): except Exception: # pylint: disable=broad-except _LOGGER.exception("Snapshot %s error", snapshot.slug) - return False + return None else: _LOGGER.info("Partial-Snapshot %s done", snapshot.slug) self.snapshots_obj[snapshot.slug] = snapshot - return True + return snapshot finally: self._scheduler.suspend = False diff --git a/home-assistant-polymer b/home-assistant-polymer index c3e35a27b..0ffb31999 160000 --- a/home-assistant-polymer +++ b/home-assistant-polymer @@ -1 +1 @@ -Subproject commit c3e35a27bad1a40ce1a12a78e91209f349b9f9c8 +Subproject commit 0ffb31999e97a7acbd07945fa5e0245d5a425817 diff --git a/setup.py b/setup.py index f5698177b..2eb19533e 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ setup( install_requires=[ 'async_timeout==2.0.0', 'aiohttp==2.3.10', - 'docker==3.0.1', + 'docker==3.1.0', 'colorlog==3.1.2', 'voluptuous==0.11.1', 'gitpython==2.1.8', diff --git a/version.json b/version.json index e94cdf57c..294d369c1 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "hassio": "0.91", + "hassio": "0.92", "homeassistant": "0.63.3", "resinos": "1.1", "resinhup": "0.3",