Skip to content
Snippets Groups Projects
Commit adb6b2c0 authored by Alessandro Costantini's avatar Alessandro Costantini
Browse files

Classes added to configure Public/private network and router for the selected tenant.

parent 061be8de
No related branches found
No related tags found
1 merge request!9Development
......@@ -66,9 +66,7 @@ class iaas::profile::neutron::router (
}
if $ipaddress_br_ex == '' {
#Costa
# $local_ip = $::facts["ipaddress_${public_interface}"]
$local_ip = $::ipaddress
$local_ip = $::facts["ipaddress_${public_interface}"]
} else {
$local_ip = $::ipaddress_br_ex
}
......@@ -78,29 +76,38 @@ class iaas::profile::neutron::router (
enabled => true,
tunnel_types => ['gre'],
bridge_mappings => ['external:br-ex'],
#Costa
# require => File['etc_default_neutron-server'],
require => File['/etc/default/neutron-server'],
require => File['etc_default_neutron-server'],
}
#Costa
# $_external_device = device_for_network($external_network)
# if $_external_device != 'br_ex' {
$_external_device = 'br-ex'
if $_external_device != 'br-ex' {
$_external_device = device_for_network($external_network)
#added alert for notification (debug)
#notify {"debug message: ${external_network}; ${_external_device}":
#loglevel => alert
#}
if $_external_device != 'br_ex' {
# Store initial configuration from the public interface (assigned by DHCP) to restore on br-ex
$public_ipaddress = $::facts["ipaddress_${public_interface}"]
$public_netmask = $::facts["netmask_${public_interface}"]
network_config { $external_device:
ensure => 'present',
family => 'inet',
method => 'manual',
options => {
'up' => "ifconfig ${external_device} promisc up",
'down' => "ifconfig ${external_device} promisc down",
},
} ->
#added alert for notification (debug)
#notify {"debug message: ${_external_device}; ${external_device}":
#loglevel => alert
#}
#Commented, external device left unchanged
# network_config { $_external_device:
# ensure => 'present',
# family => 'inet',
# method => 'manual',
# method => dhcp,
# options => {
# 'up' => "ifconfig ${external_device} promisc up",
# 'down' => "ifconfig ${external_device} promisc down",
# },
# } ->
network_config { 'br-ex':
ensure => 'present',
family => 'inet',
......@@ -108,7 +115,7 @@ class iaas::profile::neutron::router (
ipaddress => $public_ipaddress,
netmask => $public_netmask,
} ->
vs_port { $external_device:
vs_port { $_external_device:
ensure => present,
bridge => 'br-ex',
require => Class['::neutron::agents::ml2::ovs'],
......@@ -122,4 +129,8 @@ class iaas::profile::neutron::router (
require => Package['ifupdown-extra']
}
}
#Public/private network configuration for tenant - added
class { '::iaas::setup::sharednetwork': }
}
# A convenience method to set up a router between
# a private subnet and the public network. The
# $title of the resource is 'tenant:subnet',
# where tenant is the name of the tenant to assign
# the router to and subnet is the name of the
# subnet to connect the router to.
define iaas::setup::router {
$valarray = split($title, ':')
$tenant = $valarray[0]
$subnet = $valarray[1]
neutron_router { $tenant:
tenant_name => $tenant,
gateway_network_name => 'public',
require => [Neutron_network['public'], Neutron_subnet[$subnet]]
} ->
neutron_router_interface { $title:
ensure => present
}
}
# A static class to set up a shared network. Should appear on the
# controller node. It sets up the public network, a private network,
# two subnets (one for admin, one for test), and the routers that
# connect the subnets to the public network.
#
# After this class has run, you should have a functional network
# avaiable for your test user to launch and connect machines to.
class iaas::setup::sharednetwork (
#New variable definition
# tenant where configure network defined as yaml variable
$tenant = hiera('iaas::profile::network::tenant', undef),
$external_network = hiera('iaas::profile::neutron::external_network', undef),
$gateway = hiera('iaas::profile::neutron::external_gateway', undef),
# $dns = hiera('iaas::profile::base::dns_servers', undef),
$start_ip = hiera('iaas::profile::neutron::network_external_ippool_start', undef),
$end_ip = hiera('iaas::profile::neutron::network_external_ippool_end', undef),
$private_network = hiera('iaas::profile::neutron::network_neutron_private', undef),
) {
$ip_range = "start=${start_ip},end=${end_ip}"
notify {"debug message: ${start_ip}; ${end_ip}; ${ip_range}":
loglevel => alert
}
neutron_network { 'public':
tenant_name => 'services',
provider_network_type => 'gre',
router_external => true,
provider_segmentation_id => 3604,
shared => true,
} ->
neutron_subnet { $external_network:
cidr => $external_network,
ip_version => '4',
gateway_ip => $gateway,
enable_dhcp => false,
network_name => 'public',
tenant_name => 'services',
allocation_pools => [$ip_range],
#DNS commented
# dns_nameservers => [$dns],
}
neutron_network { 'private':
tenant_name => 'services',
provider_network_type => 'gre',
router_external => false,
provider_segmentation_id => 4063,
shared => true,
} ->
neutron_subnet { $private_network:
cidr => $private_network,
ip_version => '4',
enable_dhcp => true,
network_name => 'private',
tenant_name => 'services',
#DNS commented
# dns_nameservers => [$dns],
}
# router setup for the selected tenant
iaas::setup::router { "${tenant}:${private_network}": }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment