Create basic module structure

1. Create required folders
2. Add LICENSE, README.md, Gemfile, Rakefile and metadata.json
3. Add murano-specific resources
4. Add tests for resources

Change-Id: If8bb71f369340c0c7799db836622f9b5d2c09a7c
This commit is contained in:
Alexey Deryugin 2015-06-19 15:19:02 +03:00
parent 31507ed5e8
commit 480f45c61d
17 changed files with 518 additions and 0 deletions

10
.fixtures.yml Normal file
View File

@ -0,0 +1,10 @@
fixtures:
repositories:
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile'
'concat':
repo: 'git://github.com/puppetlabs/puppetlabs-concat.git'
ref: '1.2.1'
'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
'sysctl': 'git://github.com/duritong/puppet-sysctl.git'
symlinks:
'murano': "#{source_dir}"

28
Gemfile Normal file
View File

@ -0,0 +1,28 @@
source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', '~> 2.1.0', :require => false
gem 'metadata-json-lint'
gem 'puppet-lint-param-docs'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-absolute_template_path'
gem 'puppet-lint-trailing_newline-check'
# Puppet 4.x related lint checks
gem 'puppet-lint-unquoted_string-check'
gem 'puppet-lint-leading_zero-check'
gem 'puppet-lint-variable_contains_upcase'
gem 'puppet-lint-numericvariable'
gem 'beaker-rspec', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
# vim:ft=ruby

13
LICENSE Normal file
View File

@ -0,0 +1,13 @@
Copyright 2012 OpenStack Foundation
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.

80
README.md Normal file
View File

