Skip to content

Commit

Permalink
Merge "Add region support for type creation/setting"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jun 27, 2014
2 parents 9b33d7e + 9d0b0f3 commit 1a98a74
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ dependency 'puppetlabs/inifile', '>=1.0.0 <2.0.0'
dependency 'puppetlabs/keystone', '>=4.0.0 <5.0.0'
dependency 'puppetlabs/mysql', '>=0.9.0 <3.0.0'
dependency 'puppetlabs/rabbitmq', '>=2.0.2 <4.0.0'
dependency 'puppetlabs/stdlib', '>=3.2.0'
dependency 'puppetlabs/stdlib', '>=4.0.0'
27 changes: 20 additions & 7 deletions manifests/type.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
# [*os_auth_url*]
# (optional) The keystone auth url. Defaults to 'http://127.0.0.1:5000/v2.0/'.
#
# [*os_region_name*]
# (optional) The keystone region name. Default is unset.
#
# Author: Andrew Woodward <[email protected]>

define cinder::type (
Expand All @@ -33,27 +36,36 @@
$os_tenant_name = 'admin',
$os_username = 'admin',
$os_auth_url = 'http://127.0.0.1:5000/v2.0/',
$os_region_name = undef,
) {

$volume_name = $name

# TODO: (xarses) This should be moved to a ruby provider so that among other
# reasons, the credential discovery magic can occur like in neutron.

$cinder_env = [
"OS_TENANT_NAME=${os_tenant_name}",
"OS_USERNAME=${os_username}",
"OS_PASSWORD=${os_password}",
"OS_AUTH_URL=${os_auth_url}",
]

if $os_region_name {
$region_env = ["OS_REGION_NAME=${os_region_name}"]
}
else {
$region_env = []
}

exec {"cinder type-create ${volume_name}":
command => "cinder type-create ${volume_name}",
unless => "cinder type-list | grep ${volume_name}",
environment => [
"OS_TENANT_NAME=${os_tenant_name}",
"OS_USERNAME=${os_username}",
"OS_PASSWORD=${os_password}",
"OS_AUTH_URL=${os_auth_url}",
],
environment => concat($cinder_env, $region_env),
require => Package['python-cinderclient']
}

if ($set_value and $set_key) {

Exec["cinder type-create ${volume_name}"] ->
cinder::type_set { $set_value:
type => $volume_name,
Expand All @@ -62,6 +74,7 @@
os_tenant_name => $os_tenant_name,
os_username => $os_username,
os_auth_url => $os_auth_url,
os_region_name => $os_region_name,
}
}
}
25 changes: 19 additions & 6 deletions manifests/type_set.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
# [*os_auth_url*]
# (optional) The keystone auth url. Defaults to 'http://127.0.0.1:5000/v2.0/'.
#
# [*os_region_name*]
# (optional) The keystone region name. Default is unset.
#
# Author: Andrew Woodward <[email protected]>


Expand All @@ -32,20 +35,30 @@
$os_tenant_name = 'admin',
$os_username = 'admin',
$os_auth_url = 'http://127.0.0.1:5000/v2.0/',
$os_region_name = undef,
) {

# TODO: (xarses) This should be moved to a ruby provider so that among other
# reasons, the credential discovery magic can occur like in neutron.

$cinder_env = [
"OS_TENANT_NAME=${os_tenant_name}",
"OS_USERNAME=${os_username}",
"OS_PASSWORD=${os_password}",
"OS_AUTH_URL=${os_auth_url}",
]

if $os_region_name {
$region_env = ["OS_REGION_NAME=${os_region_name}"]
}
else {
$region_env = []
}

exec {"cinder type-key ${type} set ${key}=${name}":
path => '/usr/bin',
command => "cinder type-key ${type} set ${key}=${name}",
environment => [
"OS_TENANT_NAME=${os_tenant_name}",
"OS_USERNAME=${os_username}",
"OS_PASSWORD=${os_password}",
"OS_AUTH_URL=${os_auth_url}",
],
environment => concat($cinder_env, $region_env),
require => Package['python-cinderclient']
}
}

0 comments on commit 1a98a74

Please sign in to comment.