Skip to content

Commit

Permalink
Automatic update
Browse files Browse the repository at this point in the history
This module update commit was generated by Bade.
For more info please check https://github.com/paramite/bade

This commit is setting modules to following state:
glance
 - old commit: 92180ae9a13c9c48f4f1bec7a0805e02b768fb51
 - new commit: 4e8e53bff3818c7cfda3317426281d8f6c4ea295

Change-Id: Id135db9844f21f79e52eb3ccd026362e80532a70
Fixes: rhbz#1258576
  • Loading branch information
javierpena committed Sep 1, 2015
1 parent 9fbba71 commit 90ef421
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 295 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod 'galera',
:git => 'https://github.com/redhat-openstack/puppet-galera.git'

mod 'glance',
:commit => '92180ae9a13c9c48f4f1bec7a0805e02b768fb51',
:commit => '4e8e53bff3818c7cfda3317426281d8f6c4ea295',
:git => 'https://github.com/openstack/puppet-glance.git'

mod 'gluster',
Expand Down
4 changes: 2 additions & 2 deletions glance/.fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ fixtures:
'concat':
'repo': 'git://github.com/puppetlabs/puppetlabs-concat.git'
'ref': '1.2.1'
'keystone': 'git://github.com/stackforge/puppet-keystone.git'
'keystone': 'git://github.com/openstack/puppet-keystone.git'
'mysql': 'git://github.com/puppetlabs/puppetlabs-mysql.git'
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
'openstacklib': 'git://github.com/openstack/puppet-openstacklib.git'
'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
'rabbitmq':
repo: 'git://github.com/puppetlabs/puppetlabs-rabbitmq'
Expand Down
6 changes: 3 additions & 3 deletions glance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ Module Description

The glance module is a thorough attempt to make Puppet capable of managing the entirety of glance. This includes manifests to provision such things as keystone endpoints, RPC configurations specific to glance, and database connections. Types are shipped as part of the glance module to assist in manipulation of configuration files.

This module is tested in combination with other modules needed to build and leverage an entire OpenStack software stack. These modules can be found, all pulled together in the [openstack module](https://github.com/stackfoge/puppet-openstack).
This module is tested in combination with other modules needed to build and leverage an entire OpenStack software stack. These modules can be found, all pulled together in the [openstack module](https://github.com/stackforge/puppet-openstack).

Setup
-----

**What the glance module affects**

* glance, the image service for OpenStack.
* [Glance](https://wiki.openstack.org/wiki/Glance), the image service for OpenStack.

### Installing glance

example% puppet module install openstack/glance
puppet module install openstack/glance

### Beginning with glance

Expand Down
153 changes: 25 additions & 128 deletions glance/lib/puppet/provider/glance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,29 @@
# this probably could have all gone in the provider file.
# But maybe this is good long-term.
require 'puppet/util/inifile'
class Puppet::Provider::Glance < Puppet::Provider
require 'puppet/provider/openstack'
require 'puppet/provider/openstack/auth'
require 'puppet/provider/openstack/credentials'
class Puppet::Provider::Glance < Puppet::Provider::Openstack

extend Puppet::Provider::Openstack::Auth

def self.request(service, action, properties=nil)
begin
super
rescue Puppet::Error::OpenstackAuthInputError => error
glance_request(service, action, error, properties)
end
end

def self.glance_request(service, action, error, properties=nil)
@credentials.username = glance_credentials['admin_user']
@credentials.password = glance_credentials['admin_password']
@credentials.project_name = glance_credentials['admin_tenant_name']
@credentials.auth_url = auth_endpoint
raise error unless @credentials.set?
Puppet::Provider::Openstack.request(service, action, properties, @credentials)
end

def self.glance_credentials
@glance_credentials ||= get_glance_credentials
Expand Down Expand Up @@ -51,10 +73,6 @@ def self.get_glance_credentials
end
end

def glance_credentials
self.class.glance_credentials
end

def self.auth_endpoint
@auth_endpoint ||= get_auth_endpoint
end
Expand All @@ -79,129 +97,8 @@ def self.glance_hash
@glance_hash ||= build_glance_hash
end

def self.reset
@glance_hash = nil
@glance_file = nil
@glance_credentials = nil
@auth_endpoint = nil
end

def glance_hash
self.class.glance_hash
end

def self.auth_glance(*args)
begin
g = glance_credentials
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
if (e.message =~ /\[Errno 111\] Connection refused/) or (e.message =~ /\(HTTP 400\)/) or (e.message =~ /HTTP Unable to establish connection/)
sleep 10
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
raise(e)
end
end
end

def auth_glance(*args)
self.class.auth_glance(args)
end

def self.auth_glance_stdin(*args)
begin
g = glance_credentials
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
# Redirect stderr to stdout in order to report errors
# Ignore good output
err = `#{command} 3>&1 1>/dev/null 2>&3`
if $? != 0
raise(Puppet::Error, err)
end
end
end

def auth_glance_stdin(*args)
self.class.auth_glance_stdin(args)
def bool_to_sym(bool)
bool == true ? :true : :false
end

private
def self.list_glance_images
ids = []
(auth_glance('image-list').split("\n")[3..-2] || []).collect do |line|
ids << line.split('|')[1].strip()
end
return ids
end

def self.get_glance_image_attr(id, attr)
(auth_glance('image-show', id).split("\n") || []).collect do |line|
if line =~ /^#{attr}:/
return line.split(': ')[1..-1]
end
end
end

def self.get_glance_image_attrs(id)
attrs = {}
(auth_glance('image-show', id).split("\n")[3..-2] || []).collect do |line|
attrs[line.split('|')[1].strip()] = line.split('|')[2].strip()
end
return attrs
end

def parse_table(table)
# parse the table into an array of maps with a simplistic state machine
found_header = false
parsed_header = false
keys = nil
results = []
table.split("\n").collect do |line|
# look for the header
if not found_header
if line =~ /^\+[-|+]+\+$/
found_header = true
nil
end
# look for the key names in the table header
elsif not parsed_header
if line =~ /^(\|\s*[:alpha:]\s*)|$/
keys = line.split('|').map(&:strip)
parsed_header = true
end
# parse the values in the rest of the table
elsif line =~ /^|.*|$/
values = line.split('|').map(&:strip)
result = Hash[keys.zip values]
results << result
end
end
results
end

# Remove warning from the output. This is a temporary hack until
# things will be refactored to use the REST API
def self.remove_warnings(results)
found_header = false
in_warning = false
results.split("\n").collect do |line|
unless found_header
if line =~ /^\+[-\+]+\+$/ # Matches upper and lower box borders
in_warning = false
found_header = true
line
elsif line =~ /^WARNING/ or line =~ /UserWarning/ or in_warning
# warnings can be multi line, we have to skip all of them
in_warning = true
nil
else
line
end
else
line
end
end.compact.join("\n")
end
end
111 changes: 0 additions & 111 deletions glance/lib/puppet/provider/glance_image/glance.rb

This file was deleted.

Loading

0 comments on commit 90ef421

Please sign in to comment.