File: server.pp

package info (click to toggle)
puppet-module-neutron 25.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,708 kB
  • sloc: ruby: 12,680; python: 38; sh: 15; makefile: 10
file content (521 lines) | stat: -rw-r--r-- 20,561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# == Class: neutron::server
#
# Setup and configure the neutron API endpoint
#
# === Parameters
#
# [*package_ensure*]
#   (Optional) The state of the package
#   Defaults to present
#
# [*enabled*]
#   (Optional) The state of the service
#   Defaults to true
#
# [*manage_service*]
#   (Optional) Whether to start/stop the service
#   Defaults to true
#
# [*service_name*]
#   (Optional) Name of the service that will be providing the
#   server functionality of neutron-api.
#   If the value is 'httpd', this means neutron API will be a web
#   service, and you must use another class to configure that
#   web service. For example, use class { 'neutron::wsgi::apache'...}
#   to make neutron-api be a web app using apache mod_wsgi.
#   If set to false, then neutron-server isn't in use, and we will
#   be using neutron-api and neutron-rpc-server instead.
#   Defaults to $::neutron::params::server_service
#
# [*server_package*]
#   (Optional) Name of the package holding neutron-server.
#   If service_name is set to false, then this also must be
#   set to false. With false, no package will be installed
#   before running the neutron-server service.
#   Defaults to $::neutron::params::server_package
#
# [*api_package_name*]
#   (Optional) Name of the package holding neutron-api.
#   If this parameter is set to false,
#   Default to $::neutron::params::api_package_name
#
# [*api_service_name*]
#   (Optional) Name of the service for neutron-api.
#   If service_name is set to false, this parameter must
#   be set with a value, so that an API server will run.
#   Defaults to $::neutron::params::api_service_name
#
# [*rpc_package_name*]
#   (Optional) Name of the package for neutron-rpc-server.
#   Default to $::neutron::params::rpc_package_name
#
# [*rpc_service_name*]
#   (Optional) Name of the service for the RPC listener.
#   If service_name is set to false, this parameter must
#   be set with a value, so that an RPC server will run.
#   Defaults to $::neutron::params::rpc_service_name
#
# [*periodic_workers_package_name*]
#   (Optional) Name of the package for neutron-periodic-workers.
#   Defaults to $::neutron::params::peiodic_workers_package_name
#
# [*periodic_workers_service_name*]
#   (Optional) Name of the service for the periodic workers.
#   If service_name is set to false, this parameter must
#   be set with a value, so that an RPC server will run.
#   Defaults to $::neutron::params::peiodic_workers_service_name
#
# [*sync_db*]
#   (Optional) Run neutron-db-manage on api nodes after installing the package.
#   Defaults to false
#
# [*api_workers*]
#   (Optional) Number of separate worker processes to spawn.  Greater than 0
#   launches that number of child processes as workers.  The parent process
#   manages them.
#   Defaults to: $facts['os_workers']
#
# [*rpc_workers*]
#   (Optional) Number of separate worker processes to spawn.  Greater than 0
#   launches that number of child processes as workers.  The parent process
#   manages them.
#   Defaults to: $facts['os_workers']
#
# [*rpc_state_report_workers*]
#   (Optional) Number of RPC worker process dedicated to state reports queue.
#   Defaults to: $facts['os_service_default'].
#
# [*rpc_response_max_timeout*]
#   (Optional) Maximum seconds to wait for a response from an RPC call
#   Defaults to: $facts['os_service_default']
#
# [*agent_down_time*]
#   (Optional) Seconds to regard the agent as down; should be at least twice
#   report_interval, to be sure the agent is down for good.
#   agent_down_time is a config for neutron-server, set by class neutron::server
#   report_interval is a config for neutron agents, set by class neutron
#   Defaults to: $facts['os_service_default']
#
# [*enable_new_agents*]
#   (Optional) Agent starts with admin_state_up=False when enable_new_agents=False. In the
#   case, user's resources will not be scheduled automatically to the agent until
#   admin changes admin_state_up to True.
#   Defaults to: $facts['os_service_default']
#
# [*network_scheduler_driver*]
#   (Optional) The scheduler used when scheduling networks.
#   Defaults to $facts['os_service_default']
#
# [*router_scheduler_driver*]
#   (Optional) Driver to use for scheduling router to a default L3 agent.
#   Defaults to $facts['os_service_default']
#
# [*router_distributed*]
#   (Optional) Setting the "router_distributed" flag to "True" will default to the creation
#   of distributed tenant routers.
#   Also can be the type of the router on the create request (admin-only attribute).
#   Defaults to $facts['os_service_default']
#
# [*enable_dvr*]
#   (Optional) Setting the "enable_dvr" flag to "False" will disable "dvr" API extension exposure.
#   Defaults to $facts['os_service_default']
#
# [*dhcp_load_type*]
#   (Optional) The resource type whose load is being reported by the agent.
#   The expected values are either 'networks', 'subnets', 'ports'.
#   Defaults to $facts['os_service_default']
#
#   Example:
#
#     class { 'neutron':
#       dhcp_load_type => 'networks'
#     }
#
# [*default_availability_zones*]
#   (Optional) A list of availability zones that are picked when availability zone is not specified
#   The expected input is an array when specified.
#   Defaults to $facts['os_service_default']
#
#   Example:
#
#     class { 'neutron':
#       default_availability_zones => ['zone1', 'zone2']
#     }
#
# [*allow_automatic_l3agent_failover*]
#   (Optional) Allow automatic rescheduling of routers from dead L3 agents with
#   admin_state_up set to True to alive agents.
#   Defaults to $facts['os_service_default']
#
# [*allow_automatic_dhcp_failover*]
#   (Optional) Allow automatic rescheduling of dhcp from dead dhcp agents with
#   admin_state_up set to True to alive agents.
#   Defaults to $facts['os_service_default']
#
# [*l3_ha*]
#   (Optional) Enable high availability for virtual routers.
#   Defaults to false
#
# [*max_l3_agents_per_router*]
#   (Optional) Maximum number of l3 agents which a HA router will be scheduled on. If set to '0', a router will be scheduled on every agent.
#   Defaults to '3'
#
# [*l3_ha_net_cidr*]
#   (Optional) CIDR of the administrative network if HA mode is enabled.
#   Defaults to $facts['os_service_default']
#
# [*l3_ha_network_type*]
#   (Optional) The network type to use when creating the HA network for an HA
#   router.
#   Defaults to $facts['os_service_default']
#
# [*l3_ha_network_physical_name*]
#   (Optional) The physical network name with which the HA network can be
#   created.
#   Defaults to $facts['os_service_default']
#
# [*network_auto_schedule*]
#   (Optional) Allow auto scheduling networks to DHCP agent
#   Defaults to $facts['os_service_default'].
#
# [*service_providers*]
#   (Optional) (Array) Configures the service providers for neutron server.
#   Defaults to $facts['os_service_default']
#
#   Example:
#
#   class { 'neutron::server':
#     service_providers => [
#        'VPN:openswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default'
#     ]
#   }
#
# [*auth_strategy*]
#   (Optional) The strategy to use for authentication.
#   Defaults to 'keystone'
#
# [*enable_proxy_headers_parsing*]
#   (Optional) Enable paste middleware to handle SSL requests through
#   HTTPProxyToWSGI middleware.
#   Defaults to $facts['os_service_default'].
#
# [*max_request_body_size*]
#   (Optional) Set max request body size
#   Defaults to $facts['os_service_default'].
#
# [*ovs_integration_bridge*]
#   (Optional) Name of Open vSwitch bridge to use
#   Defaults to $facts['os_service_default']
#
# [*igmp_snooping_enable*]
#   (Optional) Enable IGMP snooping for integration bridge. If this option is
#   set to True, support for Internet Group Management Protocol (IGMP) is
#   enabled in integration bridge.
#   Defaults to $facts['os_service_default']
#
# [*igmp_flood*]
#   (Optional) Multicast packets (except reports) are unconditionally forwarded
#   to the ports bridging a local network to a physical network.
#   Defaults to $facts['os_service_default']
#
# [*igmp_flood_reports*]
#   (Optional) Multicast reports are unconditionally forwarded to the ports
#   bridging a logical network to a physical network.
#   Defaults to $facts['os_service_default']
#
# [*igmp_flood_unregistered*]
#   (Optional) This option enables or disables flooding of unregistered
#   multicast packets to all ports. If False, the switch will send unregistered
#   multicast packets only to ports connected to multicast routers.
#   Defaults to $facts['os_service_default']
#
# [*enable_default_route_ecmp*]
#   (Optional) Define the default value for enable_default_route_ecmp if not
#   speficied on the router.
#   Defaults to $facts['os_service_default']
#
# [*enable_default_route_bfd*]
#   (Optional) Define the default value for enable_default_route_bfd if not
#   speficied on the router.
#   Defaults to $facts['os_service_default']
#
# DEPRECATED PARAMETERS
#
# [*ensure_dr_package*]
#   (Optional) Ensures installation of Neutron Dynamic Routing package before
#   starting API service. Set to true to ensure installation of the package
#   that is required to start neutron service if bgp service_plugin is enabled.
#   Defaults to false
#
class neutron::server (
  $package_ensure                   = 'present',
  Boolean $enabled                  = true,
  Boolean $manage_service           = true,
  $service_name                     = $::neutron::params::server_service,
  $server_package                   = $::neutron::params::server_package,
  $api_package_name                 = $::neutron::params::api_package_name,
  $api_service_name                 = $::neutron::params::api_service_name,
  $rpc_package_name                 = $::neutron::params::rpc_package_name,
  $rpc_service_name                 = $::neutron::params::rpc_service_name,
  $periodic_workers_package_name    = $::neutron::params::periodic_workers_package_name,
  $periodic_workers_service_name    = $::neutron::params::periodic_workers_service_name,
  Boolean $sync_db                  = false,
  $api_workers                      = $facts['os_workers'],
  $rpc_workers                      = $facts['os_workers'],
  $rpc_state_report_workers         = $facts['os_service_default'],
  $rpc_response_max_timeout         = $facts['os_service_default'],
  $agent_down_time                  = $facts['os_service_default'],
  $enable_new_agents                = $facts['os_service_default'],
  $network_scheduler_driver         = $facts['os_service_default'],
  $router_scheduler_driver          = $facts['os_service_default'],
  $router_distributed               = $facts['os_service_default'],
  $enable_dvr                       = $facts['os_service_default'],
  $dhcp_load_type                   = $facts['os_service_default'],
  $default_availability_zones       = $facts['os_service_default'],
  $allow_automatic_l3agent_failover = $facts['os_service_default'],
  $allow_automatic_dhcp_failover    = $facts['os_service_default'],
  $l3_ha                            = $facts['os_service_default'],
  $max_l3_agents_per_router         = $facts['os_service_default'],
  $l3_ha_net_cidr                   = $facts['os_service_default'],
  $l3_ha_network_type               = $facts['os_service_default'],
  $l3_ha_network_physical_name      = $facts['os_service_default'],
  $network_auto_schedule            = $facts['os_service_default'],
  $service_providers                = $facts['os_service_default'],
  $auth_strategy                    = 'keystone',
  $enable_proxy_headers_parsing     = $facts['os_service_default'],
  $max_request_body_size            = $facts['os_service_default'],
  $ovs_integration_bridge           = $facts['os_service_default'],
  $igmp_snooping_enable             = $facts['os_service_default'],
  $igmp_flood                       = $facts['os_service_default'],
  $igmp_flood_reports               = $facts['os_service_default'],
  $igmp_flood_unregistered          = $facts['os_service_default'],
  $enable_default_route_ecmp        = $facts['os_service_default'],
  $enable_default_route_bfd         = $facts['os_service_default'],
  # DEPRECATED PARAMETERS
  Boolean $ensure_dr_package        = false,
) inherits neutron::params {

  include neutron::deps
  include neutron::db
  include neutron::policy

  if !is_service_default($dhcp_load_type) {
    if ! ($dhcp_load_type in ['networks', 'subnets', 'ports'] ) {
      fail('Unsupported dhcp_load_type. It should be one of networks, subnets and ports.')
    }
  }

  if $ensure_dr_package {
    warning("The ensure_dr_package parameter is deprecated. \
Use the neutron::services::dr class instead.")
    ensure_packages('neutron-dynamic-routing', {
      ensure => $package_ensure,
      name   => $::neutron::params::dynamic_routing_package,
      tag    => ['openstack', 'neutron-package'],
    })
  }

  if $sync_db {
    include neutron::db::sync
  }

  neutron_config {
    'DEFAULT/l3_ha':                            value => $l3_ha;
    'DEFAULT/max_l3_agents_per_router':         value => $max_l3_agents_per_router;
    'DEFAULT/l3_ha_net_cidr':                   value => $l3_ha_net_cidr;
    'DEFAULT/l3_ha_network_type':               value => $l3_ha_network_type;
    'DEFAULT/l3_ha_network_physical_name':      value => $l3_ha_network_physical_name;
    'DEFAULT/api_workers':                      value => $api_workers;
    'DEFAULT/rpc_workers':                      value => $rpc_workers;
    'DEFAULT/rpc_state_report_workers':         value => $rpc_state_report_workers;
    'DEFAULT/rpc_response_max_timeout':         value => $rpc_response_max_timeout;
    'DEFAULT/agent_down_time':                  value => $agent_down_time;
    'DEFAULT/enable_new_agents':                value => $enable_new_agents;
    'DEFAULT/network_scheduler_driver':         value => $network_scheduler_driver;
    'DEFAULT/router_scheduler_driver':          value => $router_scheduler_driver;
    'DEFAULT/router_distributed':               value => $router_distributed;
    'DEFAULT/enable_dvr':                       value => $enable_dvr;
    'DEFAULT/allow_automatic_l3agent_failover': value => $allow_automatic_l3agent_failover;
    'DEFAULT/allow_automatic_dhcp_failover':    value => $allow_automatic_dhcp_failover;
    'DEFAULT/dhcp_load_type':                   value => $dhcp_load_type;
    'DEFAULT/default_availability_zones':       value => join(any2array($default_availability_zones), ',');
    'DEFAULT/network_auto_schedule':            value => $network_auto_schedule;
    'ovs/integration_bridge':                   value => $ovs_integration_bridge;
    'service_providers/service_provider':       value => $service_providers;
    'ovs/igmp_snooping_enable':                 value => $igmp_snooping_enable;
    'ovs/igmp_flood':                           value => $igmp_flood;
    'ovs/igmp_flood_reports':                   value => $igmp_flood_reports;
    'ovs/igmp_flood_unregistered':              value => $igmp_flood_unregistered;
    'DEFAULT/enable_default_route_ecmp':        value => $enable_default_route_ecmp;
    'DEFAULT/enable_default_route_bfd':         value => $enable_default_route_bfd;
  }

  if $service_name {
    if $server_package {
      package { 'neutron-server':
        ensure => $package_ensure,
        name   => $::neutron::params::server_package,
        tag    => ['openstack', 'neutron-package'],
      }
    }
  } else {
    if $api_package_name {
      package { 'neutron-api':
        ensure => $package_ensure,
        name   => $api_package_name,
        tag    => ['openstack', 'neutron-package'],
      }
    }

    if $rpc_package_name and $rpc_service_name {
      package { 'neutron-rpc-server':
        ensure => $package_ensure,
        name   => $rpc_package_name,
        tag    => ['openstack', 'neutron-package'],
      }
    }

    if $periodic_workers_package_name {
      package { 'neutron-periodic-workers':
        ensure => $package_ensure,
        name   => $periodic_workers_package_name,
        tag    => ['openstack', 'neutron-package'],
      }
    }
  }

  if ($auth_strategy == 'keystone') {
    include neutron::keystone::authtoken
  }

  oslo::middleware { 'neutron_config':
    enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
    max_request_body_size        => $max_request_body_size,
  }

  if $manage_service {
    if $enabled {
      $service_ensure = 'running'
    } else {
      $service_ensure = 'stopped'
    }

    # $service_name is the old 'neutron-server' service. If it is in use,
    # then we don't need to start neutron-api and neutron-rpc-server. If
    # it is not, then we must start neutron-api and neutron-rpc-server instead.
    if $service_name {
      if $service_name == $::neutron::params::server_service {
        service { 'neutron-server':
          ensure     => $service_ensure,
          name       => $::neutron::params::server_service,
          enable     => $enabled,
          hasstatus  => true,
          hasrestart => true,
          tag        => ['neutron-service', 'neutron-server-eventlet'],
        }
        Neutron_api_paste_ini<||> ~> Service['neutron-server']

      } elsif $service_name == 'httpd' {
        fail('Use api_service_name and rpc_service_name to run api service by httpd')

      } else {
        warning('Support for arbitrary service name is deprecated')
        # backward compatibility so operators can customize the service name.
        service { 'neutron-server':
          ensure     => $service_ensure,
          name       => $service_name,
          enable     => $enabled,
          hasstatus  => true,
          hasrestart => true,
          tag        => ['neutron-service'],
        }
      }

    } else {
      if $::neutron::params::server_service {
        # we need to make sure neutron-server is stopped before trying to
        # start separate services.
        service { 'neutron-server':
          ensure     => 'stopped',
          name       => $::neutron::params::server_service,
          enable     => false,
          hasstatus  => true,
          hasrestart => true,
          tag        => ['neutron-service'],
        }
      }

      if $api_service_name {
        if $api_service_name == 'httpd' {
          Service <| title == 'httpd' |> { tag +> 'neutron-service' }
          Neutron_api_paste_ini<||> ~> Service[$api_service_name]

          if $::neutron::params::server_service {
            Service['neutron-server'] -> Service[$api_service_name]
          }

          if $::neutron::params::api_service_name {
            # we need to make sure api service is stopped before trying to
            # start apache
            service { 'neutron-api':
              ensure     => 'stopped',
              name       => $::neutron::params::api_service_name,
              enable     => false,
              hasstatus  => true,
              hasrestart => true,
              tag        => ['neutron-service'],
            }
            Service['neutron-api'] -> Service[$api_service_name]
          }

        } else {
          service { 'neutron-api':
            ensure     => $service_ensure,
            name       => $api_service_name,
            enable     => $enabled,
            hasstatus  => true,
            hasrestart => true,
            tag        => ['neutron-service', 'neutron-server-eventlet'],
          }

          Neutron_api_paste_ini<||> ~> Service['neutron-api']
          Neutron_api_uwsgi_config<||> ~> Service['neutron-api']

          if $::neutron::params::server_service {
            Service['neutron-server'] -> Service['neutron-api']
          }
        }
      }

      if $rpc_service_name {
        service { 'neutron-rpc-server':
          ensure     => $service_ensure,
          name       => $rpc_service_name,
          enable     => $enabled,
          hasstatus  => true,
          hasrestart => true,
          tag        => ['neutron-service'],
        }

        if $::neutron::params::server_service {
          Service['neutron-server'] -> Service['neutron-rpc-server']
        }
      }

      if $periodic_workers_service_name {
        service { 'neutron-periodic-workers':
          ensure     => $service_ensure,
          name       => $periodic_workers_service_name,
          enable     => $enabled,
          hasstatus  => true,
          hasrestart => true,
          tag        => ['neutron-service'],
        }

        if $::neutron::params::server_service {
          Service['neutron-server'] -> Service['neutron-periodic-workers']
        }
      }
    }
  }
}