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
|
# murano_application type
#
# == Parameters
# [*name*]
# Name for the new application
# Required
#
# [*package_path*]
# Path to package file
# Required
#
# [*exists_action*]
# Default action when a package
# already exists
# Optional
#
# [*public*]
# Make the package available for users
# from other tenants
# Optional
#
# [*category*]
# Category for the new application
# Optional
#
require 'puppet'
Puppet::Type.newtype(:murano_application) do
@doc = 'Manage creation of Murano applications.'
ensurable
newparam(:name, :namevar => true) do
desc 'Name for the new application'
validate do |value|
unless value.is_a? String
raise ArgumentError, 'name parameter must be a String'
end
unless value =~ /^[a-z0-9\.\-_]+$/
raise ArgumentError, "#{value} is not a valid name"
end
end
end
newproperty(:package_path) do
desc 'Path to package file'
validate do |value|
unless value.is_a? String
raise ArgumentError, 'package_path parameter must be a String'
end
end
newvalues(/\S+/)
end
newproperty(:exists_action) do
desc 'Default action when a package already exists'
defaultto('s')
validate do |value|
allowed_actions = ['s', 'a', 'u']
raise ArgumentError, 'Unknown action is set' unless allowed_actions.include?(value)
end
end
newproperty(:public) do
desc 'Make the package available for users from other tenants'
defaultto('true')
newvalues(/(t|T)rue/, /(f|F)alse/, true, false)
munge do |value|
value.to_s.downcase.to_sym
end
end
newproperty(:category) do
desc 'Package category'
validate do |value|
unless value.is_a? String
raise ArgumentError, 'category parameter must be a String'
end
end
end
validate do
raise ArgumentError, 'Name and package path must be set' unless self[:name] and self[:package_path]
end
autorequire(:anchor) do
['murano::service::end']
end
end
|