Merge "Remove nova-network code"

This commit is contained in:
Zuul 2019-05-22 22:59:23 +00:00 committed by Gerrit Code Review
commit a6e7f4cf12
19 changed files with 13 additions and 847 deletions

View File

@ -1,43 +0,0 @@
require File.join(File.dirname(__FILE__), '..','..','..', 'puppet/provider/nova')
Puppet::Type.type(:nova_network).provide(:nova, :parent => Puppet::Provider::Nova) do
desc "Manage nova network"
optional_commands :nova => 'nova'
def create
optional_opts = []
{
# this needs to be converted from a project name to an id
:project => '--project_id',
:dns1 => '--dns1',
:dns2 => '--dns2',
:gateway => '--gateway',
:bridge => '--bridge',
:vlan_start => '--vlan-start',
:allowed_start => '--allowed-start',
:allowed_end => '--allowed-end',
}.each do |param, opt|
if resource[param]
optional_opts.push(opt).push(resource[param])
end
end
opts = [resource[:label], "--fixed-range-v4", resource[:name]]
auth_nova('network-create', opts + optional_opts)
end
def exists?
instances = auth_nova('network-list')
return instances.split('\n')[1..-1].detect do |n|
n =~ /(\S+)\s+(#{resource[:network]})\s+(\S+)/
end
end
def destroy
auth_nova("network-delete", resource[:network])
end
end

View File

@ -1,71 +0,0 @@
Puppet::Type.newtype(:nova_network) do
@doc = "Manage creation/deletion of nova networks. During creation, network
CIDR and netmask will be calculated automatically"
ensurable
# there are concerns about determining uniqueness of network
# segments b/c it is actually the combination of network/prefix
# that determine uniqueness
newparam(:network, :namevar => true) do
desc "IPv4 Network (ie, 192.168.1.0/24)"
newvalues(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(\d|[1-2]\d|3[0-2]))$/)
end
newparam(:label) do
desc "The Nova network label"
defaultto "novanetwork"
munge do |value|
Puppet.deprecation_warning('nova_network is deprecated and will be removed in a future release')
value
end
end
newparam(:num_networks) do
desc 'Number of networks to create'
defaultto(1)
end
newparam(:bridge) do
desc 'bridge to use for flat network'
end
newparam(:project) do
desc 'project that the network is associated with'
end
newparam(:gateway) do
end
newparam(:dns1) do
desc 'first dns server'
end
newparam(:dns2) do
desc 'second dns server'
end
newparam(:allowed_start) do
desc 'Start of allowed addresses for instances'
newvalues(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)
end
newparam(:allowed_end) do
desc 'End of allowed addresses for instances'
newvalues(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)
end
newparam(:vlan_start) do
end
newparam(:network_size) do
defaultto('256')
end
validate do
raise(Puppet::Error, 'Label must be set') unless self[:label]
end
end

View File

@ -1,50 +0,0 @@
# == Class: nova::compute::neutron
#
# Manage the network driver to use for compute guests
# This will use virtio for VM guests and the
# specified driver for the VIF
#
# DEPRECATED!
#
# === Parameters
#
# [*libvirt_vif_driver*]
# (optional) The libvirt VIF driver to configure the VIFs.
# Defaults to 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver'.
#
# [*force_snat_range*]
# (optional) Force SNAT rule to specified network for nova-network
# Default to 0.0.0.0/0
# Due to architecture constraints in nova_config, it's not possible to setup
# more than one SNAT rule though initial parameter is MultiStrOpt
class nova::compute::neutron (
$libvirt_vif_driver = 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver',
$force_snat_range = '0.0.0.0/0',
) {
include ::nova::deps
# NOTE(tobias-urdin): libvirt/vif_driver option does not exist and force_snat_range is
# a nova-network specific config which is deprecated.
warning('nova::compute::network class is deprecated and will be removed in a future release')
nova_config {
'libvirt/vif_driver': value => $libvirt_vif_driver;
}
if $libvirt_vif_driver == 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver' and $force_snat_range {
# Validate ip and mask for force_snat_range
$force_snat_range_array = split($force_snat_range, '/')
if is_ip_address($force_snat_range_array[0]) and is_integer($force_snat_range_array[1]) {
nova_config {
'DEFAULT/force_snat_range': value => $force_snat_range;
}
} else {
fail('force_snat_range should be IPv4 or IPv6 CIDR notation')
}
} else {
nova_config {
'DEFAULT/force_snat_range': ensure => absent;
}
}
}

