Run the glance
CLI tool with appropriate region name
This is pretty important in situations where Keystone contains information about multiple regions. The holding assumption is that the glance::image etc are used for image upload for the current region. Change-Id: I0a24cd24ddf3e0b1fab94e693a2fac847cc7271c
This commit is contained in:
parent
f377c0229c
commit
abd028a5f6
@ -15,7 +15,8 @@ class Puppet::Provider::Glance < Puppet::Provider
|
|||||||
glance_file['keystone_authtoken']['auth_protocol'] and
|
glance_file['keystone_authtoken']['auth_protocol'] and
|
||||||
glance_file['keystone_authtoken']['admin_tenant_name'] and
|
glance_file['keystone_authtoken']['admin_tenant_name'] and
|
||||||
glance_file['keystone_authtoken']['admin_user'] and
|
glance_file['keystone_authtoken']['admin_user'] and
|
||||||
glance_file['keystone_authtoken']['admin_password']
|
glance_file['keystone_authtoken']['admin_password'] and
|
||||||
|
glance_file['DEFAULT']['os_region_name']
|
||||||
|
|
||||||
g = {}
|
g = {}
|
||||||
g['auth_host'] = glance_file['keystone_authtoken']['auth_host'].strip
|
g['auth_host'] = glance_file['keystone_authtoken']['auth_host'].strip
|
||||||
@ -24,6 +25,7 @@ class Puppet::Provider::Glance < Puppet::Provider
|
|||||||
g['admin_tenant_name'] = glance_file['keystone_authtoken']['admin_tenant_name'].strip
|
g['admin_tenant_name'] = glance_file['keystone_authtoken']['admin_tenant_name'].strip
|
||||||
g['admin_user'] = glance_file['keystone_authtoken']['admin_user'].strip
|
g['admin_user'] = glance_file['keystone_authtoken']['admin_user'].strip
|
||||||
g['admin_password'] = glance_file['keystone_authtoken']['admin_password'].strip
|
g['admin_password'] = glance_file['keystone_authtoken']['admin_password'].strip
|
||||||
|
g['os_region_name'] = glance_file['DEFAULT']['os_region_name'].strip
|
||||||
|
|
||||||
# auth_admin_prefix not required to be set.
|
# auth_admin_prefix not required to be set.
|
||||||
g['auth_admin_prefix'] = (glance_file['keystone_authtoken']['auth_admin_prefix'] || '').strip
|
g['auth_admin_prefix'] = (glance_file['keystone_authtoken']['auth_admin_prefix'] || '').strip
|
||||||
@ -72,11 +74,11 @@ class Puppet::Provider::Glance < Puppet::Provider
|
|||||||
def self.auth_glance(*args)
|
def self.auth_glance(*args)
|
||||||
begin
|
begin
|
||||||
g = glance_credentials
|
g = glance_credentials
|
||||||
remove_warnings(glance('--os-tenant-name', g['admin_tenant_name'], '--os-username', g['admin_user'], '--os-password', g['admin_password'], '--os-auth-url', auth_endpoint, args))
|
remove_warnings(glance('--os-tenant-name', g['admin_tenant_name'], '--os-username', g['admin_user'], '--os-password', g['admin_password'], '--os-region-name', g['os_region_name'], '--os-auth-url', auth_endpoint, args))
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
if (e.message =~ /\[Errno 111\] Connection refused/) or (e.message =~ /\(HTTP 400\)/) or (e.message =~ /HTTP Unable to establish connection/)
|
if (e.message =~ /\[Errno 111\] Connection refused/) or (e.message =~ /\(HTTP 400\)/) or (e.message =~ /HTTP Unable to establish connection/)
|
||||||
sleep 10
|
sleep 10
|
||||||
remove_warnings(glance('--os-tenant-name', g['admin_tenant_name'], '--os-username', g['admin_user'], '--os-password', g['admin_password'], '--os-auth-url', auth_endpoint, args))
|
remove_warnings(glance('--os-tenant-name', g['admin_tenant_name'], '--os-username', g['admin_user'], '--os-password', g['admin_password'], '--os-region-name', g['os_region_name'], '--os-auth-url', auth_endpoint, args))
|
||||||
else
|
else
|
||||||
raise(e)
|
raise(e)
|
||||||
end
|
end
|
||||||
@ -90,7 +92,7 @@ class Puppet::Provider::Glance < Puppet::Provider
|
|||||||
def self.auth_glance_stdin(*args)
|
def self.auth_glance_stdin(*args)
|
||||||
begin
|
begin
|
||||||
g = glance_credentials
|
g = glance_credentials
|
||||||
command = "glance --os-tenant-name #{g['admin_tenant_name']} --os-username #{g['admin_user']} --os-password #{g['admin_password']} --os-auth-url #{auth_endpoint} #{args.join(' ')}"
|
command = "glance --os-tenant-name #{g['admin_tenant_name']} --os-username #{g['admin_user']} --os-password #{g['admin_password']} --os-region-name #{g['os_region_name']} --os-auth-url #{auth_endpoint} #{args.join(' ')}"
|
||||||
|
|
||||||
# This is a horrible, horrible hack
|
# This is a horrible, horrible hack
|
||||||
# Redirect stderr to stdout in order to report errors
|
# Redirect stderr to stdout in order to report errors
|
||||||
|
@ -35,6 +35,10 @@ describe Puppet::Provider::Glance do
|
|||||||
'admin_tenant_name' => 'foo',
|
'admin_tenant_name' => 'foo',
|
||||||
'admin_user' => 'user',
|
'admin_user' => 'user',
|
||||||
'admin_password' => 'pass'
|
'admin_password' => 'pass'
|
||||||
|
},
|
||||||
|
'DEFAULT' =>
|
||||||
|
{
|
||||||
|
'os_region_name' => 'SomeRegion',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
|
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
|
||||||
@ -47,6 +51,8 @@ describe Puppet::Provider::Glance do
|
|||||||
'user',
|
'user',
|
||||||
'--os-password',
|
'--os-password',
|
||||||
'pass',
|
'pass',
|
||||||
|
'--os-region-name',
|
||||||
|
'SomeRegion',
|
||||||
'--os-auth-url',
|
'--os-auth-url',
|
||||||
'http://127.0.0.1:35357/v2.0/',
|
'http://127.0.0.1:35357/v2.0/',
|
||||||
['test_retries']
|
['test_retries']
|
||||||
|
Loading…
Reference in New Issue
Block a user