Browse Source

Import plugin's code

Change-Id: Ie5e65d8886bdbaf0fd33e1bc3f4a11e0d8685635
Ilya Popov 1 year ago
parent
commit
db629270fe
75 changed files with 4758 additions and 0 deletions
  1. 2
    0
      README.md
  2. 141
    0
      deployment_scripts/manifests/watcher.pp
  3. 45
    0
      deployment_scripts/manifests/watcher_db.pp
  4. 39
    0
      deployment_scripts/manifests/watcher_haproxy.pp
  5. 66
    0
      deployment_scripts/manifests/watcher_hiera_override.pp
  6. 33
    0
      deployment_scripts/manifests/watcher_keystone.pp
  7. 13
    0
      deployment_scripts/manifests/watcher_logging.pp
  8. 15
    0
      deployment_scripts/manifests/watcher_pin_plugin_repo.pp
  9. 6
    0
      deployment_scripts/manifests/watcher_timezone.pp
  10. 21
    0
      deployment_scripts/modules/watcher/Gemfile
  11. 14
    0
      deployment_scripts/modules/watcher/LICENSE
  12. 85
    0
      deployment_scripts/modules/watcher/README.md
  13. 1
    0
      deployment_scripts/modules/watcher/Rakefile
  14. 10
    0
      deployment_scripts/modules/watcher/lib/puppet/provider/watcher_config/ini_setting.rb
  15. 53
    0
      deployment_scripts/modules/watcher/lib/puppet/type/watcher_config.rb
  16. 241
    0
      deployment_scripts/modules/watcher/manifests/api.pp
  17. 84
    0
      deployment_scripts/modules/watcher/manifests/applier.pp
  18. 32
    0
      deployment_scripts/modules/watcher/manifests/config.pp
  19. 75
    0
      deployment_scripts/modules/watcher/manifests/db.pp
  20. 30
    0
      deployment_scripts/modules/watcher/manifests/db/create_schema.pp
  21. 74
    0
      deployment_scripts/modules/watcher/manifests/db/mysql.pp
  22. 57
    0
      deployment_scripts/modules/watcher/manifests/db/postgresql.pp
  23. 32
    0
      deployment_scripts/modules/watcher/manifests/db/upgrade.pp
  24. 122
    0
      deployment_scripts/modules/watcher/manifests/decision_engine.pp
  25. 34
    0
      deployment_scripts/modules/watcher/manifests/deps.pp
  26. 471
    0
      deployment_scripts/modules/watcher/manifests/init.pp
  27. 101
    0
      deployment_scripts/modules/watcher/manifests/keystone/auth.pp
  28. 274
    0
      deployment_scripts/modules/watcher/manifests/keystone/authtoken.pp
  29. 118
    0
      deployment_scripts/modules/watcher/manifests/logging.pp
  30. 29
    0
      deployment_scripts/modules/watcher/manifests/params.pp
  31. 42
    0
      deployment_scripts/modules/watcher/manifests/policy.pp
  32. 67
    0
      deployment_scripts/modules/watcher/metadata.json
  33. 0
    0
      deployment_scripts/modules/watcher/releasenotes/source/_static/.placeholder
  34. 262
    0
      deployment_scripts/modules/watcher/releasenotes/source/conf.py
  35. 18
    0
      deployment_scripts/modules/watcher/releasenotes/source/index.rst
  36. 5
    0
      deployment_scripts/modules/watcher/releasenotes/source/unreleased.rst
  37. 13
    0
      deployment_scripts/modules/watcher/setup.cfg
  38. 22
    0
      deployment_scripts/modules/watcher/setup.py
  39. 11
    0
      deployment_scripts/modules/watcher/spec/acceptance/nodesets/centos-70-x64.yml
  40. 10
    0
      deployment_scripts/modules/watcher/spec/acceptance/nodesets/default.yml
  41. 10
    0
      deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-centos7.yml
  42. 10
    0
      deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-trusty.yml
  43. 10
    0
      deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-xenial.yml
  44. 11
    0
      deployment_scripts/modules/watcher/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
  45. 77
    0
      deployment_scripts/modules/watcher/spec/acceptance/watcher_spec.rb
  46. 161
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_api_spec.rb
  47. 93
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_applier_spec.rb
  48. 58
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_db_create_schema_spec.rb
  49. 73
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_db_mysql_spec.rb
  50. 37
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_db_postgresql_spec.rb
  51. 117
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_db_spec.rb
  52. 60
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_db_upgrade_spec.rb
  53. 101
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_decision_engine_spec.rb
  54. 299
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_init_spec.rb
  55. 128
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_keystone_auth_spec.rb
  56. 151
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_keystone_authtoken_spec.rb
  57. 139
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_logging_spec.rb
  58. 37
    0
      deployment_scripts/modules/watcher/spec/classes/watcher_policy_spec.rb
  59. 5
    0
      deployment_scripts/modules/watcher/spec/shared_examples.rb
  60. 10
    0
      deployment_scripts/modules/watcher/spec/spec_helper.rb
  61. 1
    0
      deployment_scripts/modules/watcher/spec/spec_helper_acceptance.rb
  62. 68
    0
      deployment_scripts/modules/watcher/spec/unit/provider/watcher_config/ini_setting_spec.rb
  63. 64
    0
      deployment_scripts/modules/watcher/spec/unit/type/watcher_config_spec.rb
  64. 5
    0
      deployment_scripts/modules/watcher/test-requirements.txt
  65. 12
    0
      deployment_scripts/modules/watcher/tests/init.pp
  66. 8
    0
      deployment_scripts/modules/watcher/tox.ini
  67. 129
    0
      deployment_tasks.yaml
  68. 10
    0
      environment_config.yaml
  69. 64
    0
      functions.sh
  70. 20
    0
      metadata.yaml
  71. 12
    0
      network_roles.yaml
  72. 6
    0
      node_roles.yaml
  73. 0
    0
      repositories/centos/.gitkeep
  74. 0
    0
      repositories/ubuntu/.gitkeep
  75. 4
    0
      volumes.yaml

+ 2
- 0
README.md View File

@@ -0,0 +1,2 @@
1
+# Detached watcher role
2
+Plugin to deploy watcher on separate node

+ 141
- 0
deployment_scripts/manifests/watcher.pp View File

@@ -0,0 +1,141 @@
1
+notice('MODULAR: watcher/watcher.pp')
2
+
3
+prepare_network_config(hiera_hash('network_scheme', {}))
4
+
5
+$watcher_hash                = hiera_hash('watcher_plugin', {})
6
+$watcher_plugins             = pick($watcher_hash['plugins'], {})
7
+$rabbit_hash                 = hiera_hash('rabbit', {})
8
+$neutron_config              = hiera_hash('neutron_config', {})
9
+$public_ssl_hash             = hiera_hash('public_ssl', {})
10
+$ssl_hash                    = hiera_hash('use_ssl', {})
11
+$external_dns                = hiera_hash('external_dns', {})
12
+$primary_watcher             = roles_include(['primary-watcher-node', 'primary-controller'])
13
+$public_ip                   = hiera('public_vip')
14
+$database_ip                 = hiera('database_vip')
15
+$management_ip               = hiera('management_vip')
16
+$region                      = hiera('region', 'RegionOne')
17
+$use_neutron                 = hiera('use_neutron', false)
18
+$service_endpoint            = hiera('service_endpoint')
19
+$syslog_log_facility_watcher = hiera('syslog_log_facility_watcher')
20
+$debug                       = pick($watcher_hash['debug'], hiera('debug', false))
21
+$verbose                     = pick($watcher_hash['verbose'], hiera('verbose', true))
22
+$default_log_levels          = hiera_hash('default_log_levels', {})
23
+$use_syslog                  = hiera('use_syslog', true)
24
+$use_stderr                  = hiera('use_stderr', false)
25
+$rabbit_ha_queues            = hiera('rabbit_ha_queues', false)
26
+$amqp_port                   = hiera('amqp_port')
27
+$amqp_hosts                  = hiera('amqp_hosts')
28
+
29
+$internal_auth_protocol = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'protocol', 'http')
30
+$internal_auth_address  = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'hostname', [hiera('keystone_endpoint', ''), $service_endpoint, $management_ip])
31
+$admin_auth_protocol    = get_ssl_property($ssl_hash, {}, 'keystone', 'admin', 'protocol', 'http')
32
+$admin_auth_address     = get_ssl_property($ssl_hash, {}, 'keystone', 'admin', 'hostname', [hiera('keystone_endpoint', ''), $service_endpoint, $management_ip])
33
+$api_bind_host          = get_network_role_property('management', 'ipaddr')
34
+
35
+$region_name            = pick(hiera('region_name'), 'RegionOne')
36
+
37
+$firewall_rule = '214 watcher-api'
38
+$api_bind_port = '9322'
39
+
40
+$watcher_user     = pick($watcher_hash['user'], 'watcher')
41
+$watcher_password = $watcher_hash['user_password']
42
+
43
+$mysql_hash          = hiera_hash('mysql', {})
44
+$mysql_root_password = $mysql_hash['root_password']
45
+
46
+$db_type     = 'mysql'
47
+$db_user     = pick($watcher_hash['db_user'], 'watcher')
48
+$db_name     = pick($watcher_hash['db_name'], 'watcher')
49
+$db_password = pick($watcher_hash['root_password'], $mysql_root_password)
50
+$db_host     = pick($watcher_hash['db_host'], $database_ip)
51
+# LP#1526938 - python-mysqldb supports this, python-pymysql does not
52
+if $::os_package_type == 'debian' {
53
+  $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 }
54
+} else {
55
+  $extra_params = { 'charset' => 'utf8' }
56
+}
57
+$db_connection = os_database_connection({
58
+  'dialect'  => $db_type,
59
+  'host'     => $db_host,
60
+  'database' => $db_name,
61
+  'username' => $db_user,
62
+  'password' => $db_password,
63
+  'extra'    => $extra_params
64
+})
65
+
66
+notice($db_connection)
67
+
68
+####### Disable upstart startup on install #######
69
+tweaks::ubuntu_service_override { ['watcher-api', 'watcher-engine']:
70
+  package_name => 'watcher',
71
+}
72
+
73
+include ::firewall
74
+firewall { $firewall_rule :
75
+  dport  => $api_bind_port,
76
+  proto  => 'tcp',
77
+  action => 'accept',
78
+}
79
+
80
+$nova_scheduler_default_filters = 'RetryFilter,AvailabilityZoneFilter,AggregateRamFilter,AggregateCoreFilter,DiskFilter,ComputeFilter,AggregateInstanceExtraSpecsFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateMetaDataIsolation'
81
+$nova_ram_allocation_ratio = '1.5'
82
+$nova_scheduler_driver = 'nova.scheduler.filter_scheduler.FilterScheduler'
83
+$nova_disk_allocation_ratio = '1.0'
84
+$nova_cpu_allocation_ratio = '8.0'
85
+$nova_max_instances_per_host = '50'
86
+$nova_scheduler_available_filters = 'nova.scheduler.filters.all_filters'
87
+
88
+class { '::watcher' :
89
+  ensure_package      => 'latest',
90
+  database_connection => $db_connection,
91
+  notification_driver => 'messagingv2',
92
+  password            => $watcher_password,
93
+  username            => $watcher_user,
94
+  admin_user          => $watcher_user,
95
+  admin_password      => $watcher_password,
96
+  auth_uri            => "${internal_auth_protocol}://${internal_auth_address}:5000/",
97
+  auth_url            => "${admin_auth_protocol}://${admin_auth_address}:35357/v3",
98
+  identity_uri        => "${internal_auth_protocol}://${internal_auth_address}:35357/", 
99
+  region_name         => $region_name,
100
+  rabbit_os_host      => $amqp_hosts,
101
+  rabbit_os_user      => $rabbit_hash['user'],
102
+  rabbit_os_password  => $rabbit_hash['password'],
103
+  rabbit_ha_queues    => true,
104
+  nova_scheduler_default_filters => $nova_scheduler_default_filters,
105
+  nova_ram_allocation_ratio => $nova_ram_allocation_ratio,
106
+  nova_scheduler_driver => $nova_scheduler_driver,
107
+  nova_disk_allocation_ratio => $nova_disk_allocation_ratio,
108
+  nova_cpu_allocation_ratio =>$nova_cpu_allocation_ratio,
109
+  nova_max_instances_per_host => $nova_max_instances_per_host,
110
+  nova_scheduler_available_filters => $nova_scheduler_available_filters,
111
+}
112
+
113
+class { '::watcher::api':
114
+  watcher_client_auth_uri => "${internal_auth_protocol}://${internal_auth_address}:5000/",
115
+  watcher_client_auth_url => "${admin_auth_protocol}://${admin_auth_address}:35357/",
116
+  watcher_client_username => $watcher_user,
117
+  watcher_client_password => $watcher_password,
118
+  watcher_api_bind_host   => $api_bind_host,
119
+  watcher_api_port        => $api_bind_port,
120
+  package_ensure          => 'latest',
121
+  create_db_schema        => true,
122
+  upgrade_db              => true
123
+}
124
+
125
+class { '::watcher::applier' :
126
+  package_ensure      => 'latest',
127
+}
128
+
129
+class { '::watcher::decision_engine' :
130
+  package_ensure      => 'latest',
131
+  planner             => 'forced_order',
132
+}
133
+
134
+#class { '::watcher::policy': }
135
+
136
+package { 'python-watcherclient':
137
+  ensure => 'latest',
138
+  tag    => ['openstack', 'watcher-package'],
139
+}
140
+
141
+Firewall[$firewall_rule] -> Class['watcher::api']

+ 45
- 0
deployment_scripts/manifests/watcher_db.pp View File

