20171024000002_check_mk_integration2.rb 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. class CheckMkIntegration2 < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. Setting.create_if_not_exists(
  6. title: 'Check_MK integration',
  7. name: 'check_mk_integration',
  8. area: 'Integration::Switch',
  9. description: 'Defines if Check_MK (http://mathias-kettner.com/check_mk.html) is enabled or not.',
  10. options: {
  11. form: [
  12. {
  13. display: '',
  14. null: true,
  15. name: 'check_mk_integration',
  16. tag: 'boolean',
  17. options: {
  18. true => 'yes',
  19. false => 'no',
  20. },
  21. },
  22. ],
  23. },
  24. state: false,
  25. preferences: {
  26. prio: 1,
  27. permission: ['admin.integration'],
  28. },
  29. frontend: false
  30. )
  31. Setting.create_if_not_exists(
  32. title: 'Sender',
  33. name: 'check_mk_sender',
  34. area: 'Integration::CheckMK',
  35. description: 'Defines the sender email address of the service emails.',
  36. options: {
  37. form: [
  38. {
  39. display: '',
  40. null: false,
  41. name: 'check_mk_sender',
  42. tag: 'input',
  43. placeholder: 'check_mk@monitoring.example.com',
  44. },
  45. ],
  46. },
  47. state: 'check_mk@monitoring.example.com',
  48. preferences: {
  49. prio: 2,
  50. permission: ['admin.integration'],
  51. },
  52. frontend: false,
  53. )
  54. Setting.create_if_not_exists(
  55. title: 'Group',
  56. name: 'check_mk_group_id',
  57. area: 'Integration::CheckMK',
  58. description: 'Defines the group of created tickets.',
  59. options: {
  60. form: [
  61. {
  62. display: '',
  63. null: false,
  64. name: 'check_mk_group_id',
  65. tag: 'select',
  66. relation: 'Group',
  67. },
  68. ],
  69. },
  70. state: 1,
  71. preferences: {
  72. prio: 3,
  73. permission: ['admin.integration'],
  74. },
  75. frontend: false
  76. )
  77. Setting.create_if_not_exists(
  78. title: 'Auto close',
  79. name: 'check_mk_auto_close',
  80. area: 'Integration::CheckMK',
  81. description: 'Defines if tickets should be closed if service is recovered.',
  82. options: {
  83. form: [
  84. {
  85. display: '',
  86. null: true,
  87. name: 'check_mk_auto_close',
  88. tag: 'boolean',
  89. options: {
  90. true => 'yes',
  91. false => 'no',
  92. },
  93. translate: true,
  94. },
  95. ],
  96. },
  97. state: true,
  98. preferences: {
  99. prio: 4,
  100. permission: ['admin.integration'],
  101. },
  102. frontend: false
  103. )
  104. Setting.create_if_not_exists(
  105. title: 'Auto close state',
  106. name: 'check_mk_auto_close_state_id',
  107. area: 'Integration::CheckMK',
  108. description: 'Defines the state of auto closed tickets.',
  109. options: {
  110. form: [
  111. {
  112. display: '',
  113. null: false,
  114. name: 'check_mk_auto_close_state_id',
  115. tag: 'select',
  116. relation: 'TicketState',
  117. translate: true,
  118. },
  119. ],
  120. },
  121. state: 4,
  122. preferences: {
  123. prio: 5,
  124. permission: ['admin.integration'],
  125. },
  126. frontend: false
  127. )
  128. Setting.create_if_not_exists(
  129. title: 'Check_MK tolen',
  130. name: 'check_mk_token',
  131. area: 'Core',
  132. description: 'Defines the Check_MK token for allowing updates.',
  133. options: {},
  134. state: SecureRandom.hex(16),
  135. preferences: {
  136. permission: ['admin.integration'],
  137. },
  138. frontend: false
  139. )
  140. Setting.create_if_not_exists(
  141. title: 'Defines postmaster filter.',
  142. name: '5200_postmaster_filter_check_mk',
  143. area: 'Postmaster::PreFilter',
  144. description: 'Defines postmaster filter to manage Check_MK (http://mathias-kettner.com/check_mk.html) emails.',
  145. options: {},
  146. state: 'Channel::Filter::CheckMk',
  147. frontend: false
  148. )
  149. end
  150. end