View File

@ -44,10 +44,6 @@ class nova::deps {
-> Nova_floating<||>
Anchor['nova::dbsync::end']
-> Nova_floating<||>
Anchor['nova::dbsync_api::end']
-> Nova_network<||>
Anchor['nova::dbsync::end']
-> Nova_network<||>
# all cache settings should be applied and all packages should be installed
# before service startup

View File

@ -413,10 +413,6 @@
# exceptions in the API service
# Defaults to undef
#
# [*use_ipv6*]
# (optional) Use IPv6 or not.
# Defaults to undef
#
class nova(
$ensure_package = 'present',
$database_connection = undef,
@ -510,7 +506,6 @@ class nova(
$notify_api_faults = undef,
$image_service = undef,
$notify_on_api_faults = undef,
$use_ipv6 = undef,
) inherits nova::params {
include ::nova::deps
@ -518,10 +513,6 @@ class nova(
# maintain backward compatibility
include ::nova::db
if $use_ipv6 {
warning('nova::use_ipv6 is deprecated and will be removed in a future release')
}
validate_legacy(Array, 'validate_array', $enabled_ssl_apis)
if empty($enabled_ssl_apis) and $use_ssl {
warning('enabled_ssl_apis is empty but use_ssl is set to true')
@ -716,11 +707,6 @@ but should be one of: ssh-rsa, ssh-dsa, ssh-ecdsa.")
topics => $notification_topics,
}
# TODO(tobias-urdin): Remove when use_ipv6 params is removed.
nova_config {
'os_vif_linux_bridge/use_ipv6': value => $use_ipv6;
}
nova_config {
'cinder/catalog_info': value => $cinder_catalog_info;
'DEFAULT/ovsdb_connection': value => $ovsdb_connection;

View File

@ -1,75 +0,0 @@
# === Parameters:
#
# DEPRECATED!
#
# [*network*]
# (required) IPv4 CIDR of network to create.
#
# [*label*]
# (optional) The label of the network.
# Defaults to 'novanetwork'.
#
# [*num_networks*]
# (optional) Number of networks to split $network into.
# Defaults to 1
#
# [*network_size*]
# (optional) Size of the network to create
# Defaults to 255
#
# [*vlan_start*]
# (optional) The vlan number to use if in vlan mode
# Defaults to undef
#
# [*allowed_start*]
# (optional) Start of allowed addresses for instances
# Defaults to undef
#
# [*allowed_end*]
# (optional) End of allowed addresses for instances
# Defaults to undef
#
# [*project*]
# (optional) Project that network should be associated with
# Defaults to undef
#
# [*dns1*]
# (optional) First DNS server
# Defaults to undef
#
# [*dns2*]
# (optional) Second DNS server
# Defaults to undef
#
define nova::manage::network (
$network,
$label = 'novanetwork',
$num_networks = 1,
$network_size = 255,
$vlan_start = undef,
$project = undef,
$allowed_start = undef,
$allowed_end = undef,
$dns1 = undef,
$dns2 = undef
) {
include ::nova::deps
warning('nova::manage::network is deprecated and will be removed in a future release')
nova_network { $name:
ensure => present,
network => $network,
label => $label,
num_networks => $num_networks,
network_size => $network_size,
project => $project,
vlan_start => $vlan_start,
allowed_start => $allowed_start,
allowed_end => $allowed_end,
dns1 => $dns1,
dns2 => $dns2,
}
}

View File

@ -1,47 +0,0 @@
# bridge.pp
#
# DEPRECATED!
#
# === Parameters:
#
# [*ip*]
# (mandatory) IP address of the bridge interface.
#
# [*netmask*]
# (optional) Netmask of the bridge interface.
# Defaults to '255.255.255.0' (/24).
#
define nova::network::bridge (
$ip,
$netmask = '255.255.255.0'
) {
include ::nova::deps
warning('nova::network::bridge is deprecated and will be removed in a future release')
case $::osfamily {
'Debian': {
$context = '/files/etc/network/interfaces'
augeas { "bridge_${name}":
context => $context,
changes => [
"set auto[child::1 = '${name}']/1 ${name}",
"set iface[. = '${name}'] ${name}",
"set iface[. = '${name}']/family inet",
"set iface[. = '${name}']/method static",
"set iface[. = '${name}']/address ${ip}",
"set iface[. = '${name}']/netmask ${netmask}",
"set iface[. = '${name}']/bridge_ports none",
],
notify => Exec['networking-refresh'],
}
}
'RedHat' : {
}
default: { fail('nova::network_bridge currently only supports osfamily Debian and RedHat') }
}
}

View File

@ -1,46 +0,0 @@
# == Class: nova::network::flat
#
# Configuration settings for nova flat network
#
# DEPRECATED!
#
# === Parameters:
#
# [*fixed_range*]
# (required) The IPv4 CIDR for the network
#
# [*flat_interface*]
# (optional) Interface that flat network will use for bridging
# Defaults to undef
#
# [*public_interface*]
# (optional) The interface to use for public traffic
# Defaults to undef
#
# [*flat_network_bridge*]
# (optional) The name of the bridge to use
# Defaults to 'br100'
#
class nova::network::flat (
$fixed_range,
$flat_interface=undef,
$public_interface = undef,
$flat_network_bridge = 'br100'
) {
include ::nova::deps
warning('nova::network::flat is deprecated and nova-network will be removed in a future release')
if $public_interface {
nova_config { 'DEFAULT/public_interface': value => $public_interface }
}
nova_config {
'DEFAULT/network_manager': value => 'nova.network.manager.FlatManager';
'DEFAULT/fixed_range': value => $fixed_range;
'DEFAULT/flat_interface': value => $flat_interface;
'DEFAULT/flat_network_bridge': value => $flat_network_bridge;
}
}

View File

@ -1,83 +0,0 @@
# == Class: nova::network::flatdhcp
#
# Configures nova-network with flat dhcp option
#
# DEPRECATED!
#
# === Parameters:
#
# [*fixed_range*]
# (required) The IPv4 CIDR for the flat network
#
# [*flat_interface*]
# (optional) FlatDHCP will bridge into this interface
# Defaults to undef
#
# [*public_interface*]
# (optional)
# Defaults to undef
#
# [*flat_network_bridge*]
# (optional) Bridge for simple network instances (
# Defaults to 'br100'
#
# [*force_dhcp_release*]
# (optional) Send a dhcp release on instance termination
# Defaults to true
#
# [*flat_injected*]
# (optional) Whether to attempt to inject network setup into guest
# Defaults to false
#
# [*dhcp_domain*]
# (optional) domain to use for building the hostnames
# Defaults to 'novalocal'
#
# [*dhcpbridge*]
# (optional) 'location of nova-dhcpbridge'
# Defaults to '/usr/bin/nova-dhcpbridge'
#
# [*dhcpbridge_flagfile*]
# (optional) location of flagfiles for dhcpbridge
# Defaults to '/etc/nova/nova.conf
#
class nova::network::flatdhcp (
$fixed_range,
$flat_interface = undef,
$public_interface = undef,
$flat_network_bridge = 'br100',
$force_dhcp_release = true,
$flat_injected = false,
$dhcp_domain = 'novalocal',
$dhcpbridge = '/usr/bin/nova-dhcpbridge',
$dhcpbridge_flagfile = '/etc/nova/nova.conf'
) {
include ::nova::deps
warning('nova::network::flatdhcp is deprecated and nova-network will be removed in a future release')
if $::osfamily == 'RedHat' and $::operatingsystem != 'Fedora' {
package { 'dnsmasq-utils':
ensure => present,
tag => ['openstack', 'nova-support-package'],
}
}
if $public_interface {
nova_config { 'DEFAULT/public_interface': value => $public_interface }
}
nova_config {
'DEFAULT/network_manager': value => 'nova.network.manager.FlatDHCPManager';
'DEFAULT/fixed_range': value => $fixed_range;
'DEFAULT/flat_interface': value => $flat_interface;
'DEFAULT/flat_network_bridge': value => $flat_network_bridge;
'DEFAULT/force_dhcp_release': value => $force_dhcp_release;
'DEFAULT/flat_injected': value => $flat_injected;
'DEFAULT/dhcp_domain': value => $dhcp_domain;
'DEFAULT/dhcpbridge': value => $dhcpbridge;
'DEFAULT/dhcpbridge_flagfile': value => $dhcpbridge_flagfile;
}
}

View File

@ -1,76 +0,0 @@
# == Class: nova::network::vlan
#
# Configures nova network to use vlans
#
# DEPRECATED!
#
# === Parameters:
#
# [*fixed_range*]
# (required) IPv4 CIDR of the network
#
# [*vlan_interface*]
# (required) Physical ethernet adapter name for vlan networking
#
# [*public_interface*]
# (optional) Interface for public traffic
# Defaults to undef
#
# [*vlan_start*]
# (optional) First vlan to use
# Defaults to '300'
#
# [*force_dhcp_release*]
# (optional) Whether to send a dhcp release on instance termination
# Defaults to true
#
# [*dhcp_domain*]
# (optional) Domain to use for building the hostnames
# Defaults to 'novalocal'
#
# [*dhcpbridge*]
# (optional) location of nova-dhcpbridge
# Defaults to '/usr/bin/nova-dhcpbridge'
#
# [*dhcpbridge_flagfile*]
# (optional) location of flagfiles for dhcpbridge
# Defaults to '/etc/nova/nova.conf'
#
class nova::network::vlan (
$fixed_range,
$vlan_interface,
$public_interface = undef,
$vlan_start = '300',
$force_dhcp_release = true,
$dhcp_domain = 'novalocal',
$dhcpbridge = '/usr/bin/nova-dhcpbridge',
$dhcpbridge_flagfile = '/etc/nova/nova.conf'
) {
include ::nova::deps
warning('nova::network::vlan is deprecated and nova-network will be removed in a future release')
if $::osfamily == 'RedHat' and $::operatingsystem != 'Fedora' {
package { 'dnsmasq-utils':
ensure => present,
tag => ['openstack', 'nova-support-package'],
}
}
if $public_interface {
nova_config { 'DEFAULT/public_interface': value => $public_interface }
}
nova_config {
'DEFAULT/network_manager': value => 'nova.network.manager.VlanManager';
'DEFAULT/fixed_range': value => $fixed_range;
'DEFAULT/vlan_interface': value => $vlan_interface;
'DEFAULT/vlan_start': value => $vlan_start;
'DEFAULT/force_dhcp_release': value => $force_dhcp_release;
'DEFAULT/dhcp_domain': value => $dhcp_domain;
'DEFAULT/dhcpbridge': value => $dhcpbridge;
'DEFAULT/dhcpbridge_flagfile': value => $dhcpbridge_flagfile;
}
}

View File

@ -0,0 +1,13 @@
---
upgrade:
- |
The deprecated nova-network classes nova::network::bridge, nova::network::flat, nova::network::flatdhcp
and nova::network::vlan classes is now removed.
- |
The deprecated nova_network resource is now removed.
- |
The deprecated class nova::compute::neutron is now removed.
- |
The deprecated class nova::manage::network is now removed.
- |
The deprecated parameter nova::use_ipv6 is now removed.

View File

@ -1,50 +0,0 @@
# TODO(tobias-urdin): This is deprecated and should be removed in T release.
require 'spec_helper'
describe 'nova::compute::neutron' do
context 'with default parameters' do
it { is_expected.to contain_nova_config('libvirt/vif_driver').with_value('nova.virt.libvirt.vif.LibvirtGenericVIFDriver')}
it { is_expected.to contain_nova_config('DEFAULT/force_snat_range').with(:value => '0.0.0.0/0') }
end
context 'when overriding params' do
let :params do
{:libvirt_vif_driver => 'foo' }
end
it { is_expected.to contain_nova_config('libvirt/vif_driver').with_value('foo')}
it { is_expected.to contain_nova_config('DEFAULT/force_snat_range').with_ensure(:absent) }
end
context 'with force_snat_range parameter set to false' do
let :params do
{ :force_snat_range => false, }
end
it { is_expected.to contain_nova_config('DEFAULT/force_snat_range').with_ensure('absent') }
end
context 'with force_snat_range parameter set to 10.0.0.0/24' do
let :params do
{ :force_snat_range => '10.0.0.0/24', }
end
it { is_expected.to contain_nova_config('DEFAULT/force_snat_range').with_value('10.0.0.0/24') }
end
context 'with force_snat_range parameter set to fe80::/64' do
let :params do
{ :force_snat_range => 'fe80::/64', }
end
it { is_expected.to contain_nova_config('DEFAULT/force_snat_range').with_value('fe80::/64') }
end
context 'with force_snat_range parameter set ip without mask' do
let :params do
{ :force_snat_range => '10.0.0.0', }
end
it_raises 'a Puppet::Error', /force_snat_range should be IPv4 or IPv6 CIDR notation/
end
end

View File

@ -93,7 +93,6 @@ describe 'nova' do
:os_region_name => 'MyRegion',
:cross_az_attach => 'MyAZ',
:ovsdb_connection => 'tcp:127.0.0.1:6640',
:use_ipv6 => true,
:upgrade_level_cells => '1.0.0',
:upgrade_level_cert => '1.0.0',
:upgrade_level_compute => '1.0.0',
@ -172,7 +171,6 @@ describe 'nova' do
is_expected.to contain_nova_config('notifications/notification_format').with_value('unversioned')
is_expected.to contain_nova_config('DEFAULT/report_interval').with_value('60')
is_expected.to contain_nova_config('DEFAULT/ovsdb_connection').with_value('tcp:127.0.0.1:6640')
is_expected.to contain_nova_config('os_vif_linux_bridge/use_ipv6').with_value('true')
is_expected.to contain_nova_config('cinder/os_region_name').with_value('MyRegion')
is_expected.to contain_nova_config('cinder/cross_az_attach').with_value('MyAZ')
is_expected.to contain_nova_config('DEFAULT/ssl_only').with_value(true)

View File

@ -1,38 +0,0 @@
# TODO(tobias-urdin): This is deprecated and should be removed in T release.
require 'spec_helper'
describe 'nova::network::flat' do
describe 'with only required parameters' do
let :params do
{
:fixed_range => '10.0.0.0/32'
}
end
it { is_expected.to contain_nova_config('DEFAULT/network_manager').with_value('nova.network.manager.FlatManager') }
it { is_expected.to_not contain_nova_config('DEFAULT/public_interface') }
it { is_expected.to contain_nova_config('DEFAULT/fixed_range').with_value('10.0.0.0/32') }
it { is_expected.to contain_nova_config('DEFAULT/flat_network_bridge').with_value('br100') }
it { is_expected.to contain_nova_config('DEFAULT/flat_interface').with_value(nil) }
end
describe 'when overriding class parameters' do
let :params do
{
:flat_interface => 'eth1',
:fixed_range => '10.0.0.0/32',
:public_interface => 'eth0',
:flat_network_bridge => 'br1001',
}
end
it { is_expected.to contain_nova_config('DEFAULT/public_interface').with_value('eth0') }
it { is_expected.to contain_nova_config('DEFAULT/flat_network_bridge').with_value('br1001') }
it { is_expected.to contain_nova_config('DEFAULT/fixed_range').with_value('10.0.0.0/32') }
it { is_expected.to contain_nova_config('DEFAULT/flat_interface').with_value('eth1') }
end
end

View File

@ -1,50 +0,0 @@
# TODO(tobias-urdin): This is deprecated and should be removed in T release.
require 'spec_helper'
describe 'nova::network::flatdhcp' do
describe 'with only required parameters' do
let :params do
{
:flat_interface => 'eth1',
:fixed_range => '10.0.0.0/32'
}
end
it { is_expected.to contain_nova_config('DEFAULT/network_manager').with_value('nova.network.manager.FlatDHCPManager') }
it { is_expected.to_not contain_nova_config('DEFAULT/public_interface') }
it { is_expected.to contain_nova_config('DEFAULT/fixed_range').with_value('10.0.0.0/32') }
it { is_expected.to contain_nova_config('DEFAULT/flat_interface').with_value('eth1') }
it { is_expected.to contain_nova_config('DEFAULT/flat_interface').with_value('eth1') }
it { is_expected.to contain_nova_config('DEFAULT/flat_network_bridge').with_value('br100') }
it { is_expected.to contain_nova_config('DEFAULT/force_dhcp_release').with_value(true) }
it { is_expected.to contain_nova_config('DEFAULT/flat_injected').with_value(false) }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
end
describe 'when overriding class parameters' do
let :params do
{
:flat_interface => 'eth1',
:fixed_range => '10.0.0.0/32',
:public_interface => 'eth0',
:flat_network_bridge => 'br1001',
:force_dhcp_release => false,
:flat_injected => true,
:dhcpbridge => '/usr/bin/dhcpbridge',
:dhcpbridge_flagfile => '/etc/nova/nova-dhcp.conf'
}
end
it { is_expected.to contain_nova_config('DEFAULT/public_interface').with_value('eth0') }
it { is_expected.to contain_nova_config('DEFAULT/flat_network_bridge').with_value('br1001') }
it { is_expected.to contain_nova_config('DEFAULT/force_dhcp_release').with_value(false) }
it { is_expected.to contain_nova_config('DEFAULT/flat_injected').with_value(true) }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge').with_value('/usr/bin/dhcpbridge') }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge_flagfile').with_value('/etc/nova/nova-dhcp.conf') }
end
end

View File

@ -1,48 +0,0 @@
# TODO(tobias-urdin): This is deprecated and should be removed in T release.
require 'spec_helper'
describe 'nova::network::vlan' do
describe 'with only required parameters' do
let :params do
{
:vlan_interface => 'eth1',
:fixed_range => '10.0.0.0/32'
}
end
it { is_expected.to contain_nova_config('DEFAULT/network_manager').with_value('nova.network.manager.VlanManager') }
it { is_expected.to_not contain_nova_config('DEFAULT/public_interface') }
it { is_expected.to contain_nova_config('DEFAULT/fixed_range').with_value('10.0.0.0/32') }
it { is_expected.to contain_nova_config('DEFAULT/vlan_start').with_value('300') }
it { is_expected.to contain_nova_config('DEFAULT/vlan_interface').with_value('eth1') }
it { is_expected.to contain_nova_config('DEFAULT/force_dhcp_release').with_value(true) }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
end
describe 'with parameters overridden' do
let :params do
{
:vlan_interface => 'eth1',
:fixed_range => '10.0.0.0/32',
:public_interface => 'eth0',
:vlan_start => '100',
:force_dhcp_release => false,
:dhcpbridge => '/usr/bin/dhcpbridge',
:dhcpbridge_flagfile => '/etc/nova/nova-dhcp.conf'
}
end
it { is_expected.to contain_nova_config('DEFAULT/network_manager').with_value('nova.network.manager.VlanManager') }
it { is_expected.to contain_nova_config('DEFAULT/public_interface').with_value('eth0') }
it { is_expected.to contain_nova_config('DEFAULT/fixed_range').with_value('10.0.0.0/32') }
it { is_expected.to contain_nova_config('DEFAULT/vlan_start').with_value('100') }
it { is_expected.to contain_nova_config('DEFAULT/vlan_interface').with_value('eth1') }
it { is_expected.to contain_nova_config('DEFAULT/force_dhcp_release').with_value(false) }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge').with_value('/usr/bin/dhcpbridge') }
it { is_expected.to contain_nova_config('DEFAULT/dhcpbridge_flagfile').with_value('/etc/nova/nova-dhcp.conf') }
end
end

View File

@ -1,74 +0,0 @@
require 'spec_helper'
describe 'nova::manage::network' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat', :os => { :family => 'RedHat', :release => { :major => '8'}}})
end
let :pre_condition do
'include nova'
end
let :title do
'foo'
end
describe 'with only required parameters' do
let :params do
{
:network => '10.0.0.0/24'
}
end
it { is_expected.to contain_nova_network('foo').with(
:ensure => 'present',
:network => '10.0.0.0/24',
:label => 'novanetwork',
:num_networks => 1,
:project => nil,
:allowed_start => nil,
:allowed_end => nil,
) }
end
describe 'when overriding num networks' do
let :params do
{
:network => '10.0.0.0/20',
:num_networks => 2
}
end
it { is_expected.to contain_nova_network('foo').with(
:network => '10.0.0.0/20',
:num_networks => 2
) }
end
describe 'when overriding projects' do
let :params do
{
:network => '10.0.0.0/20',
:project => 'foo'
}
end
it { is_expected.to contain_nova_network('foo').with(
:network => '10.0.0.0/20',
:project => 'foo'
) }
end
describe 'when overriding allowed range' do
let :params do
{
:network => '10.0.0.0/20',
:allowed_start => '10.0.0.1',
:allowed_end => '10.0.0.5'
}
end
it { is_expected.to contain_nova_network('foo').with(
:network => '10.0.0.0/20',
:allowed_start => '10.0.0.1',
:allowed_end => '10.0.0.5'
) }
end
end

View File

@ -1,64 +0,0 @@
# TODO(tobias-urdin): This is deprecated and should be removed in T release.
require 'puppet'
require 'puppet/provider/nova_network/nova'
require 'tempfile'
provider_class = Puppet::Type.type(:nova_network).provider(:nova)
describe provider_class do
let :net_attrs do
{
:network => '10.20.0.0/16',
:label => 'novanetwork',
:ensure => 'present',
}
end
let :resource do
Puppet::Type::Nova_network.new(net_attrs)
end
let :provider do
provider_class.new(resource)
end
shared_examples 'nova_network' do
describe '#exists?' do
it 'should check non-existing network' do
provider.expects(:auth_nova).with("network-list")
.returns('"+--------------------------------------+-------------+-------------+\n| ID | Label | Cidr |\n+--------------------------------------+-------------+-------------+\n| 703edc62-36ab-4c41-9d73-884b30e9acbd | novanetwork | 10.0.0.0/16 |\n+--------------------------------------+-------------+-------------+\n"
')
expect(provider.exists?).to be_falsey
end
it 'should check existing network' do
provider.expects(:auth_nova).with("network-list")
.returns('"+--------------------------------------+-------------+-------------+\n| ID | Label | Cidr |\n+--------------------------------------+-------------+-------------+\n| 703edc62-36ab-4c41-9d73-884b30e9acbd | novanetwork | 10.20.0.0/16 |\n+--------------------------------------+-------------+-------------+\n"
')
expect(provider.exists?).to be_truthy
end
end
describe '#create' do
it 'should create network' do
provider.expects(:auth_nova).with("network-create", ['novanetwork', '--fixed-range-v4', '10.20.0.0/16'] )
.returns('"+--------------------------------------+-------------+-------------+\n| ID | Label | Cidr |\n+--------------------------------------+-------------+-------------+\n| 703edc62-36ab-4c41-9d73-88sdfsdfsdfsd | nova-network | 10.20.0.0/16 |\n+--------------------------------------+-------------+-------------+\n"
')
provider.create
end
end
describe '#destroy' do
it 'should destroy network' do
resource[:ensure] = :absent
provider.expects(:auth_nova).with("network-delete", "10.20.0.0/16")
.returns('"+--------------------------------------+-------------+-------------+\n| ID | Label | Cidr |\n+--------------------------------------+-------------+-------------+\n
')
provider.destroy
end
end
end
it_behaves_like('nova_network')
end

View File

@ -1,12 +0,0 @@
# TODO(tobias-urdin): This is deprecated and should be removed in T release.
require 'puppet'
require 'puppet/type/nova_network'
describe 'Puppet::Type.type(:nova_network)' do
it 'should reject an invalid ipv4 CIDR value' do
expect { Puppet::Type.type(:nova_network).new(:network => '192.168.1.0') }.to raise_error(Puppet::Error, /Invalid value/)
expect { Puppet::Type.type(:nova_network).new(:network => '::1/24') }.to raise_error(Puppet::Error, /Invalid value/)
end
it 'should accept a valid ipv4 CIDR value' do
Puppet::Type.type(:nova_network).new(:network => '192.168.1.0/24')
end
end