@@ -0,0 +1,45 @@
1
+notice('MODULAR: watcher/watcher_db.pp')
2
+
3
+$watcher_hash    = hiera_hash('watcher_plugin', {})
4
+$mysql_hash     = hiera_hash('mysql', {})
5
+$management_vip = hiera('management_vip', undef)
6
+$database_vip   = hiera('database_vip')
7
+
8
+$mysql_root_user     = pick($mysql_hash['root_user'], 'root')
9
+$mysql_db_create     = pick($mysql_hash['db_create'], true)
10
+$mysql_root_password = $mysql_hash['root_password']
11
+
12
+$db_user     = pick($watcher_hash['db_user'], 'watcher')
13
+$db_name     = pick($watcher_hash['db_name'], 'watcher')
14
+$db_password = pick($watcher_hash['db_password'], $mysql_root_password)
15
+
16
+$db_host          = pick($watcher_hash['db_host'], $database_vip)
17
+$db_create        = pick($watcher_hash['db_create'], $mysql_db_create)
18
+$db_root_user     = pick($watcher_hash['root_user'], $mysql_root_user)
19
+$db_root_password = pick($watcher_hash['root_password'], $mysql_root_password)
20
+
21
+$allowed_hosts = [ 'localhost', '127.0.0.1', '%' ]
22
+
23
+class { '::openstack::galera::client':
24
+  custom_setup_class => hiera('mysql_custom_setup_class', 'galera'),
25
+}
26
+
27
+class { 'watcher::db::mysql':
28
+  user          => $db_user,
29
+  password      => $db_password,
30
+  dbname        => $db_name,
31
+  allowed_hosts => $allowed_hosts,
32
+}
33
+
34
+class { 'osnailyfacter::mysql_access':
35
+  db_host     => $db_host,
36
+  db_user     => $db_root_user,
37
+  db_password => $db_root_password,
38
+}
39
+
40
+Class['openstack::galera::client'] ->
41
+  Class['osnailyfacter::mysql_access'] ->
42
+    Class['watcher::db::mysql']
43
+
44
+class mysql::server {}
45
+include mysql::server

+ 39
- 0
deployment_scripts/manifests/watcher_haproxy.pp View File

@@ -0,0 +1,39 @@
1
+notice('MODULAR: watcher/watcher_haproxy.pp')
2
+
3
+$watcher_hash    = hiera_hash('watcher_plugin',{})
4
+$public_ssl_hash = hiera_hash('public_ssl', {})
5
+$ssl_hash        = hiera_hash('use_ssl', {})
6
+$external_lb     = hiera('external_lb', false)
7
+
8
+if (!$external_lb) {
9
+  $public_ssl        = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'usage', false)
10
+  $public_ssl_path   = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'path', [''])
11
+  $internal_ssl      = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'usage', false)
12
+  $internal_ssl_path = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'path', [''])
13
+
14
+  $server_names        = $watcher_hash['watcher_nodes']
15
+  $ipaddresses         = $watcher_hash['watcher_ipaddresses']
16
+  $public_virtual_ip   = hiera('public_vip')
17
+  $internal_virtual_ip = hiera('management_vip')
18
+
19
+  Openstack::Ha::Haproxy_service {
20
+    internal_virtual_ip => $internal_virtual_ip,
21
+    ipaddresses         => $ipaddresses,
22
+    public_virtual_ip   => $public_virtual_ip,
23
+    server_names        => $server_names,
24
+    public              => true,
25
+  }
26
+
27
+  openstack::ha::haproxy_service { 'watcher-api':
28
+    order                  => '214',
29
+    listen_port            => 9322,
30
+    public_ssl             => $public_ssl,
31
+    public_ssl_path        => $public_ssl_path,
32
+    internal_ssl           => $internal_ssl,
33
+    internal_ssl_path      => $internal_ssl_path,
34
+    require_service        => 'watcher_api',
35
+    haproxy_config_options => {
36
+      'http-request' => 'set-header X-Forwarded-Proto https if { ssl_fc }',
37
+    },
38
+  }
39
+}

+ 66
- 0
deployment_scripts/manifests/watcher_hiera_override.pp View File

@@ -0,0 +1,66 @@
1
+notice('MODULAR: watcher/watcher_hiera_override.pp')
2
+
3
+$watcher_plugin = hiera('fuel-plugin-watcher', undef)
4
+$hiera_dir = '/etc/hiera/plugins'
5
+$plugin_name = 'fuel-plugin-watcher'
6
+$plugin_yaml = "${plugin_name}.yaml"
7
+
8
+if $watcher_plugin {
9
+  $network_metadata    = hiera_hash('network_metadata')
10
+  $watcher_base_hash   = hiera_hash('watcher', {})
11
+  $user_password       = $watcher_plugin['user_password']
12
+  $watcher_role_exists = empty(nodes_with_roles(['primary-watcher-node'])) ? {
13
+    true    => false,
14
+    default => true,
15
+  }
16
+  if $watcher_role_exists {
17
+    $watcher_nodes       = get_nodes_hash_by_roles($network_metadata, ['primary-watcher-node', 'watcher-node'])
18
+    $watcher_address_map = get_node_to_ipaddr_map_by_network_role($watcher_nodes, 'management')
19
+    $watcher_nodes_ips   = values($watcher_address_map)
20
+    $watcher_nodes_names = keys($watcher_address_map)
21
+  } else {
22
+    $watcher_nodes       = get_nodes_hash_by_roles($network_metadata, ['primary-controller', 'controller'])
23
+    $watcher_address_map = get_node_to_ipaddr_map_by_network_role($watcher_nodes, 'management')
24
+    $watcher_nodes_ips   = values($watcher_address_map)
25
+    $watcher_nodes_names = keys($watcher_address_map)
26
+  }
27
+
28
+  $syslog_log_facility_watcher = hiera('syslog_log_facility_watcher', 'LOG_LOCAL0')
29
+  $default_log_levels         = hiera('default_log_levels')
30
+
31
+  ###################
32
+  $calculated_content = inline_template('
33
+watcher_plugin:
34
+  user_password: <%= @user_password %>
35
+  watcher_standalone: <%= @watcher_role_exists %>
36
+  watcher_ipaddresses:
37
+<%
38
+@watcher_nodes_ips.each do |watcherip|
39
+%>    - <%= watcherip %>
40
+<% end -%>
41
+  watcher_nodes:
42
+<%
43
+@watcher_nodes_names.each do |watchername|
44
+%>    - <%= watchername %>
45
+<% end -%>
46
+syslog_log_facility_watcher: <%= @syslog_log_facility_watcher %>
47
+"watcher::logging::default_log_levels":
48
+<%
49
+@default_log_levels.each do |k,v|
50
+%>  <%= k %>: <%= v %>
51
+<% end -%>
52
+')
53
+
54
+  ###################
55
+  file {'/etc/hiera/override':
56
+    ensure  => directory,
57
+  } ->
58
+  file { "${hiera_dir}/${plugin_yaml}":
59
+    ensure  => file,
60
+    content => "${calculated_content}",
61
+  }
62
+
63
+  package {'ruby-deep-merge':
64
+    ensure  => 'installed',
65
+  }
66
+}

+ 33
- 0
deployment_scripts/manifests/watcher_keystone.pp View File

@@ -0,0 +1,33 @@
1
+notice('watcher PLUGIN: watcher_keystone.pp')
2
+
3
+$watcher_hash      = hiera_hash('watcher_plugin', {})
4
+$public_ip         = hiera('public_vip')
5
+$management_ip     = hiera('management_vip')
6
+$region            = hiera('region', 'RegionOne')
7
+$public_ssl_hash   = hiera('public_ssl')
8
+$ssl_hash          = hiera_hash('use_ssl', {})
9
+
10
+$public_protocol   = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'protocol', 'http')
11
+$public_address    = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'hostname', [$public_ip])
12
+$internal_protocol = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'protocol', 'http')
13
+$internal_address  = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'hostname', [$management_ip])
14
+$admin_protocol    = get_ssl_property($ssl_hash, {}, 'watcher', 'admin', 'protocol', 'http')
15
+$admin_address     = get_ssl_property($ssl_hash, {}, 'watcher', 'admin', 'hostname', [$management_ip])
16
+
17
+$api_bind_port     = '9322'
18
+$tenant            = pick($watcher_hash['tenant'], 'services')
19
+$public_url        = "${public_protocol}://${public_address}:${api_bind_port}"
20
+$internal_url      = "${internal_protocol}://${internal_address}:${api_bind_port}"
21
+$admin_url         = "${admin_protocol}://${admin_address}:${api_bind_port}"
22
+
23
+class {'::osnailyfacter::wait_for_keystone_backends':}
24
+class { 'watcher::keystone::auth':
25
+  password     => pick($watcher_hash['user_password'], 'watcher'),
26
+  region       => $region,
27
+  tenant       => $tenant,
28
+  public_url   => $public_url,
29
+  internal_url => $internal_url,
30
+  admin_url    => $admin_url,
31
+}
32
+
33
+Class['::osnailyfacter::wait_for_keystone_backends'] -> Class['watcher::keystone::auth']

+ 13
- 0
deployment_scripts/manifests/watcher_logging.pp View File

@@ -0,0 +1,13 @@
1
+notice('MODULAR: watcher/watcher_logging.pp')
2
+
3
+$content=':syslogtag, contains, "watcher" -/var/log/watcher-all.log
4
+### stop further processing for the matched entries
5
+& ~'
6
+
7
+include ::rsyslog::params
8
+
9
+::rsyslog::snippet { '57-watcher':
10
+  content => $content,
11
+}
12
+
13
+Rsyslog::Snippet['57-watcher'] ~> Service[$::rsyslog::params::service_name]

+ 15
- 0
deployment_scripts/manifests/watcher_pin_plugin_repo.pp View File

@@ -0,0 +1,15 @@
1
+notice('MODULAR: watcher/watcher_pin_plugin_repo.pp')
2
+
3
+$master_ip = pick(hiera('master_ip'), 'localhost')
4
+$location  = "http://${master_ip}:8080/watcher"
5
+
6
+apt::source { 'watcher':
7
+  location => $location,
8
+  release => 'mos9.0-watcher',
9
+  repos => 'main',
10
+}
11
+
12
+apt::pin { 'watcher':
13
+    release => 'mos9.0-watcher',
14
+    priority => 1300,
15
+}

+ 6
- 0
deployment_scripts/manifests/watcher_timezone.pp View File

@@ -0,0 +1,6 @@
1
+notice('MODULAR: watcher/watcher_timezone.pp')
2
+
3
+#TODO: customize timezone
4
+exec {'moscow_timezone':
5
+    command => '/usr/bin/timedatectl set-timezone Europe/Moscow'
6
+}  ~> service { 'rsyslog': }

+ 21
- 0
deployment_scripts/modules/watcher/Gemfile View File

@@ -0,0 +1,21 @@
1
+source ENV['GEM_SOURCE'] || "https://rubygems.org"
2
+
3
+group :development, :test, :system_tests do
4
+  gem 'puppet-openstack_spec_helper',
5
+      :git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper',
6
+      :require => 'false'
7
+end
8
+
9
+if facterversion = ENV['FACTER_GEM_VERSION']
10
+  gem 'facter', facterversion, :require => false
11
+else
12
+  gem 'facter', :require => false
13
+end
14
+
15
+if puppetversion = ENV['PUPPET_GEM_VERSION']
16
+  gem 'puppet', puppetversion, :require => false
17
+else
18
+  gem 'puppet', :require => false
19
+end
20
+
21
+# vim:ft=ruby

+ 14
- 0
deployment_scripts/modules/watcher/LICENSE View File

@@ -0,0 +1,14 @@
1
+Copyright 2016 OVH Group
2
+Copyright 2016 OpenStack Foundation
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.

+ 85
- 0
deployment_scripts/modules/watcher/README.md View File

