예제 #1
0
    def __init__(self, *args, **kwargs):
        super(LongTermBackupRetentionPolicyAction, self).__init__(
            BackupRetentionPolicyHelper.LONG_TERM_SQL_OPERATIONS, *args,
            **kwargs)

        self.backup_type = BackupRetentionPolicyHelper.LongTermBackupType[
            self.data.get('backup-type')]
        retention_period = self.data['retention-period']
        retention_period_units = RetentionPeriod.Units[
            self.data['retention-period-units']]
        self.iso8601_duration = RetentionPeriod.iso8601_duration(
            retention_period, retention_period_units)
예제 #2
0
    def get_retention_from_backup_policy(self, retention_policy):
        actual_retention_iso8601 = self.backup_type.get_retention_from_backup_policy(
            retention_policy)

        try:
            actual_duration, actual_duration_units = RetentionPeriod.parse_iso8601_retention_period(
                actual_retention_iso8601)
        except ValueError:
            return None

        if actual_duration_units.iso8601_symbol != self.retention_period_units.iso8601_symbol:
            return None
        return actual_duration
예제 #3
0
 def test_iso8601_duration_days(self):
     duration = RetentionPeriod.iso8601_duration(23,
                                                 RetentionPeriod.Units.days)
     self.assertEqual(duration, "P23D")
예제 #4
0
 def test_parse_iso8601_retention_period_months(self):
     duration = "P8M"
     period, unit = RetentionPeriod.parse_iso8601_retention_period(duration)
     self.assertEqual(period, 8)
     self.assertEqual(unit.iso8601_symbol, 'M')
예제 #5
0
 def test_parse_iso8601_retention_period_years(self):
     duration = "P5Y"
     period, unit = RetentionPeriod.parse_iso8601_retention_period(duration)
     self.assertEqual(period, 5)
     self.assertEqual(unit.iso8601_symbol, 'Y')
예제 #6
0
 def test_parse_iso8601_retention_period_weeks(self):
     duration = "P17W"
     period, unit = RetentionPeriod.parse_iso8601_retention_period(duration)
     self.assertEqual(period, 17)
     self.assertEqual(unit.iso8601_symbol, 'W')
예제 #7
0
 def test_parse_iso8601_retention_period_days(self):
     duration = "P31D"
     period, unit = RetentionPeriod.parse_iso8601_retention_period(duration)
     self.assertEqual(period, 31)
     self.assertEqual(unit.iso8601_symbol, 'D')
예제 #8
0
 def test_iso8601_duration_years(self):
     duration = RetentionPeriod.iso8601_duration(
         3, RetentionPeriod.Units.years)
     self.assertEqual(duration, "P3Y")
예제 #9
0
 def test_iso8601_duration_months(self):
     duration = RetentionPeriod.iso8601_duration(
         7, RetentionPeriod.Units.months)
     self.assertEqual(duration, "P7M")
예제 #10
0
 def test_iso8601_duration_weeks(self):
     duration = RetentionPeriod.iso8601_duration(
         12, RetentionPeriod.Units.weeks)
     self.assertEqual(duration, "P12W")