try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / manifests / type_set.pp
1 # ==Define: cinder::type_set
2 #
3 # Assigns keys after the volume type is set.
4 #
5 # === Parameters
6 #
7 # [*os_password*]
8 #   (required) The keystone tenant:username password.
9 #
10 # [*type*]
11 #   (required) Accepts single name of type to set.
12 #
13 # [*key*]
14 #   (required) the key name that we are setting the value for.
15 #
16 # [*os_tenant_name*]
17 #   (optional) The keystone tenant name. Defaults to 'admin'.
18 #
19 # [*os_username*]
20 #   (optional) The keystone user name. Defaults to 'admin.
21 #
22 # [*os_auth_url*]
23 #   (optional) The keystone auth url. Defaults to 'http://127.0.0.1:5000/v2.0/'.
24 #
25 # [*os_region_name*]
26 #   (optional) The keystone region name. Default is unset.
27 #
28 # Author: Andrew Woodward <awoodward@mirantis.com>
29
30
31 define cinder::type_set (
32   $type,
33   $key,
34   $os_password,
35   $os_tenant_name = 'admin',
36   $os_username    = 'admin',
37   $os_auth_url    = 'http://127.0.0.1:5000/v2.0/',
38   $os_region_name = undef,
39   ) {
40
41 # TODO: (xarses) This should be moved to a ruby provider so that among other
42 #   reasons, the credential discovery magic can occur like in neutron.
43
44   $cinder_env = [
45     "OS_TENANT_NAME=${os_tenant_name}",
46     "OS_USERNAME=${os_username}",
47     "OS_PASSWORD=${os_password}",
48     "OS_AUTH_URL=${os_auth_url}",
49   ]
50
51   if $os_region_name {
52     $region_env = ["OS_REGION_NAME=${os_region_name}"]
53   }
54   else {
55     $region_env = []
56   }
57
58   exec {"cinder type-key ${type} set ${key}=${name}":
59     path        => ['/usr/bin', '/bin'],
60     command     => "cinder type-key ${type} set ${key}=${name}",
61     unless      => "cinder extra-specs-list | grep -Eq '\\b${type}\\b.*\\b${key}\\b.*\\b${name}\\b'",
62     environment => concat($cinder_env, $region_env),
63     require     => Package['python-cinderclient']
64   }
65 }