@@ -0,0 +1,85 @@
1
+Team and repository tags
2
+========================
3
+
4
+[![Team and repository tags](http://governance.openstack.org/badges/puppet-watcher.svg)](http://governance.openstack.org/reference/tags/index.html)
5
+
6
+<!-- Change things from this point on -->
7
+
8
+watcher
9
+=======
10
+
11
+#### Table of Contents
12
+
13
+1. [Overview - What is the watcher module?](#overview)
14
+2. [Module Description - What does the module do?](#module-description)
15
+3. [Setup - The basics of getting started with watcher](#setup)
16
+4. [Implementation - An under-the-hood peek at what the module is doing](#implementation)
17
+5. [Limitations - OS compatibility, etc.](#limitations)
18
+6. [Development - Guide for contributing to the module](#development)
19
+7. [Contributors - Those with commits](#contributors)
20
+
21
+Overview
22
+--------
23
+
24
+The watcher module is a part of [OpenStack](https://www.openstack.org), an effort by the OpenStack infrastructure team to provide continuous integration testing and code review for OpenStack and OpenStack community projects not part of the core software.  The module its self is used to flexibly configure and manage the Watcher service for OpenStack.
25
+
26
+Module Description
27
+------------------
28
+
29
+The watcher module is a thorough attempt to make Puppet capable of managing the entirety of watcher.  This includes manifests to provision region specific endpoint and database connections.  Types are shipped as part of the watcher module to assist in manipulation of configuration files.
30
+
31
+Setup
32
+-----
33
+
34
+**What the watcher module affects**
35
+
36
+* [Watcher](https://wiki.openstack.org/wiki/Watcher), the Watcher service for OpenStack.
37
+
38
+### Installing watcher
39
+
40
+    watcher is not currently in Puppet Forge, but is anticipated to be added soon.  Once that happens, you'll be able to install watcher with:
41
+    puppet module install openstack/watcher
42
+
43
+### Beginning with watcher
44
+
45
+To utilize the watcher module's functionality you will need to declare multiple resources.
46
+
47
+Implementation
48
+--------------
49
+
50
+### watcher
51
+
52
+watcher is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
53
+
54
+Limitations
55
+------------
56
+
57
+* All the watcher types use the CLI tools and so need to be ran on the watcher node.
58
+
59
+Beaker-Rspec
60
+------------
61
+
62
+This module has beaker-rspec tests
63
+
64
+To run the tests on the default vagrant node:
65
+
66
+```shell
67
+bundle install
68
+bundle exec rake acceptance
69
+```
70
+
71
+For more information on writing and running beaker-rspec tests visit the documentation:
72
+
73
+* https://github.com/puppetlabs/beaker-rspec/blob/master/README.md
74
+
75
+Development
76
+-----------
77
+
78
+Developer documentation for the entire puppet-openstack project.
79
+
80
+* http://docs.openstack.org/developer/puppet-openstack-guide/
81
+
82
+Contributors
83
+------------
84
+
85
+* https://github.com/openstack/puppet-watcher/graphs/contributors

+ 1
- 0
deployment_scripts/modules/watcher/Rakefile View File

@@ -0,0 +1 @@
1
+require 'puppet-openstack_spec_helper/rake_tasks'

+ 10
- 0
deployment_scripts/modules/watcher/lib/puppet/provider/watcher_config/ini_setting.rb View File

@@ -0,0 +1,10 @@
1
+Puppet::Type.type(:watcher_config).provide(
2
+  :ini_setting,
3
+  :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
4
+) do
5
+
6
+  def self.file_path
7
+    '/etc/watcher/watcher.conf'
8
+  end
9
+
10
+end

+ 53
- 0
deployment_scripts/modules/watcher/lib/puppet/type/watcher_config.rb View File

@@ -0,0 +1,53 @@
1
+Puppet::Type.newtype(:watcher_config) do
2
+
3
+  ensurable
4
+
5
+  newparam(:name, :namevar => true) do
6
+    desc 'Section/setting name to manage from watcher.conf'
7
+    newvalues(/\S+\/\S+/)
8
+  end
9
+
10
+  newproperty(:value) do
11
+    desc 'The value of the setting to be defined.'
12
+    munge do |value|
13
+      value = value.to_s.strip
14
+      value.capitalize! if value =~ /^(true|false)$/i
15
+      value
16
+    end
17
+    newvalues(/^[\S ]*$/)
18
+
19
+    def is_to_s( currentvalue )
20
+      if resource.secret?
21
+        return '[old secret redacted]'
22
+      else
23
+        return currentvalue
24
+      end
25
+    end
26
+
27
+    def should_to_s( newvalue )
28
+      if resource.secret?
29
+        return '[new secret redacted]'
30
+      else
31
+        return newvalue
32
+      end
33
+    end
34
+  end
35
+
36
+  newparam(:secret, :boolean => true) do
37
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
38
+
39
+    newvalues(:true, :false)
40
+
41
+    defaultto false
42
+  end
43
+
44
+  newparam(:ensure_absent_val) do
45
+    desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
46
+    defaultto('<SERVICE DEFAULT>')
47
+  end
48
+
49
+  autorequire(:package) do
50
+    'watcher'
51
+  end
52
+
53
+end

+ 241
- 0
deployment_scripts/modules/watcher/manifests/api.pp View File

@@ -0,0 +1,241 @@
1
+# == Class: watcher::api
2
+#
3
+# Configure Watcher API service.
4
+#
5
+# === Parameters:
6
+#
7
+# All options are optional unless specified otherwise.
8
+# All options defaults to $::os_service_default and
9
+# the default values from the service are used.
10
+#
11
+# === Watcher configuration section: watcher_clients_auth
12
+#
13
+# [*watcher_client_password*]
14
+#   (required) User's password
15
+#
16
+# [*watcher_client_username*]
17
+#   (optional) The name of the auth user
18
+#   Defaults to watcher.
19
+#
20
+# [*watcher_client_auth_uri*]
21
+#   (Optional) Public Identity API endpoint.
22
+#   Defaults to 'http://localhost:5000/'
23
+#
24
+# [*watcher_client_auth_url*]
25
+#   Specifies the admin Identity URI for Watcher to use.
26
+#   Default 'http://localhost:35357/'
27
+#
28
+# [*package_ensure*]
29
+#   (Optional)Ensure state of the openstackclient package.
30
+#   Defaults to 'present'.
31
+#
32
+# [*enabled*]
33
+#   (Optional) Whether the watcher api service will be run
34
+#   Defaults to true
35
+#
36
+# [*manage_service*]
37
+#   (Optional) Whether the service should be managed by Puppet.
38
+#   Defaults to true.
39
+#
40
+# [*validate*]
41
+#   (Optional) Whether to validate the service is working after any service
42
+#   refreshes
43
+#   Defaults to false
44
+#
45
+# [*watcher_api_port*]
46
+#   (Optional) The port on which the watcher API will listen.
47
+#   Defaults to 9322.
48
+#
49
+# [*watcher_api_max_limit*]
50
+#   (Optional)The maximum number of items returned in a single response from a
51
+#   collection resource.
52
+#   Defaults to $::os_service_default
53
+#
54
+# [*watcher_api_bind_host*]
55
+#   (Optional) Listen IP for the watcher API server.
56
+#   Defaults to '0.0.0.0'.
57
+#
58
+# [*watcher_api_workers*]
59
+#   (Optional) Number of worker processors to for the Watcher API service.
60
+#   Defaults to $::os_workers.
61
+#
62
+# [*watcher_api_enable_ssl_api*]
63
+#   (Optional) Enable the integrated stand-alone API to service requests via HTTPS instead
64
+#   of HTTP. If there is a front-end service performing HTTPS offloading from the
65
+#   service, this option should be False; note, you will want to change public
66
+#   API endpoint to represent SSL termination URL with 'public_endpoint' option.
67
+#   Defaults to $::os_service_default.
68
+#
69
+# [*watcher_client_default_domain_name*]
70
+#   (Optional)domain name to use with v3 API and v2 parameters. It will
71
+#   be used for both the user and project domain in v3 and ignored in v2
72
+#   authentication.
73
+#   Defaults to $::os_service_default
74
+#
75
+# [*watcher_client_project_name*]
76
+#   (Optional) Service project name.
77
+#   Defaults to undef
78
+#
79
+# [*watcher_client_certfile*]
80
+#   (Optional) PEM encoded client certificate cert file.
81
+#   Defaults to undef
82
+#
83
+# [*watcher_client_cafile*]
84
+#   (Optional)PEM encoded Certificate Authority to use when verifying HTTPs
85
+#   connections.
86
+#   Defaults to undef
87
+#
88
+# [*watcher_client_project_domain_name*]
89
+#   (Optional) Domain name containing project.
90
+#   Defaults to undef
91
+#
92
+# [*watcher_client_insecure*]
93
+#   (Optional) Verify HTTPS connections.
94
+#   Defaults to undef
95
+#
96
+# [*watcher_client_keyfile*]
97
+#   (Optional) PEM encoded client certificate key file.
98
+#   Defaults to undef
99
+#
100
+# [*watcher_client_auth_type*]
101
+#   (Optional) Authentication type to load.
102
+#   Defaults to undef
103
+#
104
+# === Watcher API service validation
105
+#
106
+# [*validation_options*]
107
+#   (Optional) Service validation options
108
+#   Should be a hash of options defined in openstacklib::service_validation
109
+#   If empty, defaults values are taken from openstacklib function.
110
+#   Require validate set at True.
111
+#   Defaults to {}
112
+#
113
+# === DB managment
114
+#
115
+# [*create_db_schema*]
116
+#   (Optional) Run watcher-db-manage create_schema on api nodes after
117
+#   installing the package.
118
+#   Defaults to false
119
+#
120
+# [*upgrade_db*]
121
+#   (Optional) Run watcher-db-manage upgrade on api nodes after
122
+#   installing the package.
123
+#   Defaults to false
124
+#
125
+# [*auth_strategy*]
126
+#   (optional) Type of authentication to be used.
127
+#   Defaults to 'keystone'
128
+#
129
+class watcher::api (
130
+  $watcher_client_password,
131
+  $watcher_client_username            = 'watcher',
132
+  $watcher_client_auth_uri            = 'http://localhost:5000/',
133
+  $watcher_client_auth_url            = 'http://localhost:35357/',
134
+  $package_ensure                     = 'present',
135
+  $enabled                            = true,
136
+  $manage_service                     = true,
137
+  $validate                           = false,
138
+  $watcher_api_port                   = '9322',
139
+  $watcher_api_max_limit              = $::os_service_default,
140
+  $watcher_api_bind_host              = '0.0.0.0',
141
+  $watcher_api_workers                = $::os_workers,
142
+  $watcher_api_enable_ssl_api         = $::os_service_default,
143
+  $watcher_client_default_domain_name = $::os_service_default,
144
+  $watcher_client_project_name        = 'services',
145
+  $watcher_client_certfile            = $::os_service_default,
146
+  $watcher_client_cafile              = $::os_service_default,
147
+  $watcher_client_project_domain_name = $::os_service_default,
148
+  $watcher_client_insecure            = $::os_service_default,
149
+  $watcher_client_keyfile             = $::os_service_default,
150
+  $watcher_client_auth_type           = 'password',
151
+  $validation_options                 = {},
152
+  $create_db_schema                   = false,
153
+  $upgrade_db                         = false,
154
+  $auth_strategy                      = 'keystone',
155
+) {
156
+
157
+  include ::watcher::params
158
+  include ::watcher::policy
159
+  include ::watcher::deps
160
+
161
+  #if $auth_strategy == 'keystone' {
162
+  #  include ::watcher::keystone::authtoken
163
+  #}
164
+
165
+  validate_string($watcher_client_password)
166
+
167
+  package { 'watcher-api':
168
+    ensure => $package_ensure,
169
+    name   => $::watcher::params::api_package_name,
170
+    tag    => ['openstack', 'watcher-package'],
171
+  }
172
+
173
+  if $manage_service {
174
+    if $enabled {
175
+      $service_ensure = 'running'
176
+    } else {
177
+      $service_ensure = 'stopped'
178
+    }
179
+  }
180
+
181
+  if $create_db_schema {
182
+    include ::watcher::db::create_schema
183
+  }
184
+
185
+  if $upgrade_db {
186
+    include ::watcher::db::upgrade
187
+  }
188
+
189
+  # NOTE(danpawlik) Watcher doesn't support db_sync command.
190
+  service { 'watcher-api':
191
+    ensure     => $service_ensure,
192
+    name       => $::watcher::params::api_service_name,
193
+    enable     => $enabled,
194
+    hasstatus  => true,
195
+    hasrestart => true,
196
+    tag        => [ 'watcher-service',
197
+                    'watcher-db-manage-create_schema',
198
+                    'watcher-db-manage-upgrade'],
199
+  }
200
+
201
+  if $enabled {
202
+    watcher_config {
203
+      'api/port':           value => $watcher_api_port;
204
+      'api/max_limit':      value => $watcher_api_max_limit;
205
+      'api/host':           value => $watcher_api_bind_host;
206
+      'api/workers':        value => $watcher_api_workers;
207
+      'api/enable_ssl_api': value => $watcher_api_enable_ssl_api;
208
+    }
209
+  }
210
+
211
+  # NOTE(danpawlik) Watcher and other core Openstack services are using
212
+  # keystone_authtoken section and also another similar section used to
213
+  # configure client auth credentials. So these parameters are similar to
214
+  # parameters in watcher::keystone::authtoken.
215
+  watcher_config {
216
+    'watcher_clients_auth/username':            value => $watcher_client_username;
217
+    'watcher_clients_auth/password':            value => $watcher_client_password, secret => true;
218
+    'watcher_clients_auth/auth_url':            value => $watcher_client_auth_url;
219
+    'watcher_clients_auth/auth_uri':            value => $watcher_client_auth_uri;
220
+    'watcher_clients_auth/project_name':        value => $watcher_client_project_name;
221
+    'watcher_clients_auth/project_domain_name': value => $watcher_client_project_domain_name;
222
+    'watcher_clients_auth/insecure':            value => $watcher_client_insecure;
223
+    'watcher_clients_auth/auth_type':           value => $watcher_client_auth_type;
224
+    'watcher_clients_auth/cafile':              value => $watcher_client_cafile;
225
+    'watcher_clients_auth/certfile':            value => $watcher_client_certfile;
226
+    'watcher_clients_auth/keyfile':             value => $watcher_client_keyfile;
227
+  }
228
+
229
+  if $validate {
230
+    $defaults = {
231
+      'watcher-api' => {
232
+        # lint:ignore:140chars
233
+        'command'  => "watcher --os-auth-url ${watcher_client_auth_url} --os-project-name ${watcher_client_project_name} --os-username ${watcher_client_username} --os-password ${watcher_client_password} goal list",
234
+        # lint:endignore
235
+      }
236
+    }
237
+    $validation_options_hash = merge($defaults, $validation_options)
238
+    create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Anchor[watcher::service::end]'})
239
+  }
240
+
241
+}

+ 84
- 0
deployment_scripts/modules/watcher/manifests/applier.pp View File

@@ -0,0 +1,84 @@
1
+# == Class: watcher::applier
2
+#
3
+# === Parameters
4
+#
5
+# [*package_ensure*]
6
+#   (Optional) The state of the package.
7
+#   Defaults to 'present'.
8
+#
9
+# [*enabled*]
10
+#   (Optional) The state of the service
11
+#   Defaults to 'true'.
12
+#
13
+# [*manage_service*]
14
+#   (Optional) Whether to start/stop the service.
15
+#   Defaults to 'true'.
16
+#
17
+# [*applier_workers*]
18
+#   (Optional) Number of workers for watcher applier service.
19
+#   Defaults to $::os_service_default
20
+#
21
+# [*applier_conductor_topic*]
22
+#   (Optional) The topic name used forcontrol events, this topic used
23
+#   for rpc call
24
+#   Defaults to $::os_service_default
25
+#
26
+# [*applier_status_topic*]
27
+#   (Optional) The topic name used for status events, this topic is used
28
+#   so as to notifythe others components of the system
29
+#   Defaults to $::os_service_default
30
+#
31
+# [*applier_publisher_id*]
32
+#   (Optional) The identifier used by watcher module on the message broker
33
+#   Defaults to $::os_service_default
34
+#
35
+# [*applier_workflow_engine*]
36
+#   (Optional) Select the engine to use to execute the workflow
37
+#   Defaults to $::os_service_default
38
+#
39
+class watcher::applier (
40
+  $package_ensure          = 'present',
41
+  $enabled                 = true,
42
+  $manage_service          = true,
43
+  $applier_workers         = $::os_service_default,
44
+  $applier_conductor_topic = $::os_service_default,
45
+  $applier_status_topic    = $::os_service_default,
46
+  $applier_publisher_id    = $::os_service_default,
47
+  $applier_workflow_engine = $::os_service_default,
48
+) {
49
+
50
+  include ::watcher::params
51
+  include ::watcher::deps
52
+
53
+  package { 'watcher-applier':
54
+    ensure => $package_ensure,
55
+    name   => $::watcher::params::applier_package_name,
56
+    tag    => ['openstack', 'watcher-package'],
57
+  }
58
+
59
+  if $manage_service {
60
+    if $enabled {
61
+      $service_ensure = 'running'
62
+    } else {
63
+      $service_ensure = 'stopped'
64
+    }
65
+  }
66
+
67
+  service { 'watcher-applier':
68
+    ensure     => $service_ensure,
69
+    name       => $::watcher::params::applier_service_name,
70
+    enable     => $enabled,
71
+    hasstatus  => true,
72
+    hasrestart => true,
73
+    tag        => ['watcher-service'],
74
+  }
75
+
76
+  watcher_config {
77
+    'watcher_applier/workers':          value => $applier_workers;
78
+    'watcher_applier/conductor_topic':  value => $applier_conductor_topic;
79
+    'watcher_applier/status_topic':     value => $applier_status_topic;
80
+    'watcher_applier/publisher_id':     value => $applier_publisher_id;
81
+    'watcher_applier/workflow_engine':  value => $applier_workflow_engine;
82
+  }
83
+
84
+}

+ 32
- 0
deployment_scripts/modules/watcher/manifests/config.pp View File

@@ -0,0 +1,32 @@
1
+# == Class: watcher::config
2
+#
3
+# This class is used to manage arbitrary watcher configurations.
4
+#
5
+# === Parameters
6
+#
7
+# [*watcher_config*]
8
+#   (optional) Allow configuration of arbitrary watcher configurations.
9
+#   The value is an hash of watcher_config resources. Example:
10
+#   { 'DEFAULT/foo' => { value => 'fooValue'},
11
+#     'DEFAULT/bar' => { value => 'barValue'}
12
+#   }
13
+#   In yaml format, Example:
14
+#   watcher_config:
15
+#     DEFAULT/foo:
16
+#       value: fooValue
17
+#     DEFAULT/bar:
18
+#       value: barValue
19
+#
20
+#   NOTE: The configuration MUST NOT be already handled by this module
21
+#   or Puppet catalog compilation will fail with duplicate resources.
22
+#
23
+class watcher::config (
24
+  $watcher_config = {},
25
+) {
26
+
27
+  include ::watcher::deps
28
+
29
+  validate_hash($watcher_config)
30
+
31
+  create_resources('watcher_config', $watcher_config)
32
+}

+ 75
- 0
deployment_scripts/modules/watcher/manifests/db.pp View File

@@ -0,0 +1,75 @@
1
+# == Class: watcher::db
2
+#
3
+#  Configure the watcher database
4
+#
5
+# === Parameters
6
+#
7
+# [*database_connection*]
8
+#   (Optional) Url used to connect to database.
9
+#   Defaults to "sqlite:////var/lib/watcher/watcher.sqlite".
10
+#
11
+# [*database_idle_timeout*]
12
+#   (Optional) Timeout when db connections should be reaped.
13
+#   Defaults to $::os_service_default
14
+#
15
+# [*database_db_max_retries*]
16
+#   (optional) Maximum retries in case of connection error or deadlock error
17
+#   before error is raised. Set to -1 to specify an infinite retry count.
18
+#   Defaults to $::os_service_default
19
+#
20
+# [*database_max_retries*]
21
+#   (Optional) Maximum number of database connection retries during startup.
22
+#   Setting -1 implies an infinite retry count.
23
+#   Defaults to $::os_service_default
24
+#
25
+# [*database_retry_interval*]
26
+#   (Optional) Interval between retries of opening a database connection.
27
+#   Defaults to $::os_service_default
28
+#
29
+# [*database_min_pool_size*]
30
+#   (Optional) Minimum number of SQL connections to keep open in a pool.
31
+#   Defaults to $::os_service_default
32
+#
33
+# [*database_max_pool_size*]
34
+#   (Optional) Maximum number of SQL connections to keep open in a pool.
35
+#   Defaults to $::os_service_default
36
+#
37
+# [*database_max_overflow*]
38
+#   (Optional) If set, use this value for max_overflow with sqlalchemy.
39
+#   Defaults to $::os_service_default
40
+#
41
+class watcher::db (
42
+  $database_connection     = 'sqlite://var/lib/watcher/watcher.sqlite',
43
+  $database_idle_timeout   = $::os_service_default,
44
+  $database_min_pool_size  = $::os_service_default,
45
+  $database_max_pool_size  = $::os_service_default,
46
+  $database_db_max_retries = $::os_service_default,
47
+  $database_max_retries    = $::os_service_default,
48
+  $database_retry_interval = $::os_service_default,
49
+  $database_max_overflow   = $::os_service_default,
50
+) {
51
+  $database_connection_real     = pick($::watcher::database_connection, $database_connection)
52
+  $database_idle_timeout_real   = pick($::watcher::database_idle_timeout, $database_idle_timeout)
53
+  $database_min_pool_size_real  = pick($::watcher::database_min_pool_size, $database_min_pool_size)
54
+  $database_max_pool_size_real  = pick($::watcher::database_max_pool_size, $database_max_pool_size)
55
+  $database_max_retries_real    = pick($::watcher::database_max_retries, $database_max_retries)
56
+  $database_retry_interval_real = pick($::watcher::database_retry_interval, $database_retry_interval)
57
+  $database_max_overflow_real   = pick($::watcher::database_max_overflow, $database_max_overflow)
58
+
59
+  include ::watcher::deps
60
+  notice($database_connection)
61
+
62
+  #validate_re($database_connection,
63
+  #  '^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
64
+
65
+  watcher_config { 
66
+    'database/connection': value => $database_connection_real;
67
+    'database/idle_timeout': value => $database_idle_timeout_real;
68
+    'database/min_pool_size': value => $database_min_pool_size_real;
69
+    'database/db_max_retries': value => $database_db_max_retries_real;
70
+    'database/max_retries': value    => $database_max_retries_real;
71
+    'database/retry_interval': value => $database_retry_interval_real;
72
+    'database/max_pool_size': value => $database_max_pool_size_real;
73
+    'database/max_overflow': value => $database_max_overflow_real;
74
+  }
75
+}

+ 30
- 0
deployment_scripts/modules/watcher/manifests/db/create_schema.pp View File

@@ -0,0 +1,30 @@
1
+#
2
+# Class to execute watcher-db-manage create_schema
3
+#
4
+# == Parameters
5
+#
6
+# [*extra_params*]
7
+#   (optional) String of extra command line parameters to append
8
+#   to the watcher-db-manage create_schema command.
9
+#   Defaults to '--config-file /etc/watcher/watcher.conf'
10
+#
11
+class watcher::db::create_schema(
12
+  $extra_params  = '--config-file /etc/watcher/watcher.conf',
13
+) {
14
+
15
+  include ::watcher::deps
16
+
17
+  exec { 'watcher-db-manage-create_schema':
18
+    command     => "watcher-db-manage ${extra_params} create_schema",
19
+    path        => '/usr/bin',
20
+    user        => 'watcher',
21
+    refreshonly => true,
22
+    subscribe   => [
23
+      Anchor['watcher::install::end'],
24
+      Anchor['watcher::config::end'],
25
+      Anchor['watcher::db::create_schema::begin']
26
+    ],
27
+    notify      => Anchor['watcher::db::create_schema::end'],
28
+  }
29
+
30
+}

+ 74
- 0
deployment_scripts/modules/watcher/manifests/db/mysql.pp View File

@@ -0,0 +1,74 @@
1
+# The watcher::db::mysql class implements mysql backend for watcher
2
+#
3
+# This class can be used to create tables, users and grant
4
+# privilege for a mysql watcher database.
5
+#
6
+# == parameters
7
+#
8
+# [*password*]
9
+#   (Mandatory) Password to connect to the database.
10
+#   Defaults to 'false'.
11
+#
12
+# [*dbname*]
13
+#   (Optional) Name of the database.
14
+#   Defaults to 'watcher'.
15
+#
16
+# [*user*]
17
+#   (Optional) User to connect to the database.
18
+#   Defaults to 'watcher'.
19
+#
20
+# [*host*]
21
+#   (Optional) The default source host user is allowed to connect from.
22
+#   Defaults to '127.0.0.1'
23
+#
24
+# [*allowed_hosts*]
25
+#   (Optional) Other hosts the user is allowed to connect from.
26
+#   Defaults to 'undef'.
27
+#
28
+# [*charset*]
29
+#   (Optional) The database charset.
30
+#   Defaults to 'utf8'
31
+#
32
+# [*collate*]
33
+#   (Optional) The database collate.
34
+#   Only used with mysql modules >= 2.2.
35
+#   Defaults to 'utf8_general_ci'
36
+#
37
+# == Dependencies
38
+#   Class['mysql::server']
39
+#
40
+# == Examples
41
+#
42
+# == Authors
43
+#
44
+# == Copyright
45
+#
46
+class watcher::db::mysql(
47
+  $password,
48
+  $dbname        = 'watcher',
49
+  $user          = 'watcher',
50
+  $host          = '127.0.0.1',
51
+  $charset       = 'utf8',
52
+  $collate       = 'utf8_general_ci',
53
+  $allowed_hosts = undef
54
+) {
55
+
56
+  include ::watcher::deps
57
+
58
+  validate_string($password)
59
+
60
+  ::openstacklib::db::mysql { 'watcher':
61
+    user          => $user,
62
+    password_hash => mysql_password($password),
63
+    dbname        => $dbname,
64
+    host          => $host,
65
+    charset       => $charset,
66
+    collate       => $collate,
67
+    allowed_hosts => $allowed_hosts,
68
+  }
69
+
70
+  Anchor['watcher::db::begin']
71
+  ~> Class['watcher::db::mysql']
72
+  ~> Anchor['watcher::db::end']
73
+
74
+}

+ 57
- 0
deployment_scripts/modules/watcher/manifests/db/postgresql.pp View File

@@ -0,0 +1,57 @@
1
+# == Class: watcher::db::postgresql
2
+#
3
+# Class that configures postgresql for watcher
4
+# Requires the Puppetlabs postgresql module.
5
+#
6
+# === Parameters
7
+#
8
+# [*password*]
9
+#   (Required) Password to connect to the database.
10
+#
11
+# [*dbname*]
12
+#   (Optional) Name of the database.
13
+#   Defaults to 'watcher'.
14
+#
15
+# [*user*]
16
+#   (Optional) User to connect to the database.
17
+#   Defaults to 'watcher'.
18
+#
19
+#  [*encoding*]
20
+#    (Optional) The charset to use for the database.
21
+#    Default to undef.
22
+#
23
+#  [*privileges*]
24
+#    (Optional) Privileges given to the database user.
25
+#    Default to 'ALL'
26
+#
27
+# == Dependencies
28
+#
29
+# == Examples
30
+#
31
+# == Authors
32
+#
33
+# == Copyright
34
+#
35
+class watcher::db::postgresql(
36
+  $password,
37
+  $dbname     = 'watcher',
38
+  $user       = 'watcher',
39
+  $encoding   = undef,
40
+  $privileges = 'ALL',
41
+) {
42
+
43
+  include ::watcher::deps
44
+
45
+  ::openstacklib::db::postgresql { 'watcher':
46
+    password_hash => postgresql_password($user, $password),
47
+    dbname        => $dbname,
48
+    user          => $user,
49
+    encoding      => $encoding,
50
+    privileges    => $privileges,
51
+  }
52
+
53
+  Anchor['watcher::db::begin']
54
+  ~> Class['watcher::db::postgresql']
55
+  ~> Anchor['watcher::db::end']
56
+
57
+}

+ 32
- 0
deployment_scripts/modules/watcher/manifests/db/upgrade.pp View File

@@ -0,0 +1,32 @@
1
+#
2
+# Class to execute watcher-db-manage upgrade
3
+# It's because watcher-db-manage doesn't support sync db.
4
+#
5
+# == Parameters
6
+#
7
+# [*extra_params*]
8
+#   (optional) String of extra command line parameters to append
9
+#   to the watcher-db-manage upgrade command.
10
+#   Defaults to '--config-file /etc/watcher/watcher.conf'
11
+#
12
+class watcher::db::upgrade(
13
+  $extra_params  = '--config-file /etc/watcher/watcher.conf',
14
+) {
15
+
16
+  include ::watcher::deps
17
+
18
+  exec { 'watcher-db-manage-upgrade':
19
+    command     => "watcher-db-manage ${extra_params} upgrade",
20
+    path        => '/usr/bin',
21
+    user        => 'watcher',
22
+    refreshonly => true,
23
+    subscribe   => [
24
+      Anchor['watcher::install::end'],
25
+      Anchor['watcher::config::end'],
26
+      Anchor['watcher::db::create_schema::end'],
27
+      Anchor['watcher::db::upgrade::begin']
28
+    ],
29
+    notify      => Anchor['watcher::db::upgrade::end'],
30
+  }
31
+
32
+}

+ 122
- 0
deployment_scripts/modules/watcher/manifests/decision_engine.pp View File

@@ -0,0 +1,122 @@
1
+# == Class: watcher::decision_engine
2
+#
3
+# === Parameters
4
+#
5
+# [*package_ensure*]
6
+#   (Optional) The state of the package.
7
+#   Defaults to 'present'.
8
+#
9
+# [*enabled*]
10
+#   (Optional) The state of the service
11
+#   Defaults to 'true'.
12
+#
13
+# [*manage_service*]
14
+#   (Optional) Whether to start/stop the service.
15
+#   Defaults to 'true'.
16
+#
17
+# [*decision_engine_conductor_topic*]
18
+#   (Optional) The topic name used forcontrol events, this topic used
19
+#   for rpc call
20
+#   Defaults to $::os_service_default
21
+#
22
+# [*decision_engine_status_topic*]
23
+#   (Optional) The topic name used for status events, this topic is used
24
+#   so as to notifythe others components of the system
25
+#   Defaults to $::os_service_default
26
+#
27
+# [*decision_engine_notification_topics*]
28
+#   (Optional) The topic names from which notification events will be
29
+#   listened to (list value)
30
+#   Defaults to $::os_service_default
31
+#
32
+# [*decision_engine_publisher_id*]
33
+#   (Optional) The identifier used by watcher module on the message broker
34
+#   Defaults to $::os_service_default
35
+#
36
+# [*decision_engine_workers*]
37
+#   (Optional) The maximum number of threads that can be used to execute
38
+#   strategies
39
+#   Defaults to $::os_service_default
40
+#
41
+# [*planner*]
42
+#   (Optional) The selected planner used to schedule the actions (string value)
43
+#   Defaults to $::os_service_default
44
+#
45
+# [*weights*]
46
+#   (Optional) Hash of weights used to schedule the actions (dict value).
47
+#   The key is an action, value is an order number.
48
+#   Defaults to $::os_service_default
49
+#   Example:
50
+#     { 'change_nova_service_state' => '2',
51
+#       'migrate' => '3', 'nop' => '0', 'sleep' => '1' }
52
+#
53
+#
54
+class watcher::decision_engine (
55
+  $package_ensure                      = 'present',
56
+  $enabled                             = true,
57
+  $manage_service                      = true,
58
+  $decision_engine_conductor_topic     = $::os_service_default,
59
+  $decision_engine_status_topic        = $::os_service_default,
60
+  $decision_engine_notification_topics = $::os_service_default,
61
+  $decision_engine_publisher_id        = $::os_service_default,
62
+  $decision_engine_workers             = $::os_service_default,
63
+  $planner                             = $::os_service_default,
64
+  $weights                             = $::os_service_default,
65
+) {
66
+
67
+  include ::watcher::params
68
+  include ::watcher::deps
69
+
70
+  if !is_service_default($weights) {
71
+    validate_hash($weights)
72
+    $weights_real = join(sort(join_keys_to_values($weights, ':')), ',')
73
+  } else {
74
+    $weights_real = $weights
75
+  }
76
+
77
+  if !is_service_default($decision_engine_notification_topics) or
78
+    empty($decision_engine_notification_topics) {
79
+    warning('$decision_engine_notification_topics needs to be an array')
80
+    $decision_engine_notification_topics_real = any2array($decision_engine_notification_topics)
81
+  } else {
82
+    $decision_engine_notification_topics_real = $decision_engine_notification_topics
83
+  }
84
+
85
+  package { 'watcher-decision-engine':
86
+    ensure => $package_ensure,
87
+    name   => $::watcher::params::decision_engine_package_name,
88
+    tag    => ['openstack', 'watcher-package'],
89
+  }
90
+
91
+  if $manage_service {
92
+    if $enabled {
93
+      $service_ensure = 'running'
94
+    } else {
95
+      $service_ensure = 'stopped'
96
+    }
97
+  }
98
+
99
+  service { 'watcher-decision-engine':
100
+    ensure     => $service_ensure,
101
+    name       => $::watcher::params::decision_engine_service_name,
102
+    enable     => $enabled,
103
+    hasstatus  => true,
104
+    hasrestart => true,
105
+    tag        => ['watcher-service'],
106
+  }
107
+
108
+  watcher_config {
109
+    'watcher_decision_engine/conductor_topic':     value => $decision_engine_conductor_topic;
110
+    'watcher_decision_engine/status_topic':        value => $decision_engine_status_topic;
111
+    'watcher_decision_engine/notification_topics': value => $decision_engine_notification_topics_real;
112
+    'watcher_decision_engine/publisher_id':        value => $decision_engine_publisher_id;
113
+    'watcher_decision_engine/max_workers':         value => $decision_engine_workers;
114
+    'watcher_decision_engine/continuous_audit_interval': value => 30;
115
+  }
116
+
117
+  watcher_config {
118
+    'watcher_planner/planner':          value => $planner;
119
+    'watcher_planners.default/weights': value => $weights_real;
120
+  }
121
+
122
+}

+ 34
- 0
deployment_scripts/modules/watcher/manifests/deps.pp View File

@@ -0,0 +1,34 @@
1
+# == Class: watcher::deps
2
+#
3
+#  watcher anchors and dependency management
4
+#
5
+class watcher::deps {
6
+  anchor { 'watcher::install::begin': }
7
+  -> Package<| tag == 'watcher-package'|>
8
+  ~> anchor { 'watcher::install::end': }
9
+  -> anchor { 'watcher::config::begin': }
10
+  -> Watcher_config<||>
11
+  ~> anchor { 'watcher::config::end': }
12
+  ~> anchor { 'watcher::db::begin': }
13
+  ~> anchor { 'watcher::db::end': }
14
+  ~> anchor { 'watcher::db::create_schema::begin': }
15
+  ~> anchor { 'watcher::db::create_schema::end': }
16
+  ~> anchor { 'watcher::db::upgrade::begin': }
17
+  ~> anchor { 'watcher::db::upgrade::end': }
18
+  ~> anchor { 'watcher::service::begin': }
19
+  ~> Service<| tag == 'watcher-service' |>
20
+  ~> anchor { 'watcher::service::end': }
21
+
22
+  # policy config should occur in the config block also.
23
+  Anchor['watcher::config::begin']
24
+  -> Openstacklib::Policy::Base<||>
25
+  ~> Anchor['watcher::config::end']
26
+
27
+  Anchor['watcher::install::end'] ~> Anchor['watcher::service::begin']
28
+  Anchor['watcher::config::end']  ~> Anchor['watcher::service::begin']
29
+
30
+  anchor { 'watcher-start':
31
+    require => Anchor['watcher::install::end'],
32
+    before  => Anchor['watcher::config::begin'],
33
+  }
34
+}

+ 471
- 0
deployment_scripts/modules/watcher/manifests/init.pp View File

@@ -0,0 +1,471 @@
1
+# == Class: watcher
2
+#
3
+# Full description of class watcher here.
4
+#
5
+# === Parameters:
6
+#
7
+# [*use_ssl*]
8
+#   (required) Enable SSL on the API server.
9
+#   Defaults to false.
10
+#
11
+# [*ceilometer_client_api_version*]
12
+#   (required) Version of Ceilometer API to use in ceilometerclient.
13
+#   Default is 2.
14
+#
15
+# [*cinder_client_api_version*]
16
+#   (required) Version of Cinder API to use in cinderclient.
17
+#   Default is 2.
18
+#
19
+# [*glance_client_api_version*]
20
+#   (required) Version of Glance API to use in glanceclient.
21
+#   Default is 2.
22
+#
23
+# [*neutron_client_api_version*]
24
+#   (required) Version of Neutron API to use in neutronclient.
25
+#   Default is 2.
26
+#
27
+# [*nova_client_api_version*]
28
+#   (required) Version of Nova API to use in novaclient.
29
+#   Default is 2.
30
+#
31
+# [*rpc_backend*]
32
+#   (optional) The messaging driver to use, defaults to rabbit. Other drivers
33
+#   include amqp and zmq.
34
+#   Defaults to 'rabbit'.
35
+#
36
+# [*ensure_package*]
37
+#  (optional) Whether the watcher api package will be installed
38
+#  Defaults to 'present'
39
+#
40
+# [*rabbit_login_method*]
41
+#   (optional) The RabbitMQ login method. (string value)
42
+#   Defaults to $::os_service_default
43
+#
44
+# [*rabbit_retry_interval*]
45
+#   (Optional) How frequently to retry connecting with RabbitMQ.
46
+#   (integer value)
47
+#   Defaults to $::os_service_default
48
+#
49
+# [*rabbit_retry_backoff*]
50
+#   (Optional) How long to backoff for between retries when connecting
51
+#   to RabbitMQ. (integer value)
52
+#   Defaults to $::os_service_default
53
+#
54
+# [*rabbit_interval_max*]
55
+#   (Optional) Maximum interval of RabbitMQ connection retries. (integer value)
56
+#   Defaults to $::os_service_default
57
+#
58
+# [*rabbit_max_retries*]
59
+#   (Optional) Maximum number of RabbitMQ connection retries. (integer value)
60
+#   Defaults to $::os_service_default
61
+#
62
+# [*rabbit_use_ssl*]
63
+#   (optional) Connect over SSL for RabbitMQ.
64
+#   Defaults to $::os_service_default
65
+#
66
+# [*rabbit_heartbeat_rate*]
67
+#   (optional) ow often times during the heartbeat_timeout_threshold we
68
+#   check the heartbeat.
69
+#   Defaults to $::os_service_default
70
+#
71
+# [*rabbit_ha_queues*]
72
+#   (optional) Use HA queues in RabbitMQ (x-ha-policy: all). If you change this
73
+#   option, you must wipe the RabbitMQ database.
74
+#   Defaults to $::os_service_default
75
+#
76
+# [*rabbit_transient_queues_ttl*]
77
+#   (Optional) Positive integer representing duration in seconds for
78
+#   queue TTL (x-expires). Queues which are unused for the duration
79
+#   of the TTL are automatically deleted.
80
+#   The parameter affects only reply and fanout queues. (integer value)
81
+#   Min to 1
82
+#   Defaults to $::os_service_default
83
+#
84
+# [*rabbit_heartbeat_timeout_threshold*]
85
+#   (Optional) Number of seconds after which the Rabbit broker is
86
+#   considered down if heartbeat's keep-alive fails
87
+#   (0 disable the heartbeat). EXPERIMENTAL. (integer value)
88
+#   Defaults to $::os_service_default
89
+#
90
+# [*kombu_ssl_ca_certs*]
91
+#   (optional) SSL certification authority file (valid only if SSL enabled).
92
+#   Defaults to $::os_service_default
93
+#
94
+# [*kombu_ssl_certfile*]
95
+#   (optional) SSL cert file (valid only if SSL enabled).
96
+#   Defaults to $::os_service_default
97
+#
98
+# [*kombu_ssl_keyfile*]
99
+#   (optional) SSL key file (valid only if SSL enabled).
100
+#   Defaults to $::os_service_default
101
+#
102
+# [*kombu_ssl_version*]
103
+#   (optional) SSL version to use (valid only if SSL enabled). Valid values are
104
+#   TLSv1 and SSLv23. SSLv2, SSLv3, TLSv1_1, and TLSv1_2 may be
105
+#   available on some distributions.
106
+#   Defaults to $::os_service_default
107
+#
108
+# [*kombu_reconnect_delay*]
109
+#   (optional) How long to wait before reconnecting in response to an AMQP
110
+#   consumer cancel notification.
111
+#   Defaults to $::os_service_default
112
+#
113
+# [*kombu_missing_consumer_retry_timeout*]
114
+#  (optional)How long to wait a missing client beforce abandoning to send it
115
+#   its replies. This value should not be longer than rpc_response_timeout.
116
+#   Defaults to $::os_service_default
117
+#
118
+# [*kombu_failover_strategy*]
119
+#   (Optional) Determines how the next RabbitMQ node is chosen in case the one
120
+#   we are currently connected to becomes unavailable. Takes effect only if
121
+#   more than one RabbitMQ node is provided in config. (string value)
122
+#   Defaults to $::os_service_default
123
+#
124
+# [*kombu_compression*]
125
+#   (optional) Possible values are: gzip, bz2. If not set compression will not
126
+#   be used. This option may notbe available in future versions. EXPERIMENTAL.
127
+#   (string value)
128
+#   Defaults to $::os_service_default
129
+#
130
+# [*amqp_durable_queues*]
131
+#   (optional) Use durable queues in AMQP.
132
+#   Defaults to $::os_service_default
133
+#
134
+# [*default_transport_url*]
135
+#   (Optional) A URL representing the messaging driver to use and its full
136
+#   configuration. If not set, we fall back to the rpc_backend option
137
+#   and driver specific configuration.
138
+#   Defaults to $::os_service_default
139
+#
140
+# [*rpc_response_timeout*]
141
+#  (Optional) Seconds to wait for a response from a call.
142
+#  Defaults to $::os_service_default
143
+#
144
+# [*control_exchange*]
145
+#   (Optional) The default exchange under which topics are scoped. May be
146
+#   overridden by an exchange name specified in the transport_url
147
+#   option.
148
+#   Defaults to $::os_service_default
149
+#
150
+# [*amqp_password*]
151
+#   (Optional) Password for message broker authentication.
152
+#   Defaults to $::os_service_default
153
+#
154
+# [*amqp_username*]
155
+#   (Optional) User name for message broker authentication.
156
+#   Defaults to $::os_service_default
157
+#
158
+# [*amqp_ssl_ca_file*]
159
+#   (Optional) CA certificate PEM file to verify server certificate.
160
+#   Defaults to $::os_service_default
161
+#
162
+# [*amqp_ssl_key_file*]
163
+#   (Optional) Private key PEM file used to sign cert_file certificate.
164
+#   Defaults to $::os_service_default
165
+#
166
+# [*amqp_container_name*]
167
+#   (Optional) Name for the AMQP container.
168
+#   Defaults to $::os_service_default
169
+#
170
+# [*amqp_sasl_mechanisms*]
171
+#   (Optional) Space separated list of acceptable SASL mechanisms.
172
+#   Defaults to $::os_service_default
173
+#
174
+# [*amqp_server_request_prefix*]
175
+#   (Optional) Address prefix used when sending to a specific server.
176
+#   Defaults to $::os_service_default
177
+#
178
+# [*amqp_ssl_key_password*]
179
+#   (Optional) Password for decrypting ssl_key_file (if encrypted).
180
+#   Defaults to $::os_service_default
181
+#
182
+# [*amqp_idle_timeout*]
183
+#   (Optional) Timeout for inactive connections (in seconds).
184
+#   Defaults to $::os_service_default
185
+#
186
+# [*amqp_ssl_cert_file*]
187
+#   (Optional) Identifying certificate PEM file to present to clients.
188
+#   Defaults to $::os_service_default
189
+#
190
+# [*amqp_broadcast_prefix*]
191
+#   (Optional) Address prefix used when broadcasting to all servers.
192
+#   Defaults to $::os_service_default
193
+#
194
+# [*amqp_trace*]
195
+#   (Optional) Debug: dump AMQP frames to stdout.
196
+#   Defaults to $::os_service_default
197
+#
198
+# [*amqp_allow_insecure_clients*]
199
+#   (Optional) Accept clients using either SSL or plain TCP.
200
+#   Defaults to $::os_service_default
201
+#
202
+# [*amqp_sasl_config_name*]
203
+#   (Optional) Name of configuration file (without .conf suffix).
204
+#   Defaults to $::os_service_default
205
+#
206
+# [*amqp_sasl_config_dir*]
207
+#   (Optional) Path to directory that contains the SASL configuration.
208
+#   Defaults to $::os_service_default
209
+#
210
+# [*amqp_group_request_prefix*]
211
+#   (Optional) Address prefix when sending to any server in group.
212
+#   Defaults to $::os_service_default
213
+#
214
+# [*rpc_cast_timeout*]
215
+#  (optional) Seconds to wait before a cast expires (TTL).
216
+#  The default value of -1 specifies an infinite linger
217
+#  period. The value of 0 specifies no linger period.
218
+#  Pending messages shall be discarded immediately
219
+#  when the socket is closed. Only supported by impl_zmq.
220
+#  Defaults to $::os_service_default.
221
+#
222
+# [*rpc_poll_timeout*]
223
+#  (optional) The default number of seconds that poll should wait.
224
+#  Poll raises timeout exception when timeout expired.
225
+#  Defaults to $::os_service_default.
226
+#
227
+# [*rpc_zmq_bind_address*]
228
+#  (optional) ZeroMQ bind address.
229
+#  Should be a wildcard (*), an ethernet interface, or IP.
230
+#  The "host" option should point or resolve to this address.
231
+#  Defaults to $::os_service_default.
232
+#
233
+# [*rpc_zmq_bind_port_retries*]
234
+#  (optional) Number of retries to find free port number
235
+#  before fail with ZMQBindError.
236
+#  Defaults to $::os_service_default.
237
+#
238
+# [*rpc_zmq_concurrency*]
239
+#  (optional) Type of concurrency used.
240
+#  Either "native" or "eventlet".
241
+#  Defaults to $::os_service_default.
242
+#
243
+# [*rpc_zmq_contexts*]
244
+#  (optional) Number of ZeroMQ contexts.
245
+#  Defaults to $::os_service_default.
246
+#
247
+# [*rpc_zmq_host*]
248
+#  (optional) Name of this node.
249
+#  Must be a valid hostname, FQDN, or IP address.
250
+#  Must match "host" option, if running Nova.
251
+#  Defaults to $::os_service_default.
252
+#
253
+# [*rpc_zmq_ipc_dir*]
254
+#  (optional) Directory for holding IPC sockets.
255
+#  Defaults to $::os_service_default.
256
+#
257
+# [*rpc_zmq_matchmaker*]
258
+#  (optional) MatchMaker driver.
259
+#  Defaults to $::os_service_default.
260
+#
261
+# [*rpc_zmq_max_port*]
262
+#  (optional) Maximal port number for random ports range.
263
+#  Defaults to $::os_service_default.
264
+#
265
+# [*rpc_zmq_min_port*]
266
+#  (optional) Minimal port number for random ports range.
267
+#  Defaults to $::os_service_default.
268
+#
269
+# [*rpc_zmq_topic_backlog*]
270
+#  (optional) Maximum number of ingress messages to locally buffer per topic.
271
+#  Defaults to $::os_service_default.
272
+#
273
+# [*use_pub_sub*]
274
+#  (optional) Use PUB/SUB pattern for fanout methods.
275
+#  PUB/SUB always uses proxy.
276
+#  Defaults to $::os_service_default.
277
+#
278
+# [*zmq_target_expire*]
279
+#  (optional) Expiration timeout in seconds of a name service
280
+#  record about existing target ( < 0 means no timeout).
281
+#  Defaults to $::os_service_default.
282
+#
283
+# [*notification_transport_url*]
284
+#  (optional) A URL representing the messaging driver to use for notifications
285
+#  and its full configuration. Transport URLs take the form:
286
+#    transport://user:pass@host1:port[,hostN:portN]/virtual_host
287
+#  Defaults to $::os_service_default
288
+#
289
+# [*notification_driver*]
290
+#  (optional) Driver or drivers to handle sending notifications.
291
+#  Value can be a string or a list.
292
+#  Defaults to $::os_service_default
293
+#
294
+# [*notification_topics*]
295
+#  (optional) AMQP topic used for OpenStack notifications
296
+#  Defaults to $::os_service_default
297
+#
298
+# [*purge_config*]
299
+#   (optional) Whether to set only the specified config options
300
+#   in the watcher config.
301
+#   Defaults to false.
302
+#
303
+# === Authors
304
+#
305
+# Daniel Pawlik  <daniel.pawlik@corp.ovh.com>
306
+#
307
+class watcher (
308
+  $purge_config                         = false,
309
+  $use_ssl                              = false,
310
+  $ceilometer_client_api_version        = '2',
311
+  $cinder_client_api_version            = '2',
312
+  $glance_client_api_version            = '2',
313
+  $neutron_client_api_version           = '2',
314
+  $nova_client_api_version              = '2',
315
+  $rpc_backend                          = 'rabbit',
316
+  $ensure_package                       = 'present',
317
+  $database_connection     = undef,
318
+  $database_idle_timeout   = undef,
319
+  $database_min_pool_size  = undef,
320
+  $database_max_pool_size  = undef,
321
+  $database_max_retries    = undef,
322
+  $database_retry_interval = undef,
323
+  $database_max_overflow   = undef,
324
+  $rabbit_os_user,
325
+  $rabbit_os_password,
326
+  $rabbit_os_host,
327
+  $rabbit_login_method                  = $::os_service_default,
328
+  $rabbit_retry_interval                = $::os_service_default,
329
+  $rabbit_retry_backoff                 = $::os_service_default,
330
+  $rabbit_interval_max                  = $::os_service_default,
331
+  $rabbit_max_retries                   = $::os_service_default,
332
+  $rabbit_use_ssl                       = $::os_service_default,
333
+  $rabbit_heartbeat_rate                = $::os_service_default,
334
+  $rabbit_ha_queues                     = $::os_service_default,
335
+  $rabbit_transient_queues_ttl          = $::os_service_default,
336
+  $rabbit_heartbeat_timeout_threshold   = $::os_service_default,
337
+  $kombu_ssl_ca_certs                   = $::os_service_default,
338
+  $kombu_ssl_certfile                   = $::os_service_default,
339
+  $kombu_ssl_keyfile                    = $::os_service_default,
340
+  $kombu_ssl_version                    = $::os_service_default,
341
+  $kombu_reconnect_delay                = $::os_service_default,
342
+  $kombu_missing_consumer_retry_timeout = $::os_service_default,
343
+  $kombu_failover_strategy              = $::os_service_default,
344
+  $kombu_compression                    = $::os_service_default,
345
+  $amqp_durable_queues                  = $::os_service_default,
346
+  $default_transport_url                = $::os_service_default,
347
+  $rpc_response_timeout                 = $::os_service_default,
348
+  $control_exchange                     = $::os_service_default,
349
+  # amqp
350
+  $amqp_username                        = $::os_service_default,
351
+  $amqp_password                        = $::os_service_default,
352
+  $amqp_ssl_ca_file                     = $::os_service_default,
353
+  $amqp_ssl_key_file                    = $::os_service_default,
354
+  $amqp_container_name                  = $::os_service_default,
355
+  $amqp_sasl_mechanisms                 = $::os_service_default,
356
+  $amqp_server_request_prefix           = $::os_service_default,
357
+  $amqp_ssl_key_password                = $::os_service_default,
358
+  $amqp_idle_timeout                    = $::os_service_default,
359
+  $amqp_ssl_cert_file                   = $::os_service_default,
360
+  $amqp_broadcast_prefix                = $::os_service_default,
361
+  $amqp_trace                           = $::os_service_default,
362
+  $amqp_allow_insecure_clients          = $::os_service_default,
363
+  $amqp_sasl_config_name                = $::os_service_default,
364
+  $amqp_sasl_config_dir                 = $::os_service_default,
365
+  $amqp_group_request_prefix            = $::os_service_default,
366
+  # zmq
367
+  $rpc_cast_timeout                     = $::os_service_default,
368
+  $rpc_poll_timeout                     = $::os_service_default,
369
+  $rpc_zmq_bind_address                 = $::os_service_default,
370
+  $rpc_zmq_bind_port_retries            = $::os_service_default,
371
+  $rpc_zmq_concurrency                  = $::os_service_default,
372
+  $rpc_zmq_contexts                     = $::os_service_default,
373
+  $rpc_zmq_host                         = $::os_service_default,
374
+  $rpc_zmq_ipc_dir                      = $::os_service_default,
375
+  $rpc_zmq_matchmaker                   = $::os_service_default,
376
+  $rpc_zmq_max_port                     = $::os_service_default,
377
+  $rpc_zmq_min_port                     = $::os_service_default,
378
+  $rpc_zmq_topic_backlog                = $::os_service_default,
379
+  $use_pub_sub                          = $::os_service_default,
380
+  $zmq_target_expire                    = $::os_service_default,
381
+  # messaging
382
+  $notification_transport_url           = $::os_service_default,
383
+  $notification_driver                  = $::os_service_default,
384
+  $notification_topics                  = $::os_service_default,
385
+  $auth_uri                             = $::os_service_default,
386
+  $auth_url                             = $::os_service_default,
387
+  $identity_uri                         = $::os_service_default,
388
+  $admin_user                           = 'watcher',
389
+  $admin_password                       = $::os_service_default,
390
+  $username                             = $::os_service_default,
391
+  $password                             = $::os_service_default,
392
+  $admin_tenant_name                    = 'services',
393
+  $user_domain_name                     = 'Default',
394
+  $project_domain_name                  = 'Default',
395
+  $region_name                          = $::os_service_default,
396
+  $nova_scheduler_default_filters = $::os_service_default,
397
+  $nova_ram_allocation_ratio = $::os_service_default,
398
+  $nova_scheduler_driver = $::os_service_default,
399
+  $nova_disk_allocation_ratio = $::os_service_default,
400
+  $nova_cpu_allocation_ratio = $::os_service_default,
401
+  $nova_max_instances_per_host = $::os_service_default,
402
+  $nova_scheduler_available_filters = $::os_service_default,
403
+) {
404
+
405
+  include ::openstacklib::openstackclient
406
+
407
+  include ::watcher::deps
408
+  include ::watcher::params
409
+  include ::watcher::policy
410
+  include ::watcher::db
411
+  include ::watcher::logging
412
+
413
+  package { 'watcher':
414
+    ensure => $ensure_package,
415
+    name   => $::watcher::params::common_package_name,
416
+    tag    => ['openstack', 'watcher-package'],
417
+  }
418
+
419
+  resources { 'watcher_config':
420
+    purge  => $purge_config,
421
+  }
422
+
423
+  if $rpc_backend == 'rabbit' {
424
+
425
+    watcher_config {
426
+      'oslo_messaging_rabbit/rabbit_userid' :    value => $rabbit_os_user;
427
+      'oslo_messaging_rabbit/rabbit_password' :  value => $rabbit_os_password;
428
+      'oslo_messaging_rabbit/rabbit_hosts' :     value => $rabbit_os_host;
429
+      'oslo_messaging_rabbit/rabbit_ha_queues':  value => $rabbit_ha_queues;
430
+    }
431
+  } else {
432
+    watcher_config { 'DEFAULT/rpc_backend': value => $rpc_backend }
433
+  }
434
+
435
+
436
+  watcher_config {
437
+    'DEFAULT/scheduler_default_filters': value => $nova_scheduler_default_filters;
438
+    'DEFAULT/ram_allocation_ratio': value => $nova_ram_allocation_ratio;
439
+    'DEFAULT/scheduler_driver': value => $nova_scheduler_driver;
440
+    'DEFAULT/disk_allocation_ratio': value => $nova_disk_allocation_ratio;
441
+    'DEFAULT/cpu_allocation_ratio': value => $nova_cpu_allocation_ratio;
442
+    'DEFAULT/max_instances_per_host': value => $nova_max_instances_per_host;
443
+    'DEFAULT/scheduler_available_filters': value => $nova_scheduler_available_filters;
444
+    'keystone_authtoken/region_name':          value => $region_name;
445
+    'keystone_authtoken/auth_uri' :            value => $auth_uri;
446
+    'keystone_authtoken/auth_url' :            value => $auth_url;
447
+    'keystone_authtoken/identity_uri' :        value => $identity_uri;
448
+    'keystone_authtoken/admin_user' :          value => $admin_user;
449
+    'keystone_authtoken/admin_password' :      value => $admin_password;
450
+    'keystone_authtoken/username' :            value => $username;
451
+    'keystone_authtoken/project_name' :        value => $admin_tenant_name;
452
+    'keystone_authtoken/admin_tenant_name' :   value => $admin_tenant_name;
453
+    'keystone_authtoken/password' :            value => $password;
454
+    'keystone_authtoken/user_domain_name' :    value => $user_domain_name;
455
+    'keystone_authtoken/project_domain_name' : value => $project_domain_name;
456
+  }
457
+    
458
+
459
+  watcher_config {
460
+    'oslo_messaging_default/transport_url': value        => $default_transport_url;
461
+    'oslo_messaging_default/rpc_response_timeout': value => $rpc_response_timeout;
462
+    'oslo_messaging_default/control_exchange': value     => $control_exchange;
463
+  }
464
+
465
+  watcher_config {
466
+    'oslo_messaging_notification/transport_url': value => $notification_transport_url;
467
+    'oslo_messaging_notification/driver':        value => $notification_driver;
468
+    'oslo_messaging_notification/topics':        value => $notification_topics;
469
+  }
470
+}
471
+

+ 101
- 0
deployment_scripts/modules/watcher/manifests/keystone/auth.pp View File

@@ -0,0 +1,101 @@
1
+# == Class: watcher::keystone::auth
2
+#
3
+# Configures watcher user, service and endpoint in Keystone.
4
+#
5
+# === Parameters
6
+#
7
+# [*password*]
8
+#   (required) Password for watcher user.
9
+#
10
+# [*auth_name*]
11
+#   Username for watcher service. Defaults to 'watcher'.
12
+#
13
+# [*email*]
14
+#   Email for watcher user. Defaults to 'watcher@localhost'.
15
+#
16
+# [*tenant*]
17
+#   Tenant for watcher user. Defaults to 'services'.
18
+#
19
+# [*configure_endpoint*]
20
+#   Should watcher endpoint be configured? Defaults to 'true'.
21
+#
22
+# [*configure_user*]
23
+#   (Optional) Should the service user be configured?
24
+#   Defaults to 'true'.
25
+#
26
+# [*configure_user_role*]
27
+#   (Optional) Should the admin role be configured for the service user?
28
+#   Defaults to 'true'.
29
+#
30
+# [*service_type*]
31
+#   Type of service. Defaults to 'key-manager'.
32
+#
33
+# [*region*]
34
+#   Region for endpoint. Defaults to 'RegionOne'.
35
+#
36
+# [*service_name*]
37
+#   (optional) Name of the service.
38
+#   Defaults to the value of auth_name.
39
+#
40
+# [*service_description*]
41
+#   (optional) Description of the service.
42
+#   Default to 'watcher API Service'
43
+#
44
+# [*public_url*]
45
+#   (optional) The endpoint's public url. (Defaults to 'http://127.0.0.1:9322')
46
+#   This url should *not* contain any trailing '/'.
47
+#
48
+# [*admin_url*]
49
+#   (optional) The endpoint's admin url. (Defaults to 'http://127.0.0.1:9322')
50
+#   This url should *not* contain any trailing '/'.
51
+#
52
+# [*internal_url*]
53
+#   (optional) The endpoint's internal url. (Defaults to 'http://127.0.0.1:9322')
54
+#
55
+class watcher::keystone::auth (
56
+  $password,
57
+  $auth_name           = 'watcher',
58
+  $email               = 'watcher@localhost',
59
+  $tenant              = 'services',
60
+  $configure_endpoint  = true,
61
+  $configure_user      = true,
62
+  $configure_user_role = true,
63
+  $service_name        = undef,
64
+  $service_description = 'Infrastructure Optimization service',
65
+  $service_type        = 'infra-optim',
66
+  $region              = 'RegionOne',
67
+  $public_url          = 'http://127.0.0.1:9322',
68
+  $admin_url           = 'http://127.0.0.1:9322',
69
+  $internal_url        = 'http://127.0.0.1:9322',
70
+) {
71
+
72
+  include ::watcher::deps
73
+
74
+  $real_service_name = pick($service_name, $auth_name)
75
+
76
+  if $configure_user_role {
77
+    Keystone_user_role["${auth_name}@${tenant}"] ~> Anchor['watcher::service::end']
78
+  }
79
+
80
+  if $configure_endpoint {
81
+    Keystone_endpoint["${region}/${real_service_name}::${service_type}"]  ~> Anchor['watcher::service::end']
82
+  }
83
+
84
+  keystone::resource::service_identity { 'watcher':
85
+    configure_user      => $configure_user,
86
+    configure_user_role => $configure_user_role,
87
+    configure_endpoint  => $configure_endpoint,
88
+    service_name        => $real_service_name,
89
+    service_type        => $service_type,
90
+    service_description => $service_description,
91
+    region              => $region,
92
+    auth_name           => $auth_name,
93
+    password            => $password,
94
+    email               => $email,
95
+    tenant              => $tenant,
96
+    public_url          => $public_url,
97
+    internal_url        => $internal_url,
98
+    admin_url           => $admin_url,
99
+  }
100
+
101
+}

+ 274
- 0
deployment_scripts/modules/watcher/manifests/keystone/authtoken.pp View File

@@ -0,0 +1,274 @@
1
+# == Class: watcher::keystone::authtoken
2
+#
3
+# Configure the keystone_authtoken section in the configuration file
4
+#
5
+# === Parameters:
6
+#
7
+# [*password*]
8
+#   (Optional) Password to create for the service user
9
+#   Defaults to $::os_service_default
10
+#
11
+# [*username*]
12
+#   (Optional) The name of the service user
13
+#   Defaults to 'watcher'
14
+#
15
+# [*auth_url*]
16
+#   (Optional) The URL to use for authentication.
17
+#   Defaults to 'http://localhost:35357'
18
+#
19
+# [*project_name*]
20
+#   (Optional) Service project name
21
+#   Defaults to 'services'
22
+#
23
+# [*user_domain_name*]
24
+#   (Optional) Name of domain for $username
25
+#   Defaults to $::os_service_default
26
+#
27
+# [*project_domain_name*]
28
+#   (Optional) Name of domain for $project_name
29
+#   Defaults to $::os_service_default
30
+#
31
+# [*insecure*]
32
+#   (Optional) If true, explicitly allow TLS without checking server cert
33
+#   against any certificate authorities.  WARNING: not recommended.  Use with
34
+#   caution.
35
+#   Defaults to $:os_service_default
36
+#
37
+# [*auth_section*]
38
+#   (Optional) Config Section from which to load plugin specific options
39
+#   Defaults to $::os_service_default.
40
+#
41
+# [*auth_type*]
42
+#   (Optional) Authentication type to load
43
+#   Defaults to 'password'
44
+#
45
+# [*auth_uri*]
46
+#   (Optional) Complete public Identity API endpoint.
47
+#   Defaults to 'http://localhost:5000'
48
+#
49
+# [*auth_version*]
50
+#   (Optional) API version of the admin Identity API endpoint.
51
+#   Defaults to $::os_service_default.
52
+#
53
+# [*cache*]
54
+#   (Optional) Env key for the swift cache.
55
+#   Defaults to $::os_service_default.
56
+#
57
+# [*cafile*]
58
+#   (Optional) A PEM encoded Certificate Authority to use when verifying HTTPs
59
+#   connections.
60
+#   Defaults to $::os_service_default.
61
+#
62
+# [*certfile*]
63
+#   (Optional) Required if identity server requires client certificate
64
+#   Defaults to $::os_service_default.
65
+#
66
+# [*check_revocations_for_cached*]
67
+#   (Optional) If true, the revocation list will be checked for cached tokens.
68
+#   This requires that PKI tokens are configured on the identity server.
69
+#   boolean value.
70
+#   Defaults to $::os_service_default.
71
+#
72
+# [*delay_auth_decision*]
73
+#   (Optional) Do not handle authorization requests within the middleware, but
74
+#   delegate the authorization decision to downstream WSGI components. Boolean
75
+#   value
76
+#   Defaults to $::os_service_default.
77
+#
78
+# [*enforce_token_bind*]
79
+#   (Optional) Used to control the use and type of token binding. Can be set
80
+#   to: "disabled" to not check token binding. "permissive" (default) to
81
+#   validate binding information if the bind type is of a form known to the
82
+#   server and ignore it if not. "strict" like "permissive" but if the bind
83
+#   type is unknown the token will be rejected. "required" any form of token
84
+#   binding is needed to be allowed. Finally the name of a binding method that
85
+#   must be present in tokens. String value.
86
+#   Defaults to $::os_service_default.
87
+#
88
+# [*hash_algorithms*]
89
+#   (Optional) Hash algorithms to use for hashing PKI tokens. This may be a
90
+#   single algorithm or multiple. The algorithms are those supported by Python
91
+#   standard hashlib.new(). The hashes will be tried in the order given, so put
92
+#   the preferred one first for performance. The result of the first hash will
93
+#   be stored in the cache. This will typically be set to multiple values only
94
+#   while migrating from a less secure algorithm to a more secure one. Once all
95
+#   the old tokens are expired this option should be set to a single value for
96
+#   better performance. List value.
97
+#   Defaults to $::os_service_default.
98
+#
99
+# [*http_connect_timeout*]
100
+#   (Optional) Request timeout value for communicating with Identity API
101
+#   server.
102
+#   Defaults to $::os_service_default.
103
+#
104
+# [*http_request_max_retries*]
105
+#   (Optional) How many times are we trying to reconnect when communicating
106
+#   with Identity API Server. Integer value
107
+#   Defaults to $::os_service_default.
108
+#
109
+# [*include_service_catalog*]
110
+#   (Optional) Indicate whether to set the X-Service-Catalog header. If False,
111
+#   middleware will not ask for service catalog on token validation and will
112
+#   not set the X-Service-Catalog header. Boolean value.
113
+#   Defaults to $::os_service_default.
114
+#
115
+# [*keyfile*]
116
+#   (Optional) Required if identity server requires client certificate
117
+#   Defaults to $::os_service_default.
118
+#
119
+# [*memcache_pool_conn_get_timeout*]
120
+#   (Optional) Number of seconds that an operation will wait to get a memcached
121
+#   client connection from the pool. Integer value
122
+#   Defaults to $::os_service_default.
123
+#
124
+# [*memcache_pool_dead_retry*]
125
+#   (Optional) Number of seconds memcached server is considered dead before it
126
+#   is tried again. Integer value
127
+#   Defaults to $::os_service_default.
128
+#
129
+# [*memcache_pool_maxsize*]
130
+#   (Optional) Maximum total number of open connections to every memcached
131
+#   server. Integer value
132
+#   Defaults to $::os_service_default.
133
+#
134
+# [*memcache_pool_socket_timeout*]
135
+#   (Optional) Number of seconds a connection to memcached is held unused in
136
+#   the
137
+#   pool before it is closed. Integer value
138
+#   Defaults to $::os_service_default.
139
+#
140
+# [*memcache_pool_unused_timeout*]
141
+#   (Optional) Number of seconds a connection to memcached is held unused in
142
+#   the
143
+#   pool before it is closed. Integer value
144
+#   Defaults to $::os_service_default.
145
+#
146
+# [*memcache_secret_key*]
147
+#   (Optional, mandatory if memcache_security_strategy is defined) This string
148
+#   is used for key derivation.
149
+#   Defaults to $::os_service_default.
150
+#
151
+# [*memcache_security_strategy*]
152
+#   (Optional) If defined, indicate whether token data should be authenticated
153
+#   or authenticated and encrypted. If MAC, token data is authenticated (with
154
+#   HMAC) in the cache. If ENCRYPT, token data is encrypted and authenticated
155
+#   in the cache. If the value is not one of these options or empty,
156
+#   auth_token will raise an exception on initialization.
157
+#   Defaults to $::os_service_default.
158
+#
159
+# [*memcache_use_advanced_pool*]
160
+#   (Optional)  Use the advanced (eventlet safe) memcached client pool. The
161
+#   advanced pool will only work under python 2.x Boolean value
162
+#   Defaults to $::os_service_default.
163
+#
164
+# [*memcached_servers*]
165
+#   (Optional) Optionally specify a list of memcached server(s) to use for
166
+#   caching. If left undefined, tokens will instead be cached in-process.
167
+#   Defaults to $::os_service_default.
168
+#
169
+# [*manage_memcache_package*]
170
+#  (Optional) Whether to install the python-memcache package.
171
+#  Defaults to false.
172
+#
173
+# [*region_name*]
174
+#   (Optional) The region in which the identity server can be found.
175
+#   Defaults to $::os_service_default.
176
+#
177
+# [*revocation_cache_time*]
178
+#   (Optional) Determines the frequency at which the list of revoked tokens is
179
+#   retrieved from the Identity service (in seconds). A high number of
180
+#   revocation events combined with a low cache duration may significantly
181
+#   reduce performance. Only valid for PKI tokens. Integer value
182
+#   Defaults to $::os_service_default.
183
+#
184
+# [*token_cache_time*]
185
+#   (Optional) In order to prevent excessive effort spent validating tokens,
186
+#   the middleware caches previously-seen tokens for a configurable duration
187
+#   (in seconds). Set to -1 to disable caching completely. Integer value
188
+#   Defaults to $::os_service_default.
189
+#
190
+class watcher::keystone::authtoken (
191
+  $password                       = $::os_service_default,
192
+  $username                       = 'watcher',
193
+  $auth_url                       = 'http://localhost:35357',
194
+  $project_name                   = 'services',
195
+  $user_domain_name               = $::os_service_default,
196
+  $project_domain_name            = $::os_service_default,
197
+  $insecure                       = $::os_service_default,
198
+  $auth_section                   = $::os_service_default,
199
+  $auth_type                      = 'password',
200
+  $auth_uri                       = 'http://localhost:5000',
201
+  $auth_version                   = $::os_service_default,
202
+  $cache                          = $::os_service_default,
203
+  $cafile                         = $::os_service_default,
204
+  $certfile                       = $::os_service_default,
205
+  $check_revocations_for_cached   = $::os_service_default,
206
+  $delay_auth_decision            = $::os_service_default,
207
+  $enforce_token_bind             = $::os_service_default,
208
+  $hash_algorithms                = $::os_service_default,
209
+  $http_connect_timeout           = $::os_service_default,
210
+  $http_request_max_retries       = $::os_service_default,
211
+  $include_service_catalog        = $::os_service_default,
212
+  $keyfile                        = $::os_service_default,
213
+  $memcache_pool_conn_get_timeout = $::os_service_default,
214
+  $memcache_pool_dead_retry       = $::os_service_default,
215
+  $memcache_pool_maxsize          = $::os_service_default,
216
+  $memcache_pool_socket_timeout   = $::os_service_default,
217
+  $memcache_secret_key            = $::os_service_default,
218
+  $memcache_security_strategy     = $::os_service_default,
219
+  $memcache_use_advanced_pool     = $::os_service_default,
220
+  $memcache_pool_unused_timeout   = $::os_service_default,
221
+  $memcached_servers              = $::os_service_default,
222
+  $manage_memcache_package        = false,
223
+  $region_name                    = $::os_service_default,
224
+  $revocation_cache_time          = $::os_service_default,
225
+  $token_cache_time               = $::os_service_default,
226
+) {
227
+
228
+  include ::watcher::deps
229
+
230
+  if is_service_default($password) and ! $::watcher::api::watcher_client_password {
231
+    fail('Please set password for watcher service user')
232
+  }
233
+
234
+  validate_string($password)
235
+
236
+  keystone::resource::authtoken { 'watcher_config':
237
+    password                       => $password,
238
+    username                       => $username,
239
+    project_name                   => $project_name,
240
+    auth_url                       => $auth_url,
241
+    auth_uri                       => $auth_uri,
242
+    auth_version                   => $auth_version,
243
+    auth_type                      => $auth_type,
244
+    auth_section                   => $auth_section,
245
+    user_domain_name               => $user_domain_name,
246
+    project_domain_name            => $project_domain_name,
247
+    insecure                       => $insecure,
248
+    cache                          => $cache,
249
+    cafile                         => $cafile,
250
+    certfile                       => $certfile,
251
+    check_revocations_for_cached   => $check_revocations_for_cached,
252
+    delay_auth_decision            => $delay_auth_decision,
253
+    enforce_token_bind             => $enforce_token_bind,
254
+    hash_algorithms                => $hash_algorithms,
255
+    http_connect_timeout           => $http_connect_timeout,
256
+    http_request_max_retries       => $http_request_max_retries,
257
+    include_service_catalog        => $include_service_catalog,
258
+    keyfile                        => $keyfile,
259
+    memcache_pool_conn_get_timeout => $memcache_pool_conn_get_timeout,
260
+    memcache_pool_dead_retry       => $memcache_pool_dead_retry,
261
+    memcache_pool_maxsize          => $memcache_pool_maxsize,
262
+    memcache_pool_socket_timeout   => $memcache_pool_socket_timeout,
263
+    memcache_secret_key            => $memcache_secret_key,
264
+    memcache_security_strategy     => $memcache_security_strategy,
265
+    memcache_use_advanced_pool     => $memcache_use_advanced_pool,
266
+    memcache_pool_unused_timeout   => $memcache_pool_unused_timeout,
267
+    memcached_servers              => $memcached_servers,
268
+    manage_memcache_package        => $manage_memcache_package,
269
+    region_name                    => $region_name,
270
+    revocation_cache_time          => $revocation_cache_time,
271
+    token_cache_time               => $token_cache_time,
272
+  }
273
+
274
+}

+ 118
- 0
deployment_scripts/modules/watcher/manifests/logging.pp View File

@@ -0,0 +1,118 @@
1
+# Class watcher::logging
2
+#
3
+#  watcher logging configuration
4
+#
5
+# == parameters
6
+#
7
+#  [*debug*]
8
+#    (Optional) Should the daemons log debug messages
9
+#    Defaults to $::os_service_default
10
+#
11
+#  [*use_syslog*]
12
+#    (Optional) Use syslog for logging.
13
+#    Defaults to $::os_service_default
14
+#
15
+#  [*use_stderr*]
16
+#    (optional) Use stderr for logging
17
+#    Defaults to $::os_service_default
18
+#
19
+#  [*syslog_log_facility*]
20
+#    (Optional) Syslog facility to receive log lines.
21
+#    Defaults to $::os_service_default
22
+#
23
+#  [*log_dir*]
24
+#    (optional) Directory where logs should be stored.
25
+#    If set to $::os_service_default, it will not log to any directory.
26
+#    Defaults to '/var/log/watcher'.
27
+#
28
+#  [*log_file*]
29
+#    (optional) File where logs should be stored.
30
+#    Defaults to '/var/log/watcher/watcher.log'
31
+#
32
+#  [*logging_context_format_string*]
33
+#    (optional) Format string to use for log messages with context.
34
+#    Defaults to $::os_service_default
35
+#    Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
36
+#              [%(request_id)s %(user_identity)s] %(instance)s%(message)s'
37
+#
38
+#  [*logging_default_format_string*]
39
+#    (optional) Format string to use for log messages without context.
40
+#    Defaults to $::os_service_default
41
+#    Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
42
+#              [-] %(instance)s%(message)s'
43
+#
44
+#  [*logging_debug_format_suffix*]
45
+#    (optional) Formatted data to append to log format when level is DEBUG.
46
+#    Defaults to $::os_service_default
47
+#    Example: '%(funcName)s %(pathname)s:%(lineno)d'
48
+#
49
+#  [*logging_exception_prefix*]
50
+#    (optional) Prefix each line of exception output with this format.
51
+#    Defaults to $::os_service_default
52
+#    Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
53
+#
54
+#  [*log_config_append*]
55
+#    (optional) The name of an additional logging configuration file.
56
+#    Defaults to $::os_service_default
57
+#    See https://docs.python.org/2/howto/logging.html
58
+#
59
+#  [*default_log_levels*]
60
+#    (optional) Hash of logger (keys) and level (values) pairs.
61
+#    Defaults to $::os_service_default
62
+#    Example:
63
+#      { 'amqp'  => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
64
+#           'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
65
+#           'oslo.messaging' => 'INFO', 'iso8601' => 'WARN',
66
+#           'requests.packages.urllib3.connectionpool' => 'WARN',
67
+#           'urllib3.connectionpool' => 'WARN',
68
+#           'websocket' => 'WARN', 'watchermiddleware' => 'WARN',
69
+#           'routes.middleware' => 'WARN', stevedore => 'WARN' }
70
+#
71
+#  [*publish_errors*]
72
+#    (optional) Publish error events (boolean value).
73
+#    Defaults to $::os_service_default
74
+#
75
+#  [*fatal_deprecations*]
76
+#    (optional) Make deprecations fatal (boolean value)
77
+#    Defaults to $::os_service_default
78
+#
79
+#  [*instance_format*]
80
+#    (optional) If an instance is passed with the log message, format it
81
+#               like this (string value).
82
+#    Defaults to undef.
83
+#    Example: '[instance: %(uuid)s] '
84
+#
85
+#  [*instance_uuid_format*]
86
+#    (optional) If an instance UUID is passed with the log message, format
87
+#               it like this (string value).
88
+#    Defaults to $::os_service_default
89
+#    Example: instance_uuid_format='[instance: %(uuid)s] '
90
+#
91
+#  [*log_date_format*]
92
+#    (optional) Format string for %%(asctime)s in log records.
93
+#    Defaults to $::os_service_default
94
+#    Example: 'Y-%m-%d %H:%M:%S'
95
+
96
+class watcher::logging(
97
+  $use_syslog                    = $::os_service_default,
98
+  $use_stderr                    = $::os_service_default,
99
+  $syslog_log_facility           = $::os_service_default,
100
+  $log_dir                       = '/var/log/watcher',
101
+  $log_file                      = '/var/log/watcher/watcher.log',
102
+  $debug                         = $::os_service_default,
103
+  $logging_context_format_string = $::os_service_default,
104
+  $logging_default_format_string = $::os_service_default,
105
+  $logging_debug_format_suffix   = $::os_service_default,
106
+  $logging_exception_prefix      = $::os_service_default,
107
+  $log_config_append             = $::os_service_default,
108
+  $default_log_levels            = $::os_service_default,
109
+  $publish_errors                = $::os_service_default,
110
+  $fatal_deprecations            = $::os_service_default,
111
+  $instance_format               = $::os_service_default,
112
+  $instance_uuid_format          = $::os_service_default,
113
+  $log_date_format               = $::os_service_default,
114
+) {
115
+
116
+  include ::watcher::deps
117
+
118
+}

+ 29
- 0
deployment_scripts/modules/watcher/manifests/params.pp View File

@@ -0,0 +1,29 @@
1
+# Parameters for puppet-watcher
2
+#
3
+class watcher::params {
4
+
5
+  case $::osfamily {
6
+    'RedHat': {
7
+      $api_service_name             = 'openstack-watcher-api'
8
+      $api_package_name             = 'openstack-watcher-api'
9
+      $common_package_name          = 'openstack-watcher-common'
10
+      $applier_package_name         = 'openstack-watcher-applier'
11
+      $applier_service_name         = 'openstack-watcher-applier'
12
+      $decision_engine_package_name = 'openstack-watcher-decision-engine'
13
+      $decision_engine_service_name = 'openstack-watcher-decision-engine'
14
+    }
15
+    'Debian': {
16
+      $api_service_name             = 'watcher-api'
17
+      $api_package_name             = 'watcher-api'
18
+      $common_package_name          = 'watcher-common'
19
+      $applier_package_name         = 'watcher-applier'
20
+      $applier_service_name         = 'watcher-applier'
21
+      $decision_engine_package_name = 'watcher-decision-engine'
22
+      $decision_engine_service_name = 'watcher-decision-engine'
23
+    }
24
+    default: {
25
+      fail("Unsupported osfamily: ${::osfamily} operatingsystem")
26
+    }
27
+
28
+  } # Case $::osfamily
29
+}

+ 42
- 0
deployment_scripts/modules/watcher/manifests/policy.pp View File

@@ -0,0 +1,42 @@
1
+# == Class: watcher::policy
2
+#
3
+# Configure the watcher policies
4
+#
5
+# === Parameters
6
+#
7
+# [*policies*]
8
+#   (optional) Set of policies to configure for watcher
9
+#   Example :
10
+#     {
11
+#       'watcher-context_is_admin' => {
12
+#         'key' => 'context_is_admin',
13
+#         'value' => 'true'
14
+#       },
15
+#       'watcher-default' => {
16
+#         'key' => 'default',
17
+#         'value' => 'rule:admin_or_owner'
18
+#       }
19
+#     }
20
+#   Defaults to empty hash.
21
+#
22
+# [*policy_path*]
23
+#   (optional) Path to the nova policy.json file
24
+#   Defaults to /etc/watcher/policy.json
25
+#
26
+class watcher::policy (
27
+  $policies    = {},
28
+  $policy_path = '/etc/watcher/policy.json',
29
+) {
30
+
31
+  include ::watcher::deps
32
+
33
+  validate_hash($policies)
34
+
35
+  Openstacklib::Policy::Base {
36
+    file_path => $policy_path,
37
+  }
38
+
39
+  create_resources('openstacklib::policy::base', $policies)
40
+
41
+
42
+}

+ 67
- 0
deployment_scripts/modules/watcher/metadata.json View File

@@ -0,0 +1,67 @@
1
+{
2
+  "name": "openstack-watcher",
3
+  "version": "10.3.0",
4
+  "author": "OpenStack Contributors",
5
+  "summary": "Puppet module for OpenStack Watcher",
6
+  "license": "Apache-2.0",
7
+  "source": "git://github.com/openstack/puppet-watcher.git",
8
+  "project_page": "https://launchpad.net/puppet-watcher",
9
+  "issues_url": "https://bugs.launchpad.net/puppet-watcher",
10
+  "description": "Installs and configures OpenStack Watcher.",
11
+  "requirements": [
12
+    {
13
+      "name": "pe",
14
+      "version_requirement": "4.x"
15
+    },
16
+    {
17
+      "name": "puppet",
18
+      "version_requirement": "4.x"
19
+    }
20
+  ],
21
+  "operatingsystem_support": [
22
+    {
23
+      "operatingsystem": "Debian",
24
+      "operatingsystemrelease": [
25
+        "8"
26
+      ]
27
+    },
28
+    {
29
+      "operatingsystem": "Fedora",
30
+      "operatingsystemrelease": [
31
+        "21",
32
+        "22"
33
+      ]
34
+    },
35
+    {
36
+      "operatingsystem": "RedHat",
37
+      "operatingsystemrelease": [
38
+        "7"
39
+      ]
40
+    },
41
+    {
42
+      "operatingsystem": "Ubuntu",
43
+      "operatingsystemrelease": [
44
+        "14.04",
45
+        "16.04"
46
+      ]
47
+    }
48
+  ],
49
+  "dependencies": [
50
+    {
51
+      "name": "puppetlabs/inifile",
52
+      "version_requirement": ">=1.0.0 <2.0.0"
53
+    },
54
+    {
55
+      "name": "puppetlabs/stdlib",
56
+      "version_requirement": ">= 4.2.0 <5.0.0"
57
+    },
58
+    {
59
+      "name": "openstack/openstacklib",
60
+      "version_requirement": ">=10.3.0 <11.0.0"
61
+    },
62
+    {
63
+      "name": "openstack/oslo",
64
+      "version_requirement": ">=10.3.0 <11.0.0"
65
+    }
66
+  ]
67
+}

+ 0
- 0
deployment_scripts/modules/watcher/releasenotes/source/_static/.placeholder View File


+ 262
- 0
deployment_scripts/modules/watcher/releasenotes/source/conf.py View File

@@ -0,0 +1,262 @@
1
+# -*- coding: utf-8 -*-
2
+# Licensed under the Apache License, Version 2.0 (the "License");
3
+# you may not use this file except in compliance with the License.
4
+# You may obtain a copy of the License at
5
+#
6
+#    http://www.apache.org/licenses/LICENSE-2.0
7
+#
8
+# Unless required by applicable law or agreed to in writing, software
9
+# distributed under the License is distributed on an "AS IS" BASIS,
10
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11
+# implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+#
15
+
16
+# If extensions (or modules to document with autodoc) are in another directory,
17
+# add these directories to sys.path here. If the directory is relative to the
18
+# documentation root, use os.path.abspath to make it absolute, like shown here.
19
+#sys.path.insert(0, os.path.abspath('.'))
20
+
21
+# -- General configuration ------------------------------------------------
22
+
23
+# If your documentation needs a minimal Sphinx version, state it here.
24
+#needs_sphinx = '1.0'