Initial commit for MN Cluster
Change-Id: Ic49335035a443d6a21a9575327c769c626e5bbe9
This commit is contained in:
parent
9538a6ca7d
commit
5c8bb3e4cd
125
manifests/cluster.pp
Normal file
125
manifests/cluster.pp
Normal file
@ -0,0 +1,125 @@
|
||||
# == Class: midonet::midonet_api
|
||||
#
|
||||
# Install and run midonet_api
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*zk_servers*]
|
||||
# List of hash [{ip, port}] Zookeeper instances that run in cluster.
|
||||
# [*keystone_auth*]
|
||||
# Whether to authenticate the API request through a Keystone service. Default:
|
||||
# false.
|
||||
# [*vtep*]
|
||||
# Whether to enable the vtep service endpoint. Default: false
|
||||
# [*tomcat_package*]
|
||||
# The name of the tomcat package to install. The module already inserts a
|
||||
# value depending on the distribution used. Don't override it unless you know
|
||||
# what you are doing.
|
||||
# [*bind_address*]
|
||||
# Let choose the address to bind instead of all of them
|
||||
# [*api_ip*]
|
||||
# Exposed IP address. By default, it exposes the first internet address that
|
||||
# founds in the host.
|
||||
# [*api_port*]
|
||||
# TCP listening port. By default, 8080
|
||||
# [*keystone_host*]
|
||||
# Keystone service endpoint IP. Not used if keystone_auth is false.
|
||||
# [*keystone_port*]
|
||||
# Keystone service endpoint port. Not used if keystone_auth is false.
|
||||
# [*keystone_admin_token*]
|
||||
# Keystone admin token. Not used if keystone_auth is false.
|
||||
# [*keystone_tenant_name*]
|
||||
# Keystone tenant name. 'admin' by default. Not used if keystone_auth is false.
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# The easiest way to run this class is:
|
||||
#
|
||||
# include midonet::midonet_api
|
||||
#
|
||||
# This call assumes that there is a zookeeper running in the target host and the
|
||||
# module will spawn a midonet_api without keystone authentication.
|
||||
#
|
||||
# This is a quite naive deployment, just for demo purposes. A more realistic one
|
||||
# would be:
|
||||
#
|
||||
# class {'midonet::midonet_api':
|
||||
# zk_servers => [{'ip' => 'host1',
|
||||
# 'port' => '2183'},
|
||||
# {'ip' => 'host2'}],
|
||||
# keystone_auth => true,
|
||||
# vtep => true,
|
||||
# api_ip => '92.234.12.4',
|
||||
# keystone_host => '92.234.12.9',
|
||||
# keystone_port => 35357 (35357 is already the default)
|
||||
# keystone_admin_token => 'arrakis',
|
||||
# keystone_tenant_name => 'other-than-admin' ('admin' by default)
|
||||
# }
|
||||
#
|
||||
# You can alternatively use the Hiera.yaml style:
|
||||
#
|
||||
# midonet::midonet_api::zk_servers:
|
||||
# - ip: 'host1'
|
||||
# port: 2183
|
||||
# - ip: 'host2'
|
||||
# midonet::midonet_api::vtep: true
|
||||
# midonet::midonet_api::keystone_auth: true
|
||||
# midonet::midonet_api::api_ip: '92.234.12.4'
|
||||
# midonet::midonet_api::keystone_host: '92.234.12.9'
|
||||
# midonet::midonet_api::keystone_port: 35357
|
||||
# midonet::midonet_api::keystone_admin_token: 'arrakis'
|
||||
# midonet::midonet_api::keystone_tenant_name: 'admin'
|
||||
#
|
||||
# Please note that Zookeeper port is not mandatory and defaulted to 2181.
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# Midonet (http://midonet.org)
|
||||
#
|
||||
# === Copyright
|
||||
#
|
||||
# Copyright (c) 2015 Midokura SARL, All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
class midonet::cluster (
|
||||
$zk_servers,
|
||||
$keystone_auth,
|
||||
$vtep,
|
||||
$tomcat_package,
|
||||
$keystone_host=$::ipaddress,
|
||||
$keystone_port=35357,
|
||||
$keystone_admin_token=undef,
|
||||
$keystone_tenant_name='admin',
|
||||
$api_ip=$::ipaddress,
|
||||
$api_port='8080',
|
||||
$bind_address='0.0.0.0'
|
||||
) {
|
||||
|
||||
contain midonet::midonet_api::install
|
||||
|
||||
class {'midonet::midonet_api::run':
|
||||
zk_servers => $zk_servers,
|
||||
keystone_auth => $keystone_auth,
|
||||
tomcat_package => $tomcat_package,
|
||||
vtep => $vtep,
|
||||
api_ip => $api_ip,
|
||||
api_port => $api_port,
|
||||
keystone_host => $keystone_host,
|
||||
keystone_port => $keystone_port,
|
||||
keystone_admin_token => $keystone_admin_token,
|
||||
keystone_tenant_name => $keystone_tenant_name,
|
||||
bind_address => $bind_address
|
||||
}
|
||||
contain midonet::midonet_api::run
|
||||
}
|
35
manifests/cluster/install.pp
Normal file
35
manifests/cluster/install.pp
Normal file
@ -0,0 +1,35 @@
|
||||
# == Class: midonet::midonet_api::install
|
||||
# Check out the midonet::midonet_api class for a full understanding of
|
||||
# how to use the midonet_api resource
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# Midonet (http://midonet.org)
|
||||
#
|
||||
# === Copyright
|
||||
#
|
||||
# Copyright (c) 2015 Midokura SARL, All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
class midonet::cluster::install (
|
||||
$package_name = 'midonet-cluster',
|
||||
) {
|
||||
|
||||
include midonet::repository
|
||||
|
||||
package {'midonet-cluster':
|
||||
ensure => present,
|
||||
name => $package_name,
|
||||
}
|
||||
}
|
45
manifests/cluster/run.pp
Normal file
45
manifests/cluster/run.pp
Normal file
@ -0,0 +1,45 @@
|
||||
# == Class: midonet::cluster::run
|
||||
# Check out the midonet::cluster class for a full understanding of
|
||||
# how to use the cluster resource
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# Midonet (http://midonet.org)
|
||||
#
|
||||
# === Copyright
|
||||
#
|
||||
# Copyright (c) 2016 Midokura SARL, All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
class midonet::cluster::run (
|
||||
$service_name = 'midonet-cluster',
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
$cluster_config_path = '/etc/midonet/midonet.conf',
|
||||
$zookeeper_hosts = [{ 'ip' => '127.0.0.1', 'port' => '2181' }],
|
||||
) {
|
||||
|
||||
file { 'cluster_config':
|
||||
ensure => present,
|
||||
path => $cluster_config_path,
|
||||
content => template('midonet/cluster/midonet.conf.erb'),
|
||||
require => Package['midonet-cluster'],
|
||||
} ~>
|
||||
|
||||
service { 'midonet-cluster':
|
||||
ensure => $service_ensure,
|
||||
name => $service_name,
|
||||
enable => $service_enable,
|
||||
}
|
||||
}
|
24
templates/cluster/keystone_config.xml.erb
Normal file
24
templates/cluster/keystone_config.xml.erb
Normal file
@ -0,0 +1,24 @@
|
||||
<!-- Keystone configuration -->
|
||||
<context-param>
|
||||
<param-name>keystone-service_protocol</param-name>
|
||||
<param-value>http</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>keystone-service_host</param-name>
|
||||
<param-value><%= @keystone_host %></param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>keystone-service_port</param-name>
|
||||
<param-value><%= @keystone_port %></param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>keystone-admin_token</param-name>
|
||||
<param-value><%= @keystone_admin_token %></param-value>
|
||||
</context-param>
|
||||
<!-- This tenant name is used to get the scoped token from Keystone, and
|
||||
should be the tenant name of the user that owns the token sent in the
|
||||
request -->
|
||||
<context-param>
|
||||
<param-name>keystone-tenant_name</param-name>
|
||||
<param-value><%= @keystone_tenant_name %></param-value>
|
||||
</context-param>
|
20
templates/cluster/midonet.conf.erb
Normal file
20
templates/cluster/midonet.conf.erb
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright 2016 Midokura SARL │
|
||||
# │
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); │
|
||||
# you may not use this file except in compliance with the License. │
|
||||
# You may obtain a copy of the License at │
|
||||
# │
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 │
|
||||
# │
|
||||
# Unless required by applicable law or agreed to in writing, software │
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, │
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │
|
||||
# See the License for the specific language governing permissions and │
|
||||
# limitations under the License. │
|
||||
│
|
||||
[zookeeper]
|
||||
<%- zkarr = Array.new -%>
|
||||
<%- @zookeeper_hosts.each do |s| -%>
|
||||
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%>
|
||||
<%- end -%>
|
||||
zookeeper_hosts = <%= zkarr.join(",") %>
|
14
templates/cluster/mockauth_config.xml.erb
Normal file
14
templates/cluster/mockauth_config.xml.erb
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
<!-- Mock auth configuration -->
|
||||
<context-param>
|
||||
<param-name>mock_auth-admin_token</param-name>
|
||||
<param-value>999888777666</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>mock_auth-tenant_admin_token</param-name>
|
||||
<param-value>999888777666</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>mock_auth-tenant_user_token</param-name>
|
||||
<param-value>999888777666</param-value>
|
||||
</context-param>
|
110
templates/cluster/web.xml.erb
Normal file
110
templates/cluster/web.xml.erb
Normal file
@ -0,0 +1,110 @@
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||
|
||||
<web-app>
|
||||
<display-name>MidoNet API</display-name>
|
||||
|
||||
<!-- REST API configuration -->
|
||||
<!-- This value overrides the default base URI. This is typically set if
|
||||
you are proxying the API server and the base URI that the clients use
|
||||
to access the API is different from the actual server base URI. -->
|
||||
<context-param>
|
||||
<param-name>rest_api-base_uri</param-name>
|
||||
<param-value>http://<%= @api_ip %>:<%= @api_port %>/midonet-api</param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- CORS configuration -->
|
||||
<context-param>
|
||||
<param-name>cors-access_control_allow_origin</param-name>
|
||||
<param-value>*</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>cors-access_control_allow_headers</param-name>
|
||||
<param-value>Origin, X-Auth-Token, Content-Type, Accept, Authorization</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>cors-access_control_allow_methods</param-name>
|
||||
<param-value>GET, POST, PUT, DELETE, OPTIONS</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>cors-access_control_expose_headers</param-name>
|
||||
<param-value>Location</param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- Auth configuration -->
|
||||
<context-param>
|
||||
<param-name>auth-auth_provider</param-name>
|
||||
<!-- Specify the class path of the auth service -->
|
||||
<%- if @keystone_auth -%>
|
||||
<param-value>org.midonet.api.auth.keystone.v2_0.KeystoneService</param-value>
|
||||
<%- else -%>
|
||||
<param-value>org.midonet.api.auth.MockAuthService</param-value>
|
||||
<%- end -%>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>auth-admin_role</param-name>
|
||||
<param-value>admin</param-value>
|
||||
</context-param>
|
||||
|
||||
<%- if @keystone_auth -%>
|
||||
<%= scope.function_template(['midonet/midonet-api/keystone_config.xml.erb']) %>
|
||||
<%- else -%>
|
||||
<%= scope.function_template(['midonet/midonet-api/mockauth_config.xml.erb']) %>
|
||||
<%- end -%>
|
||||
|
||||
<!-- Zookeeper configuration -->
|
||||
<!-- The following parameters should match the ones in midolman.conf
|
||||
except 'use_mock' -->
|
||||
<context-param>
|
||||
<param-name>zookeeper-use_mock</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>zookeeper-zookeeper_hosts</param-name>
|
||||
<!-- comma separated list of Zookeeper nodes(host:port) -->
|
||||
<%- zkarr = Array.new -%>
|
||||
<%- @zk_servers.each do |s| -%>
|
||||
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%>
|
||||
<%- end -%>
|
||||
<param-value><%= zkarr.join(",") %></param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>zookeeper-session_timeout</param-name>
|
||||
<param-value>30000</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>zookeeper-midolman_root_key</param-name>
|
||||
<param-value>/midonet/v1</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>zookeeper-curator_enabled</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- VXLAN gateway configuration -->
|
||||
<context-param>
|
||||
<param-name>midobrain-vxgw_enabled</param-name>
|
||||
<param-value><%= @vtep %></param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- Servlet Listner -->
|
||||
<listener>
|
||||
<listener-class>
|
||||
<!-- Use Jersey's Guice compatible context listener -->
|
||||
org.midonet.api.servlet.JerseyGuiceServletContextListener
|
||||
</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Servlet filter -->
|
||||
<filter>
|
||||
<!-- Filter to enable Guice -->
|
||||
<filter-name>Guice Filter</filter-name>
|
||||
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>Guice Filter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
</web-app>
|
Loading…
x
Reference in New Issue
Block a user