Merge "Merge neutron provider with upstream"
This commit is contained in:
commit
c1d60b7db2
@ -3,9 +3,6 @@ require 'puppet/util/inifile'
|
|||||||
|
|
||||||
class Puppet::Provider::Neutron < Puppet::Provider
|
class Puppet::Provider::Neutron < Puppet::Provider
|
||||||
|
|
||||||
#NOTE(xenolog): self.prefetch was removed with comment:
|
|
||||||
# FIXME:(xarses) needs to be abstraced from subresources and re-written here
|
|
||||||
|
|
||||||
def self.conf_filename
|
def self.conf_filename
|
||||||
'/etc/neutron/neutron.conf'
|
'/etc/neutron/neutron.conf'
|
||||||
end
|
end
|
||||||
@ -78,8 +75,6 @@ correctly configured.")
|
|||||||
if q.key?('nova_region_name')
|
if q.key?('nova_region_name')
|
||||||
authenv[:OS_REGION_NAME] = q['nova_region_name']
|
authenv[:OS_REGION_NAME] = q['nova_region_name']
|
||||||
end
|
end
|
||||||
# NOTE(bogdando) contribute change to upstream #1384097:
|
|
||||||
# enhanced message checks within a given time frame
|
|
||||||
rv = nil
|
rv = nil
|
||||||
timeout = 120
|
timeout = 120
|
||||||
end_time = Time.now.to_i + timeout
|
end_time = Time.now.to_i + timeout
|
||||||
@ -189,74 +184,19 @@ correctly configured.")
|
|||||||
return results
|
return results
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.auth_keystone(*args)
|
|
||||||
q = neutron_credentials
|
|
||||||
authenv = {
|
|
||||||
:OS_AUTH_URL => self.auth_endpoint,
|
|
||||||
:OS_USERNAME => q['admin_user'],
|
|
||||||
:OS_TENANT_NAME => q['admin_tenant_name'],
|
|
||||||
:OS_PASSWORD => q['admin_password']
|
|
||||||
}
|
|
||||||
if q.key?('nova_region_name')
|
|
||||||
authenv[:OS_REGION_NAME] = q['nova_region_name']
|
|
||||||
end
|
|
||||||
|
|
||||||
rv = nil
|
|
||||||
timeout = 120
|
|
||||||
end_time = Time.now.to_i + timeout
|
|
||||||
loop do
|
|
||||||
begin
|
|
||||||
withenv authenv do
|
|
||||||
rv = keystone(args)
|
|
||||||
end
|
|
||||||
break
|
|
||||||
rescue Puppet::ExecutionFailure => e
|
|
||||||
if ! e.message =~ /(\(HTTP\s+400\))|
|
|
||||||
(400-\{\'message\'\:\s+\'\'\})|
|
|
||||||
(\[Errno 111\]\s+Connection\s+refused)|
|
|
||||||
(503\s+Service\s+Unavailable)|
|
|
||||||
(504\s+Gateway\s+Time-out)|
|
|
||||||
(\:\s+Maximum\s+attempts\s+reached)|
|
|
||||||
(Unauthorized\:\s+bad\s+credentials)|
|
|
||||||
(Max\s+retries\s+exceeded)/
|
|
||||||
raise(e)
|
|
||||||
end
|
|
||||||
current_time = Time.now.to_i
|
|
||||||
if current_time > end_time
|
|
||||||
#raise(e)
|
|
||||||
break
|
|
||||||
else
|
|
||||||
wait = end_time - current_time
|
|
||||||
Puppet::debug("Non-fatal error: \"#{e.message}\"")
|
|
||||||
notice("Keystone API not avalaible. Wait up to #{wait} sec.")
|
|
||||||
end
|
|
||||||
sleep(2)
|
|
||||||
# Note(xarses): Don't remove, we know that there is one of the
|
|
||||||
# Recoverable erros above, So we will retry a few more times
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return rv
|
|
||||||
end
|
|
||||||
|
|
||||||
def auth_keystone(*args)
|
|
||||||
self.class.auth_neutron(args)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_tenant_id(catalog, name)
|
def self.get_tenant_id(catalog, name)
|
||||||
rv = nil
|
instance_type = 'keystone_tenant'
|
||||||
auth_keystone('tenant-list').each do |line|
|
instance = catalog.resource("#{instance_type.capitalize!}[#{name}]")
|
||||||
fields=line.split(/\s*\|\s*/)
|
if ! instance
|
||||||
if fields[1] and fields[1].size == 32
|
instance = Puppet::Type.type(instance_type).instances.find do |i|
|
||||||
if fields[2] == name
|
i.provider.name == name
|
||||||
rv = fields[1]
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if rv.nil?
|
if instance
|
||||||
fail("Unable to get tenant-ID for tenant '#{name}'")
|
return instance.provider.id
|
||||||
|
else
|
||||||
|
fail("Unable to find #{instance_type} for name #{name}")
|
||||||
end
|
end
|
||||||
return rv
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.parse_creation_output(data)
|
def self.parse_creation_output(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user