1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2014 Deutsche Telekom AG
5 # Author: Thomas Bechtold <t.bechtold@telekom.de>
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may
8 # not use this file except in compliance with the License. You may obtain
9 # a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 # License for the specific language governing permissions and limitations
23 # Name for the new aggregate
26 # [*availability_zone*]
27 # The availability zone. ie "zone1"
31 # String with key/value pairs. ie "key=value,key=value"
35 # A comma seperated list with hosts or a single host. ie "host1,host2"
41 Puppet::Type.newtype(:nova_aggregate) do
43 @doc = "Manage creation of nova aggregations."
47 autorequire(:nova_config) do
48 ['auth_host', 'auth_port', 'auth_protocol', 'admin_tenant_name', 'admin_user', 'admin_password']
51 newparam(:name, :namevar => true) do
52 desc 'Name for the new aggregate'
54 if not value.is_a? String
55 raise ArgumentError, "name parameter must be a String"
57 unless value =~ /[a-z0-9]+/
58 raise ArgumentError, "#{value} is not a valid name"
64 desc 'The unique Id of the aggregate'
66 raise ArgumentError, 'This is a read only property'
70 newproperty(:availability_zone) do
71 desc 'The availability zone of the aggregate'
73 if not value.is_a? String
74 raise ArgumentError, "availability zone must be a String"
79 newproperty(:metadata) do
80 desc 'The metadata of the aggregate'
81 #convert DSL/string form to internal form which is a single hash
84 value.split(",").map{|el| el.strip()}.each do |pair|
85 key, value = pair.split("=", 2)
86 internal[key.strip()] = value.strip()
92 value.split(",").each do |kv|
93 raise ArgumentError, "Key/value pairs must be separated by an =" unless value.include?("=")
98 newproperty(:hosts) do
99 desc 'Single host or comma seperated list of hosts'
100 #convert DSL/string form to internal form
102 return value.split(",").map{|el| el.strip()}
107 raise ArgumentError, 'Name type must be set' unless self[:name]