okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 1 | from oslo_config import cfg |
okozachenko | ca2b37a | 2021-05-06 20:38:02 +0300 | [diff] [blame] | 2 | from staffeln.common import constants |
okozachenko | 24bfc9e | 2021-05-04 15:20:11 +0300 | [diff] [blame] | 3 | from staffeln.i18n import _ |
| 4 | |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 5 | conductor_group = cfg.OptGroup( |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 6 | "conductor", |
| 7 | title="Conductor Options", |
okozachenko | 24bfc9e | 2021-05-04 15:20:11 +0300 | [diff] [blame] | 8 | help=_("Options under this group are used " "to define Conductor's configuration."), |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 9 | ) |
| 10 | |
okozachenko | af07320 | 2021-04-06 16:56:51 +0300 | [diff] [blame] | 11 | backup_opts = [ |
| 12 | cfg.IntOpt( |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 13 | "backup_workers", |
okozachenko | b8f9e2e | 2021-04-07 20:02:42 +0300 | [diff] [blame] | 14 | default=1, |
okozachenko1203 | fa747f2 | 2022-05-16 20:13:54 +1000 | [diff] [blame] | 15 | help=_( |
| 16 | "The maximum number of backup processes to " |
| 17 | "fork and run. Default to number of CPUs on the host." |
| 18 | ), |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 19 | ), |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 20 | cfg.IntOpt( |
okozachenko | 2d76518 | 2021-05-05 18:22:54 +0300 | [diff] [blame] | 21 | "backup_service_period", |
okozachenko | 168c070 | 2021-05-06 22:56:37 +0300 | [diff] [blame] | 22 | default=30, |
okozachenko | 2d76518 | 2021-05-05 18:22:54 +0300 | [diff] [blame] | 23 | min=10, |
okozachenko | 24bfc9e | 2021-05-04 15:20:11 +0300 | [diff] [blame] | 24 | help=_("The time of bakup period, the unit is one minute."), |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 25 | ), |
okozachenko | 32a692e | 2021-04-13 10:47:05 +0300 | [diff] [blame] | 26 | cfg.StrOpt( |
okozachenko | ca2b37a | 2021-05-06 20:38:02 +0300 | [diff] [blame] | 27 | "backup_cycle_timout", |
okozachenko1203 | ef49f95 | 2022-05-16 22:27:28 +1000 | [diff] [blame] | 28 | regex=( |
| 29 | r"((?P<years>\d+?)y)?((?P<months>\d+?)mon)?((?P<weeks>\d+?)w)?" |
| 30 | r"((?P<days>\d+?)d)?((?P<hours>\d+?)h)?((?P<minutes>\d+?)min)?((?P<seconds>\d+?)s)?" |
| 31 | ), |
okozachenko | ca2b37a | 2021-05-06 20:38:02 +0300 | [diff] [blame] | 32 | default=constants.DEFAULT_BACKUP_CYCLE_TIMEOUT, |
okozachenko1203 | fa747f2 | 2022-05-16 20:13:54 +1000 | [diff] [blame] | 33 | help=_( |
| 34 | "The duration while the backup cycle waits backups." |
| 35 | "<YEARS>y<MONTHS>mon<WEEKS>w<DAYS>d<HOURS>h<MINUTES>min<SECONDS>s." |
| 36 | ), |
okozachenko | ca2b37a | 2021-05-06 20:38:02 +0300 | [diff] [blame] | 37 | ), |
| 38 | cfg.StrOpt( |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 39 | "backup_metadata_key", |
okozachenko | 24bfc9e | 2021-05-04 15:20:11 +0300 | [diff] [blame] | 40 | help=_("The key string of metadata the VM, which requres back up, has"), |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 41 | ), |
ricolin | 031f06b | 2022-11-13 09:18:57 +0800 | [diff] [blame^] | 42 | cfg.StrOpt( |
| 43 | "retention_metadata_key", |
| 44 | regex=( |
| 45 | r"((?P<years>\d+?)y)?((?P<months>\d+?)mon)?((?P<weeks>\d+?)w)?" |
| 46 | r"((?P<days>\d+?)d)?((?P<hours>\d+?)h)?((?P<minutes>\d+?)min)?((?P<seconds>\d+?)s)?" |
| 47 | ), |
| 48 | help=_("The key string of metadata the VM, which use as backup retention period."), |
| 49 | ), |
okozachenko1203 | 0295070 | 2022-10-22 03:34:16 +1100 | [diff] [blame] | 50 | cfg.IntOpt( |
| 51 | "full_backup_depth", |
| 52 | default=2, |
| 53 | min=1, |
| 54 | help=_("Number of incremental backups between full backups."), |
| 55 | ), |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 56 | ] |
| 57 | |
okozachenko | af07320 | 2021-04-06 16:56:51 +0300 | [diff] [blame] | 58 | rotation_opts = [ |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 59 | cfg.IntOpt( |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 60 | "rotation_workers", |
okozachenko | 32a692e | 2021-04-13 10:47:05 +0300 | [diff] [blame] | 61 | default=1, |
okozachenko1203 | fa747f2 | 2022-05-16 20:13:54 +1000 | [diff] [blame] | 62 | help=_( |
| 63 | "The maximum number of rotation processes to " |
| 64 | "fork and run. Default to number of CPUs on the host." |
| 65 | ), |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 66 | ), |
okozachenko | 32a692e | 2021-04-13 10:47:05 +0300 | [diff] [blame] | 67 | cfg.IntOpt( |
okozachenko | 2d76518 | 2021-05-05 18:22:54 +0300 | [diff] [blame] | 68 | "retention_service_period", |
| 69 | default=20, |
| 70 | min=10, |
okozachenko | 6d277e3 | 2021-05-05 20:23:32 +0300 | [diff] [blame] | 71 | help=_("The period of the retention service, the unit is one second."), |
okozachenko | 2d76518 | 2021-05-05 18:22:54 +0300 | [diff] [blame] | 72 | ), |
| 73 | cfg.IntOpt( |
| 74 | "rotation_workers", |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 75 | default=1, |
okozachenko1203 | fa747f2 | 2022-05-16 20:13:54 +1000 | [diff] [blame] | 76 | help=_( |
| 77 | "The maximum number of rotation processes to " |
| 78 | "fork and run. Default to number of CPUs on the host." |
| 79 | ), |
okozachenko | 2d76518 | 2021-05-05 18:22:54 +0300 | [diff] [blame] | 80 | ), |
| 81 | cfg.StrOpt( |
| 82 | "retention_time", |
okozachenko1203 | ef49f95 | 2022-05-16 22:27:28 +1000 | [diff] [blame] | 83 | regex=( |
| 84 | r"((?P<years>\d+?)y)?((?P<months>\d+?)mon)?((?P<weeks>\d+?)w)?" |
| 85 | r"((?P<days>\d+?)d)?((?P<hours>\d+?)h)?((?P<minutes>\d+?)min)?((?P<seconds>\d+?)s)?" |
| 86 | ), |
okozachenko | 6d277e3 | 2021-05-05 20:23:32 +0300 | [diff] [blame] | 87 | default="2w3d", |
okozachenko1203 | fa747f2 | 2022-05-16 20:13:54 +1000 | [diff] [blame] | 88 | help=_( |
| 89 | "The time of retention period, the for mat is " |
| 90 | "<YEARS>y<MONTHS>mon<WEEKS>w<DAYS>d<HOURS>h<MINUTES>min<SECONDS>s." |
| 91 | ), |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 92 | ), |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 93 | ] |
| 94 | |
okozachenko | af07320 | 2021-04-06 16:56:51 +0300 | [diff] [blame] | 95 | CONDUCTOR_OPTS = (backup_opts, rotation_opts) |
| 96 | |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 97 | |
| 98 | def register_opts(conf): |
| 99 | conf.register_group(conductor_group) |
okozachenko | b8f9e2e | 2021-04-07 20:02:42 +0300 | [diff] [blame] | 100 | conf.register_opts(backup_opts, group=conductor_group) |
okozachenko | 32a692e | 2021-04-13 10:47:05 +0300 | [diff] [blame] | 101 | conf.register_opts(rotation_opts, group=conductor_group) |
okozachenko | 093ce9e | 2021-04-01 22:47:39 +0300 | [diff] [blame] | 102 | |
| 103 | |
| 104 | def list_opts(): |
Susanta Gautam | 73a52bb | 2021-04-27 16:01:11 +0545 | [diff] [blame] | 105 | return {"DEFAULT": rotation_opts, conductor_group: backup_opts} |