simo 2.3.7__py3-none-any.whl → 2.4.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of simo might be problematic. Click here for more details.
- simo/__pycache__/settings.cpython-38.pyc +0 -0
- simo/backups/__pycache__/admin.cpython-38.pyc +0 -0
- simo/backups/__pycache__/dynamic_settings.cpython-38.pyc +0 -0
- simo/backups/__pycache__/models.cpython-38.pyc +0 -0
- simo/backups/__pycache__/tasks.cpython-38.pyc +0 -0
- simo/backups/admin.py +64 -3
- simo/backups/dynamic_settings.py +0 -7
- simo/backups/migrations/0002_backuplog_backup_level_backup_size.py +32 -0
- simo/backups/migrations/0003_alter_backuplog_options_alter_backup_size.py +22 -0
- simo/backups/migrations/0004_alter_backup_options_alter_backuplog_options_and_more.py +29 -0
- simo/backups/migrations/__pycache__/0002_backuplog_backup_level_backup_size.cpython-38.pyc +0 -0
- simo/backups/migrations/__pycache__/0003_alter_backuplog_options_alter_backup_size.cpython-38.pyc +0 -0
- simo/backups/migrations/__pycache__/0004_alter_backup_options_alter_backuplog_options_and_more.cpython-38.pyc +0 -0
- simo/backups/models.py +9 -2
- simo/backups/tasks.py +255 -113
- simo/core/__pycache__/api.cpython-38.pyc +0 -0
- simo/core/__pycache__/context.cpython-38.pyc +0 -0
- simo/core/__pycache__/controllers.cpython-38.pyc +0 -0
- simo/core/__pycache__/models.cpython-38.pyc +0 -0
- simo/core/__pycache__/tasks.cpython-38.pyc +0 -0
- simo/core/__pycache__/views.cpython-38.pyc +0 -0
- simo/core/api.py +2 -7
- simo/core/controllers.py +8 -1
- simo/core/management/_hub_template/hub/supervisor.conf +4 -0
- simo/core/migrations/0042_alter_instance_timezone.py +18 -0
- simo/core/migrations/__pycache__/0042_alter_instance_timezone.cpython-38.pyc +0 -0
- simo/core/models.py +6 -2
- simo/core/tasks.py +8 -1
- simo/core/views.py +4 -12
- simo/fleet/__pycache__/forms.cpython-38.pyc +0 -0
- simo/fleet/forms.py +140 -176
- simo/fleet/migrations/0038_alter_colonel_type.py +18 -0
- simo/fleet/migrations/__pycache__/0038_alter_colonel_type.cpython-38.pyc +0 -0
- simo/notifications/__pycache__/models.cpython-38.pyc +0 -0
- simo/settings.py +1 -0
- simo/users/__pycache__/models.cpython-38.pyc +0 -0
- simo/users/__pycache__/serializers.cpython-38.pyc +0 -0
- simo/users/migrations/0033_alter_user_ssh_key.py +18 -0
- simo/users/migrations/__pycache__/0033_alter_user_ssh_key.cpython-38.pyc +0 -0
- simo/users/models.py +38 -16
- {simo-2.3.7.dist-info → simo-2.4.2.dist-info}/METADATA +2 -1
- {simo-2.3.7.dist-info → simo-2.4.2.dist-info}/RECORD +46 -33
- {simo-2.3.7.dist-info → simo-2.4.2.dist-info}/LICENSE.md +0 -0
- {simo-2.3.7.dist-info → simo-2.4.2.dist-info}/WHEEL +0 -0
- {simo-2.3.7.dist-info → simo-2.4.2.dist-info}/entry_points.txt +0 -0
- {simo-2.3.7.dist-info → simo-2.4.2.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
simo/backups/admin.py
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
from django.contrib import admin
|
|
2
|
-
from .
|
|
2
|
+
from django.contrib import messages
|
|
3
|
+
from django.utils.timezone import localtime
|
|
4
|
+
from django_object_actions import DjangoObjectActions, action
|
|
5
|
+
from .models import Backup, BackupLog
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
@admin.register(Backup)
|
|
6
|
-
class BackupAdmin(admin.ModelAdmin):
|
|
9
|
+
class BackupAdmin(DjangoObjectActions, admin.ModelAdmin):
|
|
7
10
|
list_display = 'datetime', 'device', 'filepath'
|
|
8
11
|
fields = 'datetime', 'device', 'filepath'
|
|
9
12
|
readonly_fields = 'datetime', 'device', 'filepath'
|
|
10
13
|
list_filter = 'datetime', 'mac',
|
|
14
|
+
actions = 'restore',
|
|
15
|
+
changelist_actions = ('backup',)
|
|
11
16
|
|
|
12
17
|
def has_change_permission(self, request, obj=None):
|
|
13
18
|
return False
|
|
@@ -16,4 +21,60 @@ class BackupAdmin(admin.ModelAdmin):
|
|
|
16
21
|
return False
|
|
17
22
|
|
|
18
23
|
def has_delete_permission(self, request, obj=None):
|
|
19
|
-
return False
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
def changelist_view(self, *args, **kwargs):
|
|
27
|
+
from .tasks import check_backups
|
|
28
|
+
check_backups()
|
|
29
|
+
return super().changelist_view(*args, **kwargs)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def restore(self, request, queryset):
|
|
33
|
+
if queryset.count() > 1:
|
|
34
|
+
messages.add_message(
|
|
35
|
+
request, messages.ERROR,
|
|
36
|
+
"Please select one snapshot."
|
|
37
|
+
)
|
|
38
|
+
return
|
|
39
|
+
from simo.backups.tasks import restore_backup
|
|
40
|
+
backup = queryset.first()
|
|
41
|
+
restore_backup.delay(backup.id)
|
|
42
|
+
messages.add_message(
|
|
43
|
+
request, messages.WARNING,
|
|
44
|
+
f"Restore command initiated. "
|
|
45
|
+
f"If things go well, your hub will reboot in ~15 minutes to the "
|
|
46
|
+
f"state it was on {localtime(backup.datetime)}. "
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
@action(
|
|
50
|
+
label="Backup now!", # optional
|
|
51
|
+
description="Start backup now!" # optional
|
|
52
|
+
)
|
|
53
|
+
def backup(modeladmin, request, queryset=None):
|
|
54
|
+
from simo.backups.tasks import perform_backup
|
|
55
|
+
perform_backup.delay()
|
|
56
|
+
messages.add_message(
|
|
57
|
+
request, messages.INFO,
|
|
58
|
+
f"Backup command initiated. "
|
|
59
|
+
f"If things go well, you will see "
|
|
60
|
+
f"a new backup in here in less than 10 mins. "
|
|
61
|
+
f"Check backup logs for errors if not."
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@admin.register(BackupLog)
|
|
66
|
+
class BackupLogAdmin(admin.ModelAdmin):
|
|
67
|
+
fields = 'datetime', 'level', 'msg'
|
|
68
|
+
list_display = fields
|
|
69
|
+
readonly_fields = fields
|
|
70
|
+
list_fields = fields
|
|
71
|
+
list_filter = 'datetime', 'level'
|
|
72
|
+
search_fields = 'msg',
|
|
73
|
+
|
|
74
|
+
def has_delete_permission(self, request, obj=None):
|
|
75
|
+
return False
|
|
76
|
+
|
|
77
|
+
def has_add_permission(self, request):
|
|
78
|
+
return False
|
|
79
|
+
|
|
80
|
+
|
simo/backups/dynamic_settings.py
CHANGED
|
@@ -7,13 +7,6 @@ from dynamic_preferences.registries import global_preferences_registry
|
|
|
7
7
|
backups = Section('backups')
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
@global_preferences_registry.register
|
|
11
|
-
class LastBackupError(StringPreference):
|
|
12
|
-
section = backups
|
|
13
|
-
name = 'last_error'
|
|
14
|
-
default = ''
|
|
15
|
-
|
|
16
|
-
|
|
17
10
|
@global_preferences_registry.register
|
|
18
11
|
class LastBackupCheck(IntegerPreference):
|
|
19
12
|
section = backups
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Generated by Django 4.2.10 on 2024-10-09 07:49
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('backups', '0001_initial'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.CreateModel(
|
|
14
|
+
name='BackupLog',
|
|
15
|
+
fields=[
|
|
16
|
+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
17
|
+
('datetime', models.DateTimeField(auto_now_add=True, db_index=True)),
|
|
18
|
+
('level', models.CharField(choices=[('info', 'INFO'), ('warning', 'WARNING'), ('error', 'ERROR')], default='info')),
|
|
19
|
+
('msg', models.TextField()),
|
|
20
|
+
],
|
|
21
|
+
),
|
|
22
|
+
migrations.AddField(
|
|
23
|
+
model_name='backup',
|
|
24
|
+
name='level',
|
|
25
|
+
field=models.IntegerField(db_index=True, default=0),
|
|
26
|
+
),
|
|
27
|
+
migrations.AddField(
|
|
28
|
+
model_name='backup',
|
|
29
|
+
name='size',
|
|
30
|
+
field=models.IntegerField(default=0),
|
|
31
|
+
),
|
|
32
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Generated by Django 4.2.10 on 2024-10-09 09:16
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('backups', '0002_backuplog_backup_level_backup_size'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name='backuplog',
|
|
15
|
+
options={'ordering': ('datetime',)},
|
|
16
|
+
),
|
|
17
|
+
migrations.AlterField(
|
|
18
|
+
model_name='backup',
|
|
19
|
+
name='size',
|
|
20
|
+
field=models.BigIntegerField(default=0),
|
|
21
|
+
),
|
|
22
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Generated by Django 4.2.10 on 2024-10-10 12:05
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('backups', '0003_alter_backuplog_options_alter_backup_size'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name='backup',
|
|
15
|
+
options={},
|
|
16
|
+
),
|
|
17
|
+
migrations.AlterModelOptions(
|
|
18
|
+
name='backuplog',
|
|
19
|
+
options={},
|
|
20
|
+
),
|
|
21
|
+
migrations.RemoveField(
|
|
22
|
+
model_name='backup',
|
|
23
|
+
name='level',
|
|
24
|
+
),
|
|
25
|
+
migrations.RemoveField(
|
|
26
|
+
model_name='backup',
|
|
27
|
+
name='size',
|
|
28
|
+
),
|
|
29
|
+
]
|
|
Binary file
|
simo/backups/migrations/__pycache__/0003_alter_backuplog_options_alter_backup_size.cpython-38.pyc
ADDED
|
Binary file
|
|
Binary file
|
simo/backups/models.py
CHANGED
|
@@ -9,10 +9,17 @@ class Backup(models.Model):
|
|
|
9
9
|
|
|
10
10
|
class Meta:
|
|
11
11
|
unique_together = 'datetime', 'mac'
|
|
12
|
-
ordering = 'datetime',
|
|
13
12
|
|
|
14
13
|
@property
|
|
15
14
|
def device(self):
|
|
16
15
|
if self.mac == str(hex(uuid.getnode())):
|
|
17
16
|
return "This machine"
|
|
18
|
-
return self.mac
|
|
17
|
+
return self.mac
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BackupLog(models.Model):
|
|
21
|
+
datetime = models.DateTimeField(db_index=True, auto_now_add=True)
|
|
22
|
+
level = models.CharField(default='info', choices=(
|
|
23
|
+
('info', "INFO"), ('warning', "WARNING"), ('error', "ERROR")
|
|
24
|
+
))
|
|
25
|
+
msg = models.TextField()
|