archive_deleted_rows.pp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #
  2. # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
  3. #
  4. # Author: Emilien Macchi <emilien.macchi@enovance.com>
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  7. # not use this file except in compliance with the License. You may obtain
  8. # a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. # License for the specific language governing permissions and limitations
  16. # under the License.
  17. #
  18. # == Class: nova::cron::archive_deleted_rows
  19. #
  20. # Move deleted instances to another table that you don't have to backup
  21. # unless you have data retention policies.
  22. #
  23. # === Parameters
  24. #
  25. # [*minute*]
  26. # (optional) Defaults to '1'.
  27. #
  28. # [*hour*]
  29. # (optional) Defaults to '0'.
  30. #
  31. # [*monthday*]
  32. # (optional) Defaults to '*'.
  33. #
  34. # [*month*]
  35. # (optional) Defaults to '*'.
  36. #
  37. # [*weekday*]
  38. # (optional) Defaults to '*'.
  39. #
  40. # [*max_rows*]
  41. # (optional) Maximum number of deleted rows to archive.
  42. # Defaults to '100'.
  43. #
  44. # [*user*]
  45. # (optional) User with access to nova files.
  46. # Defaults to 'nova'.
  47. #
  48. # [*destination*]
  49. # (optional) Path to file to which rows should be archived
  50. # Defaults to '/var/log/nova/nova-rowsflush.log'.
  51. #
  52. # [*until_complete*]
  53. # (optional) Adds --until_complete to the archive command
  54. # Defaults to false.
  55. #
  56. class nova::cron::archive_deleted_rows (
  57. $minute = 1,
  58. $hour = 0,
  59. $monthday = '*',
  60. $month = '*',
  61. $weekday = '*',
  62. $max_rows = '100',
  63. $user = 'nova',
  64. $destination = '/var/log/nova/nova-rowsflush.log',
  65. $until_complete = false,
  66. ) {
  67. include ::nova::deps
  68. if $until_complete {
  69. $until_complete_real = '--until_complete'
  70. }
  71. cron { 'nova-manage db archive_deleted_rows':
  72. command => "nova-manage db archive_deleted_rows --max_rows ${max_rows} ${until_complete_real} >>${destination} 2>&1",
  73. environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
  74. user => $user,
  75. minute => $minute,
  76. hour => $hour,
  77. monthday => $monthday,
  78. month => $month,
  79. weekday => $weekday,
  80. require => Anchor['nova::dbsync::end']
  81. }
  82. }