@ -0,0 +1,80 @@
murano
======
#### Table of Contents
1. [Overview - What is the murano module?](#overview)
2. [Module Description - What does the module do?](#module-description)
3. [Setup - The basics of getting started with murano](#setup)
4. [Implementation - An under-the-hood peek at what the module is doing](#implementation)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
7. [Contributors - Those with commits](#contributors)
8. [Release Notes - Notes on the most recent updates to the module](#release-notes)
Overview
--------
The Murano module itself is used to flexibly configure and manage the
application catalog service for OpenStack.
Module Description
------------------
The murano module is an attempt to make Puppet capable of managing the
entirety of murano.
Setup
-----
**What the murano module affects:**
* murano, the application catalog service for OpenStack.
### Beginning with murano
To use the murano module's functionality you will need to declare multiple
resources. This is not an exhaustive list of all the components needed; we
recommend you consult and understand the
[core of openstack](http://docs.openstack.org) documentation.
Examples of usage can be found in the *examples* directory.
Implementation
--------------
### murano
puppet-murano is a combination of Puppet manifests and ruby code to deliver
configuration and extra functionality through types and providers.
Limitations
-----------
None.
Beaker-Rspec
------------
This module has beaker-rspec tests
To run:
``shell
bundle install
bundle exec rspec spec/acceptance
``
Development
-----------
Developer documentation for the entire puppet-openstack project.
* https://wiki.openstack.org/wiki/Puppet-openstack#Developer_documentation
Release Notes
-------------
**1.0.0**
* Initial

6
Rakefile Normal file
View File

@ -0,0 +1,6 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')

View File

@ -0,0 +1,9 @@
module Puppet::Parser::Functions
newfunction(:get_ext_net_name, :type => :rvalue) do |args|
networks = args.first
fail 'No network data provided!' unless networks.is_a? Hash
ext_net_array = networks.find { |_, value| value.fetch('L2', {})['router_ext'] }
break unless ext_net_array
ext_net_array.first
end
end

View File

@ -0,0 +1,22 @@
Puppet::Type.type(:murano_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def file_path
'/etc/murano/murano.conf'
end
end

View File

@ -0,0 +1,22 @@
Puppet::Type.type(:murano_paste_ini_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def file_path
'/etc/murano/murano-paste.ini'
end
end

View File

@ -0,0 +1,19 @@
Puppet::Type.newtype(:murano_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from murano.conf'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
end
end

View File

@ -0,0 +1,19 @@
Puppet::Type.newtype(:murano_paste_ini_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from murano-paste.ini'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
end
end

34
metadata.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "stackforge-murano",
"version": "1.0.0",
"author": "Red Hat and StackForge Contributors",
"summary": "Puppet module for OpenStack Murano",
"license": "Apache-2.0",
"source": "git://github.com/stackforge/puppet-murano.git",
"project_page": "https://launchpad.net/puppet-murano",
"issues_url": "https://bugs.launchpad.net/puppet-murano",
"requirements": [
{ "name": "pe","version_requirement": "3.x" },
{ "name": "puppet","version_requirement": "3.x" }
],
"operatingsystem_support": [
{
"operatingsystem": "Fedora",
"operatingsystemrelease": ["20"]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": ["7"]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": ["8"]
}
],
"description": "Installs and configures OpenStack Murano (Application Catalog).",
"dependencies": [
{ "name": "stackforge/keystone", "version_requirement": ">=5.0.0 <6.0.0" },
{ "name": "puppetlabs/inifile", "version_requirement": ">=5.0.0 <6.0.0" },
{ "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" }
]
}

View File

@ -0,0 +1,85 @@
require 'spec_helper'
describe 'get_ext_net_name' do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
it 'should exist' do
Puppet::Parser::Functions.function('get_ext_net_name').should == 'function_get_ext_net_name'
end
it 'should return the network name that has router_ext enabled' do
expect(scope.function_get_ext_net_name(
[
{
"net04" =>
{
"L2" =>
{
"router_ext" => false,
}
},
"net04_ext" =>
{
"L2" =>
{
"router_ext" => true,
}
}
}
]
)).to eq 'net04_ext'
end
it 'should return nil if router_ext is not enabled' do
expect(scope.function_get_ext_net_name(
[
{
"net04" =>
{
"L2" =>
{
"router_ext" => false,
}
},
"net04_ext" =>
{
"L2" =>
{
"router_ext" => false,
}
}
}
],
)).to be_nil
end
it 'should return nil if there is no router_ext' do
expect(scope.function_get_ext_net_name(
[
{
"net04" =>
{
"L2" =>
{
}
},
"net04_ext" =>
{
"L2" =>
{
}
}
}
]
)).to be_nil
end
it 'should return nil with empty network data' do
expect(scope.function_get_ext_net_name(
[
{}
]
)).to be_nil
end
end

1
spec/spec_helper.rb Normal file
View File

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

View File

@ -0,0 +1,33 @@
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:murano_config).provider(:ini_setting)
describe provider_class do
it 'should default to the default setting when no other one is specified' do
resource = Puppet::Type::Murano_config.new(
{:name => 'DEFAULT/foo', :value => 'bar'}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('DEFAULT')
expect(provider.setting).to eq('foo')
end
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Murano_config.new(
{:name => 'dude/whoa', :value => 'bar'}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('dude')
expect(provider.setting).to eq('whoa')
end
end

View File

@ -0,0 +1,33 @@
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:murano_paste_ini_config).provider(:ini_setting)
describe provider_class do
it 'should default to the default setting when no other one is specified' do
resource = Puppet::Type::Murano_paste_ini_config.new(
{:name => 'DEFAULT/foo', :value => 'bar'}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('DEFAULT')
expect(provider.setting).to eq('foo')
end
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Murano_paste_ini_config.new(
{:name => 'dude/whoa', :value => 'bar'}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('dude')
expect(provider.setting).to eq('whoa')
end
end

View File

@ -0,0 +1,52 @@
require 'puppet'
require 'puppet/type/murano_config'
describe 'Puppet::Type.type(:murano_config)' do
before :each do
@murano_config = Puppet::Type.type(:murano_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should require a name' do
expect {
Puppet::Type.type(:murano_config).new({})
}.to raise_error(Puppet::Error, 'Title or name must be provided')
end
it 'should not expect a name with whitespace' do
expect {
Puppet::Type.type(:murano_config).new(:name => 'f oo')
}.to raise_error(Puppet::Error, /Parameter name failed/)
end
it 'should fail when there is no section' do
expect {
Puppet::Type.type(:murano_config).new(:name => 'foo')
}.to raise_error(Puppet::Error, /Parameter name failed/)
end
it 'should not require a value when ensure is absent' do
Puppet::Type.type(:murano_config).new(:name => 'DEFAULT/foo', :ensure => :absent)
end
it 'should accept a valid value' do
@murano_config[:value] = 'bar'
expect(@murano_config[:value]).to eq('bar')
end
it 'should not accept a value with whitespace' do
@murano_config[:value] = 'b ar'
expect(@murano_config[:value]).to eq('b ar')
end
it 'should accept valid ensure values' do
@murano_config[:ensure] = :present
expect(@murano_config[:ensure]).to eq(:present)
@murano_config[:ensure] = :absent
expect(@murano_config[:ensure]).to eq(:absent)
end
it 'should not accept invalid ensure values' do
expect {
@murano_config[:ensure] = :latest
}.to raise_error(Puppet::Error, /Invalid value/)
end
end

View File

@ -0,0 +1,52 @@
require 'puppet'
require 'puppet/type/murano_paste_ini_config'
describe 'Puppet::Type.type(:murano_paste_ini_config)' do
before :each do
@murano_paste_ini_config = Puppet::Type.type(:murano_paste_ini_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should require a name' do
expect {
Puppet::Type.type(:murano_paste_ini_config).new({})
}.to raise_error(Puppet::Error, 'Title or name must be provided')
end
it 'should not expect a name with whitespace' do
expect {
Puppet::Type.type(:murano_paste_ini_config).new(:name => 'f oo')
}.to raise_error(Puppet::Error, /Parameter name failed/)
end
it 'should fail when there is no section' do
expect {
Puppet::Type.type(:murano_paste_ini_config).new(:name => 'foo')
}.to raise_error(Puppet::Error, /Parameter name failed/)
end
it 'should not require a value when ensure is absent' do
Puppet::Type.type(:murano_paste_ini_config).new(:name => 'DEFAULT/foo', :ensure => :absent)
end
it 'should accept a valid value' do
@murano_paste_ini_config[:value] = 'bar'
expect(@murano_paste_ini_config[:value]).to eq('bar')
end
it 'should not accept a value with whitespace' do
@murano_paste_ini_config[:value] = 'b ar'
expect(@murano_paste_ini_config[:value]).to eq('b ar')
end
it 'should accept valid ensure values' do
@murano_paste_ini_config[:ensure] = :present
expect(@murano_paste_ini_config[:ensure]).to eq(:present)
@murano_paste_ini_config[:ensure] = :absent
expect(@murano_paste_ini_config[:ensure]).to eq(:absent)
end
it 'should not accept invalid ensure values' do
expect {
@murano_paste_ini_config[:ensure] = :latest
}.to raise_error(Puppet::Error, /Invalid value/)
end
end