Compare commits

...

19 Commits
0.90 ... 0.93

Author SHA1 Message Date
Pascal Vizeli
d46810752e Update Hass.io to version 0.93 2018-02-24 08:46:53 +01:00
Pascal Vizeli
3d10b502a0 Bugfix panel system (#379) 2018-02-24 08:38:59 +01:00
Pascal Vizeli
433c5cef3b Stop home-assistant only if they will be restored (#377) 2018-02-23 22:22:38 +01:00
Pascal Vizeli
697caf553a Pump version to 0.93 2018-02-23 11:38:04 +01:00
Pascal Vizeli
1e11359c71 Fix version conflicts 2018-02-23 11:35:43 +01:00
Pascal Vizeli
5285431825 New panel (#374) 2018-02-23 11:13:53 +01:00
Pascal Vizeli
7743a572a9 Update Hass.io to version 0.92 2018-02-23 11:01:51 +01:00
Pascal Vizeli
3b974920d3 Return snapshot slug for snapshot/import (#372)
* Update __init__.py

* Update snapshots.py

* Update API.md

* Update __init__.py

* Update __init__.py
2018-02-23 10:52:35 +01:00
Pascal Vizeli
6bc9792248 Update setup.py (#373) 2018-02-23 10:37:14 +01:00
Pascal Vizeli
da55f6fb10 Pump version to 0.92 2018-02-23 10:34:21 +01:00
Pascal Vizeli
ffa90a3407 Update Home-Assistant to version 0.63.3 2018-02-18 22:16:46 +01:00
Pascal Vizeli
0a13ea3743 Update Home-Assistant to version 0.63.3 2018-02-18 22:15:39 +01:00
Pascal Vizeli
0e2e588145 Update utils.py 2018-02-18 12:31:06 +01:00
Pascal Vizeli
b8c50fee36 Update validate.py 2018-02-18 12:30:41 +01:00
Pascal Vizeli
8cb0b7c498 Update validate.py 2018-02-18 12:23:46 +01:00
Pascal Vizeli
699fcdafba Fix pw2 (#369)
* fix rate password

* convert int
2018-02-18 12:18:11 +01:00
Pascal Vizeli
b4d5aeb5d0 Update Hass.io to version 0.91 2018-02-18 12:15:54 +01:00
Pascal Vizeli
d067dd643e Fix password hack (#368) 2018-02-18 11:51:11 +01:00
Pascal Vizeli
65a2bf2d18 Pump version to 0.91 2018-02-18 11:01:13 +01:00
12 changed files with 105 additions and 55 deletions

21
API.md
View File

@@ -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`

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@@ -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

View File

@@ -2,7 +2,7 @@
from pathlib import Path
from ipaddress import ip_network
HASSIO_VERSION = '0.90'
HASSIO_VERSION = '0.93'
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
'hassio/{}/version.json')

View File

@@ -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
@@ -288,7 +294,8 @@ class SnapshotManager(CoreSysAttributes):
await self.lock.acquire()
async with snapshot:
if FOLDER_HOMEASSISTANT in folders:
# Stop Home-Assistant if they will be restored later
if homeassistant and FOLDER_HOMEASSISTANT in folders:
await self._homeassistant.stop()
# Process folders

View File

@@ -1,6 +1,9 @@
"""Util addons functions."""
import hashlib
import shutil
import re
RE_DIGITS = re.compile(r"\d+")
def password_to_key(password):
@@ -15,7 +18,10 @@ def password_for_validating(password):
"""Generate a SHA256 hash from password."""
for _ in range(100):
password = hashlib.sha256(password.encode()).hexdigest()
return password
try:
return str(sum(map(int, RE_DIGITS.findall(password))))[0]
except (ValueError, IndexError):
return "0"
def key_to_iv(key):

View File

@@ -30,7 +30,7 @@ SCHEMA_SNAPSHOT = vol.Schema({
vol.Required(ATTR_NAME): vol.Coerce(str),
vol.Required(ATTR_DATE): vol.Coerce(str),
vol.Inclusive(ATTR_PROTECTED, 'encrypted'):
vol.All(vol.Coerce(str), vol.Length(64)),
vol.All(vol.Coerce(str), vol.Length(min=1, max=1)),
vol.Inclusive(ATTR_CRYPTO, 'encrypted'): CRYPTO_AES128,
vol.Optional(ATTR_HOMEASSISTANT, default=dict): vol.Schema({
vol.Optional(ATTR_VERSION): vol.Coerce(str),

View File

@@ -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',

View File

@@ -1,6 +1,6 @@
{
"hassio": "0.90",
"homeassistant": "0.63.2",
"hassio": "0.93",
"homeassistant": "0.63.3",
"resinos": "1.1",
"resinhup": "0.3",
"generic": "0.3",