Merge neutron provider with upstream

Upstream SHA commit: d64ec6fa45907b06ed4cadce9c4abac32d6723fe

neutron.rb was diverged from upstream due to keystone compatibility.
Since keystone module was update neutron manifest can use provider from
upstream. There were some changes to make it compatible with Ubuntu
14.04

Change-Id: Ieba2c4484518c33a77ab7fbbea399fbe02ddd9b4
Closes-Bug: 1410665
Signed-off-by: Sergii Golovatiuk <sgolovatiuk@mirantis.com>
This commit is contained in:
Sergii Golovatiuk 2015-01-15 23:41:09 +01:00
parent 59af435986
commit 32b4c3b704

View File

@ -3,9 +3,6 @@ require 'puppet/util/inifile'
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
'/etc/neutron/neutron.conf'
end
@ -78,8 +75,6 @@ correctly configured.")
if q.key?('nova_region_name')
authenv[:OS_REGION_NAME] = q['nova_region_name']
end
# NOTE(bogdando) contribute change to upstream #1384097:
# enhanced message checks within a given time frame
rv = nil
timeout = 120
end_time = Time.now.to_i + timeout
@ -189,74 +184,19 @@ correctly configured.")
return results
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)
rv = nil
auth_keystone('tenant-list').each do |line|
fields=line.split(/\s*\|\s*/)
if fields[1] and fields[1].size == 32
if fields[2] == name
rv = fields[1]
break
end
instance_type = 'keystone_tenant'
instance = catalog.resource("#{instance_type.capitalize!}[#{name}]")
if ! instance
instance = Puppet::Type.type(instance_type).instances.find do |i|
i.provider.name == name
end
end
if rv.nil?
fail("Unable to get tenant-ID for tenant '#{name}'")
if instance
return instance.provider.id
else
fail("Unable to find #{instance_type} for name #{name}")
end
return rv
end
def self.parse_creation_output(data)