Skip to content

Commit

Permalink
Add region support for type creation/setting
Browse files Browse the repository at this point in the history
Region support was added to the Volume type creation and setting code so
that the exec call will function in an environment that uses nova
regions.

Change-Id: I671bb236593dfc8beae38992752524a70f538560
(cherry picked from commit 9d0b0f3)
  • Loading branch information
matthewfischer authored and claytono committed Jul 3, 2014
1 parent fb3b49f commit 988a317
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,28 +36,37 @@
$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}":
path => '/usr/bin',
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 @@ -63,6 +75,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 988a317

Please sign in to comment.