2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 # François Charlier <francois.charlier@enovance.com>
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 Puppet::Type.type(:nova_cells).provide(:nova_manage) do
25 desc "Manage nova cells"
27 optional_commands :nova_manage => 'nova-manage'
31 cells_list = nova_manage("cell", "list")
33 if e.message =~ /No cells defined/
39 cells_list.split("\n")[1..-1].collect do |net|
40 if net =~ /^(\S+)\s+(\S+)/
51 :cell_type => '--cell_type',
52 :rabbit_username => '--username',
53 :rabbit_password => '--password',
54 :rabbit_hosts => '--hostname',
55 :rabbit_port => '--port',
56 :rabbit_virtual_host => '--virtual_host',
57 :weight_offset => '--woffset',
58 :weight_scale => '--wscale'
60 }.each do |param, opt|
62 optional_opts.push(opt).push(resource[param])
66 nova_manage('cell', 'create',
73 cells_list = nova_manage("cell", "list")
74 return cells_list.split("\n")[1..-1].detect do |n|
75 n =~ /^(\S+)\s+(#{resource[:cells].split('/').first})/
84 nova_manage("cell", "delete", resource[:name])